@@ -19,47 +19,47 @@ discard block |
||
| 19 | 19 | // Check if schema is at latest version |
| 20 | 20 | $Connection = new Connection(); |
| 21 | 21 | if ($Connection->latest() === false) { |
| 22 | - echo "You MUST update to latest schema. Run install/index.php"; |
|
| 23 | - exit(); |
|
| 22 | + echo "You MUST update to latest schema. Run install/index.php"; |
|
| 23 | + exit(); |
|
| 24 | 24 | } |
| 25 | 25 | if (PHP_SAPI != 'cli') { |
| 26 | - echo "This script MUST be called from console, not a web browser."; |
|
| 26 | + echo "This script MUST be called from console, not a web browser."; |
|
| 27 | 27 | // exit(); |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // This is to be compatible with old version of settings.php |
| 31 | 31 | if (!isset($globalSources)) { |
| 32 | - if (isset($globalSBS1Hosts)) { |
|
| 33 | - //$hosts = $globalSBS1Hosts; |
|
| 34 | - foreach ($globalSBS1Hosts as $host) { |
|
| 35 | - $globalSources[] = array('host' => $host); |
|
| 36 | - } |
|
| 37 | - } else { |
|
| 38 | - if (!isset($globalSBS1Host)) { |
|
| 39 | - echo '$globalSources MUST be defined !'; |
|
| 40 | - die; |
|
| 32 | + if (isset($globalSBS1Hosts)) { |
|
| 33 | + //$hosts = $globalSBS1Hosts; |
|
| 34 | + foreach ($globalSBS1Hosts as $host) { |
|
| 35 | + $globalSources[] = array('host' => $host); |
|
| 36 | + } |
|
| 37 | + } else { |
|
| 38 | + if (!isset($globalSBS1Host)) { |
|
| 39 | + echo '$globalSources MUST be defined !'; |
|
| 40 | + die; |
|
| 41 | 41 | } |
| 42 | 42 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 43 | 43 | $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
| 44 | - } |
|
| 44 | + } |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | $options = getopt('s::',array('source::','server','idsource::')); |
| 48 | 48 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 49 | 49 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 50 | 50 | if (isset($options['s'])) { |
| 51 | - $globalSources = array(); |
|
| 52 | - $globalSources[] = array('host' => $options['s']); |
|
| 51 | + $globalSources = array(); |
|
| 52 | + $globalSources[] = array('host' => $options['s']); |
|
| 53 | 53 | } elseif (isset($options['source'])) { |
| 54 | - $globalSources = array(); |
|
| 55 | - $globalSources[] = array('host' => $options['source']); |
|
| 54 | + $globalSources = array(); |
|
| 55 | + $globalSources[] = array('host' => $options['source']); |
|
| 56 | 56 | } |
| 57 | 57 | if (isset($options['server'])) $globalServer = TRUE; |
| 58 | 58 | if (isset($options['idsource'])) $id_source = $options['idsource']; |
| 59 | 59 | else $id_source = 1; |
| 60 | 60 | if (isset($globalServer) && $globalServer) { |
| 61 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 62 | - $SI=new SpotterServer(); |
|
| 61 | + if ($globalDebug) echo "Using Server Mode\n"; |
|
| 62 | + $SI=new SpotterServer(); |
|
| 63 | 63 | } else $SI=new SpotterImport($Connection->db); |
| 64 | 64 | //$APRS=new APRS($Connection->db); |
| 65 | 65 | $SBS=new SBS(); |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | //$servertz = system('date +%Z'); |
| 70 | 70 | // signal handler - playing nice with sockets and dump1090 |
| 71 | 71 | if (function_exists('pcntl_fork')) { |
| 72 | - pcntl_signal(SIGINT, function() { |
|
| 73 | - global $sockets; |
|
| 74 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 75 | - die("Bye!\n"); |
|
| 76 | - }); |
|
| 77 | - pcntl_signal_dispatch(); |
|
| 72 | + pcntl_signal(SIGINT, function() { |
|
| 73 | + global $sockets; |
|
| 74 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
|
| 75 | + die("Bye!\n"); |
|
| 76 | + }); |
|
| 77 | + pcntl_signal_dispatch(); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // let's try and connect |
@@ -84,162 +84,162 @@ discard block |
||
| 84 | 84 | $reset = 0; |
| 85 | 85 | |
| 86 | 86 | function create_socket($host, $port, &$errno, &$errstr) { |
| 87 | - $ip = gethostbyname($host); |
|
| 88 | - $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 89 | - $r = @socket_connect($s, $ip, $port); |
|
| 90 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 91 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 92 | - return $s; |
|
| 93 | - } |
|
| 94 | - $errno = socket_last_error($s); |
|
| 95 | - $errstr = socket_strerror($errno); |
|
| 96 | - socket_close($s); |
|
| 97 | - return false; |
|
| 87 | + $ip = gethostbyname($host); |
|
| 88 | + $s = socket_create(AF_INET, SOCK_STREAM, 0); |
|
| 89 | + $r = @socket_connect($s, $ip, $port); |
|
| 90 | + if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 91 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 92 | + return $s; |
|
| 93 | + } |
|
| 94 | + $errno = socket_last_error($s); |
|
| 95 | + $errstr = socket_strerror($errno); |
|
| 96 | + socket_close($s); |
|
| 97 | + return false; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | function create_socket_udp($host, $port, &$errno, &$errstr) { |
| 101 | - echo "Create an UDP socket...\n"; |
|
| 102 | - $ip = gethostbyname($host); |
|
| 103 | - $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 104 | - $r = @socket_bind($s, $ip, $port); |
|
| 105 | - if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 106 | - return $s; |
|
| 107 | - } |
|
| 108 | - $errno = socket_last_error($s); |
|
| 109 | - $errstr = socket_strerror($errno); |
|
| 110 | - socket_close($s); |
|
| 111 | - return false; |
|
| 101 | + echo "Create an UDP socket...\n"; |
|
| 102 | + $ip = gethostbyname($host); |
|
| 103 | + $s = socket_create(AF_INET, SOCK_DGRAM, 0); |
|
| 104 | + $r = @socket_bind($s, $ip, $port); |
|
| 105 | + if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
|
| 106 | + return $s; |
|
| 107 | + } |
|
| 108 | + $errno = socket_last_error($s); |
|
| 109 | + $errstr = socket_strerror($errno); |
|
| 110 | + socket_close($s); |
|
| 111 | + return false; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | function connect_all($hosts) { |
| 115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | - $reset++; |
|
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | - foreach ($hosts as $id => $value) { |
|
| 115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
|
| 116 | + global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | + $reset++; |
|
| 118 | + if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 119 | + foreach ($hosts as $id => $value) { |
|
| 120 | 120 | $host = $value['host']; |
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; |
| 122 | 122 | // Here we check type of source(s) |
| 123 | 123 | if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
| 124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | - //$formats[$id] = 'deltadbtxt'; |
|
| 126 | - $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | - //$last_exec['deltadbtxt'] = 0; |
|
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | - //$formats[$id] = 'vatsimtxt'; |
|
| 131 | - $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | - //$last_exec['vatsimtxt'] = 0; |
|
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | - //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | - $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | - //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 145 | - //$formats[$id] = 'radarvirtueljson'; |
|
| 146 | - $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 147 | - //$last_exec['radarvirtueljson'] = 0; |
|
| 148 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 149 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | - exit(0); |
|
| 152 | - } |
|
| 153 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 154 | - //$formats[$id] = 'planeupdatefaa'; |
|
| 155 | - $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 156 | - //$last_exec['planeupdatefaa'] = 0; |
|
| 157 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 158 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 159 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 160 | - exit(0); |
|
| 161 | - } |
|
| 162 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 163 | - //$formats[$id] = 'phpvmacars'; |
|
| 164 | - $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 165 | - //$last_exec['phpvmacars'] = 0; |
|
| 166 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 167 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 168 | - //$formats[$id] = 'phpvmacars'; |
|
| 169 | - $globalSources[$id]['format'] = 'vam'; |
|
| 170 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 171 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 172 | - //$formats[$id] = 'whazzup'; |
|
| 173 | - $globalSources[$id]['format'] = 'whazzup'; |
|
| 174 | - //$last_exec['whazzup'] = 0; |
|
| 175 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 176 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 177 | - //$formats[$id] = 'pirepsjson'; |
|
| 178 | - $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 179 | - //$last_exec['pirepsjson'] = 0; |
|
| 180 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 181 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 182 | - //$formats[$id] = 'fr24json'; |
|
| 183 | - $globalSources[$id]['format'] = 'fr24json'; |
|
| 184 | - //$last_exec['fr24json'] = 0; |
|
| 185 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 186 | - if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 187 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 188 | - exit(0); |
|
| 189 | - } |
|
| 190 | - //} else if (preg_match('/10001/',$host)) { |
|
| 191 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | - //$formats[$id] = 'tsv'; |
|
| 193 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 194 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 195 | - } |
|
| 196 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 197 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 198 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | - $hostport = explode(':',$host); |
|
| 200 | - if (isset($hostport[1])) { |
|
| 124 | + if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 125 | + //$formats[$id] = 'deltadbtxt'; |
|
| 126 | + $globalSources[$id]['format'] = 'deltadbtxt'; |
|
| 127 | + //$last_exec['deltadbtxt'] = 0; |
|
| 128 | + if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 129 | + } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 130 | + //$formats[$id] = 'vatsimtxt'; |
|
| 131 | + $globalSources[$id]['format'] = 'vatsimtxt'; |
|
| 132 | + //$last_exec['vatsimtxt'] = 0; |
|
| 133 | + if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 134 | + } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 135 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; |
|
| 137 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 138 | + if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 139 | + } else if (preg_match('/opensky/i',$host)) { |
|
| 140 | + //$formats[$id] = 'aircraftlistjson'; |
|
| 141 | + $globalSources[$id]['format'] = 'opensky'; |
|
| 142 | + //$last_exec['aircraftlistjson'] = 0; |
|
| 143 | + if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 144 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 145 | + //$formats[$id] = 'radarvirtueljson'; |
|
| 146 | + $globalSources[$id]['format'] = 'radarvirtueljson'; |
|
| 147 | + //$last_exec['radarvirtueljson'] = 0; |
|
| 148 | + if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 149 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 150 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 151 | + exit(0); |
|
| 152 | + } |
|
| 153 | + } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 154 | + //$formats[$id] = 'planeupdatefaa'; |
|
| 155 | + $globalSources[$id]['format'] = 'planeupdatefaa'; |
|
| 156 | + //$last_exec['planeupdatefaa'] = 0; |
|
| 157 | + if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 158 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 159 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 160 | + exit(0); |
|
| 161 | + } |
|
| 162 | + } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 163 | + //$formats[$id] = 'phpvmacars'; |
|
| 164 | + $globalSources[$id]['format'] = 'phpvmacars'; |
|
| 165 | + //$last_exec['phpvmacars'] = 0; |
|
| 166 | + if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 167 | + } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 168 | + //$formats[$id] = 'phpvmacars'; |
|
| 169 | + $globalSources[$id]['format'] = 'vam'; |
|
| 170 | + if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 171 | + } else if (preg_match('/whazzup/i',$host)) { |
|
| 172 | + //$formats[$id] = 'whazzup'; |
|
| 173 | + $globalSources[$id]['format'] = 'whazzup'; |
|
| 174 | + //$last_exec['whazzup'] = 0; |
|
| 175 | + if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 176 | + } else if (preg_match('/recentpireps/i',$host)) { |
|
| 177 | + //$formats[$id] = 'pirepsjson'; |
|
| 178 | + $globalSources[$id]['format'] = 'pirepsjson'; |
|
| 179 | + //$last_exec['pirepsjson'] = 0; |
|
| 180 | + if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 181 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 182 | + //$formats[$id] = 'fr24json'; |
|
| 183 | + $globalSources[$id]['format'] = 'fr24json'; |
|
| 184 | + //$last_exec['fr24json'] = 0; |
|
| 185 | + if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 186 | + if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
|
| 187 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
|
| 188 | + exit(0); |
|
| 189 | + } |
|
| 190 | + //} else if (preg_match('/10001/',$host)) { |
|
| 191 | + } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | + //$formats[$id] = 'tsv'; |
|
| 193 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 194 | + if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 195 | + } |
|
| 196 | + } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 197 | + if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 198 | + } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | + $hostport = explode(':',$host); |
|
| 200 | + if (isset($hostport[1])) { |
|
| 201 | 201 | $port = $hostport[1]; |
| 202 | 202 | $hostn = $hostport[0]; |
| 203 | - } else { |
|
| 203 | + } else { |
|
| 204 | 204 | $port = $globalSources[$id]['port']; |
| 205 | 205 | $hostn = $globalSources[$id]['host']; |
| 206 | - } |
|
| 207 | - if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 208 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 209 | - } else { |
|
| 210 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 211 | - } |
|
| 212 | - if ($s) { |
|
| 213 | - $sockets[$id] = $s; |
|
| 214 | - if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 215 | - if (preg_match('/aprs/',$hostn)) { |
|
| 206 | + } |
|
| 207 | + if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
|
| 208 | + $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 209 | + } else { |
|
| 210 | + $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 211 | + } |
|
| 212 | + if ($s) { |
|
| 213 | + $sockets[$id] = $s; |
|
| 214 | + if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
|
| 215 | + if (preg_match('/aprs/',$hostn)) { |
|
| 216 | 216 | //$formats[$id] = 'aprs'; |
| 217 | 217 | $globalSources[$id]['format'] = 'aprs'; |
| 218 | 218 | //$aprs_connect = 0; |
| 219 | 219 | //$use_aprs = true; |
| 220 | - } elseif ($port == '10001') { |
|
| 221 | - //$formats[$id] = 'tsv'; |
|
| 222 | - $globalSources[$id]['format'] = 'tsv'; |
|
| 223 | - } elseif ($port == '30002') { |
|
| 224 | - //$formats[$id] = 'raw'; |
|
| 225 | - $globalSources[$id]['format'] = 'raw'; |
|
| 226 | - } elseif ($port == '5001') { |
|
| 227 | - //$formats[$id] = 'raw'; |
|
| 228 | - $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 229 | - } elseif ($port == '30005') { |
|
| 220 | + } elseif ($port == '10001') { |
|
| 221 | + //$formats[$id] = 'tsv'; |
|
| 222 | + $globalSources[$id]['format'] = 'tsv'; |
|
| 223 | + } elseif ($port == '30002') { |
|
| 224 | + //$formats[$id] = 'raw'; |
|
| 225 | + $globalSources[$id]['format'] = 'raw'; |
|
| 226 | + } elseif ($port == '5001') { |
|
| 227 | + //$formats[$id] = 'raw'; |
|
| 228 | + $globalSources[$id]['format'] = 'flightgearmp'; |
|
| 229 | + } elseif ($port == '30005') { |
|
| 230 | 230 | // Not yet supported |
| 231 | - //$formats[$id] = 'beast'; |
|
| 232 | - $globalSources[$id]['format'] = 'beast'; |
|
| 233 | - //} else $formats[$id] = 'sbs'; |
|
| 234 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 235 | - //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 231 | + //$formats[$id] = 'beast'; |
|
| 232 | + $globalSources[$id]['format'] = 'beast'; |
|
| 233 | + //} else $formats[$id] = 'sbs'; |
|
| 234 | + } else $globalSources[$id]['format'] = 'sbs'; |
|
| 235 | + //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
|
| 236 | 236 | } |
| 237 | 237 | if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
| 238 | - } else { |
|
| 238 | + } else { |
|
| 239 | 239 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
| 240 | - } |
|
| 241 | - } |
|
| 242 | - } |
|
| 240 | + } |
|
| 241 | + } |
|
| 242 | + } |
|
| 243 | 243 | } |
| 244 | 244 | if (!isset($globalMinFetch)) $globalMinFetch = 15; |
| 245 | 245 | |
@@ -266,18 +266,18 @@ discard block |
||
| 266 | 266 | die; |
| 267 | 267 | } |
| 268 | 268 | foreach ($globalSources as $key => $source) { |
| 269 | - if (!isset($source['format'])) { |
|
| 270 | - $globalSources[$key]['format'] = 'auto'; |
|
| 271 | - } |
|
| 269 | + if (!isset($source['format'])) { |
|
| 270 | + $globalSources[$key]['format'] = 'auto'; |
|
| 271 | + } |
|
| 272 | 272 | } |
| 273 | 273 | connect_all($globalSources); |
| 274 | 274 | foreach ($globalSources as $key => $source) { |
| 275 | - if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 275 | + if (isset($source['format']) && $source['format'] == 'aprs') { |
|
| 276 | 276 | $aprs_connect = 0; |
| 277 | 277 | $use_aprs = true; |
| 278 | 278 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
| 279 | 279 | break; |
| 280 | - } |
|
| 280 | + } |
|
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | if ($use_aprs) { |
@@ -316,70 +316,70 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 318 | 318 | while ($i > 0) { |
| 319 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 320 | - // Delete old ATC |
|
| 321 | - if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 319 | + if (!$globalDaemon) $i = $endtime-time(); |
|
| 320 | + // Delete old ATC |
|
| 321 | + if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
|
| 322 | 322 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
| 323 | - $ATC->deleteOldATC(); |
|
| 324 | - } |
|
| 323 | + $ATC->deleteOldATC(); |
|
| 324 | + } |
|
| 325 | 325 | |
| 326 | - if (count($last_exec) > 0) { |
|
| 326 | + if (count($last_exec) > 0) { |
|
| 327 | 327 | $max = $globalMinFetch; |
| 328 | 328 | foreach ($last_exec as $last) { |
| 329 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 329 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 330 | 330 | } |
| 331 | 331 | if ($max != $globalMinFetch) { |
| 332 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 333 | - sleep($globalMinFetch-$max+2); |
|
| 332 | + if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 333 | + sleep($globalMinFetch-$max+2); |
|
| 334 | + } |
|
| 334 | 335 | } |
| 335 | - } |
|
| 336 | 336 | |
| 337 | 337 | |
| 338 | - //foreach ($formats as $id => $value) { |
|
| 339 | - foreach ($globalSources as $id => $value) { |
|
| 338 | + //foreach ($formats as $id => $value) { |
|
| 339 | + foreach ($globalSources as $id => $value) { |
|
| 340 | 340 | date_default_timezone_set('UTC'); |
| 341 | 341 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
| 342 | 342 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 343 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 344 | - $buffer = $Common->getData($value['host']); |
|
| 345 | - if ($buffer != '') $reset = 0; |
|
| 346 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | - $buffer = explode('\n',$buffer); |
|
| 348 | - foreach ($buffer as $line) { |
|
| 349 | - if ($line != '' && count($line) > 7) { |
|
| 350 | - $line = explode(',', $line); |
|
| 351 | - $data = array(); |
|
| 352 | - $data['hex'] = $line[1]; // hex |
|
| 353 | - $data['ident'] = $line[2]; // ident |
|
| 354 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 359 | - $data['verticalrate'] = ''; // vertical rate |
|
| 360 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 361 | - $data['emergency'] = ''; // emergency |
|
| 362 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 363 | - $data['format_source'] = 'deltadbtxt'; |
|
| 364 | - $data['id_source'] = $id_source; |
|
| 365 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 367 | - $SI->add($data); |
|
| 368 | - unset($data); |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - $last_exec[$id]['last'] = time(); |
|
| 343 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 344 | + $buffer = $Common->getData($value['host']); |
|
| 345 | + if ($buffer != '') $reset = 0; |
|
| 346 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | + $buffer = explode('\n',$buffer); |
|
| 348 | + foreach ($buffer as $line) { |
|
| 349 | + if ($line != '' && count($line) > 7) { |
|
| 350 | + $line = explode(',', $line); |
|
| 351 | + $data = array(); |
|
| 352 | + $data['hex'] = $line[1]; // hex |
|
| 353 | + $data['ident'] = $line[2]; // ident |
|
| 354 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 359 | + $data['verticalrate'] = ''; // vertical rate |
|
| 360 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
|
| 361 | + $data['emergency'] = ''; // emergency |
|
| 362 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 363 | + $data['format_source'] = 'deltadbtxt'; |
|
| 364 | + $data['id_source'] = $id_source; |
|
| 365 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 367 | + $SI->add($data); |
|
| 368 | + unset($data); |
|
| 369 | + } |
|
| 370 | + } |
|
| 371 | + $last_exec[$id]['last'] = time(); |
|
| 372 | 372 | //} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { |
| 373 | 373 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 374 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 375 | - $buffer = $Common->getData($value['host']); |
|
| 376 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | - $buffer = explode('\n',$buffer); |
|
| 378 | - $reset = 0; |
|
| 379 | - foreach ($buffer as $line) { |
|
| 380 | - if ($line != '') { |
|
| 381 | - $line = explode(':', $line); |
|
| 382 | - if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 374 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 375 | + $buffer = $Common->getData($value['host']); |
|
| 376 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | + $buffer = explode('\n',$buffer); |
|
| 378 | + $reset = 0; |
|
| 379 | + foreach ($buffer as $line) { |
|
| 380 | + if ($line != '') { |
|
| 381 | + $line = explode(':', $line); |
|
| 382 | + if (count($line) > 30 && $line[0] != 'callsign') { |
|
| 383 | 383 | $data = array(); |
| 384 | 384 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
| 385 | 385 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
@@ -392,36 +392,36 @@ discard block |
||
| 392 | 392 | if (isset($line[45])) $data['heading'] = $line[45]; // heading |
| 393 | 393 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
| 394 | 394 | $data['latitude'] = $line[5]; // lat |
| 395 | - $data['longitude'] = $line[6]; // long |
|
| 396 | - $data['verticalrate'] = ''; // vertical rate |
|
| 397 | - $data['squawk'] = ''; // squawk |
|
| 398 | - $data['emergency'] = ''; // emergency |
|
| 399 | - $data['waypoints'] = $line[30]; |
|
| 395 | + $data['longitude'] = $line[6]; // long |
|
| 396 | + $data['verticalrate'] = ''; // vertical rate |
|
| 397 | + $data['squawk'] = ''; // squawk |
|
| 398 | + $data['emergency'] = ''; // emergency |
|
| 399 | + $data['waypoints'] = $line[30]; |
|
| 400 | 400 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 401 | 401 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 402 | 402 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 403 | - $data['departure_airport_icao'] = $line[11]; |
|
| 404 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 405 | - $data['arrival_airport_icao'] = $line[13]; |
|
| 403 | + $data['departure_airport_icao'] = $line[11]; |
|
| 404 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 405 | + $data['arrival_airport_icao'] = $line[13]; |
|
| 406 | 406 | $data['frequency'] = $line[4]; |
| 407 | 407 | $data['type'] = $line[18]; |
| 408 | 408 | $data['range'] = $line[19]; |
| 409 | 409 | if (isset($line[35])) $data['info'] = $line[35]; |
| 410 | - $data['id_source'] = $id_source; |
|
| 411 | - //$data['arrival_airport_time'] = ; |
|
| 412 | - if ($line[9] != '') { |
|
| 413 | - $aircraft_data = explode('/',$line[9]); |
|
| 414 | - if (isset($aircraft_data[1])) { |
|
| 415 | - $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 416 | - } |
|
| 417 | - } |
|
| 418 | - /* |
|
| 410 | + $data['id_source'] = $id_source; |
|
| 411 | + //$data['arrival_airport_time'] = ; |
|
| 412 | + if ($line[9] != '') { |
|
| 413 | + $aircraft_data = explode('/',$line[9]); |
|
| 414 | + if (isset($aircraft_data[1])) { |
|
| 415 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | + /* |
|
| 419 | 419 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; |
| 420 | 420 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 421 | 421 | */ |
| 422 | - $data['format_source'] = $value['format']; |
|
| 422 | + $data['format_source'] = $value['format']; |
|
| 423 | 423 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 424 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 424 | + if ($line[3] == 'PILOT') $SI->add($data); |
|
| 425 | 425 | elseif ($line[3] == 'ATC') { |
| 426 | 426 | //print_r($data); |
| 427 | 427 | $data['info'] = str_replace('^§','<br />',$data['info']); |
@@ -439,247 +439,247 @@ discard block |
||
| 439 | 439 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 440 | 440 | 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']); |
| 441 | 441 | } |
| 442 | - unset($data); |
|
| 443 | - } |
|
| 444 | - } |
|
| 445 | - } |
|
| 446 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 447 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 448 | - $last_exec[$id]['last'] = time(); |
|
| 449 | - //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 450 | - } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 451 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 452 | - if ($buffer != '') { |
|
| 453 | - $all_data = json_decode($buffer,true); |
|
| 454 | - if (isset($all_data['acList'])) { |
|
| 442 | + unset($data); |
|
| 443 | + } |
|
| 444 | + } |
|
| 445 | + } |
|
| 446 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); |
|
| 447 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); |
|
| 448 | + $last_exec[$id]['last'] = time(); |
|
| 449 | + //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
|
| 450 | + } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 451 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 452 | + if ($buffer != '') { |
|
| 453 | + $all_data = json_decode($buffer,true); |
|
| 454 | + if (isset($all_data['acList'])) { |
|
| 455 | 455 | $reset = 0; |
| 456 | 456 | foreach ($all_data['acList'] as $line) { |
| 457 | - $data = array(); |
|
| 458 | - $data['hex'] = $line['Icao']; // hex |
|
| 459 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 460 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 461 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 462 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 463 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 464 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 465 | - //$data['verticalrate'] = $line['']; // verticale rate |
|
| 466 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 467 | - $data['emergency'] = ''; // emergency |
|
| 468 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 469 | - /* |
|
| 457 | + $data = array(); |
|
| 458 | + $data['hex'] = $line['Icao']; // hex |
|
| 459 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 460 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 461 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 462 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 463 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 464 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 465 | + //$data['verticalrate'] = $line['']; // verticale rate |
|
| 466 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 467 | + $data['emergency'] = ''; // emergency |
|
| 468 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 469 | + /* |
|
| 470 | 470 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 471 | 471 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 472 | 472 | */ |
| 473 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 474 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 475 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 476 | - $data['id_source'] = $id_source; |
|
| 477 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 478 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 479 | - unset($data); |
|
| 473 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 474 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 475 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 476 | + $data['id_source'] = $id_source; |
|
| 477 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 478 | + if (isset($data['datetime'])) $SI->add($data); |
|
| 479 | + unset($data); |
|
| 480 | 480 | } |
| 481 | - } else { |
|
| 481 | + } else { |
|
| 482 | 482 | $reset = 0; |
| 483 | 483 | foreach ($all_data as $line) { |
| 484 | - $data = array(); |
|
| 485 | - $data['hex'] = $line['hex']; // hex |
|
| 486 | - $data['ident'] = $line['flight']; // ident |
|
| 487 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 488 | - $data['speed'] = $line['speed']; // speed |
|
| 489 | - $data['heading'] = $line['track']; // heading |
|
| 490 | - $data['latitude'] = $line['lat']; // lat |
|
| 491 | - $data['longitude'] = $line['lon']; // long |
|
| 492 | - $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 493 | - $data['squawk'] = $line['squawk']; // squawk |
|
| 494 | - $data['emergency'] = ''; // emergency |
|
| 495 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 496 | - $data['format_source'] = 'aircraftlistjson'; |
|
| 497 | - $data['id_source'] = $id_source; |
|
| 498 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 499 | - $SI->add($data); |
|
| 500 | - unset($data); |
|
| 484 | + $data = array(); |
|
| 485 | + $data['hex'] = $line['hex']; // hex |
|
| 486 | + $data['ident'] = $line['flight']; // ident |
|
| 487 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 488 | + $data['speed'] = $line['speed']; // speed |
|
| 489 | + $data['heading'] = $line['track']; // heading |
|
| 490 | + $data['latitude'] = $line['lat']; // lat |
|
| 491 | + $data['longitude'] = $line['lon']; // long |
|
| 492 | + $data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 493 | + $data['squawk'] = $line['squawk']; // squawk |
|
| 494 | + $data['emergency'] = ''; // emergency |
|
| 495 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 496 | + $data['format_source'] = 'aircraftlistjson'; |
|
| 497 | + $data['id_source'] = $id_source; |
|
| 498 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 499 | + $SI->add($data); |
|
| 500 | + unset($data); |
|
| 501 | + } |
|
| 501 | 502 | } |
| 502 | - } |
|
| 503 | - } |
|
| 504 | - //$last_exec['aircraftlistjson'] = time(); |
|
| 505 | - $last_exec[$id]['last'] = time(); |
|
| 506 | - //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 507 | - } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 508 | - $buffer = $Common->getData($value['host']); |
|
| 509 | - $all_data = json_decode($buffer,true); |
|
| 510 | - if (isset($all_data['planes'])) { |
|
| 503 | + } |
|
| 504 | + //$last_exec['aircraftlistjson'] = time(); |
|
| 505 | + $last_exec[$id]['last'] = time(); |
|
| 506 | + //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
|
| 507 | + } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 508 | + $buffer = $Common->getData($value['host']); |
|
| 509 | + $all_data = json_decode($buffer,true); |
|
| 510 | + if (isset($all_data['planes'])) { |
|
| 511 | 511 | $reset = 0; |
| 512 | 512 | foreach ($all_data['planes'] as $key => $line) { |
| 513 | - $data = array(); |
|
| 514 | - $data['hex'] = $key; // hex |
|
| 515 | - $data['ident'] = $line[3]; // ident |
|
| 516 | - $data['altitude'] = $line[6]; // altitude |
|
| 517 | - $data['speed'] = $line[8]; // speed |
|
| 518 | - $data['heading'] = $line[7]; // heading |
|
| 519 | - $data['latitude'] = $line[4]; // lat |
|
| 520 | - $data['longitude'] = $line[5]; // long |
|
| 521 | - //$data['verticalrate'] = $line[]; // verticale rate |
|
| 522 | - $data['squawk'] = $line[10]; // squawk |
|
| 523 | - $data['emergency'] = ''; // emergency |
|
| 524 | - $data['registration'] = $line[2]; |
|
| 525 | - $data['aircraft_icao'] = $line[0]; |
|
| 526 | - $deparr = explode('-',$line[1]); |
|
| 527 | - if (count($deparr) == 2) { |
|
| 513 | + $data = array(); |
|
| 514 | + $data['hex'] = $key; // hex |
|
| 515 | + $data['ident'] = $line[3]; // ident |
|
| 516 | + $data['altitude'] = $line[6]; // altitude |
|
| 517 | + $data['speed'] = $line[8]; // speed |
|
| 518 | + $data['heading'] = $line[7]; // heading |
|
| 519 | + $data['latitude'] = $line[4]; // lat |
|
| 520 | + $data['longitude'] = $line[5]; // long |
|
| 521 | + //$data['verticalrate'] = $line[]; // verticale rate |
|
| 522 | + $data['squawk'] = $line[10]; // squawk |
|
| 523 | + $data['emergency'] = ''; // emergency |
|
| 524 | + $data['registration'] = $line[2]; |
|
| 525 | + $data['aircraft_icao'] = $line[0]; |
|
| 526 | + $deparr = explode('-',$line[1]); |
|
| 527 | + if (count($deparr) == 2) { |
|
| 528 | 528 | $data['departure_airport_icao'] = $deparr[0]; |
| 529 | 529 | $data['arrival_airport_icao'] = $deparr[1]; |
| 530 | - } |
|
| 531 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 532 | - $data['format_source'] = 'planeupdatefaa'; |
|
| 533 | - $data['id_source'] = $id_source; |
|
| 534 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 535 | - $SI->add($data); |
|
| 536 | - unset($data); |
|
| 530 | + } |
|
| 531 | + $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 532 | + $data['format_source'] = 'planeupdatefaa'; |
|
| 533 | + $data['id_source'] = $id_source; |
|
| 534 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 535 | + $SI->add($data); |
|
| 536 | + unset($data); |
|
| 537 | + } |
|
| 537 | 538 | } |
| 538 | - } |
|
| 539 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 540 | - $last_exec[$id]['last'] = time(); |
|
| 541 | - } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 542 | - $buffer = $Common->getData($value['host']); |
|
| 543 | - $all_data = json_decode($buffer,true); |
|
| 544 | - if (isset($all_data['states'])) { |
|
| 539 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 540 | + $last_exec[$id]['last'] = time(); |
|
| 541 | + } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 542 | + $buffer = $Common->getData($value['host']); |
|
| 543 | + $all_data = json_decode($buffer,true); |
|
| 544 | + if (isset($all_data['states'])) { |
|
| 545 | 545 | $reset = 0; |
| 546 | 546 | foreach ($all_data['states'] as $key => $line) { |
| 547 | - $data = array(); |
|
| 548 | - $data['hex'] = $line[0]; // hex |
|
| 549 | - $data['ident'] = trim($line[1]); // ident |
|
| 550 | - $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 551 | - $data['speed'] = round($line[9]*1.94384); // speed |
|
| 552 | - $data['heading'] = round($line[10]); // heading |
|
| 553 | - $data['latitude'] = $line[5]; // lat |
|
| 554 | - $data['longitude'] = $line[6]; // long |
|
| 555 | - $data['verticalrate'] = $line[11]; // verticale rate |
|
| 556 | - //$data['squawk'] = $line[10]; // squawk |
|
| 557 | - //$data['emergency'] = ''; // emergency |
|
| 558 | - //$data['registration'] = $line[2]; |
|
| 559 | - //$data['aircraft_icao'] = $line[0]; |
|
| 560 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 561 | - $data['format_source'] = 'opensky'; |
|
| 562 | - $data['id_source'] = $id_source; |
|
| 563 | - $SI->add($data); |
|
| 564 | - unset($data); |
|
| 547 | + $data = array(); |
|
| 548 | + $data['hex'] = $line[0]; // hex |
|
| 549 | + $data['ident'] = trim($line[1]); // ident |
|
| 550 | + $data['altitude'] = round($line[7]*3.28084); // altitude |
|
| 551 | + $data['speed'] = round($line[9]*1.94384); // speed |
|
| 552 | + $data['heading'] = round($line[10]); // heading |
|
| 553 | + $data['latitude'] = $line[5]; // lat |
|
| 554 | + $data['longitude'] = $line[6]; // long |
|
| 555 | + $data['verticalrate'] = $line[11]; // verticale rate |
|
| 556 | + //$data['squawk'] = $line[10]; // squawk |
|
| 557 | + //$data['emergency'] = ''; // emergency |
|
| 558 | + //$data['registration'] = $line[2]; |
|
| 559 | + //$data['aircraft_icao'] = $line[0]; |
|
| 560 | + $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 561 | + $data['format_source'] = 'opensky'; |
|
| 562 | + $data['id_source'] = $id_source; |
|
| 563 | + $SI->add($data); |
|
| 564 | + unset($data); |
|
| 565 | + } |
|
| 565 | 566 | } |
| 566 | - } |
|
| 567 | - //$last_exec['planeupdatefaa'] = time(); |
|
| 568 | - $last_exec[$id]['last'] = time(); |
|
| 569 | - //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 570 | - } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 571 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 572 | - $buffer = $Common->getData($value['host']); |
|
| 573 | - $all_data = json_decode($buffer,true); |
|
| 574 | - if (!empty($all_data)) $reset = 0; |
|
| 575 | - foreach ($all_data as $key => $line) { |
|
| 567 | + //$last_exec['planeupdatefaa'] = time(); |
|
| 568 | + $last_exec[$id]['last'] = time(); |
|
| 569 | + //} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { |
|
| 570 | + } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 571 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 572 | + $buffer = $Common->getData($value['host']); |
|
| 573 | + $all_data = json_decode($buffer,true); |
|
| 574 | + if (!empty($all_data)) $reset = 0; |
|
| 575 | + foreach ($all_data as $key => $line) { |
|
| 576 | 576 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 577 | - $data = array(); |
|
| 578 | - $data['hex'] = $line[0]; |
|
| 579 | - $data['ident'] = $line[16]; //$line[13] |
|
| 580 | - $data['altitude'] = $line[4]; // altitude |
|
| 581 | - $data['speed'] = $line[5]; // speed |
|
| 582 | - $data['heading'] = $line[3]; // heading |
|
| 583 | - $data['latitude'] = $line[1]; // lat |
|
| 584 | - $data['longitude'] = $line[2]; // long |
|
| 585 | - $data['verticalrate'] = $line[15]; // verticale rate |
|
| 586 | - $data['squawk'] = $line[6]; // squawk |
|
| 587 | - $data['aircraft_icao'] = $line[8]; |
|
| 588 | - $data['registration'] = $line[9]; |
|
| 589 | - $data['departure_airport_iata'] = $line[11]; |
|
| 590 | - $data['arrival_airport_iata'] = $line[12]; |
|
| 591 | - $data['emergency'] = ''; // emergency |
|
| 592 | - $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 593 | - $data['format_source'] = 'fr24json'; |
|
| 594 | - $data['id_source'] = $id_source; |
|
| 595 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 596 | - $SI->add($data); |
|
| 597 | - unset($data); |
|
| 577 | + $data = array(); |
|
| 578 | + $data['hex'] = $line[0]; |
|
| 579 | + $data['ident'] = $line[16]; //$line[13] |
|
| 580 | + $data['altitude'] = $line[4]; // altitude |
|
| 581 | + $data['speed'] = $line[5]; // speed |
|
| 582 | + $data['heading'] = $line[3]; // heading |
|
| 583 | + $data['latitude'] = $line[1]; // lat |
|
| 584 | + $data['longitude'] = $line[2]; // long |
|
| 585 | + $data['verticalrate'] = $line[15]; // verticale rate |
|
| 586 | + $data['squawk'] = $line[6]; // squawk |
|
| 587 | + $data['aircraft_icao'] = $line[8]; |
|
| 588 | + $data['registration'] = $line[9]; |
|
| 589 | + $data['departure_airport_iata'] = $line[11]; |
|
| 590 | + $data['arrival_airport_iata'] = $line[12]; |
|
| 591 | + $data['emergency'] = ''; // emergency |
|
| 592 | + $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
|
| 593 | + $data['format_source'] = 'fr24json'; |
|
| 594 | + $data['id_source'] = $id_source; |
|
| 595 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 596 | + $SI->add($data); |
|
| 597 | + unset($data); |
|
| 598 | + } |
|
| 598 | 599 | } |
| 599 | - } |
|
| 600 | - //$last_exec['fr24json'] = time(); |
|
| 601 | - $last_exec[$id]['last'] = time(); |
|
| 602 | - //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 603 | - } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 604 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 605 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 606 | - //echo $buffer; |
|
| 607 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 608 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 609 | - $all_data = json_decode($buffer,true); |
|
| 610 | - if (json_last_error() != JSON_ERROR_NONE) { |
|
| 600 | + //$last_exec['fr24json'] = time(); |
|
| 601 | + $last_exec[$id]['last'] = time(); |
|
| 602 | + //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
|
| 603 | + } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 604 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
|
| 605 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 606 | + //echo $buffer; |
|
| 607 | + $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 608 | + $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 609 | + $all_data = json_decode($buffer,true); |
|
| 610 | + if (json_last_error() != JSON_ERROR_NONE) { |
|
| 611 | 611 | die(json_last_error_msg()); |
| 612 | - } |
|
| 613 | - if (isset($all_data['mrkrs'])) { |
|
| 612 | + } |
|
| 613 | + if (isset($all_data['mrkrs'])) { |
|
| 614 | 614 | $reset = 0; |
| 615 | 615 | foreach ($all_data['mrkrs'] as $key => $line) { |
| 616 | - if (isset($line['inf'])) { |
|
| 616 | + if (isset($line['inf'])) { |
|
| 617 | 617 | $data = array(); |
| 618 | 618 | $data['hex'] = $line['inf']['ia']; |
| 619 | 619 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
| 620 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 621 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 622 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 623 | - $data['latitude'] = $line['pt'][0]; // lat |
|
| 624 | - $data['longitude'] = $line['pt'][1]; // long |
|
| 625 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 626 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 627 | - //$data['aircraft_icao'] = $line[8]; |
|
| 628 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 620 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
|
| 621 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 622 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 623 | + $data['latitude'] = $line['pt'][0]; // lat |
|
| 624 | + $data['longitude'] = $line['pt'][1]; // long |
|
| 625 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
|
| 626 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 627 | + //$data['aircraft_icao'] = $line[8]; |
|
| 628 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 629 | 629 | //$data['departure_airport_iata'] = $line[11]; |
| 630 | 630 | //$data['arrival_airport_iata'] = $line[12]; |
| 631 | - //$data['emergency'] = ''; // emergency |
|
| 631 | + //$data['emergency'] = ''; // emergency |
|
| 632 | 632 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 633 | - $data['format_source'] = 'radarvirtueljson'; |
|
| 634 | - $data['id_source'] = $id_source; |
|
| 633 | + $data['format_source'] = 'radarvirtueljson'; |
|
| 634 | + $data['id_source'] = $id_source; |
|
| 635 | 635 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
| 636 | 636 | $SI->add($data); |
| 637 | 637 | unset($data); |
| 638 | - } |
|
| 638 | + } |
|
| 639 | + } |
|
| 639 | 640 | } |
| 640 | - } |
|
| 641 | - //$last_exec['radarvirtueljson'] = time(); |
|
| 642 | - $last_exec[$id]['last'] = time(); |
|
| 643 | - //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 644 | - } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 645 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 646 | - $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 647 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 641 | + //$last_exec['radarvirtueljson'] = time(); |
|
| 642 | + $last_exec[$id]['last'] = time(); |
|
| 643 | + //} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { |
|
| 644 | + } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 645 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 646 | + $buffer = $Common->getData($value['host'].'?'.time()); |
|
| 647 | + $all_data = json_decode(utf8_encode($buffer),true); |
|
| 648 | 648 | |
| 649 | - if (isset($all_data['pireps'])) { |
|
| 649 | + if (isset($all_data['pireps'])) { |
|
| 650 | 650 | $reset = 0; |
| 651 | - foreach ($all_data['pireps'] as $line) { |
|
| 652 | - $data = array(); |
|
| 653 | - $data['id'] = $line['id']; |
|
| 654 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 655 | - $data['ident'] = $line['callsign']; // ident |
|
| 656 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 657 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 658 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 659 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 660 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 661 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 662 | - $data['latitude'] = $line['lat']; // lat |
|
| 663 | - $data['longitude'] = $line['lon']; // long |
|
| 664 | - //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 665 | - //$data['squawk'] = $line['squawk']; // squawk |
|
| 666 | - //$data['emergency'] = ''; // emergency |
|
| 667 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 668 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 669 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 670 | - //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 671 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 672 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 673 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 674 | - else $data['info'] = ''; |
|
| 675 | - $data['format_source'] = 'pireps'; |
|
| 676 | - $data['id_source'] = $id_source; |
|
| 677 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 678 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 679 | - if ($line['icon'] == 'plane') { |
|
| 651 | + foreach ($all_data['pireps'] as $line) { |
|
| 652 | + $data = array(); |
|
| 653 | + $data['id'] = $line['id']; |
|
| 654 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 655 | + $data['ident'] = $line['callsign']; // ident |
|
| 656 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 657 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 658 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 659 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 660 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 661 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 662 | + $data['latitude'] = $line['lat']; // lat |
|
| 663 | + $data['longitude'] = $line['lon']; // long |
|
| 664 | + //$data['verticalrate'] = $line['vrt']; // verticale rate |
|
| 665 | + //$data['squawk'] = $line['squawk']; // squawk |
|
| 666 | + //$data['emergency'] = ''; // emergency |
|
| 667 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 668 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 669 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 670 | + //$data['arrival_airport_time'] = $line['arrtime']; |
|
| 671 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 672 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 673 | + if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 674 | + else $data['info'] = ''; |
|
| 675 | + $data['format_source'] = 'pireps'; |
|
| 676 | + $data['id_source'] = $id_source; |
|
| 677 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 678 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 679 | + if ($line['icon'] == 'plane') { |
|
| 680 | 680 | $SI->add($data); |
| 681 | - // print_r($data); |
|
| 682 | - } elseif ($line['icon'] == 'ct') { |
|
| 681 | + // print_r($data); |
|
| 682 | + } elseif ($line['icon'] == 'ct') { |
|
| 683 | 683 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 684 | 684 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 685 | 685 | $typec = substr($data['ident'],-3); |
@@ -694,163 +694,163 @@ discard block |
||
| 694 | 694 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 695 | 695 | else $data['type'] = 'Observer'; |
| 696 | 696 | 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']); |
| 697 | - } |
|
| 698 | - unset($data); |
|
| 697 | + } |
|
| 698 | + unset($data); |
|
| 699 | + } |
|
| 699 | 700 | } |
| 700 | - } |
|
| 701 | - //$last_exec['pirepsjson'] = time(); |
|
| 702 | - $last_exec[$id]['last'] = time(); |
|
| 703 | - //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 704 | - } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 705 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 706 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 707 | - $buffer = $Common->getData($value['host']); |
|
| 708 | - $all_data = json_decode($buffer,true); |
|
| 709 | - if ($buffer != '' && is_array($all_data)) { |
|
| 701 | + //$last_exec['pirepsjson'] = time(); |
|
| 702 | + $last_exec[$id]['last'] = time(); |
|
| 703 | + //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
|
| 704 | + } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 705 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 706 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 707 | + $buffer = $Common->getData($value['host']); |
|
| 708 | + $all_data = json_decode($buffer,true); |
|
| 709 | + if ($buffer != '' && is_array($all_data)) { |
|
| 710 | 710 | $reset = 0; |
| 711 | 711 | foreach ($all_data as $line) { |
| 712 | - $data = array(); |
|
| 713 | - //$data['id'] = $line['id']; // id not usable |
|
| 714 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 715 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 716 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 717 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 718 | - $data['ident'] = $line['flightnum']; // ident |
|
| 719 | - $data['altitude'] = $line['alt']; // altitude |
|
| 720 | - $data['speed'] = $line['gs']; // speed |
|
| 721 | - $data['heading'] = $line['heading']; // heading |
|
| 722 | - $data['latitude'] = $line['lat']; // lat |
|
| 723 | - $data['longitude'] = $line['lng']; // long |
|
| 724 | - $data['verticalrate'] = ''; // verticale rate |
|
| 725 | - $data['squawk'] = ''; // squawk |
|
| 726 | - $data['emergency'] = ''; // emergency |
|
| 727 | - //$data['datetime'] = $line['lastupdate']; |
|
| 728 | - $data['last_update'] = $line['lastupdate']; |
|
| 729 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 730 | - $data['departure_airport_icao'] = $line['depicao']; |
|
| 731 | - $data['departure_airport_time'] = $line['deptime']; |
|
| 732 | - $data['arrival_airport_icao'] = $line['arricao']; |
|
| 733 | - $data['arrival_airport_time'] = $line['arrtime']; |
|
| 734 | - $data['registration'] = $line['aircraft']; |
|
| 735 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 736 | - if (isset($line['aircraftname'])) { |
|
| 712 | + $data = array(); |
|
| 713 | + //$data['id'] = $line['id']; // id not usable |
|
| 714 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 715 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 716 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 717 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 718 | + $data['ident'] = $line['flightnum']; // ident |
|
| 719 | + $data['altitude'] = $line['alt']; // altitude |
|
| 720 | + $data['speed'] = $line['gs']; // speed |
|
| 721 | + $data['heading'] = $line['heading']; // heading |
|
| 722 | + $data['latitude'] = $line['lat']; // lat |
|
| 723 | + $data['longitude'] = $line['lng']; // long |
|
| 724 | + $data['verticalrate'] = ''; // verticale rate |
|
| 725 | + $data['squawk'] = ''; // squawk |
|
| 726 | + $data['emergency'] = ''; // emergency |
|
| 727 | + //$data['datetime'] = $line['lastupdate']; |
|
| 728 | + $data['last_update'] = $line['lastupdate']; |
|
| 729 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 730 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 731 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 732 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 733 | + $data['arrival_airport_time'] = $line['arrtime']; |
|
| 734 | + $data['registration'] = $line['aircraft']; |
|
| 735 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 736 | + if (isset($line['aircraftname'])) { |
|
| 737 | 737 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 738 | 738 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 739 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 740 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 741 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 742 | - else { |
|
| 743 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 744 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 745 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 749 | - $data['id_source'] = $id_source; |
|
| 750 | - $data['format_source'] = 'phpvmacars'; |
|
| 751 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 752 | - $SI->add($data); |
|
| 753 | - unset($data); |
|
| 739 | + $aircraft_data = explode('-',$line['aircraftname']); |
|
| 740 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 741 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 742 | + else { |
|
| 743 | + $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 744 | + if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 745 | + else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 749 | + $data['id_source'] = $id_source; |
|
| 750 | + $data['format_source'] = 'phpvmacars'; |
|
| 751 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 752 | + $SI->add($data); |
|
| 753 | + unset($data); |
|
| 754 | 754 | } |
| 755 | 755 | if ($globalDebug) echo 'No more data...'."\n"; |
| 756 | 756 | unset($buffer); |
| 757 | 757 | unset($all_data); |
| 758 | - } |
|
| 759 | - //$last_exec['phpvmacars'] = time(); |
|
| 760 | - $last_exec[$id]['last'] = time(); |
|
| 761 | - } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 762 | - //$buffer = $Common->getData($hosts[$id]); |
|
| 763 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 764 | - $buffer = $Common->getData($value['host']); |
|
| 765 | - $all_data = json_decode($buffer,true); |
|
| 766 | - if ($buffer != '' && is_array($all_data)) { |
|
| 758 | + } |
|
| 759 | + //$last_exec['phpvmacars'] = time(); |
|
| 760 | + $last_exec[$id]['last'] = time(); |
|
| 761 | + } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
|
| 762 | + //$buffer = $Common->getData($hosts[$id]); |
|
| 763 | + if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 764 | + $buffer = $Common->getData($value['host']); |
|
| 765 | + $all_data = json_decode($buffer,true); |
|
| 766 | + if ($buffer != '' && is_array($all_data)) { |
|
| 767 | 767 | $reset = 0; |
| 768 | 768 | foreach ($all_data as $line) { |
| 769 | - $data = array(); |
|
| 770 | - //$data['id'] = $line['id']; // id not usable |
|
| 771 | - $data['id'] = trim($line['flight_id']); |
|
| 772 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 773 | - $data['pilot_name'] = $line['pilot_name']; |
|
| 774 | - $data['pilot_id'] = $line['pilot_id']; |
|
| 775 | - $data['ident'] = trim($line['callsign']); // ident |
|
| 776 | - $data['altitude'] = $line['altitude']; // altitude |
|
| 777 | - $data['speed'] = $line['gs']; // speed |
|
| 778 | - $data['heading'] = $line['heading']; // heading |
|
| 779 | - $data['latitude'] = $line['latitude']; // lat |
|
| 780 | - $data['longitude'] = $line['longitude']; // long |
|
| 781 | - $data['verticalrate'] = ''; // verticale rate |
|
| 782 | - $data['squawk'] = ''; // squawk |
|
| 783 | - $data['emergency'] = ''; // emergency |
|
| 784 | - //$data['datetime'] = $line['lastupdate']; |
|
| 785 | - $data['last_update'] = $line['last_update']; |
|
| 786 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 787 | - $data['departure_airport_icao'] = $line['departure']; |
|
| 788 | - //$data['departure_airport_time'] = $line['departure_time']; |
|
| 789 | - $data['arrival_airport_icao'] = $line['arrival']; |
|
| 790 | - //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 791 | - //$data['registration'] = $line['aircraft']; |
|
| 792 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 793 | - $data['aircraft_icao'] = $line['plane_type']; |
|
| 794 | - $data['id_source'] = $id_source; |
|
| 795 | - $data['format_source'] = 'vam'; |
|
| 796 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 797 | - $SI->add($data); |
|
| 798 | - unset($data); |
|
| 769 | + $data = array(); |
|
| 770 | + //$data['id'] = $line['id']; // id not usable |
|
| 771 | + $data['id'] = trim($line['flight_id']); |
|
| 772 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 773 | + $data['pilot_name'] = $line['pilot_name']; |
|
| 774 | + $data['pilot_id'] = $line['pilot_id']; |
|
| 775 | + $data['ident'] = trim($line['callsign']); // ident |
|
| 776 | + $data['altitude'] = $line['altitude']; // altitude |
|
| 777 | + $data['speed'] = $line['gs']; // speed |
|
| 778 | + $data['heading'] = $line['heading']; // heading |
|
| 779 | + $data['latitude'] = $line['latitude']; // lat |
|
| 780 | + $data['longitude'] = $line['longitude']; // long |
|
| 781 | + $data['verticalrate'] = ''; // verticale rate |
|
| 782 | + $data['squawk'] = ''; // squawk |
|
| 783 | + $data['emergency'] = ''; // emergency |
|
| 784 | + //$data['datetime'] = $line['lastupdate']; |
|
| 785 | + $data['last_update'] = $line['last_update']; |
|
| 786 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 787 | + $data['departure_airport_icao'] = $line['departure']; |
|
| 788 | + //$data['departure_airport_time'] = $line['departure_time']; |
|
| 789 | + $data['arrival_airport_icao'] = $line['arrival']; |
|
| 790 | + //$data['arrival_airport_time'] = $line['arrival_time']; |
|
| 791 | + //$data['registration'] = $line['aircraft']; |
|
| 792 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 793 | + $data['aircraft_icao'] = $line['plane_type']; |
|
| 794 | + $data['id_source'] = $id_source; |
|
| 795 | + $data['format_source'] = 'vam'; |
|
| 796 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 797 | + $SI->add($data); |
|
| 798 | + unset($data); |
|
| 799 | 799 | } |
| 800 | 800 | if ($globalDebug) echo 'No more data...'."\n"; |
| 801 | 801 | unset($buffer); |
| 802 | 802 | unset($all_data); |
| 803 | - } |
|
| 804 | - //$last_exec['phpvmacars'] = time(); |
|
| 805 | - $last_exec[$id]['last'] = time(); |
|
| 803 | + } |
|
| 804 | + //$last_exec['phpvmacars'] = time(); |
|
| 805 | + $last_exec[$id]['last'] = time(); |
|
| 806 | 806 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 807 | 807 | } 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') { |
| 808 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 809 | - //$last_exec[$id]['last'] = time(); |
|
| 808 | + if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 809 | + //$last_exec[$id]['last'] = time(); |
|
| 810 | 810 | |
| 811 | - //$read = array( $sockets[$id] ); |
|
| 812 | - $read = $sockets; |
|
| 813 | - $write = NULL; |
|
| 814 | - $e = NULL; |
|
| 815 | - $n = socket_select($read, $write, $e, $timeout); |
|
| 816 | - if ($e != NULL) var_dump($e); |
|
| 817 | - if ($n > 0) { |
|
| 811 | + //$read = array( $sockets[$id] ); |
|
| 812 | + $read = $sockets; |
|
| 813 | + $write = NULL; |
|
| 814 | + $e = NULL; |
|
| 815 | + $n = socket_select($read, $write, $e, $timeout); |
|
| 816 | + if ($e != NULL) var_dump($e); |
|
| 817 | + if ($n > 0) { |
|
| 818 | 818 | $reset = 0; |
| 819 | 819 | foreach ($read as $nb => $r) { |
| 820 | - //$value = $formats[$nb]; |
|
| 821 | - $format = $globalSources[$nb]['format']; |
|
| 822 | - if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 823 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 824 | - } else { |
|
| 825 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 826 | - } |
|
| 827 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 828 | - //echo $buffer."\n"; |
|
| 829 | - // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 830 | - //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 831 | - $error = false; |
|
| 832 | - //$SI::del(); |
|
| 833 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 834 | - // SBS format is CSV format |
|
| 835 | - if ($buffer != '') { |
|
| 820 | + //$value = $formats[$nb]; |
|
| 821 | + $format = $globalSources[$nb]['format']; |
|
| 822 | + if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
|
| 823 | + $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 824 | + } else { |
|
| 825 | + $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 826 | + } |
|
| 827 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
|
| 828 | + //echo $buffer."\n"; |
|
| 829 | + // lets play nice and handle signals such as ctrl-c/kill properly |
|
| 830 | + //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 831 | + $error = false; |
|
| 832 | + //$SI::del(); |
|
| 833 | + $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 834 | + // SBS format is CSV format |
|
| 835 | + if ($buffer != '') { |
|
| 836 | 836 | $tt[$format] = 0; |
| 837 | 837 | if ($format == 'acarssbs3') { |
| 838 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 839 | - $ACARS->add(trim($buffer)); |
|
| 840 | - $ACARS->deleteLiveAcarsData(); |
|
| 838 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 839 | + $ACARS->add(trim($buffer)); |
|
| 840 | + $ACARS->deleteLiveAcarsData(); |
|
| 841 | 841 | } elseif ($format == 'raw') { |
| 842 | - // AVR format |
|
| 843 | - $data = $SBS->parse($buffer); |
|
| 844 | - if (is_array($data)) { |
|
| 842 | + // AVR format |
|
| 843 | + $data = $SBS->parse($buffer); |
|
| 844 | + if (is_array($data)) { |
|
| 845 | 845 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 846 | 846 | $data['format_source'] = 'raw'; |
| 847 | 847 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 848 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 849 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 850 | - } |
|
| 851 | - } elseif ($format == 'flightgearsp') { |
|
| 852 | - //echo $buffer."\n"; |
|
| 853 | - if (strlen($buffer) > 5) { |
|
| 848 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 849 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 850 | + } |
|
| 851 | + } elseif ($format == 'flightgearsp') { |
|
| 852 | + //echo $buffer."\n"; |
|
| 853 | + if (strlen($buffer) > 5) { |
|
| 854 | 854 | $line = explode(',',$buffer); |
| 855 | 855 | $data = array(); |
| 856 | 856 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
@@ -866,124 +866,124 @@ discard block |
||
| 866 | 866 | $data['format_source'] = 'flightgearsp'; |
| 867 | 867 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 868 | 868 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 869 | - } |
|
| 870 | - } elseif ($format == 'acars') { |
|
| 871 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 872 | - $ACARS->add(trim($buffer)); |
|
| 873 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 874 | - $ACARS->deleteLiveAcarsData(); |
|
| 869 | + } |
|
| 870 | + } elseif ($format == 'acars') { |
|
| 871 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 872 | + $ACARS->add(trim($buffer)); |
|
| 873 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 874 | + $ACARS->deleteLiveAcarsData(); |
|
| 875 | 875 | } elseif ($format == 'flightgearmp') { |
| 876 | - if (substr($buffer,0,1) != '#') { |
|
| 876 | + if (substr($buffer,0,1) != '#') { |
|
| 877 | 877 | $data = array(); |
| 878 | 878 | //echo $buffer."\n"; |
| 879 | 879 | $line = explode(' ',$buffer); |
| 880 | 880 | if (count($line) == 11) { |
| 881 | - $userserver = explode('@',$line[0]); |
|
| 882 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 883 | - $data['ident'] = $userserver[0]; |
|
| 884 | - $data['registration'] = $userserver[0]; |
|
| 885 | - $data['latitude'] = $line[4]; |
|
| 886 | - $data['longitude'] = $line[5]; |
|
| 887 | - $data['altitude'] = $line[6]; |
|
| 888 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 889 | - $aircraft_type = $line[10]; |
|
| 890 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 891 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 892 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 881 | + $userserver = explode('@',$line[0]); |
|
| 882 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 883 | + $data['ident'] = $userserver[0]; |
|
| 884 | + $data['registration'] = $userserver[0]; |
|
| 885 | + $data['latitude'] = $line[4]; |
|
| 886 | + $data['longitude'] = $line[5]; |
|
| 887 | + $data['altitude'] = $line[6]; |
|
| 888 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 889 | + $aircraft_type = $line[10]; |
|
| 890 | + $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 891 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 892 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 893 | + } |
|
| 893 | 894 | } |
| 894 | - } |
|
| 895 | 895 | } elseif ($format == 'beast') { |
| 896 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 897 | - die; |
|
| 896 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
|
| 897 | + die; |
|
| 898 | 898 | } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
| 899 | - $line = explode("\t", $buffer); |
|
| 900 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 899 | + $line = explode("\t", $buffer); |
|
| 900 | + for($k = 0; $k < count($line); $k=$k+2) { |
|
| 901 | 901 | $key = $line[$k]; |
| 902 | - $lined[$key] = $line[$k+1]; |
|
| 903 | - } |
|
| 904 | - if (count($lined) > 3) { |
|
| 905 | - $data['hex'] = $lined['hexid']; |
|
| 906 | - //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 907 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 908 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 909 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 910 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 911 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 912 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 913 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 914 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 915 | - $data['id_source'] = $id_source; |
|
| 916 | - $data['format_source'] = 'tsv'; |
|
| 917 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 918 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 919 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 920 | - unset($lined); |
|
| 921 | - unset($data); |
|
| 922 | - } else $error = true; |
|
| 902 | + $lined[$key] = $line[$k+1]; |
|
| 903 | + } |
|
| 904 | + if (count($lined) > 3) { |
|
| 905 | + $data['hex'] = $lined['hexid']; |
|
| 906 | + //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
|
| 907 | + $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 908 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 909 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 910 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 911 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 912 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 913 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 914 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 915 | + $data['id_source'] = $id_source; |
|
| 916 | + $data['format_source'] = 'tsv'; |
|
| 917 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 918 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 919 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 920 | + unset($lined); |
|
| 921 | + unset($data); |
|
| 922 | + } else $error = true; |
|
| 923 | 923 | } elseif ($format == 'aprs' && $use_aprs) { |
| 924 | - if ($aprs_connect == 0) { |
|
| 924 | + if ($aprs_connect == 0) { |
|
| 925 | 925 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
| 926 | 926 | $aprs_connect = 1; |
| 927 | - } |
|
| 927 | + } |
|
| 928 | 928 | |
| 929 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 929 | + if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 930 | 930 | $aprs_last_tx = time(); |
| 931 | 931 | $data_aprs = "# Keep alive"; |
| 932 | 932 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 933 | - } |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 936 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 937 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 938 | - //echo $buffer."\n"; |
|
| 939 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 935 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
|
| 936 | + $buffer = str_replace('APRS <- ','',$buffer); |
|
| 937 | + $buffer = str_replace('APRS -> ','',$buffer); |
|
| 938 | + //echo $buffer."\n"; |
|
| 939 | + if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 940 | 940 | $line = $APRS->parse($buffer); |
| 941 | 941 | //print_r($line); |
| 942 | 942 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
| 943 | - $aprs_last_tx = time(); |
|
| 944 | - $data = array(); |
|
| 945 | - //print_r($line); |
|
| 946 | - $data['hex'] = $line['address']; |
|
| 947 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 948 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 949 | - //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 950 | - $data['ident'] = $line['ident']; |
|
| 951 | - $data['latitude'] = $line['latitude']; |
|
| 952 | - $data['longitude'] = $line['longitude']; |
|
| 953 | - //$data['verticalrate'] = $line[16]; |
|
| 954 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 955 | - else $data['speed'] = 0; |
|
| 956 | - $data['altitude'] = $line['altitude']; |
|
| 957 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 958 | - //else $data['heading'] = 0; |
|
| 959 | - $data['aircraft_type'] = $line['stealth']; |
|
| 960 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 961 | - $data['id_source'] = $id_source; |
|
| 962 | - $data['format_source'] = 'aprs'; |
|
| 963 | - $data['source_name'] = $line['source']; |
|
| 964 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 965 | - $currentdate = date('Y-m-d H:i:s'); |
|
| 966 | - $aprsdate = strtotime($data['datetime']); |
|
| 967 | - // Accept data if time <= system time + 20s |
|
| 968 | - if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 943 | + $aprs_last_tx = time(); |
|
| 944 | + $data = array(); |
|
| 945 | + //print_r($line); |
|
| 946 | + $data['hex'] = $line['address']; |
|
| 947 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 948 | + else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 949 | + //$data['datetime'] = date('Y-m-d H:i:s'); |
|
| 950 | + $data['ident'] = $line['ident']; |
|
| 951 | + $data['latitude'] = $line['latitude']; |
|
| 952 | + $data['longitude'] = $line['longitude']; |
|
| 953 | + //$data['verticalrate'] = $line[16]; |
|
| 954 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 955 | + else $data['speed'] = 0; |
|
| 956 | + $data['altitude'] = $line['altitude']; |
|
| 957 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 958 | + //else $data['heading'] = 0; |
|
| 959 | + $data['aircraft_type'] = $line['stealth']; |
|
| 960 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 961 | + $data['id_source'] = $id_source; |
|
| 962 | + $data['format_source'] = 'aprs'; |
|
| 963 | + $data['source_name'] = $line['source']; |
|
| 964 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 965 | + $currentdate = date('Y-m-d H:i:s'); |
|
| 966 | + $aprsdate = strtotime($data['datetime']); |
|
| 967 | + // Accept data if time <= system time + 20s |
|
| 968 | + if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 969 | 969 | $send = $SI->add($data); |
| 970 | - } else { |
|
| 970 | + } else { |
|
| 971 | 971 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
| 972 | 972 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
| 973 | - } |
|
| 974 | - unset($data); |
|
| 973 | + } |
|
| 974 | + unset($data); |
|
| 975 | 975 | } |
| 976 | 976 | elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
| 977 | 977 | echo '!! Weather Station not yet supported'."\n"; |
| 978 | 978 | } |
| 979 | 979 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
| 980 | 980 | //elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; |
| 981 | - } |
|
| 981 | + } |
|
| 982 | 982 | } else { |
| 983 | - $line = explode(',', $buffer); |
|
| 984 | - if (count($line) > 20) { |
|
| 985 | - $data['hex'] = $line[4]; |
|
| 986 | - /* |
|
| 983 | + $line = explode(',', $buffer); |
|
| 984 | + if (count($line) > 20) { |
|
| 985 | + $data['hex'] = $line[4]; |
|
| 986 | + /* |
|
| 987 | 987 | $data['datetime'] = $line[6].' '.$line[7]; |
| 988 | 988 | date_default_timezone_set($globalTimezone); |
| 989 | 989 | $datetime = new DateTime($data['datetime']); |
@@ -991,29 +991,29 @@ discard block |
||
| 991 | 991 | $data['datetime'] = $datetime->format('Y-m-d H:i:s'); |
| 992 | 992 | date_default_timezone_set('UTC'); |
| 993 | 993 | */ |
| 994 | - // Force datetime to current UTC datetime |
|
| 995 | - date_default_timezone_set('UTC'); |
|
| 996 | - $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 997 | - $data['ident'] = trim($line[10]); |
|
| 998 | - $data['latitude'] = $line[14]; |
|
| 999 | - $data['longitude'] = $line[15]; |
|
| 1000 | - $data['verticalrate'] = $line[16]; |
|
| 1001 | - $data['emergency'] = $line[20]; |
|
| 1002 | - $data['speed'] = $line[12]; |
|
| 1003 | - $data['squawk'] = $line[17]; |
|
| 1004 | - $data['altitude'] = $line[11]; |
|
| 1005 | - $data['heading'] = $line[13]; |
|
| 1006 | - $data['ground'] = $line[21]; |
|
| 1007 | - $data['emergency'] = $line[19]; |
|
| 1008 | - $data['format_source'] = 'sbs'; |
|
| 994 | + // Force datetime to current UTC datetime |
|
| 995 | + date_default_timezone_set('UTC'); |
|
| 996 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 997 | + $data['ident'] = trim($line[10]); |
|
| 998 | + $data['latitude'] = $line[14]; |
|
| 999 | + $data['longitude'] = $line[15]; |
|
| 1000 | + $data['verticalrate'] = $line[16]; |
|
| 1001 | + $data['emergency'] = $line[20]; |
|
| 1002 | + $data['speed'] = $line[12]; |
|
| 1003 | + $data['squawk'] = $line[17]; |
|
| 1004 | + $data['altitude'] = $line[11]; |
|
| 1005 | + $data['heading'] = $line[13]; |
|
| 1006 | + $data['ground'] = $line[21]; |
|
| 1007 | + $data['emergency'] = $line[19]; |
|
| 1008 | + $data['format_source'] = 'sbs'; |
|
| 1009 | 1009 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
| 1010 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1011 | - $data['id_source'] = $id_source; |
|
| 1012 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1013 | - else $error = true; |
|
| 1014 | - unset($data); |
|
| 1015 | - } else $error = true; |
|
| 1016 | - if ($error) { |
|
| 1010 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1011 | + $data['id_source'] = $id_source; |
|
| 1012 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1013 | + else $error = true; |
|
| 1014 | + unset($data); |
|
| 1015 | + } else $error = true; |
|
| 1016 | + if ($error) { |
|
| 1017 | 1017 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1018 | 1018 | if ($globalDebug) echo "Not a message. Ignoring... \n"; |
| 1019 | 1019 | } else { |
@@ -1029,13 +1029,13 @@ discard block |
||
| 1029 | 1029 | connect_all($sourceer); |
| 1030 | 1030 | $sourceer = array(); |
| 1031 | 1031 | } |
| 1032 | - } |
|
| 1032 | + } |
|
| 1033 | 1033 | } |
| 1034 | 1034 | // Sleep for xxx microseconds |
| 1035 | 1035 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
| 1036 | - } else { |
|
| 1036 | + } else { |
|
| 1037 | 1037 | if ($format == 'flightgearmp') { |
| 1038 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1038 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1039 | 1039 | //@socket_close($r); |
| 1040 | 1040 | sleep($globalMinFetch); |
| 1041 | 1041 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1044,9 +1044,9 @@ discard block |
||
| 1044 | 1044 | break; |
| 1045 | 1045 | |
| 1046 | 1046 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1047 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1048 | - else $tt[$format] = 0; |
|
| 1049 | - if ($tt[$format] > 30) { |
|
| 1047 | + if (isset($tt[$format])) $tt[$format]++; |
|
| 1048 | + else $tt[$format] = 0; |
|
| 1049 | + if ($tt[$format] > 30) { |
|
| 1050 | 1050 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
| 1051 | 1051 | //@socket_close($r); |
| 1052 | 1052 | sleep(2); |
@@ -1057,23 +1057,23 @@ discard block |
||
| 1057 | 1057 | //connect_all($globalSources); |
| 1058 | 1058 | $tt[$format]=0; |
| 1059 | 1059 | break; |
| 1060 | - } |
|
| 1060 | + } |
|
| 1061 | + } |
|
| 1061 | 1062 | } |
| 1062 | - } |
|
| 1063 | 1063 | } |
| 1064 | - } else { |
|
| 1064 | + } else { |
|
| 1065 | 1065 | $error = socket_strerror(socket_last_error()); |
| 1066 | 1066 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
| 1067 | 1067 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1068 | 1068 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1069 | 1069 | // Restart the script if possible |
| 1070 | 1070 | if (is_array($sockets)) { |
| 1071 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1071 | + if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1072 | 1072 | |
| 1073 | - foreach ($sockets as $sock) { |
|
| 1073 | + foreach ($sockets as $sock) { |
|
| 1074 | 1074 | @socket_shutdown($sock,2); |
| 1075 | 1075 | @socket_close($sock); |
| 1076 | - } |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | 1078 | } |
| 1079 | 1079 | if ($globalDebug) echo "Restart all connections..."; |
@@ -1084,13 +1084,13 @@ discard block |
||
| 1084 | 1084 | if ($reset > 40) exit('Too many attempts...'); |
| 1085 | 1085 | connect_all($globalSources); |
| 1086 | 1086 | } |
| 1087 | - } |
|
| 1087 | + } |
|
| 1088 | 1088 | } |
| 1089 | 1089 | if ($globalDaemon === false) { |
| 1090 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1091 | - $SI->checkAll(); |
|
| 1090 | + if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1091 | + $SI->checkAll(); |
|
| 1092 | + } |
|
| 1092 | 1093 | } |
| 1093 | - } |
|
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | 1096 | ?> |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | die; |
| 41 | 41 | } |
| 42 | 42 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); |
| 43 | - $globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); |
|
| 43 | + $globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | -$options = getopt('s::',array('source::','server','idsource::')); |
|
| 47 | +$options = getopt('s::', array('source::', 'server', 'idsource::')); |
|
| 48 | 48 | //if (isset($options['s'])) $hosts = array($options['s']); |
| 49 | 49 | //elseif (isset($options['source'])) $hosts = array($options['source']); |
| 50 | 50 | if (isset($options['s'])) { |
@@ -59,17 +59,17 @@ discard block |
||
| 59 | 59 | else $id_source = 1; |
| 60 | 60 | if (isset($globalServer) && $globalServer) { |
| 61 | 61 | if ($globalDebug) echo "Using Server Mode\n"; |
| 62 | - $SI=new SpotterServer(); |
|
| 63 | -} else $SI=new SpotterImport($Connection->db); |
|
| 62 | + $SI = new SpotterServer(); |
|
| 63 | +} else $SI = new SpotterImport($Connection->db); |
|
| 64 | 64 | //$APRS=new APRS($Connection->db); |
| 65 | -$SBS=new SBS(); |
|
| 66 | -$ACARS=new ACARS($Connection->db); |
|
| 67 | -$Common=new Common(); |
|
| 65 | +$SBS = new SBS(); |
|
| 66 | +$ACARS = new ACARS($Connection->db); |
|
| 67 | +$Common = new Common(); |
|
| 68 | 68 | date_default_timezone_set('UTC'); |
| 69 | 69 | //$servertz = system('date +%Z'); |
| 70 | 70 | // signal handler - playing nice with sockets and dump1090 |
| 71 | 71 | if (function_exists('pcntl_fork')) { |
| 72 | - pcntl_signal(SIGINT, function() { |
|
| 72 | + pcntl_signal(SIGINT, function() { |
|
| 73 | 73 | global $sockets; |
| 74 | 74 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; |
| 75 | 75 | die("Bye!\n"); |
@@ -113,35 +113,35 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | function connect_all($hosts) { |
| 115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 116 | - global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 116 | + global $sockets, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset; |
|
| 117 | 117 | $reset++; |
| 118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; |
| 119 | 119 | foreach ($hosts as $id => $value) { |
| 120 | 120 | $host = $value['host']; |
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; |
| 122 | 122 | // Here we check type of source(s) |
| 123 | - if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 124 | - if (preg_match('/deltadb.txt$/i',$host)) { |
|
| 123 | + if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { |
|
| 124 | + if (preg_match('/deltadb.txt$/i', $host)) { |
|
| 125 | 125 | //$formats[$id] = 'deltadbtxt'; |
| 126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 127 | 127 | //$last_exec['deltadbtxt'] = 0; |
| 128 | 128 | if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
| 129 | - } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
|
| 129 | + } else if (preg_match('/vatsim-data.txt$/i', $host)) { |
|
| 130 | 130 | //$formats[$id] = 'vatsimtxt'; |
| 131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 132 | 132 | //$last_exec['vatsimtxt'] = 0; |
| 133 | 133 | if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
| 134 | - } else if (preg_match('/aircraftlist.json$/i',$host)) { |
|
| 134 | + } else if (preg_match('/aircraftlist.json$/i', $host)) { |
|
| 135 | 135 | //$formats[$id] = 'aircraftlistjson'; |
| 136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 137 | 137 | //$last_exec['aircraftlistjson'] = 0; |
| 138 | 138 | if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
| 139 | - } else if (preg_match('/opensky/i',$host)) { |
|
| 139 | + } else if (preg_match('/opensky/i', $host)) { |
|
| 140 | 140 | //$formats[$id] = 'aircraftlistjson'; |
| 141 | 141 | $globalSources[$id]['format'] = 'opensky'; |
| 142 | 142 | //$last_exec['aircraftlistjson'] = 0; |
| 143 | 143 | if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
| 144 | - } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
|
| 144 | + } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) { |
|
| 145 | 145 | //$formats[$id] = 'radarvirtueljson'; |
| 146 | 146 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 147 | 147 | //$last_exec['radarvirtueljson'] = 0; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 151 | 151 | exit(0); |
| 152 | 152 | } |
| 153 | - } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { |
|
| 153 | + } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { |
|
| 154 | 154 | //$formats[$id] = 'planeupdatefaa'; |
| 155 | 155 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 156 | 156 | //$last_exec['planeupdatefaa'] = 0; |
@@ -159,26 +159,26 @@ discard block |
||
| 159 | 159 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 160 | 160 | exit(0); |
| 161 | 161 | } |
| 162 | - } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { |
|
| 162 | + } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { |
|
| 163 | 163 | //$formats[$id] = 'phpvmacars'; |
| 164 | 164 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 165 | 165 | //$last_exec['phpvmacars'] = 0; |
| 166 | 166 | if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
| 167 | - } else if (preg_match('/VAM-json.php$/i',$host)) { |
|
| 167 | + } else if (preg_match('/VAM-json.php$/i', $host)) { |
|
| 168 | 168 | //$formats[$id] = 'phpvmacars'; |
| 169 | 169 | $globalSources[$id]['format'] = 'vam'; |
| 170 | 170 | if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
| 171 | - } else if (preg_match('/whazzup/i',$host)) { |
|
| 171 | + } else if (preg_match('/whazzup/i', $host)) { |
|
| 172 | 172 | //$formats[$id] = 'whazzup'; |
| 173 | 173 | $globalSources[$id]['format'] = 'whazzup'; |
| 174 | 174 | //$last_exec['whazzup'] = 0; |
| 175 | 175 | if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
| 176 | - } else if (preg_match('/recentpireps/i',$host)) { |
|
| 176 | + } else if (preg_match('/recentpireps/i', $host)) { |
|
| 177 | 177 | //$formats[$id] = 'pirepsjson'; |
| 178 | 178 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 179 | 179 | //$last_exec['pirepsjson'] = 0; |
| 180 | 180 | if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
| 181 | - } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
|
| 181 | + } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { |
|
| 182 | 182 | //$formats[$id] = 'fr24json'; |
| 183 | 183 | $globalSources[$id]['format'] = 'fr24json'; |
| 184 | 184 | //$last_exec['fr24json'] = 0; |
@@ -188,15 +188,15 @@ discard block |
||
| 188 | 188 | exit(0); |
| 189 | 189 | } |
| 190 | 190 | //} else if (preg_match('/10001/',$host)) { |
| 191 | - } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 191 | + } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
|
| 192 | 192 | //$formats[$id] = 'tsv'; |
| 193 | 193 | $globalSources[$id]['format'] = 'tsv'; |
| 194 | 194 | if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
| 195 | 195 | } |
| 196 | - } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 196 | + } elseif (filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 197 | 197 | if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
| 198 | - } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
|
| 199 | - $hostport = explode(':',$host); |
|
| 198 | + } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { |
|
| 199 | + $hostport = explode(':', $host); |
|
| 200 | 200 | if (isset($hostport[1])) { |
| 201 | 201 | $port = $hostport[1]; |
| 202 | 202 | $hostn = $hostport[0]; |
@@ -205,14 +205,14 @@ discard block |
||
| 205 | 205 | $hostn = $globalSources[$id]['host']; |
| 206 | 206 | } |
| 207 | 207 | if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { |
| 208 | - $s = create_socket($hostn,$port, $errno, $errstr); |
|
| 208 | + $s = create_socket($hostn, $port, $errno, $errstr); |
|
| 209 | 209 | } else { |
| 210 | - $s = create_socket_udp($hostn,$port, $errno, $errstr); |
|
| 210 | + $s = create_socket_udp($hostn, $port, $errno, $errstr); |
|
| 211 | 211 | } |
| 212 | 212 | if ($s) { |
| 213 | 213 | $sockets[$id] = $s; |
| 214 | 214 | if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { |
| 215 | - if (preg_match('/aprs/',$hostn)) { |
|
| 215 | + if (preg_match('/aprs/', $hostn)) { |
|
| 216 | 216 | //$formats[$id] = 'aprs'; |
| 217 | 217 | $globalSources[$id]['format'] = 'aprs'; |
| 218 | 218 | //$aprs_connect = 0; |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
| 254 | 254 | else $timeout = 20; |
| 255 | 255 | $errno = ''; |
| 256 | -$errstr=''; |
|
| 256 | +$errstr = ''; |
|
| 257 | 257 | |
| 258 | 258 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 259 | 259 | /* Initiate connections to all the hosts simultaneously */ |
@@ -282,16 +282,16 @@ discard block |
||
| 282 | 282 | |
| 283 | 283 | if ($use_aprs) { |
| 284 | 284 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); |
| 285 | - $APRS=new APRS(); |
|
| 285 | + $APRS = new APRS(); |
|
| 286 | 286 | $aprs_connect = 0; |
| 287 | 287 | $aprs_keep = 120; |
| 288 | 288 | $aprs_last_tx = time(); |
| 289 | 289 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
| 290 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 290 | + else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); |
|
| 291 | 291 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
| 292 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 292 | + else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); |
|
| 293 | 293 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
| 294 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 294 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 295 | 295 | if ($aprs_full) $aprs_filter = ''; |
| 296 | 296 | |
| 297 | 297 | if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n"; |
@@ -303,12 +303,12 @@ discard block |
||
| 303 | 303 | sleep(1); |
| 304 | 304 | if ($globalDebug) echo "SCAN MODE \n\n"; |
| 305 | 305 | if (!isset($globalCronEnd)) $globalCronEnd = 60; |
| 306 | -$endtime = time()+$globalCronEnd; |
|
| 306 | +$endtime = time() + $globalCronEnd; |
|
| 307 | 307 | $i = 1; |
| 308 | 308 | $tt = array(); |
| 309 | 309 | // Delete all ATC |
| 310 | 310 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { |
| 311 | - $ATC=new ATC($Connection->db); |
|
| 311 | + $ATC = new ATC($Connection->db); |
|
| 312 | 312 | } |
| 313 | 313 | if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 314 | 314 | $ATC->deleteAll(); |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | |
| 317 | 317 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 318 | 318 | while ($i > 0) { |
| 319 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 319 | + if (!$globalDaemon) $i = $endtime - time(); |
|
| 320 | 320 | // Delete old ATC |
| 321 | 321 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 322 | 322 | if ($globalDebug) echo 'Delete old ATC...'."\n"; |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | if ($max != $globalMinFetch) { |
| 332 | 332 | if ($globalDebug) echo 'Sleeping...'."\n"; |
| 333 | - sleep($globalMinFetch-$max+2); |
|
| 333 | + sleep($globalMinFetch - $max + 2); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -343,8 +343,8 @@ discard block |
||
| 343 | 343 | //$buffer = $Common->getData($hosts[$id]); |
| 344 | 344 | $buffer = $Common->getData($value['host']); |
| 345 | 345 | if ($buffer != '') $reset = 0; |
| 346 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 347 | - $buffer = explode('\n',$buffer); |
|
| 346 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 347 | + $buffer = explode('\n', $buffer); |
|
| 348 | 348 | foreach ($buffer as $line) { |
| 349 | 349 | if ($line != '' && count($line) > 7) { |
| 350 | 350 | $line = explode(',', $line); |
@@ -373,8 +373,8 @@ discard block |
||
| 373 | 373 | } elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { |
| 374 | 374 | //$buffer = $Common->getData($hosts[$id]); |
| 375 | 375 | $buffer = $Common->getData($value['host']); |
| 376 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
|
| 377 | - $buffer = explode('\n',$buffer); |
|
| 376 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); |
|
| 377 | + $buffer = explode('\n', $buffer); |
|
| 378 | 378 | $reset = 0; |
| 379 | 379 | foreach ($buffer as $line) { |
| 380 | 380 | if ($line != '') { |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
| 386 | 386 | $data['pilot_id'] = $line[1]; |
| 387 | 387 | $data['pilot_name'] = $line[2]; |
| 388 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
|
| 388 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); |
|
| 389 | 389 | $data['ident'] = $line[0]; // ident |
| 390 | 390 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
| 391 | 391 | $data['speed'] = $line[8]; // speed |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); |
| 402 | 402 | //if (isset($line[37])) $data['last_update'] = $line[37]; |
| 403 | 403 | $data['departure_airport_icao'] = $line[11]; |
| 404 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); |
|
| 404 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); |
|
| 405 | 405 | $data['arrival_airport_icao'] = $line[13]; |
| 406 | 406 | $data['frequency'] = $line[4]; |
| 407 | 407 | $data['type'] = $line[18]; |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $data['id_source'] = $id_source; |
| 411 | 411 | //$data['arrival_airport_time'] = ; |
| 412 | 412 | if ($line[9] != '') { |
| 413 | - $aircraft_data = explode('/',$line[9]); |
|
| 413 | + $aircraft_data = explode('/', $line[9]); |
|
| 414 | 414 | if (isset($aircraft_data[1])) { |
| 415 | 415 | $data['aircraft_icao'] = $aircraft_data[1]; |
| 416 | 416 | } |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | if ($line[3] == 'PILOT') $SI->add($data); |
| 425 | 425 | elseif ($line[3] == 'ATC') { |
| 426 | 426 | //print_r($data); |
| 427 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 428 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 429 | - $typec = substr($data['ident'],-3); |
|
| 427 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 428 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 429 | + $typec = substr($data['ident'], -3); |
|
| 430 | 430 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 431 | 431 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
| 432 | 432 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 438 | 438 | elseif ($data['type'] == '') $data['type'] = 'Observer'; |
| 439 | 439 | if (!isset($data['source_name'])) $data['source_name'] = ''; |
| 440 | - 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']); |
|
| 440 | + 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']); |
|
| 441 | 441 | } |
| 442 | 442 | unset($data); |
| 443 | 443 | } |
@@ -448,9 +448,9 @@ discard block |
||
| 448 | 448 | $last_exec[$id]['last'] = time(); |
| 449 | 449 | //} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) { |
| 450 | 450 | } elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 451 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); |
|
| 451 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); |
|
| 452 | 452 | if ($buffer != '') { |
| 453 | - $all_data = json_decode($buffer,true); |
|
| 453 | + $all_data = json_decode($buffer, true); |
|
| 454 | 454 | if (isset($all_data['acList'])) { |
| 455 | 455 | $reset = 0; |
| 456 | 456 | foreach ($all_data['acList'] as $line) { |
@@ -506,7 +506,7 @@ discard block |
||
| 506 | 506 | //} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { |
| 507 | 507 | } elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 508 | 508 | $buffer = $Common->getData($value['host']); |
| 509 | - $all_data = json_decode($buffer,true); |
|
| 509 | + $all_data = json_decode($buffer, true); |
|
| 510 | 510 | if (isset($all_data['planes'])) { |
| 511 | 511 | $reset = 0; |
| 512 | 512 | foreach ($all_data['planes'] as $key => $line) { |
@@ -523,12 +523,12 @@ discard block |
||
| 523 | 523 | $data['emergency'] = ''; // emergency |
| 524 | 524 | $data['registration'] = $line[2]; |
| 525 | 525 | $data['aircraft_icao'] = $line[0]; |
| 526 | - $deparr = explode('-',$line[1]); |
|
| 526 | + $deparr = explode('-', $line[1]); |
|
| 527 | 527 | if (count($deparr) == 2) { |
| 528 | 528 | $data['departure_airport_icao'] = $deparr[0]; |
| 529 | 529 | $data['arrival_airport_icao'] = $deparr[1]; |
| 530 | 530 | } |
| 531 | - $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
|
| 531 | + $data['datetime'] = date('Y-m-d H:i:s', $line[9]); |
|
| 532 | 532 | $data['format_source'] = 'planeupdatefaa'; |
| 533 | 533 | $data['id_source'] = $id_source; |
| 534 | 534 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | $last_exec[$id]['last'] = time(); |
| 541 | 541 | } elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 542 | 542 | $buffer = $Common->getData($value['host']); |
| 543 | - $all_data = json_decode($buffer,true); |
|
| 543 | + $all_data = json_decode($buffer, true); |
|
| 544 | 544 | if (isset($all_data['states'])) { |
| 545 | 545 | $reset = 0; |
| 546 | 546 | foreach ($all_data['states'] as $key => $line) { |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | //$data['emergency'] = ''; // emergency |
| 558 | 558 | //$data['registration'] = $line[2]; |
| 559 | 559 | //$data['aircraft_icao'] = $line[0]; |
| 560 | - $data['datetime'] = date('Y-m-d H:i:s',$line[3]); |
|
| 560 | + $data['datetime'] = date('Y-m-d H:i:s', $line[3]); |
|
| 561 | 561 | $data['format_source'] = 'opensky'; |
| 562 | 562 | $data['id_source'] = $id_source; |
| 563 | 563 | $SI->add($data); |
@@ -570,7 +570,7 @@ discard block |
||
| 570 | 570 | } elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 571 | 571 | //$buffer = $Common->getData($hosts[$id]); |
| 572 | 572 | $buffer = $Common->getData($value['host']); |
| 573 | - $all_data = json_decode($buffer,true); |
|
| 573 | + $all_data = json_decode($buffer, true); |
|
| 574 | 574 | if (!empty($all_data)) $reset = 0; |
| 575 | 575 | foreach ($all_data as $key => $line) { |
| 576 | 576 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
@@ -602,11 +602,11 @@ discard block |
||
| 602 | 602 | //} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { |
| 603 | 603 | } elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 604 | 604 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); |
| 605 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); |
|
| 605 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); |
|
| 606 | 606 | //echo $buffer; |
| 607 | - $buffer = str_replace(array("\n","\r"),"",$buffer); |
|
| 608 | - $buffer = preg_replace('/,"num":(.+)/','}',$buffer); |
|
| 609 | - $all_data = json_decode($buffer,true); |
|
| 607 | + $buffer = str_replace(array("\n", "\r"), "", $buffer); |
|
| 608 | + $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); |
|
| 609 | + $all_data = json_decode($buffer, true); |
|
| 610 | 610 | if (json_last_error() != JSON_ERROR_NONE) { |
| 611 | 611 | die(json_last_error_msg()); |
| 612 | 612 | } |
@@ -629,7 +629,7 @@ discard block |
||
| 629 | 629 | //$data['departure_airport_iata'] = $line[11]; |
| 630 | 630 | //$data['arrival_airport_iata'] = $line[12]; |
| 631 | 631 | //$data['emergency'] = ''; // emergency |
| 632 | - $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
|
| 632 | + $data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] |
|
| 633 | 633 | $data['format_source'] = 'radarvirtueljson'; |
| 634 | 634 | $data['id_source'] = $id_source; |
| 635 | 635 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
@@ -644,14 +644,14 @@ discard block |
||
| 644 | 644 | } elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 645 | 645 | //$buffer = $Common->getData($hosts[$id]); |
| 646 | 646 | $buffer = $Common->getData($value['host'].'?'.time()); |
| 647 | - $all_data = json_decode(utf8_encode($buffer),true); |
|
| 647 | + $all_data = json_decode(utf8_encode($buffer), true); |
|
| 648 | 648 | |
| 649 | 649 | if (isset($all_data['pireps'])) { |
| 650 | 650 | $reset = 0; |
| 651 | 651 | foreach ($all_data['pireps'] as $line) { |
| 652 | 652 | $data = array(); |
| 653 | 653 | $data['id'] = $line['id']; |
| 654 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
|
| 654 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 655 | 655 | $data['ident'] = $line['callsign']; // ident |
| 656 | 656 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
| 657 | 657 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
@@ -680,9 +680,9 @@ discard block |
||
| 680 | 680 | $SI->add($data); |
| 681 | 681 | // print_r($data); |
| 682 | 682 | } elseif ($line['icon'] == 'ct') { |
| 683 | - $data['info'] = str_replace('^§','<br />',$data['info']); |
|
| 684 | - $data['info'] = str_replace('&sect;','',$data['info']); |
|
| 685 | - $typec = substr($data['ident'],-3); |
|
| 683 | + $data['info'] = str_replace('^§', '<br />', $data['info']); |
|
| 684 | + $data['info'] = str_replace('&sect;', '', $data['info']); |
|
| 685 | + $typec = substr($data['ident'], -3); |
|
| 686 | 686 | $data['type'] = ''; |
| 687 | 687 | if ($typec == 'APP') $data['type'] = 'Approach'; |
| 688 | 688 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
@@ -693,7 +693,7 @@ discard block |
||
| 693 | 693 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
| 694 | 694 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
| 695 | 695 | else $data['type'] = 'Observer'; |
| 696 | - 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']); |
|
| 696 | + 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']); |
|
| 697 | 697 | } |
| 698 | 698 | unset($data); |
| 699 | 699 | } |
@@ -705,14 +705,14 @@ discard block |
||
| 705 | 705 | //$buffer = $Common->getData($hosts[$id]); |
| 706 | 706 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 707 | 707 | $buffer = $Common->getData($value['host']); |
| 708 | - $all_data = json_decode($buffer,true); |
|
| 708 | + $all_data = json_decode($buffer, true); |
|
| 709 | 709 | if ($buffer != '' && is_array($all_data)) { |
| 710 | 710 | $reset = 0; |
| 711 | 711 | foreach ($all_data as $line) { |
| 712 | 712 | $data = array(); |
| 713 | 713 | //$data['id'] = $line['id']; // id not usable |
| 714 | 714 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
| 715 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 715 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 716 | 716 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
| 717 | 717 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
| 718 | 718 | $data['ident'] = $line['flightnum']; // ident |
@@ -735,12 +735,12 @@ discard block |
||
| 735 | 735 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
| 736 | 736 | if (isset($line['aircraftname'])) { |
| 737 | 737 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 738 | - $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
|
| 739 | - $aircraft_data = explode('-',$line['aircraftname']); |
|
| 738 | + $line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); |
|
| 739 | + $aircraft_data = explode('-', $line['aircraftname']); |
|
| 740 | 740 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
| 741 | 741 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
| 742 | 742 | else { |
| 743 | - $aircraft_data = explode(' ',$line['aircraftname']); |
|
| 743 | + $aircraft_data = explode(' ', $line['aircraftname']); |
|
| 744 | 744 | if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
| 745 | 745 | else $data['aircraft_icao'] = $line['aircraftname']; |
| 746 | 746 | } |
@@ -762,14 +762,14 @@ discard block |
||
| 762 | 762 | //$buffer = $Common->getData($hosts[$id]); |
| 763 | 763 | if ($globalDebug) echo 'Get Data...'."\n"; |
| 764 | 764 | $buffer = $Common->getData($value['host']); |
| 765 | - $all_data = json_decode($buffer,true); |
|
| 765 | + $all_data = json_decode($buffer, true); |
|
| 766 | 766 | if ($buffer != '' && is_array($all_data)) { |
| 767 | 767 | $reset = 0; |
| 768 | 768 | foreach ($all_data as $line) { |
| 769 | 769 | $data = array(); |
| 770 | 770 | //$data['id'] = $line['id']; // id not usable |
| 771 | 771 | $data['id'] = trim($line['flight_id']); |
| 772 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex |
|
| 772 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex |
|
| 773 | 773 | $data['pilot_name'] = $line['pilot_name']; |
| 774 | 774 | $data['pilot_id'] = $line['pilot_id']; |
| 775 | 775 | $data['ident'] = trim($line['callsign']); // ident |
@@ -820,9 +820,9 @@ discard block |
||
| 820 | 820 | //$value = $formats[$nb]; |
| 821 | 821 | $format = $globalSources[$nb]['format']; |
| 822 | 822 | if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { |
| 823 | - $buffer = socket_read($r, 6000,PHP_NORMAL_READ); |
|
| 823 | + $buffer = socket_read($r, 6000, PHP_NORMAL_READ); |
|
| 824 | 824 | } else { |
| 825 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); |
|
| 825 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); |
|
| 826 | 826 | } |
| 827 | 827 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); |
| 828 | 828 | //echo $buffer."\n"; |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
| 831 | 831 | $error = false; |
| 832 | 832 | //$SI::del(); |
| 833 | - $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); |
|
| 833 | + $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); |
|
| 834 | 834 | // SBS format is CSV format |
| 835 | 835 | if ($buffer != '') { |
| 836 | 836 | $tt[$format] = 0; |
@@ -851,10 +851,10 @@ discard block |
||
| 851 | 851 | } elseif ($format == 'flightgearsp') { |
| 852 | 852 | //echo $buffer."\n"; |
| 853 | 853 | if (strlen($buffer) > 5) { |
| 854 | - $line = explode(',',$buffer); |
|
| 854 | + $line = explode(',', $buffer); |
|
| 855 | 855 | $data = array(); |
| 856 | 856 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p |
| 857 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); |
|
| 857 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); |
|
| 858 | 858 | $data['ident'] = $line[6]; |
| 859 | 859 | $data['aircraft_name'] = $line[7]; |
| 860 | 860 | $data['longitude'] = $line[1]; |
@@ -865,21 +865,21 @@ discard block |
||
| 865 | 865 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 866 | 866 | $data['format_source'] = 'flightgearsp'; |
| 867 | 867 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 868 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 868 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 869 | 869 | } |
| 870 | 870 | } elseif ($format == 'acars') { |
| 871 | 871 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
| 872 | 872 | $ACARS->add(trim($buffer)); |
| 873 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
|
| 873 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); |
|
| 874 | 874 | $ACARS->deleteLiveAcarsData(); |
| 875 | 875 | } elseif ($format == 'flightgearmp') { |
| 876 | - if (substr($buffer,0,1) != '#') { |
|
| 876 | + if (substr($buffer, 0, 1) != '#') { |
|
| 877 | 877 | $data = array(); |
| 878 | 878 | //echo $buffer."\n"; |
| 879 | - $line = explode(' ',$buffer); |
|
| 879 | + $line = explode(' ', $buffer); |
|
| 880 | 880 | if (count($line) == 11) { |
| 881 | - $userserver = explode('@',$line[0]); |
|
| 882 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex |
|
| 881 | + $userserver = explode('@', $line[0]); |
|
| 882 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex |
|
| 883 | 883 | $data['ident'] = $userserver[0]; |
| 884 | 884 | $data['registration'] = $userserver[0]; |
| 885 | 885 | $data['latitude'] = $line[4]; |
@@ -887,24 +887,24 @@ discard block |
||
| 887 | 887 | $data['altitude'] = $line[6]; |
| 888 | 888 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 889 | 889 | $aircraft_type = $line[10]; |
| 890 | - $aircraft_type = preg_split(':/:',$aircraft_type); |
|
| 891 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
|
| 890 | + $aircraft_type = preg_split(':/:', $aircraft_type); |
|
| 891 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); |
|
| 892 | 892 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
| 893 | 893 | } |
| 894 | 894 | } |
| 895 | 895 | } elseif ($format == 'beast') { |
| 896 | 896 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; |
| 897 | 897 | die; |
| 898 | - } elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { |
|
| 898 | + } elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { |
|
| 899 | 899 | $line = explode("\t", $buffer); |
| 900 | - for($k = 0; $k < count($line); $k=$k+2) { |
|
| 900 | + for ($k = 0; $k < count($line); $k = $k + 2) { |
|
| 901 | 901 | $key = $line[$k]; |
| 902 | - $lined[$key] = $line[$k+1]; |
|
| 902 | + $lined[$key] = $line[$k + 1]; |
|
| 903 | 903 | } |
| 904 | 904 | if (count($lined) > 3) { |
| 905 | 905 | $data['hex'] = $lined['hexid']; |
| 906 | 906 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 907 | - $data['datetime'] = date('Y-m-d H:i:s');; |
|
| 907 | + $data['datetime'] = date('Y-m-d H:i:s'); ; |
|
| 908 | 908 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
| 909 | 909 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
| 910 | 910 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
@@ -922,21 +922,21 @@ discard block |
||
| 922 | 922 | } else $error = true; |
| 923 | 923 | } elseif ($format == 'aprs' && $use_aprs) { |
| 924 | 924 | if ($aprs_connect == 0) { |
| 925 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
|
| 925 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); |
|
| 926 | 926 | $aprs_connect = 1; |
| 927 | 927 | } |
| 928 | 928 | |
| 929 | - if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { |
|
| 929 | + if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { |
|
| 930 | 930 | $aprs_last_tx = time(); |
| 931 | 931 | $data_aprs = "# Keep alive"; |
| 932 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
|
| 932 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); |
|
| 933 | 933 | } |
| 934 | 934 | |
| 935 | 935 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; |
| 936 | - $buffer = str_replace('APRS <- ','',$buffer); |
|
| 937 | - $buffer = str_replace('APRS -> ','',$buffer); |
|
| 936 | + $buffer = str_replace('APRS <- ', '', $buffer); |
|
| 937 | + $buffer = str_replace('APRS -> ', '', $buffer); |
|
| 938 | 938 | //echo $buffer."\n"; |
| 939 | - if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { |
|
| 939 | + if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { |
|
| 940 | 940 | $line = $APRS->parse($buffer); |
| 941 | 941 | //print_r($line); |
| 942 | 942 | if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | $data = array(); |
| 945 | 945 | //print_r($line); |
| 946 | 946 | $data['hex'] = $line['address']; |
| 947 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 947 | + if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); |
|
| 948 | 948 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 949 | 949 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 950 | 950 | $data['ident'] = $line['ident']; |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | $currentdate = date('Y-m-d H:i:s'); |
| 966 | 966 | $aprsdate = strtotime($data['datetime']); |
| 967 | 967 | // Accept data if time <= system time + 20s |
| 968 | - if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 968 | + if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
|
| 969 | 969 | $send = $SI->add($data); |
| 970 | 970 | } else { |
| 971 | 971 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
@@ -1055,7 +1055,7 @@ discard block |
||
| 1055 | 1055 | connect_all($sourceee); |
| 1056 | 1056 | $sourceee = array(); |
| 1057 | 1057 | //connect_all($globalSources); |
| 1058 | - $tt[$format]=0; |
|
| 1058 | + $tt[$format] = 0; |
|
| 1059 | 1059 | break; |
| 1060 | 1060 | } |
| 1061 | 1061 | } |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | } |
| 1064 | 1064 | } else { |
| 1065 | 1065 | $error = socket_strerror(socket_last_error()); |
| 1066 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1066 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; |
|
| 1067 | 1067 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1068 | 1068 | if (isset($globalDebug)) echo "Restarting...\n"; |
| 1069 | 1069 | // Restart the script if possible |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | if ($globalDebug) echo "Shutdown all sockets..."; |
| 1072 | 1072 | |
| 1073 | 1073 | foreach ($sockets as $sock) { |
| 1074 | - @socket_shutdown($sock,2); |
|
| 1074 | + @socket_shutdown($sock, 2); |
|
| 1075 | 1075 | @socket_close($sock); |
| 1076 | 1076 | } |
| 1077 | 1077 | |
@@ -14,7 +14,9 @@ discard block |
||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); |
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Common.php'); |
| 16 | 16 | |
| 17 | -if (!isset($globalDebug)) $globalDebug = FALSE; |
|
| 17 | +if (!isset($globalDebug)) { |
|
| 18 | + $globalDebug = FALSE; |
|
| 19 | +} |
|
| 18 | 20 | |
| 19 | 21 | // Check if schema is at latest version |
| 20 | 22 | $Connection = new Connection(); |
@@ -54,13 +56,22 @@ discard block |
||
| 54 | 56 | $globalSources = array(); |
| 55 | 57 | $globalSources[] = array('host' => $options['source']); |
| 56 | 58 | } |
| 57 | -if (isset($options['server'])) $globalServer = TRUE; |
|
| 58 | -if (isset($options['idsource'])) $id_source = $options['idsource']; |
|
| 59 | -else $id_source = 1; |
|
| 59 | +if (isset($options['server'])) { |
|
| 60 | + $globalServer = TRUE; |
|
| 61 | +} |
|
| 62 | +if (isset($options['idsource'])) { |
|
| 63 | + $id_source = $options['idsource']; |
|
| 64 | +} else { |
|
| 65 | + $id_source = 1; |
|
| 66 | +} |
|
| 60 | 67 | if (isset($globalServer) && $globalServer) { |
| 61 | - if ($globalDebug) echo "Using Server Mode\n"; |
|
| 68 | + if ($globalDebug) { |
|
| 69 | + echo "Using Server Mode\n"; |
|
| 70 | + } |
|
| 62 | 71 | $SI=new SpotterServer(); |
| 63 | -} else $SI=new SpotterImport($Connection->db); |
|
| 72 | +} else { |
|
| 73 | + $SI=new SpotterImport($Connection->db); |
|
| 74 | +} |
|
| 64 | 75 | //$APRS=new APRS($Connection->db); |
| 65 | 76 | $SBS=new SBS(); |
| 66 | 77 | $ACARS=new ACARS($Connection->db); |
@@ -78,7 +89,9 @@ discard block |
||
| 78 | 89 | } |
| 79 | 90 | |
| 80 | 91 | // let's try and connect |
| 81 | -if ($globalDebug) echo "Connecting...\n"; |
|
| 92 | +if ($globalDebug) { |
|
| 93 | + echo "Connecting...\n"; |
|
| 94 | +} |
|
| 82 | 95 | $use_aprs = false; |
| 83 | 96 | $aprs_full = false; |
| 84 | 97 | $reset = 0; |
@@ -87,7 +100,9 @@ discard block |
||
| 87 | 100 | $ip = gethostbyname($host); |
| 88 | 101 | $s = socket_create(AF_INET, SOCK_STREAM, 0); |
| 89 | 102 | $r = @socket_connect($s, $ip, $port); |
| 90 | - if (!socket_set_nonblock($s)) echo "Unable to set nonblock on socket\n"; |
|
| 103 | + if (!socket_set_nonblock($s)) { |
|
| 104 | + echo "Unable to set nonblock on socket\n"; |
|
| 105 | + } |
|
| 91 | 106 | if ($r || socket_last_error() == 114 || socket_last_error() == 115) { |
| 92 | 107 | return $s; |
| 93 | 108 | } |
@@ -115,7 +130,9 @@ discard block |
||
| 115 | 130 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; |
| 116 | 131 | global $sockets, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset; |
| 117 | 132 | $reset++; |
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; |
|
| 133 | + if ($globalDebug) { |
|
| 134 | + echo 'Connect to all...'."\n"; |
|
| 135 | + } |
|
| 119 | 136 | foreach ($hosts as $id => $value) { |
| 120 | 137 | $host = $value['host']; |
| 121 | 138 | $globalSources[$id]['last_exec'] = 0; |
@@ -125,27 +142,37 @@ discard block |
||
| 125 | 142 | //$formats[$id] = 'deltadbtxt'; |
| 126 | 143 | $globalSources[$id]['format'] = 'deltadbtxt'; |
| 127 | 144 | //$last_exec['deltadbtxt'] = 0; |
| 128 | - if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; |
|
| 145 | + if ($globalDebug) { |
|
| 146 | + echo "Connect to deltadb source (".$host.")...\n"; |
|
| 147 | + } |
|
| 129 | 148 | } else if (preg_match('/vatsim-data.txt$/i',$host)) { |
| 130 | 149 | //$formats[$id] = 'vatsimtxt'; |
| 131 | 150 | $globalSources[$id]['format'] = 'vatsimtxt'; |
| 132 | 151 | //$last_exec['vatsimtxt'] = 0; |
| 133 | - if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; |
|
| 152 | + if ($globalDebug) { |
|
| 153 | + echo "Connect to vatsim source (".$host.")...\n"; |
|
| 154 | + } |
|
| 134 | 155 | } else if (preg_match('/aircraftlist.json$/i',$host)) { |
| 135 | 156 | //$formats[$id] = 'aircraftlistjson'; |
| 136 | 157 | $globalSources[$id]['format'] = 'aircraftlistjson'; |
| 137 | 158 | //$last_exec['aircraftlistjson'] = 0; |
| 138 | - if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 159 | + if ($globalDebug) { |
|
| 160 | + echo "Connect to aircraftlist.json source (".$host.")...\n"; |
|
| 161 | + } |
|
| 139 | 162 | } else if (preg_match('/opensky/i',$host)) { |
| 140 | 163 | //$formats[$id] = 'aircraftlistjson'; |
| 141 | 164 | $globalSources[$id]['format'] = 'opensky'; |
| 142 | 165 | //$last_exec['aircraftlistjson'] = 0; |
| 143 | - if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; |
|
| 166 | + if ($globalDebug) { |
|
| 167 | + echo "Connect to opensky source (".$host.")...\n"; |
|
| 168 | + } |
|
| 144 | 169 | } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) { |
| 145 | 170 | //$formats[$id] = 'radarvirtueljson'; |
| 146 | 171 | $globalSources[$id]['format'] = 'radarvirtueljson'; |
| 147 | 172 | //$last_exec['radarvirtueljson'] = 0; |
| 148 | - if ($globalDebug) echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 173 | + if ($globalDebug) { |
|
| 174 | + echo "Connect to radarvirtuel.com/file.json source (".$host.")...\n"; |
|
| 175 | + } |
|
| 149 | 176 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 150 | 177 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 151 | 178 | exit(0); |
@@ -154,7 +181,9 @@ discard block |
||
| 154 | 181 | //$formats[$id] = 'planeupdatefaa'; |
| 155 | 182 | $globalSources[$id]['format'] = 'planeupdatefaa'; |
| 156 | 183 | //$last_exec['planeupdatefaa'] = 0; |
| 157 | - if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 184 | + if ($globalDebug) { |
|
| 185 | + echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; |
|
| 186 | + } |
|
| 158 | 187 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 159 | 188 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 160 | 189 | exit(0); |
@@ -163,26 +192,36 @@ discard block |
||
| 163 | 192 | //$formats[$id] = 'phpvmacars'; |
| 164 | 193 | $globalSources[$id]['format'] = 'phpvmacars'; |
| 165 | 194 | //$last_exec['phpvmacars'] = 0; |
| 166 | - if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 195 | + if ($globalDebug) { |
|
| 196 | + echo "Connect to phpvmacars source (".$host.")...\n"; |
|
| 197 | + } |
|
| 167 | 198 | } else if (preg_match('/VAM-json.php$/i',$host)) { |
| 168 | 199 | //$formats[$id] = 'phpvmacars'; |
| 169 | 200 | $globalSources[$id]['format'] = 'vam'; |
| 170 | - if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; |
|
| 201 | + if ($globalDebug) { |
|
| 202 | + echo "Connect to Vam source (".$host.")...\n"; |
|
| 203 | + } |
|
| 171 | 204 | } else if (preg_match('/whazzup/i',$host)) { |
| 172 | 205 | //$formats[$id] = 'whazzup'; |
| 173 | 206 | $globalSources[$id]['format'] = 'whazzup'; |
| 174 | 207 | //$last_exec['whazzup'] = 0; |
| 175 | - if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; |
|
| 208 | + if ($globalDebug) { |
|
| 209 | + echo "Connect to whazzup source (".$host.")...\n"; |
|
| 210 | + } |
|
| 176 | 211 | } else if (preg_match('/recentpireps/i',$host)) { |
| 177 | 212 | //$formats[$id] = 'pirepsjson'; |
| 178 | 213 | $globalSources[$id]['format'] = 'pirepsjson'; |
| 179 | 214 | //$last_exec['pirepsjson'] = 0; |
| 180 | - if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 215 | + if ($globalDebug) { |
|
| 216 | + echo "Connect to pirepsjson source (".$host.")...\n"; |
|
| 217 | + } |
|
| 181 | 218 | } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { |
| 182 | 219 | //$formats[$id] = 'fr24json'; |
| 183 | 220 | $globalSources[$id]['format'] = 'fr24json'; |
| 184 | 221 | //$last_exec['fr24json'] = 0; |
| 185 | - if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; |
|
| 222 | + if ($globalDebug) { |
|
| 223 | + echo "Connect to fr24 source (".$host.")...\n"; |
|
| 224 | + } |
|
| 186 | 225 | if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { |
| 187 | 226 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; |
| 188 | 227 | exit(0); |
@@ -191,10 +230,14 @@ discard block |
||
| 191 | 230 | } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { |
| 192 | 231 | //$formats[$id] = 'tsv'; |
| 193 | 232 | $globalSources[$id]['format'] = 'tsv'; |
| 194 | - if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; |
|
| 233 | + if ($globalDebug) { |
|
| 234 | + echo "Connect to tsv source (".$host.")...\n"; |
|
| 235 | + } |
|
| 195 | 236 | } |
| 196 | 237 | } elseif (filter_var($host,FILTER_VALIDATE_URL)) { |
| 197 | - if ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 238 | + if ($globalDebug) { |
|
| 239 | + echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; |
|
| 240 | + } |
|
| 198 | 241 | } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { |
| 199 | 242 | $hostport = explode(':',$host); |
| 200 | 243 | if (isset($hostport[1])) { |
@@ -231,17 +274,25 @@ discard block |
||
| 231 | 274 | //$formats[$id] = 'beast'; |
| 232 | 275 | $globalSources[$id]['format'] = 'beast'; |
| 233 | 276 | //} else $formats[$id] = 'sbs'; |
| 234 | - } else $globalSources[$id]['format'] = 'sbs'; |
|
| 277 | + } else { |
|
| 278 | + $globalSources[$id]['format'] = 'sbs'; |
|
| 279 | + } |
|
| 235 | 280 | //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; |
| 236 | 281 | } |
| 237 | - if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 282 | + if ($globalDebug) { |
|
| 283 | + echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; |
|
| 284 | + } |
|
| 238 | 285 | } else { |
| 239 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 286 | + if ($globalDebug) { |
|
| 287 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; |
|
| 288 | + } |
|
| 240 | 289 | } |
| 241 | 290 | } |
| 242 | 291 | } |
| 243 | 292 | } |
| 244 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; |
|
| 293 | +if (!isset($globalMinFetch)) { |
|
| 294 | + $globalMinFetch = 15; |
|
| 295 | +} |
|
| 245 | 296 | |
| 246 | 297 | // Initialize all |
| 247 | 298 | $status = array(); |
@@ -249,13 +300,19 @@ discard block |
||
| 249 | 300 | $formats = array(); |
| 250 | 301 | $last_exec = array(); |
| 251 | 302 | $time = time(); |
| 252 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; |
|
| 253 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; |
|
| 254 | -else $timeout = 20; |
|
| 303 | +if (isset($globalSourcesTimeout)) { |
|
| 304 | + $timeout = $globalSourcesTimeOut; |
|
| 305 | +} else if (isset($globalSBS1TimeOut)) { |
|
| 306 | + $timeout = $globalSBS1TimeOut; |
|
| 307 | +} else { |
|
| 308 | + $timeout = 20; |
|
| 309 | +} |
|
| 255 | 310 | $errno = ''; |
| 256 | 311 | $errstr=''; |
| 257 | 312 | |
| 258 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 313 | +if (!isset($globalDaemon)) { |
|
| 314 | + $globalDaemon = TRUE; |
|
| 315 | +} |
|
| 259 | 316 | /* Initiate connections to all the hosts simultaneously */ |
| 260 | 317 | //connect_all($hosts); |
| 261 | 318 | //connect_all($globalSources); |
@@ -275,7 +332,9 @@ discard block |
||
| 275 | 332 | if (isset($source['format']) && $source['format'] == 'aprs') { |
| 276 | 333 | $aprs_connect = 0; |
| 277 | 334 | $use_aprs = true; |
| 278 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; |
|
| 335 | + if (isset($source['port']) && $source['port'] == '10152') { |
|
| 336 | + $aprs_full = true; |
|
| 337 | + } |
|
| 279 | 338 | break; |
| 280 | 339 | } |
| 281 | 340 | } |
@@ -286,23 +345,43 @@ discard block |
||
| 286 | 345 | $aprs_connect = 0; |
| 287 | 346 | $aprs_keep = 120; |
| 288 | 347 | $aprs_last_tx = time(); |
| 289 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; |
|
| 290 | - else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 291 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; |
|
| 292 | - else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 293 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; |
|
| 294 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 295 | - if ($aprs_full) $aprs_filter = ''; |
|
| 348 | + if (isset($globalAPRSversion)) { |
|
| 349 | + $aprs_version = $globalAPRSversion; |
|
| 350 | + } else { |
|
| 351 | + $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); |
|
| 352 | + } |
|
| 353 | + if (isset($globalAPRSssid)) { |
|
| 354 | + $aprs_ssid = $globalAPRSssid; |
|
| 355 | + } else { |
|
| 356 | + $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); |
|
| 357 | + } |
|
| 358 | + if (isset($globalAPRSfilter)) { |
|
| 359 | + $aprs_filter = $globalAPRSfilter; |
|
| 360 | + } else { |
|
| 361 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; |
|
| 362 | + } |
|
| 363 | + if ($aprs_full) { |
|
| 364 | + $aprs_filter = ''; |
|
| 365 | + } |
|
| 296 | 366 | |
| 297 | - if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 298 | - else $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n"; |
|
| 299 | -} |
|
| 367 | + if ($aprs_filter != '') { |
|
| 368 | + $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version} filter {$aprs_filter}\n"; |
|
| 369 | + } else { |
|
| 370 | + $aprs_login = "user {$aprs_ssid} pass -1 vers {$aprs_version}\n"; |
|
| 371 | + } |
|
| 372 | + } |
|
| 300 | 373 | |
| 301 | 374 | // connected - lets do some work |
| 302 | -if ($globalDebug) echo "Connected!\n"; |
|
| 375 | +if ($globalDebug) { |
|
| 376 | + echo "Connected!\n"; |
|
| 377 | +} |
|
| 303 | 378 | sleep(1); |
| 304 | -if ($globalDebug) echo "SCAN MODE \n\n"; |
|
| 305 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; |
|
| 379 | +if ($globalDebug) { |
|
| 380 | + echo "SCAN MODE \n\n"; |
|
| 381 | +} |
|
| 382 | +if (!isset($globalCronEnd)) { |
|
| 383 | + $globalCronEnd = 60; |
|
| 384 | +} |
|
| 306 | 385 | $endtime = time()+$globalCronEnd; |
| 307 | 386 | $i = 1; |
| 308 | 387 | $tt = array(); |
@@ -316,20 +395,28 @@ discard block |
||
| 316 | 395 | |
| 317 | 396 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. |
| 318 | 397 | while ($i > 0) { |
| 319 | - if (!$globalDaemon) $i = $endtime-time(); |
|
| 398 | + if (!$globalDaemon) { |
|
| 399 | + $i = $endtime-time(); |
|
| 400 | + } |
|
| 320 | 401 | // Delete old ATC |
| 321 | 402 | if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { |
| 322 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; |
|
| 403 | + if ($globalDebug) { |
|
| 404 | + echo 'Delete old ATC...'."\n"; |
|
| 405 | + } |
|
| 323 | 406 | $ATC->deleteOldATC(); |
| 324 | 407 | } |
| 325 | 408 | |
| 326 | 409 | if (count($last_exec) > 0) { |
| 327 | 410 | $max = $globalMinFetch; |
| 328 | 411 | foreach ($last_exec as $last) { |
| 329 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; |
|
| 412 | + if ((time() - $last['last']) < $max) { |
|
| 413 | + $max = time() - $last['last']; |
|
| 414 | + } |
|
| 330 | 415 | } |
| 331 | 416 | if ($max != $globalMinFetch) { |
| 332 | - if ($globalDebug) echo 'Sleeping...'."\n"; |
|
| 417 | + if ($globalDebug) { |
|
| 418 | + echo 'Sleeping...'."\n"; |
|
| 419 | + } |
|
| 333 | 420 | sleep($globalMinFetch-$max+2); |
| 334 | 421 | } |
| 335 | 422 | } |
@@ -338,11 +425,15 @@ discard block |
||
| 338 | 425 | //foreach ($formats as $id => $value) { |
| 339 | 426 | foreach ($globalSources as $id => $value) { |
| 340 | 427 | date_default_timezone_set('UTC'); |
| 341 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; |
|
| 428 | + if (!isset($last_exec[$id]['last'])) { |
|
| 429 | + $last_exec[$id]['last'] = 0; |
|
| 430 | + } |
|
| 342 | 431 | if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 343 | 432 | //$buffer = $Common->getData($hosts[$id]); |
| 344 | 433 | $buffer = $Common->getData($value['host']); |
| 345 | - if ($buffer != '') $reset = 0; |
|
| 434 | + if ($buffer != '') { |
|
| 435 | + $reset = 0; |
|
| 436 | + } |
|
| 346 | 437 | $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); |
| 347 | 438 | $buffer = explode('\n',$buffer); |
| 348 | 439 | foreach ($buffer as $line) { |
@@ -351,19 +442,38 @@ discard block |
||
| 351 | 442 | $data = array(); |
| 352 | 443 | $data['hex'] = $line[1]; // hex |
| 353 | 444 | $data['ident'] = $line[2]; // ident |
| 354 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude |
|
| 355 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed |
|
| 356 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading |
|
| 357 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat |
|
| 358 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long |
|
| 445 | + if (isset($line[3])) { |
|
| 446 | + $data['altitude'] = $line[3]; |
|
| 447 | + } |
|
| 448 | + // altitude |
|
| 449 | + if (isset($line[4])) { |
|
| 450 | + $data['speed'] = $line[4]; |
|
| 451 | + } |
|
| 452 | + // speed |
|
| 453 | + if (isset($line[5])) { |
|
| 454 | + $data['heading'] = $line[5]; |
|
| 455 | + } |
|
| 456 | + // heading |
|
| 457 | + if (isset($line[6])) { |
|
| 458 | + $data['latitude'] = $line[6]; |
|
| 459 | + } |
|
| 460 | + // lat |
|
| 461 | + if (isset($line[7])) { |
|
| 462 | + $data['longitude'] = $line[7]; |
|
| 463 | + } |
|
| 464 | + // long |
|
| 359 | 465 | $data['verticalrate'] = ''; // vertical rate |
| 360 | 466 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk |
| 361 | 467 | $data['emergency'] = ''; // emergency |
| 362 | 468 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 363 | 469 | $data['format_source'] = 'deltadbtxt'; |
| 364 | 470 | $data['id_source'] = $id_source; |
| 365 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 366 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; |
|
| 471 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 472 | + $data['source_name'] = $value['name']; |
|
| 473 | + } |
|
| 474 | + if (isset($value['sourcestats'])) { |
|
| 475 | + $data['sourcestats'] = $value['sourcestats']; |
|
| 476 | + } |
|
| 367 | 477 | $SI->add($data); |
| 368 | 478 | unset($data); |
| 369 | 479 | } |
@@ -381,16 +491,28 @@ discard block |
||
| 381 | 491 | $line = explode(':', $line); |
| 382 | 492 | if (count($line) > 30 && $line[0] != 'callsign') { |
| 383 | 493 | $data = array(); |
| 384 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 385 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 494 | + if (isset($line[37]) && $line[37] != '') { |
|
| 495 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; |
|
| 496 | + } else { |
|
| 497 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; |
|
| 498 | + } |
|
| 386 | 499 | $data['pilot_id'] = $line[1]; |
| 387 | 500 | $data['pilot_name'] = $line[2]; |
| 388 | 501 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); |
| 389 | 502 | $data['ident'] = $line[0]; // ident |
| 390 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude |
|
| 503 | + if ($line[7] != '' && $line[7] != 0) { |
|
| 504 | + $data['altitude'] = $line[7]; |
|
| 505 | + } |
|
| 506 | + // altitude |
|
| 391 | 507 | $data['speed'] = $line[8]; // speed |
| 392 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading |
|
| 393 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading |
|
| 508 | + if (isset($line[45])) { |
|
| 509 | + $data['heading'] = $line[45]; |
|
| 510 | + } |
|
| 511 | + // heading |
|
| 512 | + elseif (isset($line[38])) { |
|
| 513 | + $data['heading'] = $line[38]; |
|
| 514 | + } |
|
| 515 | + // heading |
|
| 394 | 516 | $data['latitude'] = $line[5]; // lat |
| 395 | 517 | $data['longitude'] = $line[6]; // long |
| 396 | 518 | $data['verticalrate'] = ''; // vertical rate |
@@ -406,7 +528,9 @@ discard block |
||
| 406 | 528 | $data['frequency'] = $line[4]; |
| 407 | 529 | $data['type'] = $line[18]; |
| 408 | 530 | $data['range'] = $line[19]; |
| 409 | - if (isset($line[35])) $data['info'] = $line[35]; |
|
| 531 | + if (isset($line[35])) { |
|
| 532 | + $data['info'] = $line[35]; |
|
| 533 | + } |
|
| 410 | 534 | $data['id_source'] = $id_source; |
| 411 | 535 | //$data['arrival_airport_time'] = ; |
| 412 | 536 | if ($line[9] != '') { |
@@ -420,24 +544,41 @@ discard block |
||
| 420 | 544 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; |
| 421 | 545 | */ |
| 422 | 546 | $data['format_source'] = $value['format']; |
| 423 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 424 | - if ($line[3] == 'PILOT') $SI->add($data); |
|
| 425 | - elseif ($line[3] == 'ATC') { |
|
| 547 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 548 | + $data['source_name'] = $value['name']; |
|
| 549 | + } |
|
| 550 | + if ($line[3] == 'PILOT') { |
|
| 551 | + $SI->add($data); |
|
| 552 | + } elseif ($line[3] == 'ATC') { |
|
| 426 | 553 | //print_r($data); |
| 427 | 554 | $data['info'] = str_replace('^§','<br />',$data['info']); |
| 428 | 555 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 429 | 556 | $typec = substr($data['ident'],-3); |
| 430 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 431 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 432 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 433 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 434 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 435 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 436 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 437 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 438 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; |
|
| 439 | - if (!isset($data['source_name'])) $data['source_name'] = ''; |
|
| 440 | - 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']); |
|
| 557 | + if ($typec == 'APP') { |
|
| 558 | + $data['type'] = 'Approach'; |
|
| 559 | + } elseif ($typec == 'TWR') { |
|
| 560 | + $data['type'] = 'Tower'; |
|
| 561 | + } elseif ($typec == 'OBS') { |
|
| 562 | + $data['type'] = 'Observer'; |
|
| 563 | + } elseif ($typec == 'GND') { |
|
| 564 | + $data['type'] = 'Ground'; |
|
| 565 | + } elseif ($typec == 'DEL') { |
|
| 566 | + $data['type'] = 'Delivery'; |
|
| 567 | + } elseif ($typec == 'DEP') { |
|
| 568 | + $data['type'] = 'Departure'; |
|
| 569 | + } elseif ($typec == 'FSS') { |
|
| 570 | + $data['type'] = 'Flight Service Station'; |
|
| 571 | + } elseif ($typec == 'CTR') { |
|
| 572 | + $data['type'] = 'Control Radar or Centre'; |
|
| 573 | + } elseif ($data['type'] == '') { |
|
| 574 | + $data['type'] = 'Observer'; |
|
| 575 | + } |
|
| 576 | + if (!isset($data['source_name'])) { |
|
| 577 | + $data['source_name'] = ''; |
|
| 578 | + } |
|
| 579 | + if (isset($ATC)) { |
|
| 580 | + 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']); |
|
| 581 | + } |
|
| 441 | 582 | } |
| 442 | 583 | unset($data); |
| 443 | 584 | } |
@@ -456,26 +597,55 @@ discard block |
||
| 456 | 597 | foreach ($all_data['acList'] as $line) { |
| 457 | 598 | $data = array(); |
| 458 | 599 | $data['hex'] = $line['Icao']; // hex |
| 459 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident |
|
| 460 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude |
|
| 461 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed |
|
| 462 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading |
|
| 463 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat |
|
| 464 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long |
|
| 600 | + if (isset($line['Call'])) { |
|
| 601 | + $data['ident'] = $line['Call']; |
|
| 602 | + } |
|
| 603 | + // ident |
|
| 604 | + if (isset($line['Alt'])) { |
|
| 605 | + $data['altitude'] = $line['Alt']; |
|
| 606 | + } |
|
| 607 | + // altitude |
|
| 608 | + if (isset($line['Spd'])) { |
|
| 609 | + $data['speed'] = $line['Spd']; |
|
| 610 | + } |
|
| 611 | + // speed |
|
| 612 | + if (isset($line['Trak'])) { |
|
| 613 | + $data['heading'] = $line['Trak']; |
|
| 614 | + } |
|
| 615 | + // heading |
|
| 616 | + if (isset($line['Lat'])) { |
|
| 617 | + $data['latitude'] = $line['Lat']; |
|
| 618 | + } |
|
| 619 | + // lat |
|
| 620 | + if (isset($line['Long'])) { |
|
| 621 | + $data['longitude'] = $line['Long']; |
|
| 622 | + } |
|
| 623 | + // long |
|
| 465 | 624 | //$data['verticalrate'] = $line['']; // verticale rate |
| 466 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk |
|
| 625 | + if (isset($line['Sqk'])) { |
|
| 626 | + $data['squawk'] = $line['Sqk']; |
|
| 627 | + } |
|
| 628 | + // squawk |
|
| 467 | 629 | $data['emergency'] = ''; // emergency |
| 468 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; |
|
| 630 | + if (isset($line['Reg'])) { |
|
| 631 | + $data['registration'] = $line['Reg']; |
|
| 632 | + } |
|
| 469 | 633 | /* |
| 470 | 634 | if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); |
| 471 | 635 | else $data['datetime'] = date('Y-m-d H:i:s'); |
| 472 | 636 | */ |
| 473 | 637 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 474 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; |
|
| 638 | + if (isset($line['Type'])) { |
|
| 639 | + $data['aircraft_icao'] = $line['Type']; |
|
| 640 | + } |
|
| 475 | 641 | $data['format_source'] = 'aircraftlistjson'; |
| 476 | 642 | $data['id_source'] = $id_source; |
| 477 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 478 | - if (isset($data['datetime'])) $SI->add($data); |
|
| 643 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 644 | + $data['source_name'] = $value['name']; |
|
| 645 | + } |
|
| 646 | + if (isset($data['datetime'])) { |
|
| 647 | + $SI->add($data); |
|
| 648 | + } |
|
| 479 | 649 | unset($data); |
| 480 | 650 | } |
| 481 | 651 | } else { |
@@ -495,7 +665,9 @@ discard block |
||
| 495 | 665 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 496 | 666 | $data['format_source'] = 'aircraftlistjson'; |
| 497 | 667 | $data['id_source'] = $id_source; |
| 498 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 668 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 669 | + $data['source_name'] = $value['name']; |
|
| 670 | + } |
|
| 499 | 671 | $SI->add($data); |
| 500 | 672 | unset($data); |
| 501 | 673 | } |
@@ -531,7 +703,9 @@ discard block |
||
| 531 | 703 | $data['datetime'] = date('Y-m-d H:i:s',$line[9]); |
| 532 | 704 | $data['format_source'] = 'planeupdatefaa'; |
| 533 | 705 | $data['id_source'] = $id_source; |
| 534 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 706 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 707 | + $data['source_name'] = $value['name']; |
|
| 708 | + } |
|
| 535 | 709 | $SI->add($data); |
| 536 | 710 | unset($data); |
| 537 | 711 | } |
@@ -571,7 +745,9 @@ discard block |
||
| 571 | 745 | //$buffer = $Common->getData($hosts[$id]); |
| 572 | 746 | $buffer = $Common->getData($value['host']); |
| 573 | 747 | $all_data = json_decode($buffer,true); |
| 574 | - if (!empty($all_data)) $reset = 0; |
|
| 748 | + if (!empty($all_data)) { |
|
| 749 | + $reset = 0; |
|
| 750 | + } |
|
| 575 | 751 | foreach ($all_data as $key => $line) { |
| 576 | 752 | if ($key != 'full_count' && $key != 'version' && $key != 'stats') { |
| 577 | 753 | $data = array(); |
@@ -592,7 +768,9 @@ discard block |
||
| 592 | 768 | $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] |
| 593 | 769 | $data['format_source'] = 'fr24json'; |
| 594 | 770 | $data['id_source'] = $id_source; |
| 595 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 771 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 772 | + $data['source_name'] = $value['name']; |
|
| 773 | + } |
|
| 596 | 774 | $SI->add($data); |
| 597 | 775 | unset($data); |
| 598 | 776 | } |
@@ -616,23 +794,39 @@ discard block |
||
| 616 | 794 | if (isset($line['inf'])) { |
| 617 | 795 | $data = array(); |
| 618 | 796 | $data['hex'] = $line['inf']['ia']; |
| 619 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] |
|
| 797 | + if (isset($line['inf']['cs'])) { |
|
| 798 | + $data['ident'] = $line['inf']['cs']; |
|
| 799 | + } |
|
| 800 | + //$line[13] |
|
| 620 | 801 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude |
| 621 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed |
|
| 622 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading |
|
| 802 | + if (isset($line['inf']['gs'])) { |
|
| 803 | + $data['speed'] = round($line['inf']['gs']*0.539957); |
|
| 804 | + } |
|
| 805 | + // speed |
|
| 806 | + if (isset($line['inf']['tr'])) { |
|
| 807 | + $data['heading'] = $line['inf']['tr']; |
|
| 808 | + } |
|
| 809 | + // heading |
|
| 623 | 810 | $data['latitude'] = $line['pt'][0]; // lat |
| 624 | 811 | $data['longitude'] = $line['pt'][1]; // long |
| 625 | 812 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate |
| 626 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk |
|
| 813 | + if (isset($line['inf']['sq'])) { |
|
| 814 | + $data['squawk'] = $line['inf']['sq']; |
|
| 815 | + } |
|
| 816 | + // squawk |
|
| 627 | 817 | //$data['aircraft_icao'] = $line[8]; |
| 628 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; |
|
| 818 | + if (isset($line['inf']['rc'])) { |
|
| 819 | + $data['registration'] = $line['inf']['rc']; |
|
| 820 | + } |
|
| 629 | 821 | //$data['departure_airport_iata'] = $line[11]; |
| 630 | 822 | //$data['arrival_airport_iata'] = $line[12]; |
| 631 | 823 | //$data['emergency'] = ''; // emergency |
| 632 | 824 | $data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] |
| 633 | 825 | $data['format_source'] = 'radarvirtueljson'; |
| 634 | 826 | $data['id_source'] = $id_source; |
| 635 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 827 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 828 | + $data['source_name'] = $value['name']; |
|
| 829 | + } |
|
| 636 | 830 | $SI->add($data); |
| 637 | 831 | unset($data); |
| 638 | 832 | } |
@@ -653,29 +847,62 @@ discard block |
||
| 653 | 847 | $data['id'] = $line['id']; |
| 654 | 848 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); |
| 655 | 849 | $data['ident'] = $line['callsign']; // ident |
| 656 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id |
|
| 657 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name |
|
| 658 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude |
|
| 659 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed |
|
| 660 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading |
|
| 661 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 850 | + if (isset($line['pilotid'])) { |
|
| 851 | + $data['pilot_id'] = $line['pilotid']; |
|
| 852 | + } |
|
| 853 | + // pilot id |
|
| 854 | + if (isset($line['name'])) { |
|
| 855 | + $data['pilot_name'] = $line['name']; |
|
| 856 | + } |
|
| 857 | + // pilot name |
|
| 858 | + if (isset($line['alt'])) { |
|
| 859 | + $data['altitude'] = $line['alt']; |
|
| 860 | + } |
|
| 861 | + // altitude |
|
| 862 | + if (isset($line['gs'])) { |
|
| 863 | + $data['speed'] = $line['gs']; |
|
| 864 | + } |
|
| 865 | + // speed |
|
| 866 | + if (isset($line['heading'])) { |
|
| 867 | + $data['heading'] = $line['heading']; |
|
| 868 | + } |
|
| 869 | + // heading |
|
| 870 | + if (isset($line['route'])) { |
|
| 871 | + $data['waypoints'] = $line['route']; |
|
| 872 | + } |
|
| 873 | + // route |
|
| 662 | 874 | $data['latitude'] = $line['lat']; // lat |
| 663 | 875 | $data['longitude'] = $line['lon']; // long |
| 664 | 876 | //$data['verticalrate'] = $line['vrt']; // verticale rate |
| 665 | 877 | //$data['squawk'] = $line['squawk']; // squawk |
| 666 | 878 | //$data['emergency'] = ''; // emergency |
| 667 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; |
|
| 668 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; |
|
| 669 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; |
|
| 879 | + if (isset($line['depicao'])) { |
|
| 880 | + $data['departure_airport_icao'] = $line['depicao']; |
|
| 881 | + } |
|
| 882 | + if (isset($line['deptime'])) { |
|
| 883 | + $data['departure_airport_time'] = $line['deptime']; |
|
| 884 | + } |
|
| 885 | + if (isset($line['arricao'])) { |
|
| 886 | + $data['arrival_airport_icao'] = $line['arricao']; |
|
| 887 | + } |
|
| 670 | 888 | //$data['arrival_airport_time'] = $line['arrtime']; |
| 671 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; |
|
| 672 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; |
|
| 673 | - if (isset($line['atis'])) $data['info'] = $line['atis']; |
|
| 674 | - else $data['info'] = ''; |
|
| 889 | + if (isset($line['aircraft'])) { |
|
| 890 | + $data['aircraft_icao'] = $line['aircraft']; |
|
| 891 | + } |
|
| 892 | + if (isset($line['transponder'])) { |
|
| 893 | + $data['squawk'] = $line['transponder']; |
|
| 894 | + } |
|
| 895 | + if (isset($line['atis'])) { |
|
| 896 | + $data['info'] = $line['atis']; |
|
| 897 | + } else { |
|
| 898 | + $data['info'] = ''; |
|
| 899 | + } |
|
| 675 | 900 | $data['format_source'] = 'pireps'; |
| 676 | 901 | $data['id_source'] = $id_source; |
| 677 | 902 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 678 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 903 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 904 | + $data['source_name'] = $value['name']; |
|
| 905 | + } |
|
| 679 | 906 | if ($line['icon'] == 'plane') { |
| 680 | 907 | $SI->add($data); |
| 681 | 908 | // print_r($data); |
@@ -684,16 +911,28 @@ discard block |
||
| 684 | 911 | $data['info'] = str_replace('&sect;','',$data['info']); |
| 685 | 912 | $typec = substr($data['ident'],-3); |
| 686 | 913 | $data['type'] = ''; |
| 687 | - if ($typec == 'APP') $data['type'] = 'Approach'; |
|
| 688 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; |
|
| 689 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; |
|
| 690 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; |
|
| 691 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; |
|
| 692 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; |
|
| 693 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; |
|
| 694 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; |
|
| 695 | - else $data['type'] = 'Observer'; |
|
| 696 | - 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']); |
|
| 914 | + if ($typec == 'APP') { |
|
| 915 | + $data['type'] = 'Approach'; |
|
| 916 | + } elseif ($typec == 'TWR') { |
|
| 917 | + $data['type'] = 'Tower'; |
|
| 918 | + } elseif ($typec == 'OBS') { |
|
| 919 | + $data['type'] = 'Observer'; |
|
| 920 | + } elseif ($typec == 'GND') { |
|
| 921 | + $data['type'] = 'Ground'; |
|
| 922 | + } elseif ($typec == 'DEL') { |
|
| 923 | + $data['type'] = 'Delivery'; |
|
| 924 | + } elseif ($typec == 'DEP') { |
|
| 925 | + $data['type'] = 'Departure'; |
|
| 926 | + } elseif ($typec == 'FSS') { |
|
| 927 | + $data['type'] = 'Flight Service Station'; |
|
| 928 | + } elseif ($typec == 'CTR') { |
|
| 929 | + $data['type'] = 'Control Radar or Centre'; |
|
| 930 | + } else { |
|
| 931 | + $data['type'] = 'Observer'; |
|
| 932 | + } |
|
| 933 | + if (isset($ATC)) { |
|
| 934 | + 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']); |
|
| 935 | + } |
|
| 697 | 936 | } |
| 698 | 937 | unset($data); |
| 699 | 938 | } |
@@ -703,7 +942,9 @@ discard block |
||
| 703 | 942 | //} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { |
| 704 | 943 | } elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 705 | 944 | //$buffer = $Common->getData($hosts[$id]); |
| 706 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 945 | + if ($globalDebug) { |
|
| 946 | + echo 'Get Data...'."\n"; |
|
| 947 | + } |
|
| 707 | 948 | $buffer = $Common->getData($value['host']); |
| 708 | 949 | $all_data = json_decode($buffer,true); |
| 709 | 950 | if ($buffer != '' && is_array($all_data)) { |
@@ -711,10 +952,16 @@ discard block |
||
| 711 | 952 | foreach ($all_data as $line) { |
| 712 | 953 | $data = array(); |
| 713 | 954 | //$data['id'] = $line['id']; // id not usable |
| 714 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 955 | + if (isset($line['pilotid'])) { |
|
| 956 | + $data['id'] = $line['pilotid'].$line['flightnum']; |
|
| 957 | + } |
|
| 715 | 958 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex |
| 716 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; |
|
| 717 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; |
|
| 959 | + if (isset($line['pilotname'])) { |
|
| 960 | + $data['pilot_name'] = $line['pilotname']; |
|
| 961 | + } |
|
| 962 | + if (isset($line['pilotid'])) { |
|
| 963 | + $data['pilot_id'] = $line['pilotid']; |
|
| 964 | + } |
|
| 718 | 965 | $data['ident'] = $line['flightnum']; // ident |
| 719 | 966 | $data['altitude'] = $line['alt']; // altitude |
| 720 | 967 | $data['speed'] = $line['gs']; // speed |
@@ -732,27 +979,41 @@ discard block |
||
| 732 | 979 | $data['arrival_airport_icao'] = $line['arricao']; |
| 733 | 980 | $data['arrival_airport_time'] = $line['arrtime']; |
| 734 | 981 | $data['registration'] = $line['aircraft']; |
| 735 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 982 | + if (isset($line['route'])) { |
|
| 983 | + $data['waypoints'] = $line['route']; |
|
| 984 | + } |
|
| 985 | + // route |
|
| 736 | 986 | if (isset($line['aircraftname'])) { |
| 737 | 987 | $line['aircraftname'] = strtoupper($line['aircraftname']); |
| 738 | 988 | $line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); |
| 739 | 989 | $aircraft_data = explode('-',$line['aircraftname']); |
| 740 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 741 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 742 | - else { |
|
| 990 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) < 5) { |
|
| 991 | + $data['aircraft_icao'] = $aircraft_data[0]; |
|
| 992 | + } elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) < 5) { |
|
| 993 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 994 | + } else { |
|
| 743 | 995 | $aircraft_data = explode(' ',$line['aircraftname']); |
| 744 | - if (isset($aircraft_data[1])) $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 745 | - else $data['aircraft_icao'] = $line['aircraftname']; |
|
| 996 | + if (isset($aircraft_data[1])) { |
|
| 997 | + $data['aircraft_icao'] = $aircraft_data[1]; |
|
| 998 | + } else { |
|
| 999 | + $data['aircraft_icao'] = $line['aircraftname']; |
|
| 1000 | + } |
|
| 746 | 1001 | } |
| 747 | 1002 | } |
| 748 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; |
|
| 1003 | + if (isset($line['route'])) { |
|
| 1004 | + $data['waypoints'] = $line['route']; |
|
| 1005 | + } |
|
| 749 | 1006 | $data['id_source'] = $id_source; |
| 750 | 1007 | $data['format_source'] = 'phpvmacars'; |
| 751 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1008 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1009 | + $data['source_name'] = $value['name']; |
|
| 1010 | + } |
|
| 752 | 1011 | $SI->add($data); |
| 753 | 1012 | unset($data); |
| 754 | 1013 | } |
| 755 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1014 | + if ($globalDebug) { |
|
| 1015 | + echo 'No more data...'."\n"; |
|
| 1016 | + } |
|
| 756 | 1017 | unset($buffer); |
| 757 | 1018 | unset($all_data); |
| 758 | 1019 | } |
@@ -760,7 +1021,9 @@ discard block |
||
| 760 | 1021 | $last_exec[$id]['last'] = time(); |
| 761 | 1022 | } elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { |
| 762 | 1023 | //$buffer = $Common->getData($hosts[$id]); |
| 763 | - if ($globalDebug) echo 'Get Data...'."\n"; |
|
| 1024 | + if ($globalDebug) { |
|
| 1025 | + echo 'Get Data...'."\n"; |
|
| 1026 | + } |
|
| 764 | 1027 | $buffer = $Common->getData($value['host']); |
| 765 | 1028 | $all_data = json_decode($buffer,true); |
| 766 | 1029 | if ($buffer != '' && is_array($all_data)) { |
@@ -789,15 +1052,22 @@ discard block |
||
| 789 | 1052 | $data['arrival_airport_icao'] = $line['arrival']; |
| 790 | 1053 | //$data['arrival_airport_time'] = $line['arrival_time']; |
| 791 | 1054 | //$data['registration'] = $line['aircraft']; |
| 792 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route |
|
| 1055 | + if (isset($line['route'])) { |
|
| 1056 | + $data['waypoints'] = $line['route']; |
|
| 1057 | + } |
|
| 1058 | + // route |
|
| 793 | 1059 | $data['aircraft_icao'] = $line['plane_type']; |
| 794 | 1060 | $data['id_source'] = $id_source; |
| 795 | 1061 | $data['format_source'] = 'vam'; |
| 796 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; |
|
| 1062 | + if (isset($value['name']) && $value['name'] != '') { |
|
| 1063 | + $data['source_name'] = $value['name']; |
|
| 1064 | + } |
|
| 797 | 1065 | $SI->add($data); |
| 798 | 1066 | unset($data); |
| 799 | 1067 | } |
| 800 | - if ($globalDebug) echo 'No more data...'."\n"; |
|
| 1068 | + if ($globalDebug) { |
|
| 1069 | + echo 'No more data...'."\n"; |
|
| 1070 | + } |
|
| 801 | 1071 | unset($buffer); |
| 802 | 1072 | unset($all_data); |
| 803 | 1073 | } |
@@ -805,7 +1075,9 @@ discard block |
||
| 805 | 1075 | $last_exec[$id]['last'] = time(); |
| 806 | 1076 | //} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { |
| 807 | 1077 | } 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') { |
| 808 | - if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); |
|
| 1078 | + if (function_exists('pcntl_fork')) { |
|
| 1079 | + pcntl_signal_dispatch(); |
|
| 1080 | + } |
|
| 809 | 1081 | //$last_exec[$id]['last'] = time(); |
| 810 | 1082 | |
| 811 | 1083 | //$read = array( $sockets[$id] ); |
@@ -813,7 +1085,9 @@ discard block |
||
| 813 | 1085 | $write = NULL; |
| 814 | 1086 | $e = NULL; |
| 815 | 1087 | $n = socket_select($read, $write, $e, $timeout); |
| 816 | - if ($e != NULL) var_dump($e); |
|
| 1088 | + if ($e != NULL) { |
|
| 1089 | + var_dump($e); |
|
| 1090 | + } |
|
| 817 | 1091 | if ($n > 0) { |
| 818 | 1092 | $reset = 0; |
| 819 | 1093 | foreach ($read as $nb => $r) { |
@@ -835,7 +1109,9 @@ discard block |
||
| 835 | 1109 | if ($buffer != '') { |
| 836 | 1110 | $tt[$format] = 0; |
| 837 | 1111 | if ($format == 'acarssbs3') { |
| 838 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1112 | + if ($globalDebug) { |
|
| 1113 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1114 | + } |
|
| 839 | 1115 | $ACARS->add(trim($buffer)); |
| 840 | 1116 | $ACARS->deleteLiveAcarsData(); |
| 841 | 1117 | } elseif ($format == 'raw') { |
@@ -844,9 +1120,15 @@ discard block |
||
| 844 | 1120 | if (is_array($data)) { |
| 845 | 1121 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 846 | 1122 | $data['format_source'] = 'raw'; |
| 847 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 848 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 849 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1123 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1124 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1125 | + } |
|
| 1126 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1127 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1128 | + } |
|
| 1129 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1130 | + $SI->add($data); |
|
| 1131 | + } |
|
| 850 | 1132 | } |
| 851 | 1133 | } elseif ($format == 'flightgearsp') { |
| 852 | 1134 | //echo $buffer."\n"; |
@@ -864,11 +1146,15 @@ discard block |
||
| 864 | 1146 | $data['speed'] = round($line[5]*1.94384); |
| 865 | 1147 | $data['datetime'] = date('Y-m-d H:i:s'); |
| 866 | 1148 | $data['format_source'] = 'flightgearsp'; |
| 867 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1149 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1150 | + $SI->add($data); |
|
| 1151 | + } |
|
| 868 | 1152 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); |
| 869 | 1153 | } |
| 870 | 1154 | } elseif ($format == 'acars') { |
| 871 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; |
|
| 1155 | + if ($globalDebug) { |
|
| 1156 | + echo 'ACARS : '.$buffer."\n"; |
|
| 1157 | + } |
|
| 872 | 1158 | $ACARS->add(trim($buffer)); |
| 873 | 1159 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); |
| 874 | 1160 | $ACARS->deleteLiveAcarsData(); |
@@ -889,7 +1175,9 @@ discard block |
||
| 889 | 1175 | $aircraft_type = $line[10]; |
| 890 | 1176 | $aircraft_type = preg_split(':/:',$aircraft_type); |
| 891 | 1177 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); |
| 892 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1178 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1179 | + $SI->add($data); |
|
| 1180 | + } |
|
| 893 | 1181 | } |
| 894 | 1182 | } |
| 895 | 1183 | } elseif ($format == 'beast') { |
@@ -905,21 +1193,43 @@ discard block |
||
| 905 | 1193 | $data['hex'] = $lined['hexid']; |
| 906 | 1194 | //$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; |
| 907 | 1195 | $data['datetime'] = date('Y-m-d H:i:s');; |
| 908 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; |
|
| 909 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; |
|
| 910 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; |
|
| 911 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; |
|
| 912 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; |
|
| 913 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; |
|
| 914 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; |
|
| 1196 | + if (isset($lined['ident'])) { |
|
| 1197 | + $data['ident'] = $lined['ident']; |
|
| 1198 | + } |
|
| 1199 | + if (isset($lined['lat'])) { |
|
| 1200 | + $data['latitude'] = $lined['lat']; |
|
| 1201 | + } |
|
| 1202 | + if (isset($lined['lon'])) { |
|
| 1203 | + $data['longitude'] = $lined['lon']; |
|
| 1204 | + } |
|
| 1205 | + if (isset($lined['speed'])) { |
|
| 1206 | + $data['speed'] = $lined['speed']; |
|
| 1207 | + } |
|
| 1208 | + if (isset($lined['squawk'])) { |
|
| 1209 | + $data['squawk'] = $lined['squawk']; |
|
| 1210 | + } |
|
| 1211 | + if (isset($lined['alt'])) { |
|
| 1212 | + $data['altitude'] = $lined['alt']; |
|
| 1213 | + } |
|
| 1214 | + if (isset($lined['heading'])) { |
|
| 1215 | + $data['heading'] = $lined['heading']; |
|
| 1216 | + } |
|
| 915 | 1217 | $data['id_source'] = $id_source; |
| 916 | 1218 | $data['format_source'] = 'tsv'; |
| 917 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 918 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 919 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); |
|
| 1219 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1220 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1221 | + } |
|
| 1222 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1223 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1224 | + } |
|
| 1225 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1226 | + $SI->add($data); |
|
| 1227 | + } |
|
| 920 | 1228 | unset($lined); |
| 921 | 1229 | unset($data); |
| 922 | - } else $error = true; |
|
| 1230 | + } else { |
|
| 1231 | + $error = true; |
|
| 1232 | + } |
|
| 923 | 1233 | } elseif ($format == 'aprs' && $use_aprs) { |
| 924 | 1234 | if ($aprs_connect == 0) { |
| 925 | 1235 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); |
@@ -944,36 +1254,50 @@ discard block |
||
| 944 | 1254 | $data = array(); |
| 945 | 1255 | //print_r($line); |
| 946 | 1256 | $data['hex'] = $line['address']; |
| 947 | - if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 948 | - else $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1257 | + if (isset($line['timestamp'])) { |
|
| 1258 | + $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); |
|
| 1259 | + } else { |
|
| 1260 | + $data['datetime'] = date('Y-m-d H:i:s'); |
|
| 1261 | + } |
|
| 949 | 1262 | //$data['datetime'] = date('Y-m-d H:i:s'); |
| 950 | 1263 | $data['ident'] = $line['ident']; |
| 951 | 1264 | $data['latitude'] = $line['latitude']; |
| 952 | 1265 | $data['longitude'] = $line['longitude']; |
| 953 | 1266 | //$data['verticalrate'] = $line[16]; |
| 954 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; |
|
| 955 | - else $data['speed'] = 0; |
|
| 1267 | + if (isset($line['speed'])) { |
|
| 1268 | + $data['speed'] = $line['speed']; |
|
| 1269 | + } else { |
|
| 1270 | + $data['speed'] = 0; |
|
| 1271 | + } |
|
| 956 | 1272 | $data['altitude'] = $line['altitude']; |
| 957 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; |
|
| 1273 | + if (isset($line['heading'])) { |
|
| 1274 | + $data['heading'] = $line['heading']; |
|
| 1275 | + } |
|
| 958 | 1276 | //else $data['heading'] = 0; |
| 959 | 1277 | $data['aircraft_type'] = $line['stealth']; |
| 960 | - if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) $data['noarchive'] = true; |
|
| 1278 | + if (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive == FALSE)) { |
|
| 1279 | + $data['noarchive'] = true; |
|
| 1280 | + } |
|
| 961 | 1281 | $data['id_source'] = $id_source; |
| 962 | 1282 | $data['format_source'] = 'aprs'; |
| 963 | 1283 | $data['source_name'] = $line['source']; |
| 964 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1284 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1285 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1286 | + } |
|
| 965 | 1287 | $currentdate = date('Y-m-d H:i:s'); |
| 966 | 1288 | $aprsdate = strtotime($data['datetime']); |
| 967 | 1289 | // Accept data if time <= system time + 20s |
| 968 | 1290 | if (($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) { |
| 969 | 1291 | $send = $SI->add($data); |
| 970 | 1292 | } else { |
| 971 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 972 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1293 | + if ($line['stealth'] != 0) { |
|
| 1294 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; |
|
| 1295 | + } else { |
|
| 1296 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; |
|
| 1297 | + } |
|
| 973 | 1298 | } |
| 974 | 1299 | unset($data); |
| 975 | - } |
|
| 976 | - elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 1300 | + } elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { |
|
| 977 | 1301 | echo '!! Weather Station not yet supported'."\n"; |
| 978 | 1302 | } |
| 979 | 1303 | //elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; |
@@ -1006,25 +1330,42 @@ discard block |
||
| 1006 | 1330 | $data['ground'] = $line[21]; |
| 1007 | 1331 | $data['emergency'] = $line[19]; |
| 1008 | 1332 | $data['format_source'] = 'sbs'; |
| 1009 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1010 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1333 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { |
|
| 1334 | + $data['source_name'] = $globalSources[$nb]['name']; |
|
| 1335 | + } |
|
| 1336 | + if (isset($globalSources[$nb]['sourcestats'])) { |
|
| 1337 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; |
|
| 1338 | + } |
|
| 1011 | 1339 | $data['id_source'] = $id_source; |
| 1012 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); |
|
| 1013 | - else $error = true; |
|
| 1340 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { |
|
| 1341 | + $send = $SI->add($data); |
|
| 1342 | + } else { |
|
| 1343 | + $error = true; |
|
| 1344 | + } |
|
| 1014 | 1345 | unset($data); |
| 1015 | - } else $error = true; |
|
| 1346 | + } else { |
|
| 1347 | + $error = true; |
|
| 1348 | + } |
|
| 1016 | 1349 | if ($error) { |
| 1017 | 1350 | if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { |
| 1018 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; |
|
| 1351 | + if ($globalDebug) { |
|
| 1352 | + echo "Not a message. Ignoring... \n"; |
|
| 1353 | + } |
|
| 1019 | 1354 | } else { |
| 1020 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; |
|
| 1355 | + if ($globalDebug) { |
|
| 1356 | + echo "Wrong line format. Ignoring... \n"; |
|
| 1357 | + } |
|
| 1021 | 1358 | if ($globalDebug) { |
| 1022 | 1359 | echo $buffer; |
| 1023 | 1360 | print_r($line); |
| 1024 | 1361 | } |
| 1025 | 1362 | //socket_close($r); |
| 1026 | - if ($globalDebug) echo "Reconnect after an error...\n"; |
|
| 1027 | - if ($format == 'aprs') $aprs_connect = 0; |
|
| 1363 | + if ($globalDebug) { |
|
| 1364 | + echo "Reconnect after an error...\n"; |
|
| 1365 | + } |
|
| 1366 | + if ($format == 'aprs') { |
|
| 1367 | + $aprs_connect = 0; |
|
| 1368 | + } |
|
| 1028 | 1369 | $sourceer[$nb] = $globalSources[$nb]; |
| 1029 | 1370 | connect_all($sourceer); |
| 1030 | 1371 | $sourceer = array(); |
@@ -1032,10 +1373,14 @@ discard block |
||
| 1032 | 1373 | } |
| 1033 | 1374 | } |
| 1034 | 1375 | // Sleep for xxx microseconds |
| 1035 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); |
|
| 1376 | + if (isset($globalSBSSleep)) { |
|
| 1377 | + usleep($globalSBSSleep); |
|
| 1378 | + } |
|
| 1036 | 1379 | } else { |
| 1037 | 1380 | if ($format == 'flightgearmp') { |
| 1038 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; |
|
| 1381 | + if ($globalDebug) { |
|
| 1382 | + echo "Reconnect FlightGear MP..."; |
|
| 1383 | + } |
|
| 1039 | 1384 | //@socket_close($r); |
| 1040 | 1385 | sleep($globalMinFetch); |
| 1041 | 1386 | $sourcefg[$nb] = $globalSources[$nb]; |
@@ -1044,10 +1389,15 @@ discard block |
||
| 1044 | 1389 | break; |
| 1045 | 1390 | |
| 1046 | 1391 | } elseif ($format != 'acars' && $format != 'flightgearsp') { |
| 1047 | - if (isset($tt[$format])) $tt[$format]++; |
|
| 1048 | - else $tt[$format] = 0; |
|
| 1392 | + if (isset($tt[$format])) { |
|
| 1393 | + $tt[$format]++; |
|
| 1394 | + } else { |
|
| 1395 | + $tt[$format] = 0; |
|
| 1396 | + } |
|
| 1049 | 1397 | if ($tt[$format] > 30) { |
| 1050 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; |
|
| 1398 | + if ($globalDebug) { |
|
| 1399 | + echo "ERROR : Reconnect ".$format."..."; |
|
| 1400 | + } |
|
| 1051 | 1401 | //@socket_close($r); |
| 1052 | 1402 | sleep(2); |
| 1053 | 1403 | $aprs_connect = 0; |
@@ -1063,12 +1413,18 @@ discard block |
||
| 1063 | 1413 | } |
| 1064 | 1414 | } else { |
| 1065 | 1415 | $error = socket_strerror(socket_last_error()); |
| 1066 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1416 | + if ($globalDebug) { |
|
| 1417 | + echo "ERROR : socket_select give this error ".$error . "\n"; |
|
| 1418 | + } |
|
| 1067 | 1419 | if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || time() - $time >= $timeout) { |
| 1068 | - if (isset($globalDebug)) echo "Restarting...\n"; |
|
| 1420 | + if (isset($globalDebug)) { |
|
| 1421 | + echo "Restarting...\n"; |
|
| 1422 | + } |
|
| 1069 | 1423 | // Restart the script if possible |
| 1070 | 1424 | if (is_array($sockets)) { |
| 1071 | - if ($globalDebug) echo "Shutdown all sockets..."; |
|
| 1425 | + if ($globalDebug) { |
|
| 1426 | + echo "Shutdown all sockets..."; |
|
| 1427 | + } |
|
| 1072 | 1428 | |
| 1073 | 1429 | foreach ($sockets as $sock) { |
| 1074 | 1430 | @socket_shutdown($sock,2); |
@@ -1076,18 +1432,24 @@ discard block |
||
| 1076 | 1432 | } |
| 1077 | 1433 | |
| 1078 | 1434 | } |
| 1079 | - if ($globalDebug) echo "Restart all connections..."; |
|
| 1435 | + if ($globalDebug) { |
|
| 1436 | + echo "Restart all connections..."; |
|
| 1437 | + } |
|
| 1080 | 1438 | sleep(2); |
| 1081 | 1439 | $time = time(); |
| 1082 | 1440 | //connect_all($hosts); |
| 1083 | 1441 | $aprs_connect = 0; |
| 1084 | - if ($reset > 40) exit('Too many attempts...'); |
|
| 1442 | + if ($reset > 40) { |
|
| 1443 | + exit('Too many attempts...'); |
|
| 1444 | + } |
|
| 1085 | 1445 | connect_all($globalSources); |
| 1086 | 1446 | } |
| 1087 | 1447 | } |
| 1088 | 1448 | } |
| 1089 | 1449 | if ($globalDaemon === false) { |
| 1090 | - if ($globalDebug) echo 'Check all...'."\n"; |
|
| 1450 | + if ($globalDebug) { |
|
| 1451 | + echo 'Check all...'."\n"; |
|
| 1452 | + } |
|
| 1091 | 1453 | $SI->checkAll(); |
| 1092 | 1454 | } |
| 1093 | 1455 | } |
@@ -13,13 +13,13 @@ discard block |
||
| 13 | 13 | * @param Array $headers header to submit with the form |
| 14 | 14 | * @return String the result |
| 15 | 15 | */ |
| 16 | - public function getData($url, $type = 'get', $data = '', $headers = '',$cookie = '',$referer = '',$timeout = '',$useragent = '') { |
|
| 16 | + public function getData($url, $type = 'get', $data = '', $headers = '', $cookie = '', $referer = '', $timeout = '', $useragent = '') { |
|
| 17 | 17 | $ch = curl_init(); |
| 18 | 18 | curl_setopt($ch, CURLOPT_URL, $url); |
| 19 | 19 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); |
| 20 | 20 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); |
| 21 | 21 | curl_setopt($ch, CURLINFO_HEADER_OUT, true); |
| 22 | - curl_setopt($ch,CURLOPT_ENCODING , "gzip"); |
|
| 22 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
| 23 | 23 | //curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5'); |
| 24 | 24 | // curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0'); |
| 25 | 25 | if ($useragent == '') { |
@@ -29,13 +29,13 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
| 31 | 31 | else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
| 32 | - curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
|
| 32 | + curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common', "curlResponseHeaderCallback")); |
|
| 33 | 33 | if ($type == 'post') { |
| 34 | 34 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
| 35 | 35 | if (is_array($data)) { |
| 36 | 36 | curl_setopt($ch, CURLOPT_POST, count($data)); |
| 37 | 37 | $data_string = ''; |
| 38 | - foreach($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
| 38 | + foreach ($data as $key=>$value) { $data_string .= $key.'='.$value.'&'; } |
|
| 39 | 39 | rtrim($data_string, '&'); |
| 40 | 40 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); |
| 41 | 41 | } else { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | } |
| 48 | 48 | if ($cookie != '') { |
| 49 | 49 | if (is_array($cookie)) { |
| 50 | - curl_setopt($ch, CURLOPT_COOKIE, implode($cookie,';')); |
|
| 50 | + curl_setopt($ch, CURLOPT_COOKIE, implode($cookie, ';')); |
|
| 51 | 51 | } else { |
| 52 | 52 | curl_setopt($ch, CURLOPT_COOKIE, $cookie); |
| 53 | 53 | } |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | $result = curl_exec($ch); |
| 59 | 59 | $info = curl_getinfo($ch); |
| 60 | 60 | curl_close($ch); |
| 61 | - if ($info['http_code'] == '503' && strstr($result,'DDoS protection by CloudFlare')) { |
|
| 61 | + if ($info['http_code'] == '503' && strstr($result, 'DDoS protection by CloudFlare')) { |
|
| 62 | 62 | echo "Cloudflare Detected\n"; |
| 63 | 63 | require_once(dirname(__FILE__).'/libs/cloudflare-bypass/libraries/cloudflareClass.php'); |
| 64 | 64 | $useragent = UAgent::random(); |
| 65 | 65 | cloudflare::useUserAgent($useragent); |
| 66 | 66 | if ($clearanceCookie = cloudflare::bypass($url)) { |
| 67 | - return $this->getData($url,'get',$data,$headers,$clearanceCookie,$referer,$timeout,$useragent); |
|
| 67 | + return $this->getData($url, 'get', $data, $headers, $clearanceCookie, $referer, $timeout, $useragent); |
|
| 68 | 68 | } |
| 69 | 69 | } else { |
| 70 | 70 | return $result; |
@@ -105,27 +105,27 @@ discard block |
||
| 105 | 105 | if ($data == '') return array(); |
| 106 | 106 | $html = str_get_html($data); |
| 107 | 107 | if ($html === false) return array(); |
| 108 | - $tabledata=array(); |
|
| 109 | - foreach($html->find('tr') as $element) |
|
| 108 | + $tabledata = array(); |
|
| 109 | + foreach ($html->find('tr') as $element) |
|
| 110 | 110 | { |
| 111 | 111 | $td = array(); |
| 112 | - foreach( $element->find('th') as $row) |
|
| 112 | + foreach ($element->find('th') as $row) |
|
| 113 | 113 | { |
| 114 | 114 | $td [] = trim($row->plaintext); |
| 115 | 115 | } |
| 116 | - $td=array_filter($td); |
|
| 116 | + $td = array_filter($td); |
|
| 117 | 117 | $tabledata[] = $td; |
| 118 | 118 | |
| 119 | 119 | $td = array(); |
| 120 | 120 | $tdi = array(); |
| 121 | - foreach( $element->find('td') as $row) |
|
| 121 | + foreach ($element->find('td') as $row) |
|
| 122 | 122 | { |
| 123 | 123 | $td [] = trim($row->plaintext); |
| 124 | 124 | $tdi [] = trim($row->innertext); |
| 125 | 125 | } |
| 126 | - $td=array_filter($td); |
|
| 127 | - $tdi=array_filter($tdi); |
|
| 128 | - $tabledata[]=array_merge($td,$tdi); |
|
| 126 | + $td = array_filter($td); |
|
| 127 | + $tdi = array_filter($tdi); |
|
| 128 | + $tabledata[] = array_merge($td, $tdi); |
|
| 129 | 129 | } |
| 130 | 130 | $html->clear(); |
| 131 | 131 | unset($html); |
@@ -140,8 +140,8 @@ discard block |
||
| 140 | 140 | public function text2array($data) { |
| 141 | 141 | $html = str_get_html($data); |
| 142 | 142 | if ($html === false) return array(); |
| 143 | - $tabledata=array(); |
|
| 144 | - foreach($html->find('p') as $element) |
|
| 143 | + $tabledata = array(); |
|
| 144 | + foreach ($html->find('p') as $element) |
|
| 145 | 145 | { |
| 146 | 146 | $tabledata [] = trim($element->plaintext); |
| 147 | 147 | } |
@@ -161,11 +161,11 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 163 | 163 | if ($lat == $latc && $lon == $lonc) return 0; |
| 164 | - $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
|
| 164 | + $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc))) + cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon) - floatval($lonc)))))*60*1.1515; |
|
| 165 | 165 | if ($unit == "km") { |
| 166 | - return round($dist * 1.609344); |
|
| 166 | + return round($dist*1.609344); |
|
| 167 | 167 | } elseif ($unit == "m") { |
| 168 | - return round($dist * 1.609344 * 1000); |
|
| 168 | + return round($dist*1.609344*1000); |
|
| 169 | 169 | } elseif ($unit == "mile" || $unit == "mi") { |
| 170 | 170 | return round($dist); |
| 171 | 171 | } elseif ($unit == "nm") { |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param float $distance distance covered |
| 182 | 182 | * @return whether distance is realistic |
| 183 | 183 | */ |
| 184 | - public function withinThreshold ($timeDifference, $distance) { |
|
| 184 | + public function withinThreshold($timeDifference, $distance) { |
|
| 185 | 185 | $x = abs($timeDifference); |
| 186 | 186 | $d = abs($distance); |
| 187 | 187 | if ($x == 0 || $d == 0) return true; |
@@ -197,12 +197,12 @@ discard block |
||
| 197 | 197 | return ($array !== array_values($array)); |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - public function isInteger($input){ |
|
| 200 | + public function isInteger($input) { |
|
| 201 | 201 | return(ctype_digit(strval($input))); |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | |
| 205 | - public function convertDec($dms,$latlong) { |
|
| 205 | + public function convertDec($dms, $latlong) { |
|
| 206 | 206 | if ($latlong == 'latitude') { |
| 207 | 207 | $deg = substr($dms, 0, 2); |
| 208 | 208 | $min = substr($dms, 2, 4); |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | $deg = substr($dms, 0, 3); |
| 211 | 211 | $min = substr($dms, 3, 5); |
| 212 | 212 | } |
| 213 | - return $deg+(($min*60)/3600); |
|
| 213 | + return $deg + (($min*60)/3600); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | public function xcopy($source, $dest) |
| 223 | 223 | { |
| 224 | 224 | $files = glob($source.'*.*'); |
| 225 | - foreach($files as $file){ |
|
| 226 | - $file_to_go = str_replace($source,$dest,$file); |
|
| 225 | + foreach ($files as $file) { |
|
| 226 | + $file_to_go = str_replace($source, $dest, $file); |
|
| 227 | 227 | copy($file, $file_to_go); |
| 228 | 228 | } |
| 229 | 229 | return true; |
@@ -234,9 +234,9 @@ discard block |
||
| 234 | 234 | * @param String $url url to check |
| 235 | 235 | * @return bool Return true on succes false on failure |
| 236 | 236 | */ |
| 237 | - public function urlexist($url){ |
|
| 238 | - $headers=get_headers($url); |
|
| 239 | - return stripos($headers[0],"200 OK")?true:false; |
|
| 237 | + public function urlexist($url) { |
|
| 238 | + $headers = get_headers($url); |
|
| 239 | + return stripos($headers[0], "200 OK") ? true : false; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | public function hex2str($hex) { |
| 248 | 248 | $str = ''; |
| 249 | 249 | $hexln = strlen($hex); |
| 250 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 250 | + for ($i = 0; $i < $hexln; $i += 2) $str .= chr(hexdec(substr($hex, $i, 2))); |
|
| 251 | 251 | return $str; |
| 252 | 252 | } |
| 253 | 253 | |
@@ -256,33 +256,33 @@ discard block |
||
| 256 | 256 | //difference in longitudinal coordinates |
| 257 | 257 | $dLon = deg2rad($lon2) - deg2rad($lon1); |
| 258 | 258 | //difference in the phi of latitudinal coordinates |
| 259 | - $dPhi = log(tan(deg2rad($lat2) / 2 + pi() / 4) / tan(deg2rad($lat1) / 2 + pi() / 4)); |
|
| 259 | + $dPhi = log(tan(deg2rad($lat2)/2 + pi()/4)/tan(deg2rad($lat1)/2 + pi()/4)); |
|
| 260 | 260 | //we need to recalculate $dLon if it is greater than pi |
| 261 | - if(abs($dLon) > pi()) { |
|
| 262 | - if($dLon > 0) { |
|
| 263 | - $dLon = (2 * pi() - $dLon) * -1; |
|
| 261 | + if (abs($dLon) > pi()) { |
|
| 262 | + if ($dLon > 0) { |
|
| 263 | + $dLon = (2*pi() - $dLon)*-1; |
|
| 264 | 264 | } else { |
| 265 | - $dLon = 2 * pi() + $dLon; |
|
| 265 | + $dLon = 2*pi() + $dLon; |
|
| 266 | 266 | } |
| 267 | 267 | } |
| 268 | 268 | //return the angle, normalized |
| 269 | - return (rad2deg(atan2($dLon, $dPhi)) + 360) % 360; |
|
| 269 | + return (rad2deg(atan2($dLon, $dPhi)) + 360)%360; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - public function checkLine($lat1,$lon1,$lat2,$lon2,$lat3,$lon3,$approx = 0.2) { |
|
| 272 | + public function checkLine($lat1, $lon1, $lat2, $lon2, $lat3, $lon3, $approx = 0.2) { |
|
| 273 | 273 | //$a = ($lon2-$lon1)*$lat3+($lat2-$lat1)*$lon3+($lat1*$lon2+$lat2*$lon1); |
| 274 | - $a = -($lon2-$lon1); |
|
| 274 | + $a = -($lon2 - $lon1); |
|
| 275 | 275 | $b = $lat2 - $lat1; |
| 276 | - $c = -($a*$lat1+$b*$lon1); |
|
| 277 | - $d = $a*$lat3+$b*$lon3+$c; |
|
| 276 | + $c = -($a*$lat1 + $b*$lon1); |
|
| 277 | + $d = $a*$lat3 + $b*$lon3 + $c; |
|
| 278 | 278 | if ($d > -$approx && $d < $approx) return true; |
| 279 | 279 | else return false; |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | public function array_merge_noappend() { |
| 283 | 283 | $output = array(); |
| 284 | - foreach(func_get_args() as $array) { |
|
| 285 | - foreach($array as $key => $value) { |
|
| 284 | + foreach (func_get_args() as $array) { |
|
| 285 | + foreach ($array as $key => $value) { |
|
| 286 | 286 | $output[$key] = isset($output[$key]) ? |
| 287 | 287 | array_merge($output[$key], $value) : $value; |
| 288 | 288 | } |
@@ -346,34 +346,34 @@ discard block |
||
| 346 | 346 | return $result; |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | - public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1){ |
|
| 349 | + public function nextcoord($latitude, $longitude, $speed, $heading, $archivespeed = 1) { |
|
| 350 | 350 | global $globalMapRefresh; |
| 351 | 351 | $distance = ($speed*0.514444*$globalMapRefresh*$archivespeed)/1000; |
| 352 | 352 | $r = 6378; |
| 353 | 353 | $latitude = deg2rad($latitude); |
| 354 | 354 | $longitude = deg2rad($longitude); |
| 355 | 355 | $bearing = deg2rad($heading); |
| 356 | - $latitude2 = asin( (sin($latitude) * cos($distance/$r)) + (cos($latitude) * sin($distance/$r) * cos($bearing)) ); |
|
| 357 | - $longitude2 = $longitude + atan2( sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r)-(sin($latitude)*sin($latitude2)) ); |
|
| 358 | - return array('latitude' => number_format(rad2deg($latitude2),5,'.',''),'longitude' => number_format(rad2deg($longitude2),5,'.','')); |
|
| 356 | + $latitude2 = asin((sin($latitude)*cos($distance/$r)) + (cos($latitude)*sin($distance/$r)*cos($bearing))); |
|
| 357 | + $longitude2 = $longitude + atan2(sin($bearing)*sin($distance/$r)*cos($latitude), cos($distance/$r) - (sin($latitude)*sin($latitude2))); |
|
| 358 | + return array('latitude' => number_format(rad2deg($latitude2), 5, '.', ''), 'longitude' => number_format(rad2deg($longitude2), 5, '.', '')); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - public function getCoordfromDistanceBearing($latitude,$longitude,$bearing,$distance) { |
|
| 361 | + public function getCoordfromDistanceBearing($latitude, $longitude, $bearing, $distance) { |
|
| 362 | 362 | // distance in meter |
| 363 | 363 | $R = 6378.14; |
| 364 | - $latitude1 = $latitude * (M_PI/180); |
|
| 365 | - $longitude1 = $longitude * (M_PI/180); |
|
| 366 | - $brng = $bearing * (M_PI/180); |
|
| 364 | + $latitude1 = $latitude*(M_PI/180); |
|
| 365 | + $longitude1 = $longitude*(M_PI/180); |
|
| 366 | + $brng = $bearing*(M_PI/180); |
|
| 367 | 367 | $d = $distance; |
| 368 | 368 | |
| 369 | 369 | $latitude2 = asin(sin($latitude1)*cos($d/$R) + cos($latitude1)*sin($d/$R)*cos($brng)); |
| 370 | - $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1),cos($d/$R)-sin($latitude1)*sin($latitude2)); |
|
| 370 | + $longitude2 = $longitude1 + atan2(sin($brng)*sin($d/$R)*cos($latitude1), cos($d/$R) - sin($latitude1)*sin($latitude2)); |
|
| 371 | 371 | |
| 372 | - $latitude2 = $latitude2 * (180/M_PI); |
|
| 373 | - $longitude2 = $longitude2 * (180/M_PI); |
|
| 372 | + $latitude2 = $latitude2*(180/M_PI); |
|
| 373 | + $longitude2 = $longitude2*(180/M_PI); |
|
| 374 | 374 | |
| 375 | - $flat = round ($latitude2,6); |
|
| 376 | - $flong = round ($longitude2,6); |
|
| 375 | + $flat = round($latitude2, 6); |
|
| 376 | + $flong = round($longitude2, 6); |
|
| 377 | 377 | /* |
| 378 | 378 | $dx = $distance*cos($bearing); |
| 379 | 379 | $dy = $distance*sin($bearing); |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | $flong = $longitude + $dlong; |
| 383 | 383 | $flat = $latitude + $dlat; |
| 384 | 384 | */ |
| 385 | - return array('latitude' => $flat,'longitude' => $flong); |
|
| 385 | + return array('latitude' => $flat, 'longitude' => $flong); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -396,14 +396,14 @@ discard block |
||
| 396 | 396 | * @param integer $level GZIP compression level (default: 9) |
| 397 | 397 | * @return string New filename (with .gz appended) if success, or false if operation fails |
| 398 | 398 | */ |
| 399 | - public function gzCompressFile($source, $level = 9){ |
|
| 400 | - $dest = $source . '.gz'; |
|
| 401 | - $mode = 'wb' . $level; |
|
| 399 | + public function gzCompressFile($source, $level = 9) { |
|
| 400 | + $dest = $source.'.gz'; |
|
| 401 | + $mode = 'wb'.$level; |
|
| 402 | 402 | $error = false; |
| 403 | 403 | if ($fp_out = gzopen($dest, $mode)) { |
| 404 | - if ($fp_in = fopen($source,'rb')) { |
|
| 404 | + if ($fp_in = fopen($source, 'rb')) { |
|
| 405 | 405 | while (!feof($fp_in)) |
| 406 | - gzwrite($fp_out, fread($fp_in, 1024 * 512)); |
|
| 406 | + gzwrite($fp_out, fread($fp_in, 1024*512)); |
|
| 407 | 407 | fclose($fp_in); |
| 408 | 408 | } else { |
| 409 | 409 | $error = true; |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | public function remove_accents($string) { |
| 422 | - if ( !preg_match('/[\x80-\xff]/', $string) ) return $string; |
|
| 422 | + if (!preg_match('/[\x80-\xff]/', $string)) return $string; |
|
| 423 | 423 | $chars = array( |
| 424 | 424 | // Decompositions for Latin-1 Supplement |
| 425 | 425 | chr(195).chr(128) => 'A', chr(195).chr(129) => 'A', |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | chr(196).chr(172) => 'I', chr(196).chr(173) => 'i', |
| 477 | 477 | chr(196).chr(174) => 'I', chr(196).chr(175) => 'i', |
| 478 | 478 | chr(196).chr(176) => 'I', chr(196).chr(177) => 'i', |
| 479 | - chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij', |
|
| 479 | + chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij', |
|
| 480 | 480 | chr(196).chr(180) => 'J', chr(196).chr(181) => 'j', |
| 481 | 481 | chr(196).chr(182) => 'K', chr(196).chr(183) => 'k', |
| 482 | 482 | chr(196).chr(184) => 'k', chr(196).chr(185) => 'L', |
@@ -492,13 +492,13 @@ discard block |
||
| 492 | 492 | chr(197).chr(140) => 'O', chr(197).chr(141) => 'o', |
| 493 | 493 | chr(197).chr(142) => 'O', chr(197).chr(143) => 'o', |
| 494 | 494 | chr(197).chr(144) => 'O', chr(197).chr(145) => 'o', |
| 495 | - chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe', |
|
| 496 | - chr(197).chr(148) => 'R',chr(197).chr(149) => 'r', |
|
| 497 | - chr(197).chr(150) => 'R',chr(197).chr(151) => 'r', |
|
| 498 | - chr(197).chr(152) => 'R',chr(197).chr(153) => 'r', |
|
| 499 | - chr(197).chr(154) => 'S',chr(197).chr(155) => 's', |
|
| 500 | - chr(197).chr(156) => 'S',chr(197).chr(157) => 's', |
|
| 501 | - chr(197).chr(158) => 'S',chr(197).chr(159) => 's', |
|
| 495 | + chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe', |
|
| 496 | + chr(197).chr(148) => 'R', chr(197).chr(149) => 'r', |
|
| 497 | + chr(197).chr(150) => 'R', chr(197).chr(151) => 'r', |
|
| 498 | + chr(197).chr(152) => 'R', chr(197).chr(153) => 'r', |
|
| 499 | + chr(197).chr(154) => 'S', chr(197).chr(155) => 's', |
|
| 500 | + chr(197).chr(156) => 'S', chr(197).chr(157) => 's', |
|
| 501 | + chr(197).chr(158) => 'S', chr(197).chr(159) => 's', |
|
| 502 | 502 | chr(197).chr(160) => 'S', chr(197).chr(161) => 's', |
| 503 | 503 | chr(197).chr(162) => 'T', chr(197).chr(163) => 't', |
| 504 | 504 | chr(197).chr(164) => 'T', chr(197).chr(165) => 't', |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | for ($i = 0, $int = '', $concat_flag = true; $i < $length; $i++) { |
| 533 | 533 | if (is_numeric($string[$i]) && $concat_flag) { |
| 534 | 534 | $int .= $string[$i]; |
| 535 | - } elseif(!$concat && $concat_flag && strlen($int) > 0) { |
|
| 535 | + } elseif (!$concat && $concat_flag && strlen($int) > 0) { |
|
| 536 | 536 | $concat_flag = false; |
| 537 | 537 | } |
| 538 | 538 | } |
@@ -9,16 +9,16 @@ discard block |
||
| 9 | 9 | require_once(dirname(__FILE__).'/class.Source.php'); |
| 10 | 10 | |
| 11 | 11 | class SpotterImport { |
| 12 | - private $all_flights = array(); |
|
| 13 | - private $last_delete_hourly = 0; |
|
| 14 | - private $last_delete = 0; |
|
| 15 | - private $stats = array(); |
|
| 16 | - private $tmd = 0; |
|
| 17 | - private $source_location = array(); |
|
| 18 | - public $db = null; |
|
| 19 | - public $nb = 0; |
|
| 20 | - |
|
| 21 | - public function __construct($dbc = null) { |
|
| 12 | + private $all_flights = array(); |
|
| 13 | + private $last_delete_hourly = 0; |
|
| 14 | + private $last_delete = 0; |
|
| 15 | + private $stats = array(); |
|
| 16 | + private $tmd = 0; |
|
| 17 | + private $source_location = array(); |
|
| 18 | + public $db = null; |
|
| 19 | + public $nb = 0; |
|
| 20 | + |
|
| 21 | + public function __construct($dbc = null) { |
|
| 22 | 22 | global $globalBeta; |
| 23 | 23 | $Connection = new Connection($dbc); |
| 24 | 24 | $this->db = $Connection->db(); |
@@ -29,18 +29,18 @@ discard block |
||
| 29 | 29 | $currentdate = date('Y-m-d'); |
| 30 | 30 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 31 | 31 | if (!empty($sourcestat)) { |
| 32 | - foreach($sourcestat as $srcst) { |
|
| 33 | - $type = $srcst['stats_type']; |
|
| 32 | + foreach($sourcestat as $srcst) { |
|
| 33 | + $type = $srcst['stats_type']; |
|
| 34 | 34 | if ($type == 'polar' || $type == 'hist') { |
| 35 | - $source = $srcst['source_name']; |
|
| 36 | - $data = $srcst['source_data']; |
|
| 37 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 38 | - } |
|
| 39 | - } |
|
| 35 | + $source = $srcst['source_name']; |
|
| 36 | + $data = $srcst['source_data']; |
|
| 37 | + $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + } |
|
| 40 | 41 | } |
| 41 | - } |
|
| 42 | 42 | |
| 43 | - public function get_Schedule($id,$ident) { |
|
| 43 | + public function get_Schedule($id,$ident) { |
|
| 44 | 44 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 45 | 45 | // Get schedule here, so it's done only one time |
| 46 | 46 | |
@@ -60,42 +60,42 @@ discard block |
||
| 60 | 60 | $operator = $Spotter->getOperator($ident); |
| 61 | 61 | $scheduleexist = false; |
| 62 | 62 | if ($Schedule->checkSchedule($operator) == 0) { |
| 63 | - $operator = $Translation->checkTranslation($ident); |
|
| 64 | - if ($Schedule->checkSchedule($operator) == 0) { |
|
| 63 | + $operator = $Translation->checkTranslation($ident); |
|
| 64 | + if ($Schedule->checkSchedule($operator) == 0) { |
|
| 65 | 65 | $schedule = $Schedule->fetchSchedule($operator); |
| 66 | 66 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 68 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 69 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 70 | - // Should also check if route schedule = route from DB |
|
| 71 | - if ($schedule['DepartureAirportIATA'] != '') { |
|
| 67 | + if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 68 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 69 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 70 | + // Should also check if route schedule = route from DB |
|
| 71 | + if ($schedule['DepartureAirportIATA'] != '') { |
|
| 72 | 72 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
| 73 | - $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 74 | - if (trim($airport_icao) != '') { |
|
| 73 | + $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
|
| 74 | + if (trim($airport_icao) != '') { |
|
| 75 | 75 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 76 | 76 | if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
| 77 | - } |
|
| 77 | + } |
|
| 78 | + } |
|
| 78 | 79 | } |
| 79 | - } |
|
| 80 | - if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 80 | + if ($schedule['ArrivalAirportIATA'] != '') { |
|
| 81 | 81 | if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) { |
| 82 | - $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 83 | - if (trim($airport_icao) != '') { |
|
| 82 | + $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
|
| 83 | + if (trim($airport_icao) != '') { |
|
| 84 | 84 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 85 | 85 | if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
| 86 | - } |
|
| 86 | + } |
|
| 87 | + } |
|
| 87 | 88 | } |
| 88 | - } |
|
| 89 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 89 | + $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 90 | 90 | } |
| 91 | - } else $scheduleexist = true; |
|
| 91 | + } else $scheduleexist = true; |
|
| 92 | 92 | } else $scheduleexist = true; |
| 93 | 93 | // close connection, at least one way will work ? |
| 94 | - if ($scheduleexist) { |
|
| 94 | + if ($scheduleexist) { |
|
| 95 | 95 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 96 | - $sch = $Schedule->getSchedule($operator); |
|
| 96 | + $sch = $Schedule->getSchedule($operator); |
|
| 97 | 97 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 98 | - } |
|
| 98 | + } |
|
| 99 | 99 | $Spotter->db = null; |
| 100 | 100 | $Schedule->db = null; |
| 101 | 101 | $Translation->db = null; |
@@ -110,92 +110,92 @@ discard block |
||
| 110 | 110 | } |
| 111 | 111 | */ |
| 112 | 112 | } |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - public function checkAll() { |
|
| 115 | + public function checkAll() { |
|
| 116 | 116 | global $globalDebug; |
| 117 | 117 | if ($globalDebug) echo "Update last seen flights data...\n"; |
| 118 | 118 | foreach ($this->all_flights as $key => $flight) { |
| 119 | - if (isset($this->all_flights[$key]['id'])) { |
|
| 119 | + if (isset($this->all_flights[$key]['id'])) { |
|
| 120 | 120 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 121 | - $Spotter = new Spotter($this->db); |
|
| 122 | - $real_arrival = $this->arrival($key); |
|
| 123 | - $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 124 | - } |
|
| 121 | + $Spotter = new Spotter($this->db); |
|
| 122 | + $real_arrival = $this->arrival($key); |
|
| 123 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 124 | + } |
|
| 125 | + } |
|
| 125 | 126 | } |
| 126 | - } |
|
| 127 | 127 | |
| 128 | - public function arrival($key) { |
|
| 128 | + public function arrival($key) { |
|
| 129 | 129 | global $globalClosestMinDist, $globalDebug; |
| 130 | 130 | if ($globalDebug) echo 'Update arrival...'."\n"; |
| 131 | 131 | $Spotter = new Spotter($this->db); |
| 132 | - $airport_icao = ''; |
|
| 133 | - $airport_time = ''; |
|
| 134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 132 | + $airport_icao = ''; |
|
| 133 | + $airport_time = ''; |
|
| 134 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 135 | 135 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 136 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 137 | - if (isset($closestAirports[0])) { |
|
| 138 | - if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 139 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 140 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 142 | - } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 143 | - foreach ($closestAirports as $airport) { |
|
| 144 | - if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 145 | - $airport_icao = $airport['icao']; |
|
| 146 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 148 | - break; |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 152 | - $airport_icao = $closestAirports[0]['icao']; |
|
| 153 | - $airport_time = $this->all_flights[$key]['datetime']; |
|
| 154 | - } else { |
|
| 155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 156 | - } |
|
| 157 | - } else { |
|
| 158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - } else { |
|
| 162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 163 | - } |
|
| 164 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - public function del() { |
|
| 136 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 137 | + if (isset($closestAirports[0])) { |
|
| 138 | + if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
|
| 139 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 140 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 141 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 142 | + } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
|
| 143 | + foreach ($closestAirports as $airport) { |
|
| 144 | + if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
|
| 145 | + $airport_icao = $airport['icao']; |
|
| 146 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 147 | + if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 148 | + break; |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 152 | + $airport_icao = $closestAirports[0]['icao']; |
|
| 153 | + $airport_time = $this->all_flights[$key]['datetime']; |
|
| 154 | + } else { |
|
| 155 | + if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 156 | + } |
|
| 157 | + } else { |
|
| 158 | + if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + } else { |
|
| 162 | + if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 163 | + } |
|
| 164 | + return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + public function del() { |
|
| 170 | 170 | global $globalDebug; |
| 171 | 171 | // Delete old infos |
| 172 | 172 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 173 | 173 | foreach ($this->all_flights as $key => $flight) { |
| 174 | - if (isset($flight['lastupdate'])) { |
|
| 175 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 176 | - if (isset($this->all_flights[$key]['id'])) { |
|
| 177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 174 | + if (isset($flight['lastupdate'])) { |
|
| 175 | + if ($flight['lastupdate'] < (time()-3000)) { |
|
| 176 | + if (isset($this->all_flights[$key]['id'])) { |
|
| 177 | + if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 178 | 178 | /* |
| 179 | 179 | $SpotterLive = new SpotterLive(); |
| 180 | 180 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
| 181 | 181 | $SpotterLive->db = null; |
| 182 | 182 | */ |
| 183 | - $real_arrival = $this->arrival($key); |
|
| 184 | - $Spotter = new Spotter($this->db); |
|
| 185 | - if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
| 183 | + $real_arrival = $this->arrival($key); |
|
| 184 | + $Spotter = new Spotter($this->db); |
|
| 185 | + if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
|
| 186 | 186 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
| 187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 188 | 188 | } |
| 189 | 189 | // Put in archive |
| 190 | 190 | // $Spotter->db = null; |
| 191 | - } |
|
| 192 | - unset($this->all_flights[$key]); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - } |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - public function add($line) { |
|
| 191 | + } |
|
| 192 | + unset($this->all_flights[$key]); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + } |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + public function add($line) { |
|
| 199 | 199 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
| 200 | 200 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 201 | 201 | if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
@@ -220,18 +220,18 @@ discard block |
||
| 220 | 220 | |
| 221 | 221 | // SBS format is CSV format |
| 222 | 222 | if(is_array($line) && isset($line['hex'])) { |
| 223 | - //print_r($line); |
|
| 224 | - if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 223 | + //print_r($line); |
|
| 224 | + if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
|
| 225 | 225 | |
| 226 | 226 | // Increment message number |
| 227 | 227 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 228 | - $current_date = date('Y-m-d'); |
|
| 229 | - $source = $line['source_name']; |
|
| 230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 231 | - if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 232 | - $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 233 | - $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 228 | + $current_date = date('Y-m-d'); |
|
| 229 | + $source = $line['source_name']; |
|
| 230 | + if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 231 | + if (!isset($this->stats[$current_date][$source]['msg'])) { |
|
| 232 | + $this->stats[$current_date][$source]['msg']['date'] = time(); |
|
| 233 | + $this->stats[$current_date][$source]['msg']['nb'] = 1; |
|
| 234 | + } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /* |
@@ -247,40 +247,40 @@ discard block |
||
| 247 | 247 | //$this->db = $dbc; |
| 248 | 248 | |
| 249 | 249 | //$hex = trim($line['hex']); |
| 250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 251 | - else $id = trim($line['id']); |
|
| 250 | + if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 251 | + else $id = trim($line['id']); |
|
| 252 | 252 | |
| 253 | 253 | if (!isset($this->all_flights[$id])) { |
| 254 | - $this->all_flights[$id] = array(); |
|
| 255 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 256 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
| 257 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 258 | - if (!isset($line['id'])) { |
|
| 254 | + $this->all_flights[$id] = array(); |
|
| 255 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 256 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
| 257 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 258 | + if (!isset($line['id'])) { |
|
| 259 | 259 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 260 | 260 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 261 | 261 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 262 | 262 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
| 263 | - //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 264 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 265 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 263 | + //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 264 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 265 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | //print_r($this->all_flights); |
| 269 | 269 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 270 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 271 | - //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 270 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 271 | + //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
|
| 272 | 272 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 273 | - //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 274 | - if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 273 | + //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 274 | + if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') { |
|
| 275 | 275 | $timeelapsed = microtime(true); |
| 276 | 276 | $Spotter = new Spotter($this->db); |
| 277 | 277 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 278 | 278 | $Spotter->db = null; |
| 279 | 279 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 280 | 280 | if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
| 281 | - } |
|
| 282 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 283 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 281 | + } |
|
| 282 | + if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 283 | + if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 284 | 284 | } |
| 285 | 285 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 286 | 286 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
@@ -304,9 +304,9 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 306 | 306 | if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
| 307 | - if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 307 | + if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
|
| 308 | 308 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 309 | - } else { |
|
| 309 | + } else { |
|
| 310 | 310 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 311 | 311 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 312 | 312 | /* |
@@ -315,41 +315,41 @@ discard block |
||
| 315 | 315 | print_r($line); |
| 316 | 316 | */ |
| 317 | 317 | return ''; |
| 318 | - } |
|
| 318 | + } |
|
| 319 | 319 | } else { |
| 320 | 320 | date_default_timezone_set('UTC'); |
| 321 | 321 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 325 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 325 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 326 | 326 | } |
| 327 | 327 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 328 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 328 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 329 | 329 | } |
| 330 | 330 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 331 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
| 331 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
| 332 | 332 | } |
| 333 | 333 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 334 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
| 334 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 338 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 339 | - if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 339 | + if ($this->all_flights[$id]['addedSpotter'] == 1) { |
|
| 340 | 340 | $timeelapsed = microtime(true); |
| 341 | - $Spotter = new Spotter($this->db); |
|
| 342 | - $fromsource = NULL; |
|
| 343 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 344 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 341 | + $Spotter = new Spotter($this->db); |
|
| 342 | + $fromsource = NULL; |
|
| 343 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 344 | + elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 345 | 345 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 346 | 346 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 347 | 347 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 348 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 348 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 349 | 349 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 350 | 350 | $Spotter->db = null; |
| 351 | 351 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 352 | - } |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | /* |
| 355 | 355 | if (!isset($line['id'])) { |
@@ -359,26 +359,26 @@ discard block |
||
| 359 | 359 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 360 | 360 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 361 | 361 | */ |
| 362 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 362 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 363 | 363 | |
| 364 | - //$putinarchive = true; |
|
| 365 | - if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 364 | + //$putinarchive = true; |
|
| 365 | + if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
|
| 366 | 366 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
| 367 | - } |
|
| 368 | - if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 367 | + } |
|
| 368 | + if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
|
| 369 | 369 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
| 370 | - } |
|
| 371 | - if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 372 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 373 | - } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 370 | + } |
|
| 371 | + if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
|
| 372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 373 | + } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
|
| 374 | 374 | $timeelapsed = microtime(true); |
| 375 | 375 | $Spotter = new Spotter($this->db); |
| 376 | 376 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 377 | 377 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 378 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 378 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 379 | 379 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 380 | 380 | |
| 381 | - } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 381 | + } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
|
| 382 | 382 | $timeelapsed = microtime(true); |
| 383 | 383 | $Spotter = new Spotter($this->db); |
| 384 | 384 | $route = $Spotter->getRouteInfo(trim($line['ident'])); |
@@ -392,43 +392,43 @@ discard block |
||
| 392 | 392 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 393 | 393 | |
| 394 | 394 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 395 | - //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 396 | - if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 395 | + //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
|
| 396 | + if ($route['fromairport_icao'] != $route['toairport_icao']) { |
|
| 397 | 397 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 398 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 399 | - } |
|
| 398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 399 | + } |
|
| 400 | 400 | } |
| 401 | 401 | if (!isset($globalFork)) $globalFork = TRUE; |
| 402 | 402 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 403 | 403 | if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
| 404 | 404 | } |
| 405 | - } |
|
| 405 | + } |
|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | if (isset($line['speed']) && $line['speed'] != '') { |
| 409 | 409 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 410 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 411 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 412 | - //$dataFound = true; |
|
| 410 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 411 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 412 | + //$dataFound = true; |
|
| 413 | 413 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 414 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 415 | - if ($distance > 1000 && $distance < 10000) { |
|
| 416 | - // use datetime |
|
| 414 | + $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 415 | + if ($distance > 1000 && $distance < 10000) { |
|
| 416 | + // use datetime |
|
| 417 | 417 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 418 | 418 | $speed = $speed*3.6; |
| 419 | 419 | if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
| 420 | 420 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 421 | - } |
|
| 421 | + } |
|
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | |
| 425 | 425 | |
| 426 | - if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 427 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 428 | - else unset($timediff); |
|
| 429 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
| 426 | + if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
|
| 427 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 428 | + else unset($timediff); |
|
| 429 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
| 430 | 430 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
| 431 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 431 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 432 | 432 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 433 | 433 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 434 | 434 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -442,16 +442,16 @@ discard block |
||
| 442 | 442 | if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
| 443 | 443 | $this->tmd = 0; |
| 444 | 444 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 445 | - } |
|
| 445 | + } |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 449 | - //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 449 | + //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 450 | 450 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 451 | 451 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 452 | - $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 453 | - $dataFound = true; |
|
| 454 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 452 | + $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
|
| 453 | + $dataFound = true; |
|
| 454 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 455 | 455 | } |
| 456 | 456 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 457 | 457 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
@@ -462,20 +462,20 @@ discard block |
||
| 462 | 462 | //$putinarchive = true; |
| 463 | 463 | } |
| 464 | 464 | */ |
| 465 | - /* |
|
| 465 | + /* |
|
| 466 | 466 | } elseif (isset($this->all_flights[$id]['latitude'])) { |
| 467 | 467 | if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n"; |
| 468 | 468 | } |
| 469 | 469 | */ |
| 470 | 470 | } |
| 471 | 471 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 472 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 473 | - //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 472 | + if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 473 | + //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
|
| 474 | 474 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 475 | 475 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 476 | - $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 477 | - $dataFound = true; |
|
| 478 | - $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 476 | + $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
|
| 477 | + $dataFound = true; |
|
| 478 | + $this->all_flights[$id]['time_last_coord'] = time(); |
|
| 479 | 479 | } |
| 480 | 480 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 481 | 481 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
@@ -493,54 +493,54 @@ discard block |
||
| 493 | 493 | */ |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | - } else if ($globalDebug && $timediff > 20) { |
|
| 496 | + } else if ($globalDebug && $timediff > 20) { |
|
| 497 | 497 | $this->tmd = $this->tmd + 1; |
| 498 | 498 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 499 | 499 | echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
| 500 | 500 | echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
| 501 | 501 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 502 | - } |
|
| 502 | + } |
|
| 503 | 503 | } |
| 504 | 504 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 505 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 506 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 505 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 506 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 507 | 507 | } |
| 508 | 508 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 509 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 510 | - //$dataFound = true; |
|
| 509 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 510 | + //$dataFound = true; |
|
| 511 | 511 | } |
| 512 | 512 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 513 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 514 | 514 | } |
| 515 | 515 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 516 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 516 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 517 | 517 | } |
| 518 | 518 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 519 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 520 | - //$dataFound = true; |
|
| 519 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 520 | + //$dataFound = true; |
|
| 521 | 521 | } |
| 522 | 522 | if (isset($line['ground']) && $line['ground'] != '') { |
| 523 | - if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 523 | + if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
|
| 524 | 524 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 525 | 525 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 526 | 526 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 527 | 527 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
| 528 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 528 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 529 | 529 | elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 530 | - } |
|
| 531 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 532 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 533 | - //$dataFound = true; |
|
| 530 | + } |
|
| 531 | + if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 532 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 533 | + //$dataFound = true; |
|
| 534 | 534 | } |
| 535 | 535 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 536 | - if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 537 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 538 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 539 | - $highlight = ''; |
|
| 540 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 541 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 542 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 543 | - if ($highlight != '') { |
|
| 536 | + if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
|
| 537 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 538 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 539 | + $highlight = ''; |
|
| 540 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 541 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 542 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 543 | + if ($highlight != '') { |
|
| 544 | 544 | $timeelapsed = microtime(true); |
| 545 | 545 | $Spotter = new Spotter($this->db); |
| 546 | 546 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
@@ -549,38 +549,38 @@ discard block |
||
| 549 | 549 | |
| 550 | 550 | //$putinarchive = true; |
| 551 | 551 | //$highlight = ''; |
| 552 | - } |
|
| 552 | + } |
|
| 553 | 553 | |
| 554 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 555 | - //$dataFound = true; |
|
| 554 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 555 | + //$dataFound = true; |
|
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 559 | - //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 559 | + //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
|
| 560 | 560 | if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
| 561 | 561 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 562 | 562 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 563 | 563 | //$dataFound = true; |
| 564 | - //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 564 | + //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
|
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 568 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 568 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | if (isset($line['heading']) && $line['heading'] != '') { |
| 572 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 573 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 574 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 575 | - //$dataFound = true; |
|
| 572 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 573 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 574 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 575 | + //$dataFound = true; |
|
| 576 | 576 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 577 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 578 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 579 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 580 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 577 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 578 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 579 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 580 | + if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 581 | 581 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 582 | - // If not enough messages and ACARS set heading to 0 |
|
| 583 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 582 | + // If not enough messages and ACARS set heading to 0 |
|
| 583 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 584 | 584 | } |
| 585 | 585 | if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
| 586 | 586 | elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
@@ -591,119 +591,119 @@ discard block |
||
| 591 | 591 | //if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 592 | 592 | //if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 593 | 593 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 594 | - $this->all_flights[$id]['lastupdate'] = time(); |
|
| 595 | - if ($this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 596 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 597 | - //print_r($this->all_flights); |
|
| 598 | - //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 599 | - //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 600 | - if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 594 | + $this->all_flights[$id]['lastupdate'] = time(); |
|
| 595 | + if ($this->all_flights[$id]['addedSpotter'] == 0) { |
|
| 596 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 597 | + //print_r($this->all_flights); |
|
| 598 | + //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
|
| 599 | + //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
|
| 600 | + if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
|
| 601 | 601 | if ($globalDebug) echo "Check if aircraft is already in DB..."; |
| 602 | 602 | $timeelapsed = microtime(true); |
| 603 | 603 | $SpotterLive = new SpotterLive($this->db); |
| 604 | 604 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
| 605 | - $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
| 606 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 605 | + $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
|
| 606 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 607 | 607 | } elseif (isset($line['id'])) { |
| 608 | - $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
| 609 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 608 | + $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
|
| 609 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 610 | 610 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 611 | - $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
| 612 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 611 | + $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
|
| 612 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 613 | 613 | } else $recent_ident = ''; |
| 614 | 614 | $SpotterLive->db=null; |
| 615 | 615 | |
| 616 | 616 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 617 | 617 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 618 | - } else { |
|
| 618 | + } else { |
|
| 619 | 619 | $recent_ident = ''; |
| 620 | 620 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
| 621 | - } |
|
| 622 | - //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 623 | - if($recent_ident == "") |
|
| 624 | - { |
|
| 621 | + } |
|
| 622 | + //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
|
| 623 | + if($recent_ident == "") |
|
| 624 | + { |
|
| 625 | 625 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 626 | 626 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 627 | 627 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 628 | 628 | //adds the spotter data for the archive |
| 629 | 629 | $ignoreImport = false; |
| 630 | 630 | foreach($globalAirportIgnore as $airportIgnore) { |
| 631 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 631 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 632 | 632 | $ignoreImport = true; |
| 633 | - } |
|
| 633 | + } |
|
| 634 | 634 | } |
| 635 | 635 | if (count($globalAirportAccept) > 0) { |
| 636 | - $ignoreImport = true; |
|
| 637 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 636 | + $ignoreImport = true; |
|
| 637 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 638 | 638 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 639 | - $ignoreImport = false; |
|
| 639 | + $ignoreImport = false; |
|
| 640 | + } |
|
| 640 | 641 | } |
| 641 | - } |
|
| 642 | 642 | } |
| 643 | 643 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 644 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 644 | + foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 645 | 645 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
| 646 | - $ignoreImport = true; |
|
| 646 | + $ignoreImport = true; |
|
| 647 | + } |
|
| 647 | 648 | } |
| 648 | - } |
|
| 649 | 649 | } |
| 650 | 650 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 651 | - $ignoreImport = true; |
|
| 652 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 651 | + $ignoreImport = true; |
|
| 652 | + foreach($globalAirlineAccept as $airlineAccept) { |
|
| 653 | 653 | if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
| 654 | - $ignoreImport = false; |
|
| 654 | + $ignoreImport = false; |
|
| 655 | + } |
|
| 655 | 656 | } |
| 656 | - } |
|
| 657 | 657 | } |
| 658 | 658 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 659 | - $ignoreImport = true; |
|
| 660 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 659 | + $ignoreImport = true; |
|
| 660 | + foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 661 | 661 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 662 | - $ignoreImport = false; |
|
| 662 | + $ignoreImport = false; |
|
| 663 | + } |
|
| 663 | 664 | } |
| 664 | - } |
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | if (!$ignoreImport) { |
| 668 | - $highlight = ''; |
|
| 669 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 670 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 671 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 672 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 673 | - $timeelapsed = microtime(true); |
|
| 674 | - $Spotter = new Spotter($this->db); |
|
| 675 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
| 676 | - $Spotter->db = null; |
|
| 677 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 668 | + $highlight = ''; |
|
| 669 | + if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 670 | + if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 671 | + if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 672 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 673 | + $timeelapsed = microtime(true); |
|
| 674 | + $Spotter = new Spotter($this->db); |
|
| 675 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
| 676 | + $Spotter->db = null; |
|
| 677 | + if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 678 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 679 | 679 | |
| 680 | - // Add source stat in DB |
|
| 681 | - $Stats = new Stats($this->db); |
|
| 682 | - if (!empty($this->stats)) { |
|
| 680 | + // Add source stat in DB |
|
| 681 | + $Stats = new Stats($this->db); |
|
| 682 | + if (!empty($this->stats)) { |
|
| 683 | 683 | if ($globalDebug) echo 'Add source stats : '; |
| 684 | - foreach($this->stats as $date => $data) { |
|
| 685 | - foreach($data as $source => $sourced) { |
|
| 686 | - //print_r($sourced); |
|
| 687 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 688 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 689 | - if (isset($sourced['msg'])) { |
|
| 690 | - if (time() - $sourced['msg']['date'] > 10) { |
|
| 691 | - $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 692 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 693 | - unset($this->stats[$date][$source]['msg']); |
|
| 694 | - } |
|
| 695 | - } |
|
| 696 | - } |
|
| 697 | - if ($date != date('Y-m-d')) { |
|
| 698 | - unset($this->stats[$date]); |
|
| 699 | - } |
|
| 700 | - } |
|
| 701 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 702 | - |
|
| 703 | - } |
|
| 704 | - $Stats->db = null; |
|
| 684 | + foreach($this->stats as $date => $data) { |
|
| 685 | + foreach($data as $source => $sourced) { |
|
| 686 | + //print_r($sourced); |
|
| 687 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 688 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 689 | + if (isset($sourced['msg'])) { |
|
| 690 | + if (time() - $sourced['msg']['date'] > 10) { |
|
| 691 | + $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
|
| 692 | + echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 693 | + unset($this->stats[$date][$source]['msg']); |
|
| 694 | + } |
|
| 695 | + } |
|
| 696 | + } |
|
| 697 | + if ($date != date('Y-m-d')) { |
|
| 698 | + unset($this->stats[$date]); |
|
| 699 | + } |
|
| 700 | + } |
|
| 701 | + if ($globalDebug) echo 'Done'."\n"; |
|
| 702 | + |
|
| 703 | + } |
|
| 704 | + $Stats->db = null; |
|
| 705 | 705 | |
| 706 | - $this->del(); |
|
| 706 | + $this->del(); |
|
| 707 | 707 | } elseif ($globalDebug) echo 'Ignore data'."\n"; |
| 708 | 708 | //$ignoreImport = false; |
| 709 | 709 | $this->all_flights[$id]['addedSpotter'] = 1; |
@@ -721,18 +721,18 @@ discard block |
||
| 721 | 721 | */ |
| 722 | 722 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 723 | 723 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 724 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 725 | - //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 726 | - $SpotterLive = new SpotterLive($this->db); |
|
| 727 | - $SpotterLive->deleteLiveSpotterData(); |
|
| 728 | - $SpotterLive->db=null; |
|
| 729 | - if ($globalDebug) echo " Done\n"; |
|
| 730 | - $this->last_delete = time(); |
|
| 724 | + if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 725 | + //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 726 | + $SpotterLive = new SpotterLive($this->db); |
|
| 727 | + $SpotterLive->deleteLiveSpotterData(); |
|
| 728 | + $SpotterLive->db=null; |
|
| 729 | + if ($globalDebug) echo " Done\n"; |
|
| 730 | + $this->last_delete = time(); |
|
| 731 | 731 | } |
| 732 | - } else { |
|
| 732 | + } else { |
|
| 733 | 733 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
| 734 | - $this->all_flights[$id]['id'] = $recent_ident; |
|
| 735 | - $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 734 | + $this->all_flights[$id]['id'] = $recent_ident; |
|
| 735 | + $this->all_flights[$id]['addedSpotter'] = 1; |
|
| 736 | 736 | } |
| 737 | 737 | if (isset($globalDaemon) && !$globalDaemon) { |
| 738 | 738 | $Spotter = new Spotter($this->db); |
@@ -740,14 +740,14 @@ discard block |
||
| 740 | 740 | $Spotter->db = null; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | - } |
|
| 743 | + } |
|
| 744 | 744 | } |
| 745 | - } |
|
| 746 | - //adds the spotter LIVE data |
|
| 747 | - //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 748 | - //echo "\nAdd in Live !! \n"; |
|
| 749 | - //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 750 | - if ($globalDebug) { |
|
| 745 | + } |
|
| 746 | + //adds the spotter LIVE data |
|
| 747 | + //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed); |
|
| 748 | + //echo "\nAdd in Live !! \n"; |
|
| 749 | + //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
|
| 750 | + if ($globalDebug) { |
|
| 751 | 751 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 752 | 752 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
| 753 | 753 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
@@ -755,49 +755,49 @@ discard block |
||
| 755 | 755 | if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
| 756 | 756 | else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
| 757 | 757 | } |
| 758 | - } |
|
| 759 | - $ignoreImport = false; |
|
| 760 | - if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 761 | - if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 758 | + } |
|
| 759 | + $ignoreImport = false; |
|
| 760 | + if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
|
| 761 | + if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
|
| 762 | 762 | |
| 763 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 764 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 765 | - $ignoreImport = true; |
|
| 763 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 764 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 765 | + $ignoreImport = true; |
|
| 766 | + } |
|
| 766 | 767 | } |
| 767 | - } |
|
| 768 | - if (count($globalAirportAccept) > 0) { |
|
| 769 | - $ignoreImport = true; |
|
| 770 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 771 | - if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 768 | + if (count($globalAirportAccept) > 0) { |
|
| 769 | + $ignoreImport = true; |
|
| 770 | + foreach($globalAirportIgnore as $airportIgnore) { |
|
| 771 | + if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
|
| 772 | 772 | $ignoreImport = false; |
| 773 | - } |
|
| 773 | + } |
|
| 774 | 774 | } |
| 775 | - } |
|
| 776 | - if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 775 | + } |
|
| 776 | + if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
|
| 777 | 777 | foreach($globalAirlineIgnore as $airlineIgnore) { |
| 778 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 778 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 779 | 779 | $ignoreImport = true; |
| 780 | - } |
|
| 780 | + } |
|
| 781 | 781 | } |
| 782 | - } |
|
| 783 | - if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 782 | + } |
|
| 783 | + if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
|
| 784 | 784 | $ignoreImport = true; |
| 785 | 785 | foreach($globalAirlineAccept as $airlineAccept) { |
| 786 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 786 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 787 | 787 | $ignoreImport = false; |
| 788 | - } |
|
| 788 | + } |
|
| 789 | 789 | } |
| 790 | - } |
|
| 791 | - if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 790 | + } |
|
| 791 | + if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
|
| 792 | 792 | $ignoreImport = true; |
| 793 | 793 | foreach($globalPilotIdAccept as $pilotIdAccept) { |
| 794 | - if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 795 | - $ignoreImport = false; |
|
| 796 | - } |
|
| 794 | + if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
|
| 795 | + $ignoreImport = false; |
|
| 796 | + } |
|
| 797 | + } |
|
| 797 | 798 | } |
| 798 | - } |
|
| 799 | 799 | |
| 800 | - if (!$ignoreImport) { |
|
| 800 | + if (!$ignoreImport) { |
|
| 801 | 801 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 802 | 802 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 803 | 803 | $timeelapsed = microtime(true); |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | if ($stats_heading == 16) $stats_heading = 0; |
| 837 | 837 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 838 | 838 | for ($i=0;$i<=15;$i++) { |
| 839 | - $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 839 | + $this->stats[$current_date][$source]['polar'][$i] = 0; |
|
| 840 | 840 | } |
| 841 | 841 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
| 842 | 842 | } else { |
@@ -849,11 +849,11 @@ discard block |
||
| 849 | 849 | //var_dump($this->stats); |
| 850 | 850 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 851 | 851 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 852 | - end($this->stats[$current_date][$source]['hist']); |
|
| 853 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 852 | + end($this->stats[$current_date][$source]['hist']); |
|
| 853 | + $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 854 | 854 | } else $mini = 0; |
| 855 | 855 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 856 | - $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 856 | + $this->stats[$current_date][$source]['hist'][$i] = 0; |
|
| 857 | 857 | } |
| 858 | 858 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
| 859 | 859 | } else { |
@@ -870,22 +870,22 @@ discard block |
||
| 870 | 870 | |
| 871 | 871 | |
| 872 | 872 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 873 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 874 | - $SpotterLive = new SpotterLive($this->db); |
|
| 875 | - $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 876 | - $SpotterLive->db = null; |
|
| 877 | - //SpotterLive->deleteLiveSpotterData(); |
|
| 878 | - if ($globalDebug) echo " Done\n"; |
|
| 879 | - $this->last_delete_hourly = time(); |
|
| 873 | + if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 874 | + $SpotterLive = new SpotterLive($this->db); |
|
| 875 | + $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
|
| 876 | + $SpotterLive->db = null; |
|
| 877 | + //SpotterLive->deleteLiveSpotterData(); |
|
| 878 | + if ($globalDebug) echo " Done\n"; |
|
| 879 | + $this->last_delete_hourly = time(); |
|
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - } |
|
| 883 | - //$ignoreImport = false; |
|
| 882 | + } |
|
| 883 | + //$ignoreImport = false; |
|
| 884 | 884 | } |
| 885 | 885 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 886 | 886 | if ($send) return $this->all_flights[$id]; |
| 887 | - } |
|
| 887 | + } |
|
| 888 | + } |
|
| 888 | 889 | } |
| 889 | - } |
|
| 890 | 890 | } |
| 891 | 891 | ?> |
@@ -29,18 +29,18 @@ discard block |
||
| 29 | 29 | $currentdate = date('Y-m-d'); |
| 30 | 30 | $sourcestat = $Stats->getStatsSource($currentdate); |
| 31 | 31 | if (!empty($sourcestat)) { |
| 32 | - foreach($sourcestat as $srcst) { |
|
| 32 | + foreach ($sourcestat as $srcst) { |
|
| 33 | 33 | $type = $srcst['stats_type']; |
| 34 | 34 | if ($type == 'polar' || $type == 'hist') { |
| 35 | 35 | $source = $srcst['source_name']; |
| 36 | 36 | $data = $srcst['source_data']; |
| 37 | - $this->stats[$currentdate][$source][$type] = json_decode($data,true); |
|
| 37 | + $this->stats[$currentdate][$source][$type] = json_decode($data, true); |
|
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function get_Schedule($id,$ident) { |
|
| 43 | + public function get_Schedule($id, $ident) { |
|
| 44 | 44 | global $globalDebug, $globalFork, $globalSchedulesFetch; |
| 45 | 45 | // Get schedule here, so it's done only one time |
| 46 | 46 | |
@@ -65,8 +65,8 @@ discard block |
||
| 65 | 65 | $schedule = $Schedule->fetchSchedule($operator); |
| 66 | 66 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 67 | 67 | if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
| 68 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 69 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 68 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime'])); |
|
| 69 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime'])); |
|
| 70 | 70 | // Should also check if route schedule = route from DB |
| 71 | 71 | if ($schedule['DepartureAirportIATA'] != '') { |
| 72 | 72 | if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) { |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | } |
| 89 | - $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
|
| 89 | + $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']); |
|
| 90 | 90 | } |
| 91 | 91 | } else $scheduleexist = true; |
| 92 | 92 | } else $scheduleexist = true; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | if ($scheduleexist) { |
| 95 | 95 | if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
| 96 | 96 | $sch = $Schedule->getSchedule($operator); |
| 97 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 97 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time'])); |
|
| 98 | 98 | } |
| 99 | 99 | $Spotter->db = null; |
| 100 | 100 | $Schedule->db = null; |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
| 121 | 121 | $Spotter = new Spotter($this->db); |
| 122 | 122 | $real_arrival = $this->arrival($key); |
| 123 | - $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 123 | + $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 124 | 124 | } |
| 125 | 125 | } |
| 126 | 126 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $airport_time = ''; |
| 134 | 134 | if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
| 135 | 135 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 136 | - $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
|
| 136 | + $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist); |
|
| 137 | 137 | if (isset($closestAirports[0])) { |
| 138 | 138 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 139 | 139 | $airport_icao = $closestAirports[0]['icao']; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | break; |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | - } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) { |
|
| 151 | + } elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) { |
|
| 152 | 152 | $airport_icao = $closestAirports[0]['icao']; |
| 153 | 153 | $airport_time = $this->all_flights[$key]['datetime']; |
| 154 | 154 | } else { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | } else { |
| 162 | 162 | if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
| 163 | 163 | } |
| 164 | - return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
|
| 164 | + return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
| 173 | 173 | foreach ($this->all_flights as $key => $flight) { |
| 174 | 174 | if (isset($flight['lastupdate'])) { |
| 175 | - if ($flight['lastupdate'] < (time()-3000)) { |
|
| 175 | + if ($flight['lastupdate'] < (time() - 3000)) { |
|
| 176 | 176 | if (isset($this->all_flights[$key]['id'])) { |
| 177 | 177 | if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
| 178 | 178 | /* |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $real_arrival = $this->arrival($key); |
| 184 | 184 | $Spotter = new Spotter($this->db); |
| 185 | 185 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 186 | - $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
|
| 186 | + $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']); |
|
| 187 | 187 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 188 | 188 | } |
| 189 | 189 | // Put in archive |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | $send = false; |
| 220 | 220 | |
| 221 | 221 | // SBS format is CSV format |
| 222 | - if(is_array($line) && isset($line['hex'])) { |
|
| 222 | + if (is_array($line) && isset($line['hex'])) { |
|
| 223 | 223 | //print_r($line); |
| 224 | 224 | if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) { |
| 225 | 225 | |
@@ -252,22 +252,22 @@ discard block |
||
| 252 | 252 | |
| 253 | 253 | if (!isset($this->all_flights[$id])) { |
| 254 | 254 | $this->all_flights[$id] = array(); |
| 255 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 256 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
|
| 257 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
|
| 255 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 256 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true)); |
|
| 257 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time())); |
|
| 258 | 258 | if (!isset($line['id'])) { |
| 259 | 259 | if (!isset($globalDaemon)) $globalDaemon = TRUE; |
| 260 | 260 | // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
| 261 | 261 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 262 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 262 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi'))); |
|
| 263 | 263 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 264 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 264 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 265 | 265 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | //print_r($this->all_flights); |
| 269 | 269 | if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) { |
| 270 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex']))); |
|
| 270 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex']))); |
|
| 271 | 271 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 272 | 272 | //$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 273 | 273 | //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
@@ -276,36 +276,36 @@ discard block |
||
| 276 | 276 | $Spotter = new Spotter($this->db); |
| 277 | 277 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 278 | 278 | $Spotter->db = null; |
| 279 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 280 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 279 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 280 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 281 | 281 | } |
| 282 | 282 | if ($globalAllFlights !== FALSE) $dataFound = true; |
| 283 | 283 | if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
| 284 | 284 | } |
| 285 | 285 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 286 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
|
| 286 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $line['aircraft_icao'])); |
|
| 287 | 287 | } |
| 288 | 288 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) { |
| 289 | 289 | // Get aircraft ICAO from aircraft name |
| 290 | 290 | $Spotter = new Spotter($this->db); |
| 291 | 291 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 292 | 292 | $Spotter->db = null; |
| 293 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 293 | + if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 294 | 294 | } |
| 295 | 295 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
| 296 | 296 | if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
| 297 | 297 | elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
| 298 | 298 | elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
| 299 | 299 | elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
| 300 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 300 | + if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao)); |
|
| 301 | 301 | } |
| 302 | 302 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 303 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
|
| 303 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA')); |
|
| 304 | 304 | } |
| 305 | 305 | //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) { |
| 306 | - if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) { |
|
| 306 | + if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60) { |
|
| 307 | 307 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 308 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
|
| 308 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime'])); |
|
| 309 | 309 | } else { |
| 310 | 310 | if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
| 311 | 311 | elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
@@ -318,24 +318,24 @@ discard block |
||
| 318 | 318 | } |
| 319 | 319 | } else { |
| 320 | 320 | date_default_timezone_set('UTC'); |
| 321 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s'))); |
|
| 321 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s'))); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') { |
| 325 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration'])); |
|
| 325 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration'])); |
|
| 326 | 326 | } |
| 327 | 327 | if (isset($line['waypoints']) && $line['waypoints'] != '') { |
| 328 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints'])); |
|
| 328 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints'])); |
|
| 329 | 329 | } |
| 330 | 330 | if (isset($line['pilot_id']) && $line['pilot_id'] != '') { |
| 331 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id'])); |
|
| 331 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => $line['pilot_id'])); |
|
| 332 | 332 | } |
| 333 | 333 | if (isset($line['pilot_name']) && $line['pilot_name'] != '') { |
| 334 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name'])); |
|
| 334 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => $line['pilot_name'])); |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | 337 | if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) { |
| 338 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident']))); |
|
| 338 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident']))); |
|
| 339 | 339 | if ($this->all_flights[$id]['addedSpotter'] == 1) { |
| 340 | 340 | $timeelapsed = microtime(true); |
| 341 | 341 | $Spotter = new Spotter($this->db); |
@@ -345,10 +345,10 @@ discard block |
||
| 345 | 345 | elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 346 | 346 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 347 | 347 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 348 | - $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
|
| 348 | + $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource); |
|
| 349 | 349 | if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
| 350 | 350 | $Spotter->db = null; |
| 351 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 351 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 352 | 352 | } |
| 353 | 353 | |
| 354 | 354 | /* |
@@ -359,24 +359,24 @@ discard block |
||
| 359 | 359 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 360 | 360 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 361 | 361 | */ |
| 362 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 362 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 363 | 363 | |
| 364 | 364 | //$putinarchive = true; |
| 365 | 365 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
| 366 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 366 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time'])); |
|
| 367 | 367 | } |
| 368 | 368 | if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) { |
| 369 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 369 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time'])); |
|
| 370 | 370 | } |
| 371 | 371 | if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) { |
| 372 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 372 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 373 | 373 | } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) { |
| 374 | 374 | $timeelapsed = microtime(true); |
| 375 | 375 | $Spotter = new Spotter($this->db); |
| 376 | 376 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 377 | 377 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 378 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
|
| 379 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 378 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => '')); |
|
| 379 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 380 | 380 | |
| 381 | 381 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 382 | 382 | $timeelapsed = microtime(true); |
@@ -389,34 +389,34 @@ discard block |
||
| 389 | 389 | $Translation->db = null; |
| 390 | 390 | } |
| 391 | 391 | $Spotter->db = null; |
| 392 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 392 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 393 | 393 | |
| 394 | 394 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 395 | 395 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
| 396 | 396 | if ($route['fromairport_icao'] != $route['toairport_icao']) { |
| 397 | 397 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop'])); |
| 398 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
|
| 398 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop'])); |
|
| 399 | 399 | } |
| 400 | 400 | } |
| 401 | 401 | if (!isset($globalFork)) $globalFork = TRUE; |
| 402 | 402 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 403 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 403 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident'])); |
|
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | if (isset($line['speed']) && $line['speed'] != '') { |
| 409 | 409 | // $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12])); |
| 410 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed']))); |
|
| 411 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true)); |
|
| 410 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed']))); |
|
| 411 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true)); |
|
| 412 | 412 | //$dataFound = true; |
| 413 | 413 | } else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) { |
| 414 | - $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'); |
|
| 414 | + $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'); |
|
| 415 | 415 | if ($distance > 1000 && $distance < 10000) { |
| 416 | 416 | // use datetime |
| 417 | 417 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 418 | 418 | $speed = $speed*3.6; |
| 419 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 419 | + if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed))); |
|
| 420 | 420 | if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
| 421 | 421 | } |
| 422 | 422 | } |
@@ -424,11 +424,11 @@ discard block |
||
| 424 | 424 | |
| 425 | 425 | |
| 426 | 426 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 427 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 427 | + if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']); |
|
| 428 | 428 | else unset($timediff); |
| 429 | - if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
|
| 429 | + if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')))) { |
|
| 430 | 430 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
| 431 | - if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
|
| 431 | + if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) { |
|
| 432 | 432 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 433 | 433 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 434 | 434 | $this->all_flights[$id]['putinarchive'] = true; |
@@ -436,10 +436,10 @@ discard block |
||
| 436 | 436 | if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
| 437 | 437 | $timeelapsed = microtime(true); |
| 438 | 438 | $Spotter = new Spotter($this->db); |
| 439 | - $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
|
| 439 | + $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']); |
|
| 440 | 440 | if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
| 441 | 441 | $Spotter->db = null; |
| 442 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 442 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 443 | 443 | $this->tmd = 0; |
| 444 | 444 | if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
| 445 | 445 | } |
@@ -448,13 +448,13 @@ discard block |
||
| 448 | 448 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 449 | 449 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 450 | 450 | if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
| 451 | - if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
| 451 | + if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
| 452 | 452 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 453 | 453 | $dataFound = true; |
| 454 | 454 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 455 | 455 | } |
| 456 | 456 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 457 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude'])); |
|
| 457 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude'])); |
|
| 458 | 458 | /* |
| 459 | 459 | if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) { |
| 460 | 460 | $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
@@ -472,13 +472,13 @@ discard block |
||
| 472 | 472 | if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
| 473 | 473 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 474 | 474 | if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 475 | - if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
| 475 | + if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
|
| 476 | 476 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 477 | 477 | $dataFound = true; |
| 478 | 478 | $this->all_flights[$id]['time_last_coord'] = time(); |
| 479 | 479 | } |
| 480 | 480 | // elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n"; |
| 481 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude'])); |
|
| 481 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude'])); |
|
| 482 | 482 | /* |
| 483 | 483 | if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) { |
| 484 | 484 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
@@ -496,46 +496,46 @@ discard block |
||
| 496 | 496 | } else if ($globalDebug && $timediff > 20) { |
| 497 | 497 | $this->tmd = $this->tmd + 1; |
| 498 | 498 | echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n"; |
| 499 | - echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -"; |
|
| 500 | - echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - "; |
|
| 499 | + echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -"; |
|
| 500 | + echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - "; |
|
| 501 | 501 | echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n"; |
| 502 | 502 | } |
| 503 | 503 | } |
| 504 | 504 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 505 | 505 | if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
| 506 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
|
| 506 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update'])); |
|
| 507 | 507 | } |
| 508 | 508 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
| 509 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate'])); |
|
| 509 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate'])); |
|
| 510 | 510 | //$dataFound = true; |
| 511 | 511 | } |
| 512 | 512 | if (isset($line['format_source']) && $line['format_source'] != '') { |
| 513 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source'])); |
|
| 513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source'])); |
|
| 514 | 514 | } |
| 515 | 515 | if (isset($line['source_name']) && $line['source_name'] != '') { |
| 516 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name'])); |
|
| 516 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name'])); |
|
| 517 | 517 | } |
| 518 | 518 | if (isset($line['emergency']) && $line['emergency'] != '') { |
| 519 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency'])); |
|
| 519 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency'])); |
|
| 520 | 520 | //$dataFound = true; |
| 521 | 521 | } |
| 522 | 522 | if (isset($line['ground']) && $line['ground'] != '') { |
| 523 | 523 | if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) { |
| 524 | 524 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 525 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
|
| 526 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
|
| 527 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
| 528 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 529 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 525 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0)); |
|
| 526 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1)); |
|
| 527 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
| 528 | + elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id'])); |
|
| 529 | + elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 530 | 530 | } |
| 531 | 531 | if ($line['ground'] != 1) $line['ground'] = 0; |
| 532 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
|
| 532 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground'])); |
|
| 533 | 533 | //$dataFound = true; |
| 534 | 534 | } |
| 535 | 535 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 536 | 536 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 537 | 537 | if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
| 538 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 538 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 539 | 539 | $highlight = ''; |
| 540 | 540 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
| 541 | 541 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
@@ -543,47 +543,47 @@ discard block |
||
| 543 | 543 | if ($highlight != '') { |
| 544 | 544 | $timeelapsed = microtime(true); |
| 545 | 545 | $Spotter = new Spotter($this->db); |
| 546 | - $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
|
| 546 | + $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight); |
|
| 547 | 547 | $Spotter->db = null; |
| 548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 548 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 549 | 549 | |
| 550 | 550 | //$putinarchive = true; |
| 551 | 551 | //$highlight = ''; |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 554 | + } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk'])); |
|
| 555 | 555 | //$dataFound = true; |
| 556 | 556 | } |
| 557 | 557 | |
| 558 | 558 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 559 | 559 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 560 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 561 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
|
| 562 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
|
| 560 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 561 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100))); |
|
| 562 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude'])); |
|
| 563 | 563 | //$dataFound = true; |
| 564 | 564 | //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n"; |
| 565 | 565 | } |
| 566 | 566 | |
| 567 | 567 | if (isset($line['noarchive']) && $line['noarchive'] === true) { |
| 568 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true)); |
|
| 568 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true)); |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | if (isset($line['heading']) && $line['heading'] != '') { |
| 572 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 573 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
|
| 574 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
|
| 572 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 573 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading']))); |
|
| 574 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true)); |
|
| 575 | 575 | //$dataFound = true; |
| 576 | 576 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 577 | - $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 578 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
|
| 579 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 577 | + $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 578 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading))); |
|
| 579 | + if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 580 | 580 | if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
| 581 | 581 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 582 | 582 | // If not enough messages and ACARS set heading to 0 |
| 583 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
|
| 583 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0)); |
|
| 584 | 584 | } |
| 585 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 586 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 585 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 586 | + elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 587 | 587 | |
| 588 | 588 | // print_r($this->all_flights[$id]); |
| 589 | 589 | //gets the callsign from the last hour |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | if ($dataFound === true && isset($this->all_flights[$id]['hex'])) { |
| 594 | 594 | $this->all_flights[$id]['lastupdate'] = time(); |
| 595 | 595 | if ($this->all_flights[$id]['addedSpotter'] == 0) { |
| 596 | - if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 596 | + if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 597 | 597 | //print_r($this->all_flights); |
| 598 | 598 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 599 | 599 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
@@ -603,61 +603,61 @@ discard block |
||
| 603 | 603 | $SpotterLive = new SpotterLive($this->db); |
| 604 | 604 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
| 605 | 605 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 606 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 606 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 607 | 607 | } elseif (isset($line['id'])) { |
| 608 | 608 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 609 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 609 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 610 | 610 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 611 | 611 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 612 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 612 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 613 | 613 | } else $recent_ident = ''; |
| 614 | - $SpotterLive->db=null; |
|
| 614 | + $SpotterLive->db = null; |
|
| 615 | 615 | |
| 616 | 616 | if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
| 617 | 617 | elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
| 618 | 618 | } else { |
| 619 | 619 | $recent_ident = ''; |
| 620 | - $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
|
| 620 | + $this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0)); |
|
| 621 | 621 | } |
| 622 | 622 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 623 | - if($recent_ident == "") |
|
| 623 | + if ($recent_ident == "") |
|
| 624 | 624 | { |
| 625 | 625 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
| 626 | 626 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 627 | 627 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 628 | 628 | //adds the spotter data for the archive |
| 629 | 629 | $ignoreImport = false; |
| 630 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 630 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 631 | 631 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 632 | 632 | $ignoreImport = true; |
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | 635 | if (count($globalAirportAccept) > 0) { |
| 636 | 636 | $ignoreImport = true; |
| 637 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 637 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 638 | 638 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 639 | 639 | $ignoreImport = false; |
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | 642 | } |
| 643 | 643 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 644 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 645 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 644 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 645 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 646 | 646 | $ignoreImport = true; |
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | } |
| 650 | 650 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 651 | 651 | $ignoreImport = true; |
| 652 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 653 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 652 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 653 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 654 | 654 | $ignoreImport = false; |
| 655 | 655 | } |
| 656 | 656 | } |
| 657 | 657 | } |
| 658 | 658 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 659 | 659 | $ignoreImport = true; |
| 660 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 660 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 661 | 661 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 662 | 662 | $ignoreImport = false; |
| 663 | 663 | } |
@@ -669,27 +669,27 @@ discard block |
||
| 669 | 669 | if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
| 670 | 670 | if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
| 671 | 671 | if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
| 672 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 672 | + if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 673 | 673 | $timeelapsed = microtime(true); |
| 674 | 674 | $Spotter = new Spotter($this->db); |
| 675 | - $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
|
| 675 | + $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name']); |
|
| 676 | 676 | $Spotter->db = null; |
| 677 | 677 | if ($globalDebug && isset($result)) echo $result."\n"; |
| 678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 678 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 679 | 679 | |
| 680 | 680 | // Add source stat in DB |
| 681 | 681 | $Stats = new Stats($this->db); |
| 682 | 682 | if (!empty($this->stats)) { |
| 683 | 683 | if ($globalDebug) echo 'Add source stats : '; |
| 684 | - foreach($this->stats as $date => $data) { |
|
| 685 | - foreach($data as $source => $sourced) { |
|
| 684 | + foreach ($this->stats as $date => $data) { |
|
| 685 | + foreach ($data as $source => $sourced) { |
|
| 686 | 686 | //print_r($sourced); |
| 687 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 688 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 687 | + if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date); |
|
| 688 | + if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date); |
|
| 689 | 689 | if (isset($sourced['msg'])) { |
| 690 | 690 | if (time() - $sourced['msg']['date'] > 10) { |
| 691 | 691 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
| 692 | - echo $Stats->addStatSource($nbmsg,$source,'msg',$date); |
|
| 692 | + echo $Stats->addStatSource($nbmsg, $source, 'msg', $date); |
|
| 693 | 693 | unset($this->stats[$date][$source]['msg']); |
| 694 | 694 | } |
| 695 | 695 | } |
@@ -725,18 +725,18 @@ discard block |
||
| 725 | 725 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 726 | 726 | $SpotterLive = new SpotterLive($this->db); |
| 727 | 727 | $SpotterLive->deleteLiveSpotterData(); |
| 728 | - $SpotterLive->db=null; |
|
| 728 | + $SpotterLive->db = null; |
|
| 729 | 729 | if ($globalDebug) echo " Done\n"; |
| 730 | 730 | $this->last_delete = time(); |
| 731 | 731 | } |
| 732 | 732 | } else { |
| 733 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
|
| 733 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson')) { |
|
| 734 | 734 | $this->all_flights[$id]['id'] = $recent_ident; |
| 735 | 735 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 736 | 736 | } |
| 737 | 737 | if (isset($globalDaemon) && !$globalDaemon) { |
| 738 | 738 | $Spotter = new Spotter($this->db); |
| 739 | - $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']); |
|
| 739 | + $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']); |
|
| 740 | 740 | $Spotter->db = null; |
| 741 | 741 | } |
| 742 | 742 | |
@@ -760,37 +760,37 @@ discard block |
||
| 760 | 760 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 761 | 761 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 762 | 762 | |
| 763 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 763 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 764 | 764 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 765 | 765 | $ignoreImport = true; |
| 766 | 766 | } |
| 767 | 767 | } |
| 768 | 768 | if (count($globalAirportAccept) > 0) { |
| 769 | 769 | $ignoreImport = true; |
| 770 | - foreach($globalAirportIgnore as $airportIgnore) { |
|
| 770 | + foreach ($globalAirportIgnore as $airportIgnore) { |
|
| 771 | 771 | if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) { |
| 772 | 772 | $ignoreImport = false; |
| 773 | 773 | } |
| 774 | 774 | } |
| 775 | 775 | } |
| 776 | 776 | if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) { |
| 777 | - foreach($globalAirlineIgnore as $airlineIgnore) { |
|
| 778 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) { |
|
| 777 | + foreach ($globalAirlineIgnore as $airlineIgnore) { |
|
| 778 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) { |
|
| 779 | 779 | $ignoreImport = true; |
| 780 | 780 | } |
| 781 | 781 | } |
| 782 | 782 | } |
| 783 | 783 | if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) { |
| 784 | 784 | $ignoreImport = true; |
| 785 | - foreach($globalAirlineAccept as $airlineAccept) { |
|
| 786 | - if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) { |
|
| 785 | + foreach ($globalAirlineAccept as $airlineAccept) { |
|
| 786 | + if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) { |
|
| 787 | 787 | $ignoreImport = false; |
| 788 | 788 | } |
| 789 | 789 | } |
| 790 | 790 | } |
| 791 | 791 | if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) { |
| 792 | 792 | $ignoreImport = true; |
| 793 | - foreach($globalPilotIdAccept as $pilotIdAccept) { |
|
| 793 | + foreach ($globalPilotIdAccept as $pilotIdAccept) { |
|
| 794 | 794 | if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) { |
| 795 | 795 | $ignoreImport = false; |
| 796 | 796 | } |
@@ -798,14 +798,14 @@ discard block |
||
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | if (!$ignoreImport) { |
| 801 | - if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 801 | + if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
|
| 802 | 802 | if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
| 803 | 803 | $timeelapsed = microtime(true); |
| 804 | 804 | $SpotterLive = new SpotterLive($this->db); |
| 805 | - $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
|
| 805 | + $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']); |
|
| 806 | 806 | $SpotterLive->db = null; |
| 807 | 807 | $this->all_flights[$id]['putinarchive'] = false; |
| 808 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 808 | + if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 809 | 809 | |
| 810 | 810 | // Put statistics in $this->stats variable |
| 811 | 811 | //if ($line['format_source'] != 'aprs') { |
@@ -823,19 +823,19 @@ discard block |
||
| 823 | 823 | $latitude = $globalCenterLatitude; |
| 824 | 824 | $longitude = $globalCenterLongitude; |
| 825 | 825 | } |
| 826 | - $this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude); |
|
| 826 | + $this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude); |
|
| 827 | 827 | } else { |
| 828 | 828 | $latitude = $this->source_location[$source]['latitude']; |
| 829 | 829 | $longitude = $this->source_location[$source]['longitude']; |
| 830 | 830 | } |
| 831 | - $stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 831 | + $stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 832 | 832 | //$stats_heading = $stats_heading%22.5; |
| 833 | 833 | $stats_heading = round($stats_heading/22.5); |
| 834 | - $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
|
| 834 | + $stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']); |
|
| 835 | 835 | $current_date = date('Y-m-d'); |
| 836 | 836 | if ($stats_heading == 16) $stats_heading = 0; |
| 837 | 837 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 838 | - for ($i=0;$i<=15;$i++) { |
|
| 838 | + for ($i = 0; $i <= 15; $i++) { |
|
| 839 | 839 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
| 840 | 840 | } |
| 841 | 841 | $this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance; |
@@ -850,9 +850,9 @@ discard block |
||
| 850 | 850 | if (!isset($this->stats[$current_date][$source]['hist'][$distance])) { |
| 851 | 851 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 852 | 852 | end($this->stats[$current_date][$source]['hist']); |
| 853 | - $mini = key($this->stats[$current_date][$source]['hist'])+10; |
|
| 853 | + $mini = key($this->stats[$current_date][$source]['hist']) + 10; |
|
| 854 | 854 | } else $mini = 0; |
| 855 | - for ($i=$mini;$i<=$distance;$i+=10) { |
|
| 855 | + for ($i = $mini; $i <= $distance; $i += 10) { |
|
| 856 | 856 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 857 | 857 | } |
| 858 | 858 | $this->stats[$current_date][$source]['hist'][$distance] = 1; |
@@ -865,7 +865,7 @@ discard block |
||
| 865 | 865 | if ($this->all_flights[$id]['putinarchive']) $send = true; |
| 866 | 866 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 867 | 867 | if ($globalDebug) echo $result."\n"; |
| 868 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 868 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n"; |
|
| 869 | 869 | //$this->del(); |
| 870 | 870 | |
| 871 | 871 | |
@@ -53,7 +53,9 @@ discard block |
||
| 53 | 53 | $dbc = $this->db; |
| 54 | 54 | $this->all_flights[$id]['schedule_check'] = true; |
| 55 | 55 | if ($globalSchedulesFetch) { |
| 56 | - if ($globalDebug) echo 'Getting schedule info...'."\n"; |
|
| 56 | + if ($globalDebug) { |
|
| 57 | + echo 'Getting schedule info...'."\n"; |
|
| 58 | + } |
|
| 57 | 59 | $Spotter = new Spotter($dbc); |
| 58 | 60 | $Schedule = new Schedule($dbc); |
| 59 | 61 | $Translation = new Translation($dbc); |
@@ -64,7 +66,9 @@ discard block |
||
| 64 | 66 | if ($Schedule->checkSchedule($operator) == 0) { |
| 65 | 67 | $schedule = $Schedule->fetchSchedule($operator); |
| 66 | 68 | if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) { |
| 67 | - if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 69 | + if ($globalDebug) { |
|
| 70 | + echo "-> Schedule info for ".$operator." (".$ident.")\n"; |
|
| 71 | + } |
|
| 68 | 72 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime'])); |
| 69 | 73 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime'])); |
| 70 | 74 | // Should also check if route schedule = route from DB |
@@ -73,7 +77,9 @@ discard block |
||
| 73 | 77 | $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']); |
| 74 | 78 | if (trim($airport_icao) != '') { |
| 75 | 79 | $this->all_flights[$id]['departure_airport'] = $airport_icao; |
| 76 | - if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 80 | + if ($globalDebug) { |
|
| 81 | + echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n"; |
|
| 82 | + } |
|
| 77 | 83 | } |
| 78 | 84 | } |
| 79 | 85 | } |
@@ -82,17 +88,25 @@ discard block |
||
| 82 | 88 | $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']); |
| 83 | 89 | if (trim($airport_icao) != '') { |
| 84 | 90 | $this->all_flights[$id]['arrival_airport'] = $airport_icao; |
| 85 | - if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 91 | + if ($globalDebug) { |
|
| 92 | + echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n"; |
|
| 93 | + } |
|
| 86 | 94 | } |
| 87 | 95 | } |
| 88 | 96 | } |
| 89 | 97 | $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']); |
| 90 | 98 | } |
| 91 | - } else $scheduleexist = true; |
|
| 92 | - } else $scheduleexist = true; |
|
| 99 | + } else { |
|
| 100 | + $scheduleexist = true; |
|
| 101 | + } |
|
| 102 | + } else { |
|
| 103 | + $scheduleexist = true; |
|
| 104 | + } |
|
| 93 | 105 | // close connection, at least one way will work ? |
| 94 | 106 | if ($scheduleexist) { |
| 95 | - if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 107 | + if ($globalDebug) { |
|
| 108 | + echo "-> get arrival/departure airport info for ".$ident."\n"; |
|
| 109 | + } |
|
| 96 | 110 | $sch = $Schedule->getSchedule($operator); |
| 97 | 111 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time'])); |
| 98 | 112 | } |
@@ -114,7 +128,9 @@ discard block |
||
| 114 | 128 | |
| 115 | 129 | public function checkAll() { |
| 116 | 130 | global $globalDebug; |
| 117 | - if ($globalDebug) echo "Update last seen flights data...\n"; |
|
| 131 | + if ($globalDebug) { |
|
| 132 | + echo "Update last seen flights data...\n"; |
|
| 133 | + } |
|
| 118 | 134 | foreach ($this->all_flights as $key => $flight) { |
| 119 | 135 | if (isset($this->all_flights[$key]['id'])) { |
| 120 | 136 | //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].' '.$this->all_flights[$key]['longitude']."\n"; |
@@ -127,24 +143,32 @@ discard block |
||
| 127 | 143 | |
| 128 | 144 | public function arrival($key) { |
| 129 | 145 | global $globalClosestMinDist, $globalDebug; |
| 130 | - if ($globalDebug) echo 'Update arrival...'."\n"; |
|
| 146 | + if ($globalDebug) { |
|
| 147 | + echo 'Update arrival...'."\n"; |
|
| 148 | + } |
|
| 131 | 149 | $Spotter = new Spotter($this->db); |
| 132 | 150 | $airport_icao = ''; |
| 133 | 151 | $airport_time = ''; |
| 134 | - if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50; |
|
| 152 | + if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') { |
|
| 153 | + $globalClosestMinDist = 50; |
|
| 154 | + } |
|
| 135 | 155 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 136 | 156 | $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist); |
| 137 | 157 | if (isset($closestAirports[0])) { |
| 138 | 158 | if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) { |
| 139 | 159 | $airport_icao = $closestAirports[0]['icao']; |
| 140 | 160 | $airport_time = $this->all_flights[$key]['datetime']; |
| 141 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 161 | + if ($globalDebug) { |
|
| 162 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 163 | + } |
|
| 142 | 164 | } elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') { |
| 143 | 165 | foreach ($closestAirports as $airport) { |
| 144 | 166 | if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) { |
| 145 | 167 | $airport_icao = $airport['icao']; |
| 146 | 168 | $airport_time = $this->all_flights[$key]['datetime']; |
| 147 | - if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 169 | + if ($globalDebug) { |
|
| 170 | + echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n"; |
|
| 171 | + } |
|
| 148 | 172 | break; |
| 149 | 173 | } |
| 150 | 174 | } |
@@ -152,14 +176,20 @@ discard block |
||
| 152 | 176 | $airport_icao = $closestAirports[0]['icao']; |
| 153 | 177 | $airport_time = $this->all_flights[$key]['datetime']; |
| 154 | 178 | } else { |
| 155 | - if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 179 | + if ($globalDebug) { |
|
| 180 | + echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n"; |
|
| 181 | + } |
|
| 156 | 182 | } |
| 157 | 183 | } else { |
| 158 | - if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 184 | + if ($globalDebug) { |
|
| 185 | + echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n"; |
|
| 186 | + } |
|
| 159 | 187 | } |
| 160 | 188 | |
| 161 | 189 | } else { |
| 162 | - if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 190 | + if ($globalDebug) { |
|
| 191 | + echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n"; |
|
| 192 | + } |
|
| 163 | 193 | } |
| 164 | 194 | return array('airport_icao' => $airport_icao,'airport_time' => $airport_time); |
| 165 | 195 | } |
@@ -169,12 +199,16 @@ discard block |
||
| 169 | 199 | public function del() { |
| 170 | 200 | global $globalDebug; |
| 171 | 201 | // Delete old infos |
| 172 | - if ($globalDebug) echo 'Delete old values and update latest data...'."\n"; |
|
| 202 | + if ($globalDebug) { |
|
| 203 | + echo 'Delete old values and update latest data...'."\n"; |
|
| 204 | + } |
|
| 173 | 205 | foreach ($this->all_flights as $key => $flight) { |
| 174 | 206 | if (isset($flight['lastupdate'])) { |
| 175 | 207 | if ($flight['lastupdate'] < (time()-3000)) { |
| 176 | 208 | if (isset($this->all_flights[$key]['id'])) { |
| 177 | - if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 209 | + if ($globalDebug) { |
|
| 210 | + echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n"; |
|
| 211 | + } |
|
| 178 | 212 | /* |
| 179 | 213 | $SpotterLive = new SpotterLive(); |
| 180 | 214 | $SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']); |
@@ -184,7 +218,9 @@ discard block |
||
| 184 | 218 | $Spotter = new Spotter($this->db); |
| 185 | 219 | if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') { |
| 186 | 220 | $result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']); |
| 187 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 221 | + if ($globalDebug && $result != 'success') { |
|
| 222 | + echo '!!! ERROR : '.$result."\n"; |
|
| 223 | + } |
|
| 188 | 224 | } |
| 189 | 225 | // Put in archive |
| 190 | 226 | // $Spotter->db = null; |
@@ -198,8 +234,10 @@ discard block |
||
| 198 | 234 | public function add($line) { |
| 199 | 235 | global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights; |
| 200 | 236 | //if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE; |
| 201 | - if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02'; |
|
| 202 | -/* |
|
| 237 | + if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') { |
|
| 238 | + $globalCoordMinChange = '0.02'; |
|
| 239 | + } |
|
| 240 | + /* |
|
| 203 | 241 | $Spotter = new Spotter(); |
| 204 | 242 | $dbc = $Spotter->db; |
| 205 | 243 | $SpotterLive = new SpotterLive($dbc); |
@@ -227,11 +265,15 @@ discard block |
||
| 227 | 265 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) { |
| 228 | 266 | $current_date = date('Y-m-d'); |
| 229 | 267 | $source = $line['source_name']; |
| 230 | - if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source']; |
|
| 268 | + if ($source == '' || $line['format_source'] == 'aprs') { |
|
| 269 | + $source = $line['format_source']; |
|
| 270 | + } |
|
| 231 | 271 | if (!isset($this->stats[$current_date][$source]['msg'])) { |
| 232 | 272 | $this->stats[$current_date][$source]['msg']['date'] = time(); |
| 233 | 273 | $this->stats[$current_date][$source]['msg']['nb'] = 1; |
| 234 | - } else $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 274 | + } else { |
|
| 275 | + $this->stats[$current_date][$source]['msg']['nb'] += 1; |
|
| 276 | + } |
|
| 235 | 277 | } |
| 236 | 278 | |
| 237 | 279 | /* |
@@ -247,8 +289,11 @@ discard block |
||
| 247 | 289 | //$this->db = $dbc; |
| 248 | 290 | |
| 249 | 291 | //$hex = trim($line['hex']); |
| 250 | - if (!isset($line['id'])) $id = trim($line['hex']); |
|
| 251 | - else $id = trim($line['id']); |
|
| 292 | + if (!isset($line['id'])) { |
|
| 293 | + $id = trim($line['hex']); |
|
| 294 | + } else { |
|
| 295 | + $id = trim($line['id']); |
|
| 296 | + } |
|
| 252 | 297 | |
| 253 | 298 | if (!isset($this->all_flights[$id])) { |
| 254 | 299 | $this->all_flights[$id] = array(); |
@@ -256,13 +301,21 @@ discard block |
||
| 256 | 301 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true)); |
| 257 | 302 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time())); |
| 258 | 303 | if (!isset($line['id'])) { |
| 259 | - if (!isset($globalDaemon)) $globalDaemon = TRUE; |
|
| 260 | -// if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 304 | + if (!isset($globalDaemon)) { |
|
| 305 | + $globalDaemon = TRUE; |
|
| 306 | + } |
|
| 307 | + // if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi'))); |
|
| 261 | 308 | // if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
| 262 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 309 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
|
| 310 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi'))); |
|
| 311 | + } |
|
| 263 | 312 | //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 264 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 265 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 313 | + } else { |
|
| 314 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 315 | + } |
|
| 316 | + if ($globalAllFlights !== FALSE) { |
|
| 317 | + $dataFound = true; |
|
| 318 | + } |
|
| 266 | 319 | } |
| 267 | 320 | |
| 268 | 321 | //print_r($this->all_flights); |
@@ -276,11 +329,19 @@ discard block |
||
| 276 | 329 | $Spotter = new Spotter($this->db); |
| 277 | 330 | $aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex'])); |
| 278 | 331 | $Spotter->db = null; |
| 279 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 280 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 332 | + if ($globalDebugTimeElapsed) { |
|
| 333 | + echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 334 | + } |
|
| 335 | + if ($aircraft_icao != '') { |
|
| 336 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | + if ($globalAllFlights !== FALSE) { |
|
| 340 | + $dataFound = true; |
|
| 341 | + } |
|
| 342 | + if ($globalDebug) { |
|
| 343 | + echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 281 | 344 | } |
| 282 | - if ($globalAllFlights !== FALSE) $dataFound = true; |
|
| 283 | - if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n"; |
|
| 284 | 345 | } |
| 285 | 346 | if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') { |
| 286 | 347 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao'])); |
@@ -290,14 +351,23 @@ discard block |
||
| 290 | 351 | $Spotter = new Spotter($this->db); |
| 291 | 352 | $aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']); |
| 292 | 353 | $Spotter->db = null; |
| 293 | - if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 354 | + if ($aircraft_icao != '') { |
|
| 355 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 356 | + } |
|
| 294 | 357 | } |
| 295 | 358 | if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) { |
| 296 | - if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID'; |
|
| 297 | - elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL'; |
|
| 298 | - elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE'; |
|
| 299 | - elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC'; |
|
| 300 | - if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 359 | + if ($line['aircraft_type'] == 'PARA_GLIDER') { |
|
| 360 | + $aircraft_icao = 'GLID'; |
|
| 361 | + } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') { |
|
| 362 | + $aircraft_icao = 'UHEL'; |
|
| 363 | + } elseif ($line['aircraft_type'] == 'TOW_PLANE') { |
|
| 364 | + $aircraft_icao = 'TOWPLANE'; |
|
| 365 | + } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') { |
|
| 366 | + $aircraft_icao = 'POWAIRC'; |
|
| 367 | + } |
|
| 368 | + if (isset($aircraft_icao)) { |
|
| 369 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao)); |
|
| 370 | + } |
|
| 301 | 371 | } |
| 302 | 372 | if (!isset($this->all_flights[$id]['aircraft_icao'])) { |
| 303 | 373 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA')); |
@@ -307,8 +377,11 @@ discard block |
||
| 307 | 377 | if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) { |
| 308 | 378 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime'])); |
| 309 | 379 | } else { |
| 310 | - if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 311 | - elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 380 | + if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 381 | + echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 382 | + } elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) { |
|
| 383 | + echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n"; |
|
| 384 | + } |
|
| 312 | 385 | /* |
| 313 | 386 | echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']); |
| 314 | 387 | print_r($this->all_flights[$id]); |
@@ -340,15 +413,25 @@ discard block |
||
| 340 | 413 | $timeelapsed = microtime(true); |
| 341 | 414 | $Spotter = new Spotter($this->db); |
| 342 | 415 | $fromsource = NULL; |
| 343 | - if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource; |
|
| 344 | - elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim'; |
|
| 345 | - elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao'; |
|
| 346 | - elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
|
| 347 | - elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
|
| 416 | + if (isset($globalAirlinesSource) && $globalAirlinesSource != '') { |
|
| 417 | + $fromsource = $globalAirlinesSource; |
|
| 418 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') { |
|
| 419 | + $fromsource = 'vatsim'; |
|
| 420 | + } elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') { |
|
| 421 | + $fromsource = 'ivao'; |
|
| 422 | + } elseif (isset($globalVATSIM) && $globalVATSIM) { |
|
| 423 | + $fromsource = 'vatsim'; |
|
| 424 | + } elseif (isset($globalIVAO) && $globalIVAO) { |
|
| 425 | + $fromsource = 'ivao'; |
|
| 426 | + } |
|
| 348 | 427 | $result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource); |
| 349 | - if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n"; |
|
| 428 | + if ($globalDebug && $result != 'success') { |
|
| 429 | + echo '!!! ERROR : '.$result."\n"; |
|
| 430 | + } |
|
| 350 | 431 | $Spotter->db = null; |
| 351 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 432 | + if ($globalDebugTimeElapsed) { |
|
| 433 | + echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 434 | + } |
|
| 352 | 435 | } |
| 353 | 436 | |
| 354 | 437 | /* |
@@ -359,7 +442,9 @@ discard block |
||
| 359 | 442 | else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
| 360 | 443 | } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
| 361 | 444 | */ |
| 362 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 445 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 446 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 447 | + } |
|
| 363 | 448 | |
| 364 | 449 | //$putinarchive = true; |
| 365 | 450 | if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) { |
@@ -376,7 +461,9 @@ discard block |
||
| 376 | 461 | $line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']); |
| 377 | 462 | $line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']); |
| 378 | 463 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => '')); |
| 379 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 464 | + if ($globalDebugTimeElapsed) { |
|
| 465 | + echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 466 | + } |
|
| 380 | 467 | |
| 381 | 468 | } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') { |
| 382 | 469 | $timeelapsed = microtime(true); |
@@ -389,7 +476,9 @@ discard block |
||
| 389 | 476 | $Translation->db = null; |
| 390 | 477 | } |
| 391 | 478 | $Spotter->db = null; |
| 392 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 479 | + if ($globalDebugTimeElapsed) { |
|
| 480 | + echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 481 | + } |
|
| 393 | 482 | |
| 394 | 483 | if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) { |
| 395 | 484 | //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) { |
@@ -398,9 +487,13 @@ discard block |
||
| 398 | 487 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop'])); |
| 399 | 488 | } |
| 400 | 489 | } |
| 401 | - if (!isset($globalFork)) $globalFork = TRUE; |
|
| 490 | + if (!isset($globalFork)) { |
|
| 491 | + $globalFork = TRUE; |
|
| 492 | + } |
|
| 402 | 493 | if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) { |
| 403 | - if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident'])); |
|
| 494 | + if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) { |
|
| 495 | + $this->get_Schedule($id,trim($line['ident'])); |
|
| 496 | + } |
|
| 404 | 497 | } |
| 405 | 498 | } |
| 406 | 499 | } |
@@ -416,16 +509,23 @@ discard block |
||
| 416 | 509 | // use datetime |
| 417 | 510 | $speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']); |
| 418 | 511 | $speed = $speed*3.6; |
| 419 | - if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 420 | - if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 512 | + if ($speed < 1000) { |
|
| 513 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed))); |
|
| 514 | + } |
|
| 515 | + if ($globalDebug) { |
|
| 516 | + echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n"; |
|
| 517 | + } |
|
| 421 | 518 | } |
| 422 | 519 | } |
| 423 | 520 | |
| 424 | 521 | |
| 425 | 522 | |
| 426 | 523 | if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) { |
| 427 | - if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 428 | - else unset($timediff); |
|
| 524 | + if (isset($this->all_flights[$id]['time_last_coord'])) { |
|
| 525 | + $timediff = round(time()-$this->all_flights[$id]['time_last_coord']); |
|
| 526 | + } else { |
|
| 527 | + unset($timediff); |
|
| 528 | + } |
|
| 429 | 529 | if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) { |
| 430 | 530 | if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) { |
| 431 | 531 | if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) { |
@@ -433,21 +533,31 @@ discard block |
||
| 433 | 533 | $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
| 434 | 534 | $this->all_flights[$id]['putinarchive'] = true; |
| 435 | 535 | |
| 436 | - if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 536 | + if ($globalDebug) { |
|
| 537 | + echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... '; |
|
| 538 | + } |
|
| 437 | 539 | $timeelapsed = microtime(true); |
| 438 | 540 | $Spotter = new Spotter($this->db); |
| 439 | 541 | $all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']); |
| 440 | - if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 542 | + if (!empty($all_country)) { |
|
| 543 | + $this->all_flights[$id]['over_country'] = $all_country['iso2']; |
|
| 544 | + } |
|
| 441 | 545 | $Spotter->db = null; |
| 442 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 546 | + if ($globalDebugTimeElapsed) { |
|
| 547 | + echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 548 | + } |
|
| 443 | 549 | $this->tmd = 0; |
| 444 | - if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 550 | + if ($globalDebug) { |
|
| 551 | + echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n"; |
|
| 552 | + } |
|
| 445 | 553 | } |
| 446 | 554 | } |
| 447 | 555 | |
| 448 | 556 | if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) { |
| 449 | 557 | //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 450 | - if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
| 558 | + if (!isset($this->all_flights[$id]['archive_latitude'])) { |
|
| 559 | + $this->all_flights[$id]['archive_latitude'] = $line['latitude']; |
|
| 560 | + } |
|
| 451 | 561 | if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 452 | 562 | $this->all_flights[$id]['livedb_latitude'] = $line['latitude']; |
| 453 | 563 | $dataFound = true; |
@@ -469,9 +579,13 @@ discard block |
||
| 469 | 579 | */ |
| 470 | 580 | } |
| 471 | 581 | if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) { |
| 472 | - if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360; |
|
| 582 | + if ($line['longitude'] > 180) { |
|
| 583 | + $line['longitude'] = $line['longitude'] - 360; |
|
| 584 | + } |
|
| 473 | 585 | //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == '' || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) { |
| 474 | - if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
| 586 | + if (!isset($this->all_flights[$id]['archive_longitude'])) { |
|
| 587 | + $this->all_flights[$id]['archive_longitude'] = $line['longitude']; |
|
| 588 | + } |
|
| 475 | 589 | if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') { |
| 476 | 590 | $this->all_flights[$id]['livedb_longitude'] = $line['longitude']; |
| 477 | 591 | $dataFound = true; |
@@ -502,7 +616,9 @@ discard block |
||
| 502 | 616 | } |
| 503 | 617 | } |
| 504 | 618 | if (isset($line['last_update']) && $line['last_update'] != '') { |
| 505 | - if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true; |
|
| 619 | + if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) { |
|
| 620 | + $dataFound = true; |
|
| 621 | + } |
|
| 506 | 622 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update'])); |
| 507 | 623 | } |
| 508 | 624 | if (isset($line['verticalrate']) && $line['verticalrate'] != '') { |
@@ -524,40 +640,60 @@ discard block |
||
| 524 | 640 | // Here we force archive of flight because after ground it's a new one (or should be) |
| 525 | 641 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0)); |
| 526 | 642 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1)); |
| 527 | - if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
| 528 | - elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 529 | - elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 643 | + if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) { |
|
| 644 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi'))); |
|
| 645 | + } elseif (isset($line['id'])) { |
|
| 646 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id'])); |
|
| 647 | + } elseif (isset($this->all_flights[$id]['ident'])) { |
|
| 648 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'])); |
|
| 649 | + } |
|
| 650 | + } |
|
| 651 | + if ($line['ground'] != 1) { |
|
| 652 | + $line['ground'] = 0; |
|
| 530 | 653 | } |
| 531 | - if ($line['ground'] != 1) $line['ground'] = 0; |
|
| 532 | 654 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground'])); |
| 533 | 655 | //$dataFound = true; |
| 534 | 656 | } |
| 535 | 657 | if (isset($line['squawk']) && $line['squawk'] != '') { |
| 536 | 658 | if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) { |
| 537 | - if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true; |
|
| 659 | + if ($this->all_flights[$id]['squawk'] != $line['squawk']) { |
|
| 660 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 661 | + } |
|
| 538 | 662 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
| 539 | 663 | $highlight = ''; |
| 540 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 541 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 542 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 664 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 665 | + $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC'; |
|
| 666 | + } |
|
| 667 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 668 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC'; |
|
| 669 | + } |
|
| 670 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 671 | + $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC'; |
|
| 672 | + } |
|
| 543 | 673 | if ($highlight != '') { |
| 544 | 674 | $timeelapsed = microtime(true); |
| 545 | 675 | $Spotter = new Spotter($this->db); |
| 546 | 676 | $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight); |
| 547 | 677 | $Spotter->db = null; |
| 548 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 678 | + if ($globalDebugTimeElapsed) { |
|
| 679 | + echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 680 | + } |
|
| 549 | 681 | |
| 550 | 682 | //$putinarchive = true; |
| 551 | 683 | //$highlight = ''; |
| 552 | 684 | } |
| 553 | 685 | |
| 554 | - } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 686 | + } else { |
|
| 687 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk'])); |
|
| 688 | + } |
|
| 555 | 689 | //$dataFound = true; |
| 556 | 690 | } |
| 557 | 691 | |
| 558 | 692 | if (isset($line['altitude']) && $line['altitude'] != '') { |
| 559 | 693 | //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) { |
| 560 | - if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true; |
|
| 694 | + if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) { |
|
| 695 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 696 | + } |
|
| 561 | 697 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100))); |
| 562 | 698 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude'])); |
| 563 | 699 | //$dataFound = true; |
@@ -569,21 +705,30 @@ discard block |
||
| 569 | 705 | } |
| 570 | 706 | |
| 571 | 707 | if (isset($line['heading']) && $line['heading'] != '') { |
| 572 | - if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 708 | + if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) { |
|
| 709 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 710 | + } |
|
| 573 | 711 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading']))); |
| 574 | 712 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true)); |
| 575 | 713 | //$dataFound = true; |
| 576 | 714 | } elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) { |
| 577 | 715 | $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 578 | 716 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading))); |
| 579 | - if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true; |
|
| 580 | - if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 717 | + if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) { |
|
| 718 | + $this->all_flights[$id]['putinarchive'] = true; |
|
| 719 | + } |
|
| 720 | + if ($globalDebug) { |
|
| 721 | + echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n"; |
|
| 722 | + } |
|
| 581 | 723 | } elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') { |
| 582 | 724 | // If not enough messages and ACARS set heading to 0 |
| 583 | 725 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0)); |
| 584 | 726 | } |
| 585 | - if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false; |
|
| 586 | - elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false; |
|
| 727 | + if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) { |
|
| 728 | + $dataFound = false; |
|
| 729 | + } elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) { |
|
| 730 | + $dataFound = false; |
|
| 731 | + } |
|
| 587 | 732 | |
| 588 | 733 | // print_r($this->all_flights[$id]); |
| 589 | 734 | //gets the callsign from the last hour |
@@ -598,23 +743,36 @@ discard block |
||
| 598 | 743 | //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n"; |
| 599 | 744 | //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']); |
| 600 | 745 | if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) { |
| 601 | - if ($globalDebug) echo "Check if aircraft is already in DB..."; |
|
| 746 | + if ($globalDebug) { |
|
| 747 | + echo "Check if aircraft is already in DB..."; |
|
| 748 | + } |
|
| 602 | 749 | $timeelapsed = microtime(true); |
| 603 | 750 | $SpotterLive = new SpotterLive($this->db); |
| 604 | 751 | if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) { |
| 605 | 752 | $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']); |
| 606 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 753 | + if ($globalDebugTimeElapsed) { |
|
| 754 | + echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 755 | + } |
|
| 607 | 756 | } elseif (isset($line['id'])) { |
| 608 | 757 | $recent_ident = $SpotterLive->checkIdRecent($line['id']); |
| 609 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 758 | + if ($globalDebugTimeElapsed) { |
|
| 759 | + echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 760 | + } |
|
| 610 | 761 | } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') { |
| 611 | 762 | $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']); |
| 612 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 613 | - } else $recent_ident = ''; |
|
| 763 | + if ($globalDebugTimeElapsed) { |
|
| 764 | + echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 765 | + } |
|
| 766 | + } else { |
|
| 767 | + $recent_ident = ''; |
|
| 768 | + } |
|
| 614 | 769 | $SpotterLive->db=null; |
| 615 | 770 | |
| 616 | - if ($globalDebug && $recent_ident == '') echo " Not in DB.\n"; |
|
| 617 | - elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n"; |
|
| 771 | + if ($globalDebug && $recent_ident == '') { |
|
| 772 | + echo " Not in DB.\n"; |
|
| 773 | + } elseif ($globalDebug && $recent_ident != '') { |
|
| 774 | + echo " Already in DB.\n"; |
|
| 775 | + } |
|
| 618 | 776 | } else { |
| 619 | 777 | $recent_ident = ''; |
| 620 | 778 | $this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0)); |
@@ -622,7 +780,9 @@ discard block |
||
| 622 | 780 | //if there was no aircraft with the same callsign within the last hour and go post it into the archive |
| 623 | 781 | if($recent_ident == "") |
| 624 | 782 | { |
| 625 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 783 | + if ($globalDebug) { |
|
| 784 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : "; |
|
| 785 | + } |
|
| 626 | 786 | if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; } |
| 627 | 787 | if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; } |
| 628 | 788 | //adds the spotter data for the archive |
@@ -666,26 +826,44 @@ discard block |
||
| 666 | 826 | |
| 667 | 827 | if (!$ignoreImport) { |
| 668 | 828 | $highlight = ''; |
| 669 | - if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack'; |
|
| 670 | - if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 671 | - if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency'; |
|
| 672 | - if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 829 | + if ($this->all_flights[$id]['squawk'] == '7500') { |
|
| 830 | + $highlight = 'Squawk 7500 : Hijack'; |
|
| 831 | + } |
|
| 832 | + if ($this->all_flights[$id]['squawk'] == '7600') { |
|
| 833 | + $highlight = 'Squawk 7600 : Lost Comm (radio failure)'; |
|
| 834 | + } |
|
| 835 | + if ($this->all_flights[$id]['squawk'] == '7700') { |
|
| 836 | + $highlight = 'Squawk 7700 : Emergency'; |
|
| 837 | + } |
|
| 838 | + if (!isset($this->all_flights[$id]['id'])) { |
|
| 839 | + $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi'))); |
|
| 840 | + } |
|
| 673 | 841 | $timeelapsed = microtime(true); |
| 674 | 842 | $Spotter = new Spotter($this->db); |
| 675 | 843 | $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']); |
| 676 | 844 | $Spotter->db = null; |
| 677 | - if ($globalDebug && isset($result)) echo $result."\n"; |
|
| 678 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 845 | + if ($globalDebug && isset($result)) { |
|
| 846 | + echo $result."\n"; |
|
| 847 | + } |
|
| 848 | + if ($globalDebugTimeElapsed) { |
|
| 849 | + echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 850 | + } |
|
| 679 | 851 | |
| 680 | 852 | // Add source stat in DB |
| 681 | 853 | $Stats = new Stats($this->db); |
| 682 | 854 | if (!empty($this->stats)) { |
| 683 | - if ($globalDebug) echo 'Add source stats : '; |
|
| 855 | + if ($globalDebug) { |
|
| 856 | + echo 'Add source stats : '; |
|
| 857 | + } |
|
| 684 | 858 | foreach($this->stats as $date => $data) { |
| 685 | 859 | foreach($data as $source => $sourced) { |
| 686 | 860 | //print_r($sourced); |
| 687 | - if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 688 | - if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 861 | + if (isset($sourced['polar'])) { |
|
| 862 | + echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date); |
|
| 863 | + } |
|
| 864 | + if (isset($sourced['hist'])) { |
|
| 865 | + echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date); |
|
| 866 | + } |
|
| 689 | 867 | if (isset($sourced['msg'])) { |
| 690 | 868 | if (time() - $sourced['msg']['date'] > 10) { |
| 691 | 869 | $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date'])); |
@@ -698,13 +876,17 @@ discard block |
||
| 698 | 876 | unset($this->stats[$date]); |
| 699 | 877 | } |
| 700 | 878 | } |
| 701 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 879 | + if ($globalDebug) { |
|
| 880 | + echo 'Done'."\n"; |
|
| 881 | + } |
|
| 702 | 882 | |
| 703 | 883 | } |
| 704 | 884 | $Stats->db = null; |
| 705 | 885 | |
| 706 | 886 | $this->del(); |
| 707 | - } elseif ($globalDebug) echo 'Ignore data'."\n"; |
|
| 887 | + } elseif ($globalDebug) { |
|
| 888 | + echo 'Ignore data'."\n"; |
|
| 889 | + } |
|
| 708 | 890 | //$ignoreImport = false; |
| 709 | 891 | $this->all_flights[$id]['addedSpotter'] = 1; |
| 710 | 892 | //print_r($this->all_flights[$id]); |
@@ -721,12 +903,16 @@ discard block |
||
| 721 | 903 | */ |
| 722 | 904 | //SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']); |
| 723 | 905 | if ($this->last_delete == 0 || time() - $this->last_delete > 1800) { |
| 724 | - if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 906 | + if ($globalDebug) { |
|
| 907 | + echo "---- Deleting Live Spotter data older than 9 hours..."; |
|
| 908 | + } |
|
| 725 | 909 | //SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 726 | 910 | $SpotterLive = new SpotterLive($this->db); |
| 727 | 911 | $SpotterLive->deleteLiveSpotterData(); |
| 728 | 912 | $SpotterLive->db=null; |
| 729 | - if ($globalDebug) echo " Done\n"; |
|
| 913 | + if ($globalDebug) { |
|
| 914 | + echo " Done\n"; |
|
| 915 | + } |
|
| 730 | 916 | $this->last_delete = time(); |
| 731 | 917 | } |
| 732 | 918 | } else { |
@@ -749,11 +935,17 @@ discard block |
||
| 749 | 935 | //echo "{$line[8]} {$line[7]} - MODES:{$line[4]} CALLSIGN:{$line[10]} ALT:{$line[11]} VEL:{$line[12]} HDG:{$line[13]} LAT:{$line[14]} LON:{$line[15]} VR:{$line[16]} SQUAWK:{$line[17]}\n"; |
| 750 | 936 | if ($globalDebug) { |
| 751 | 937 | if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) { |
| 752 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 753 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 938 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 939 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 940 | + } else { |
|
| 941 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n"; |
|
| 942 | + } |
|
| 754 | 943 | } else { |
| 755 | - if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 756 | - else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 944 | + if (isset($this->all_flights[$id]['source_name'])) { |
|
| 945 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n"; |
|
| 946 | + } else { |
|
| 947 | + echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n"; |
|
| 948 | + } |
|
| 757 | 949 | } |
| 758 | 950 | } |
| 759 | 951 | $ignoreImport = false; |
@@ -799,20 +991,26 @@ discard block |
||
| 799 | 991 | |
| 800 | 992 | if (!$ignoreImport) { |
| 801 | 993 | if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) { |
| 802 | - if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 994 | + if ($globalDebug) { |
|
| 995 | + echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : "; |
|
| 996 | + } |
|
| 803 | 997 | $timeelapsed = microtime(true); |
| 804 | 998 | $SpotterLive = new SpotterLive($this->db); |
| 805 | 999 | $result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']); |
| 806 | 1000 | $SpotterLive->db = null; |
| 807 | 1001 | $this->all_flights[$id]['putinarchive'] = false; |
| 808 | - if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1002 | + if ($globalDebugTimeElapsed) { |
|
| 1003 | + echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 1004 | + } |
|
| 809 | 1005 | |
| 810 | 1006 | // Put statistics in $this->stats variable |
| 811 | 1007 | //if ($line['format_source'] != 'aprs') { |
| 812 | 1008 | //if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) { |
| 813 | 1009 | if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') { |
| 814 | 1010 | $source = $this->all_flights[$id]['source_name']; |
| 815 | - if ($source == '') $source = $this->all_flights[$id]['format_source']; |
|
| 1011 | + if ($source == '') { |
|
| 1012 | + $source = $this->all_flights[$id]['format_source']; |
|
| 1013 | + } |
|
| 816 | 1014 | if (!isset($this->source_location[$source])) { |
| 817 | 1015 | $Location = new Source(); |
| 818 | 1016 | $coord = $Location->getLocationInfobySourceName($source); |
@@ -833,7 +1031,9 @@ discard block |
||
| 833 | 1031 | $stats_heading = round($stats_heading/22.5); |
| 834 | 1032 | $stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']); |
| 835 | 1033 | $current_date = date('Y-m-d'); |
| 836 | - if ($stats_heading == 16) $stats_heading = 0; |
|
| 1034 | + if ($stats_heading == 16) { |
|
| 1035 | + $stats_heading = 0; |
|
| 1036 | + } |
|
| 837 | 1037 | if (!isset($this->stats[$current_date][$source]['polar'][1])) { |
| 838 | 1038 | for ($i=0;$i<=15;$i++) { |
| 839 | 1039 | $this->stats[$current_date][$source]['polar'][$i] = 0; |
@@ -851,7 +1051,9 @@ discard block |
||
| 851 | 1051 | if (isset($this->stats[$current_date][$source]['hist'][0])) { |
| 852 | 1052 | end($this->stats[$current_date][$source]['hist']); |
| 853 | 1053 | $mini = key($this->stats[$current_date][$source]['hist'])+10; |
| 854 | - } else $mini = 0; |
|
| 1054 | + } else { |
|
| 1055 | + $mini = 0; |
|
| 1056 | + } |
|
| 855 | 1057 | for ($i=$mini;$i<=$distance;$i+=10) { |
| 856 | 1058 | $this->stats[$current_date][$source]['hist'][$i] = 0; |
| 857 | 1059 | } |
@@ -862,20 +1064,30 @@ discard block |
||
| 862 | 1064 | } |
| 863 | 1065 | |
| 864 | 1066 | $this->all_flights[$id]['lastupdate'] = time(); |
| 865 | - if ($this->all_flights[$id]['putinarchive']) $send = true; |
|
| 1067 | + if ($this->all_flights[$id]['putinarchive']) { |
|
| 1068 | + $send = true; |
|
| 1069 | + } |
|
| 866 | 1070 | //if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
| 867 | - if ($globalDebug) echo $result."\n"; |
|
| 868 | - } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1071 | + if ($globalDebug) { |
|
| 1072 | + echo $result."\n"; |
|
| 1073 | + } |
|
| 1074 | + } elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) { |
|
| 1075 | + echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n"; |
|
| 1076 | + } |
|
| 869 | 1077 | //$this->del(); |
| 870 | 1078 | |
| 871 | 1079 | |
| 872 | 1080 | if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) { |
| 873 | - if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1081 | + if ($globalDebug) { |
|
| 1082 | + echo "---- Deleting Live Spotter data Not updated since 2 hour..."; |
|
| 1083 | + } |
|
| 874 | 1084 | $SpotterLive = new SpotterLive($this->db); |
| 875 | 1085 | $SpotterLive->deleteLiveSpotterDataNotUpdated(); |
| 876 | 1086 | $SpotterLive->db = null; |
| 877 | 1087 | //SpotterLive->deleteLiveSpotterData(); |
| 878 | - if ($globalDebug) echo " Done\n"; |
|
| 1088 | + if ($globalDebug) { |
|
| 1089 | + echo " Done\n"; |
|
| 1090 | + } |
|
| 879 | 1091 | $this->last_delete_hourly = time(); |
| 880 | 1092 | } |
| 881 | 1093 | |
@@ -883,7 +1095,9 @@ discard block |
||
| 883 | 1095 | //$ignoreImport = false; |
| 884 | 1096 | } |
| 885 | 1097 | //if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN); |
| 886 | - if ($send) return $this->all_flights[$id]; |
|
| 1098 | + if ($send) { |
|
| 1099 | + return $this->all_flights[$id]; |
|
| 1100 | + } |
|
| 887 | 1101 | } |
| 888 | 1102 | } |
| 889 | 1103 | } |
@@ -4,7 +4,7 @@ discard block |
||
| 4 | 4 | require_once(dirname(__FILE__).'/class.Image.php'); |
| 5 | 5 | $global_query = "SELECT spotter_output.* FROM spotter_output"; |
| 6 | 6 | |
| 7 | -class Spotter{ |
|
| 7 | +class Spotter { |
|
| 8 | 8 | public $aircraft_correct_icaotype = array('CL64' => 'CL60', |
| 9 | 9 | 'F9LX' => 'F900', |
| 10 | 10 | 'K35T' => 'K35R', |
@@ -59,55 +59,55 @@ discard block |
||
| 59 | 59 | * @param Array $filter the filter |
| 60 | 60 | * @return Array the SQL part |
| 61 | 61 | */ |
| 62 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
| 62 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
| 63 | 63 | global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver; |
| 64 | 64 | $filters = array(); |
| 65 | 65 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
| 66 | 66 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
| 67 | 67 | $filters = $globalStatsFilters[$globalFilterName]; |
| 68 | 68 | } else { |
| 69 | - $filter = array_merge($filter,$globalStatsFilters[$globalFilterName]); |
|
| 69 | + $filter = array_merge($filter, $globalStatsFilters[$globalFilterName]); |
|
| 70 | 70 | } |
| 71 | 71 | } |
| 72 | 72 | if (isset($filter[0]['source'])) { |
| 73 | - $filters = array_merge($filters,$filter); |
|
| 73 | + $filters = array_merge($filters, $filter); |
|
| 74 | 74 | } |
| 75 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
| 75 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
| 76 | 76 | $filter_query_join = ''; |
| 77 | 77 | $filter_query_where = ''; |
| 78 | - foreach($filters as $flt) { |
|
| 78 | + foreach ($filters as $flt) { |
|
| 79 | 79 | if (isset($flt['airlines']) && !empty($flt['airlines'])) { |
| 80 | 80 | if ($flt['airlines'][0] != '') { |
| 81 | 81 | if (isset($flt['source'])) { |
| 82 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id"; |
|
| 82 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id"; |
|
| 83 | 83 | } else { |
| 84 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id"; |
|
| 84 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_output.flightaware_id"; |
|
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) { |
| 89 | 89 | if (isset($flt['source'])) { |
| 90 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id"; |
|
| 90 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id"; |
|
| 91 | 91 | } else { |
| 92 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id"; |
|
| 92 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spf ON spf.flightaware_id = spotter_output.flightaware_id"; |
|
| 93 | 93 | } |
| 94 | 94 | } |
| 95 | 95 | if (isset($flt['idents']) && !empty($flt['idents'])) { |
| 96 | 96 | if (isset($flt['source'])) { |
| 97 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id"; |
|
| 97 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id"; |
|
| 98 | 98 | } else { |
| 99 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id"; |
|
| 99 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.flightaware_id = spotter_output.flightaware_id"; |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) { |
| 103 | 103 | if (isset($flt['source'])) { |
| 104 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sf ON sf.flightaware_id = spotter_output.flightaware_id"; |
|
| 104 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sf ON sf.flightaware_id = spotter_output.flightaware_id"; |
|
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | if (isset($filter['airlines']) && !empty($filter['airlines'])) { |
| 109 | 109 | if ($filter['airlines'][0] != '') { |
| 110 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sof ON sof.flightaware_id = spotter_output.flightaware_id"; |
|
| 110 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sof ON sof.flightaware_id = spotter_output.flightaware_id"; |
|
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) { |
@@ -117,16 +117,16 @@ discard block |
||
| 117 | 117 | $filter_query_join .= " INNER JOIN (SELECT icao FROM airlines WHERE alliance = '".$filter['alliance']."') sal ON sal.icao = spotter_output.airline_icao "; |
| 118 | 118 | } |
| 119 | 119 | if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) { |
| 120 | - $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spid ON spid.flightaware_id = spotter_output.flightaware_id"; |
|
| 120 | + $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spid ON spid.flightaware_id = spotter_output.flightaware_id"; |
|
| 121 | 121 | } |
| 122 | 122 | if (isset($filter['source']) && !empty($filter['source'])) { |
| 123 | - $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')"; |
|
| 123 | + $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')"; |
|
| 124 | 124 | } |
| 125 | 125 | if (isset($filter['ident']) && !empty($filter['ident'])) { |
| 126 | 126 | $filter_query_where .= " AND ident = '".$filter['ident']."'"; |
| 127 | 127 | } |
| 128 | 128 | if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) { |
| 129 | - $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
|
| 129 | + $filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')"; |
|
| 130 | 130 | } |
| 131 | 131 | if (isset($filter['year']) && $filter['year'] != '') { |
| 132 | 132 | if ($globalDBdriver == 'mysql') { |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
| 153 | 153 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
| 154 | 154 | if ($filter_query_where != '') { |
| 155 | - $filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where); |
|
| 155 | + $filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where); |
|
| 156 | 156 | } |
| 157 | 157 | $filter_query = $filter_query_join.$filter_query_where; |
| 158 | 158 | return $filter_query; |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | * @return Array the spotter information |
| 168 | 168 | * |
| 169 | 169 | */ |
| 170 | - public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false) |
|
| 170 | + public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false) |
|
| 171 | 171 | { |
| 172 | 172 | global $globalSquawkCountry, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalAirlinesSource, $globalVAM; |
| 173 | 173 | $Image = new Image($this->db); |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | $sth = $this->db->prepare($query.$limitQuery); |
| 198 | 198 | $sth->execute($params); |
| 199 | 199 | } catch (PDOException $e) { |
| 200 | - printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery); |
|
| 200 | + printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery); |
|
| 201 | 201 | exit(); |
| 202 | 202 | } |
| 203 | 203 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | $spotter_array = array(); |
| 208 | 208 | |
| 209 | 209 | |
| 210 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 210 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 211 | 211 | { |
| 212 | 212 | $num_rows++; |
| 213 | 213 | $temp_array = array(); |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source']; |
| 252 | 252 | if (isset($row['route_stop']) && $row['route_stop'] != '') { |
| 253 | 253 | $temp_array['route_stop'] = $row['route_stop']; |
| 254 | - $allroute = explode(' ',$row['route_stop']); |
|
| 254 | + $allroute = explode(' ', $row['route_stop']); |
|
| 255 | 255 | foreach ($allroute as $route) { |
| 256 | 256 | $route_airport_array = $this->getAllAirportInfo($route); |
| 257 | 257 | if (isset($route_airport_array[0]['name'])) { |
@@ -304,17 +304,17 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | $temp_array['date'] = "about ".$dateArray['hours']." hours ago"; |
| 306 | 306 | } else { |
| 307 | - $temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC")); |
|
| 307 | + $temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC")); |
|
| 308 | 308 | } |
| 309 | 309 | $temp_array['date_minutes_past'] = $dateArray['minutes']; |
| 310 | - $temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC")); |
|
| 311 | - $temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC")); |
|
| 310 | + $temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC")); |
|
| 311 | + $temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC")); |
|
| 312 | 312 | $temp_array['date_unix'] = strtotime($row['date']." UTC"); |
| 313 | 313 | if (isset($row['last_seen']) && $row['last_seen'] != '') { |
| 314 | 314 | if (strtotime($row['last_seen']) > strtotime($row['date'])) { |
| 315 | 315 | $temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']); |
| 316 | - $temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC")); |
|
| 317 | - $temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC")); |
|
| 316 | + $temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC")); |
|
| 317 | + $temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC")); |
|
| 318 | 318 | $temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC"); |
| 319 | 319 | } |
| 320 | 320 | } |
@@ -350,9 +350,9 @@ discard block |
||
| 350 | 350 | if (!isset($row['airline_name']) || $row['airline_name'] == '') { |
| 351 | 351 | if (!is_numeric(substr($row['ident'], 0, 3))) { |
| 352 | 352 | if (is_numeric(substr($row['ident'], 2, 1))) { |
| 353 | - $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2),$fromsource); |
|
| 353 | + $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 2), $fromsource); |
|
| 354 | 354 | } elseif (is_numeric(substr($row['ident'], 3, 1))) { |
| 355 | - $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
|
| 355 | + $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource); |
|
| 356 | 356 | } else { |
| 357 | 357 | $airline_array = $this->getAllAirlineInfo('NA'); |
| 358 | 358 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | } |
| 390 | 390 | } |
| 391 | 391 | if (isset($temp_array['airline_iata']) && $temp_array['airline_iata'] != '') { |
| 392 | - $acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'],3)); |
|
| 392 | + $acars_array = $ACARS->getLiveAcarsData($temp_array['airline_iata'].substr($temp_array['ident'], 3)); |
|
| 393 | 393 | //$acars_array = ACARS->getLiveAcarsData('BA40YL'); |
| 394 | 394 | if (count($acars_array) > 0) { |
| 395 | 395 | $temp_array['acars'] = $acars_array; |
@@ -406,11 +406,11 @@ discard block |
||
| 406 | 406 | $temp_array['aircraft_date_first_reg'] = $owner_info['date_first_reg']; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | - if($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
|
| 409 | + if ($temp_array['registration'] != "" || ($globalIVAO && isset($temp_array['aircraft_type']) && $temp_array['aircraft_type'] != '')) |
|
| 410 | 410 | { |
| 411 | 411 | if ($globalIVAO) { |
| 412 | - if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type'],$temp_array['airline_icao']); |
|
| 413 | - else $image_array = $Image->getSpotterImage('',$temp_array['aircraft_type']); |
|
| 412 | + if (isset($temp_array['airline_icao'])) $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type'], $temp_array['airline_icao']); |
|
| 413 | + else $image_array = $Image->getSpotterImage('', $temp_array['aircraft_type']); |
|
| 414 | 414 | } else $image_array = $Image->getSpotterImage($temp_array['registration']); |
| 415 | 415 | if (count($image_array) > 0) { |
| 416 | 416 | $temp_array['image'] = $image_array[0]['image']; |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | $temp_array['arrival_airport_time'] = $row['arrival_airport_time']; |
| 435 | 435 | } |
| 436 | 436 | |
| 437 | - if ((!isset($globalIVAO) || ! $globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
|
| 437 | + if ((!isset($globalIVAO) || !$globalIVAO) && (!isset($globalVATSIM) || !$globalVATSIM) && (!isset($globalphpVMS) || !$globalphpVMS) && (!isset($globalVAM) || !$globalVAM)) { |
|
| 438 | 438 | if ($schedules === true) { |
| 439 | 439 | $schedule_array = $Schedule->getSchedule($temp_array['ident']); |
| 440 | 440 | //print_r($schedule_array); |
@@ -516,12 +516,12 @@ discard block |
||
| 516 | 516 | if (isset($row['squawk'])) { |
| 517 | 517 | $temp_array['squawk'] = $row['squawk']; |
| 518 | 518 | if ($row['squawk'] != '' && isset($temp_array['country_iso2'])) { |
| 519 | - $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['country_iso2']); |
|
| 520 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 519 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['country_iso2']); |
|
| 520 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry); |
|
| 521 | 521 | } elseif ($row['squawk'] != '' && isset($temp_array['over_country'])) { |
| 522 | - $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$temp_array['over_country']); |
|
| 523 | - if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 524 | - } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'],$globalSquawkCountry); |
|
| 522 | + $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $temp_array['over_country']); |
|
| 523 | + if ($temp_array['squawk_usage'] == '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry); |
|
| 524 | + } elseif ($row['squawk'] != '' && isset($globalSquawkCountry)) $temp_array['squawk_usage'] = $this->getSquawkUsage($row['squawk'], $globalSquawkCountry); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | $temp_array['query_number_rows'] = $num_rows; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * @return Array the spotter information |
| 541 | 541 | * |
| 542 | 542 | */ |
| 543 | - public function searchSpotterData($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()) |
|
| 543 | + public function searchSpotterData($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()) |
|
| 544 | 544 | { |
| 545 | 545 | global $globalTimezone, $globalDBdriver; |
| 546 | 546 | require_once(dirname(__FILE__).'/class.Translation.php'); |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | |
| 551 | 551 | $query_values = array(); |
| 552 | 552 | $additional_query = ''; |
| 553 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 553 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 554 | 554 | if ($q != "") |
| 555 | 555 | { |
| 556 | 556 | if (!is_string($q)) |
@@ -558,8 +558,8 @@ discard block |
||
| 558 | 558 | return false; |
| 559 | 559 | } else { |
| 560 | 560 | $q_array = explode(" ", $q); |
| 561 | - foreach ($q_array as $q_item){ |
|
| 562 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 561 | + foreach ($q_array as $q_item) { |
|
| 562 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 563 | 563 | $additional_query .= " AND ("; |
| 564 | 564 | if (is_int($q_item)) $additional_query .= "(spotter_output.spotter_id like '%".$q_item."%') OR "; |
| 565 | 565 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
@@ -591,37 +591,37 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | if ($registration != "") |
| 593 | 593 | { |
| 594 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 594 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 595 | 595 | if (!is_string($registration)) |
| 596 | 596 | { |
| 597 | 597 | return false; |
| 598 | 598 | } else { |
| 599 | 599 | $additional_query .= " AND spotter_output.registration = :registration"; |
| 600 | - $query_values = array_merge($query_values,array(':registration' => $registration)); |
|
| 600 | + $query_values = array_merge($query_values, array(':registration' => $registration)); |
|
| 601 | 601 | } |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | if ($aircraft_icao != "") |
| 605 | 605 | { |
| 606 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 606 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 607 | 607 | if (!is_string($aircraft_icao)) |
| 608 | 608 | { |
| 609 | 609 | return false; |
| 610 | 610 | } else { |
| 611 | 611 | $additional_query .= " AND spotter_output.aircraft_icao = :aircraft_icao"; |
| 612 | - $query_values = array_merge($query_values,array(':aircraft_icao' => $aircraft_icao)); |
|
| 612 | + $query_values = array_merge($query_values, array(':aircraft_icao' => $aircraft_icao)); |
|
| 613 | 613 | } |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | if ($aircraft_manufacturer != "") |
| 617 | 617 | { |
| 618 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 618 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 619 | 619 | if (!is_string($aircraft_manufacturer)) |
| 620 | 620 | { |
| 621 | 621 | return false; |
| 622 | 622 | } else { |
| 623 | 623 | $additional_query .= " AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer"; |
| 624 | - $query_values = array_merge($query_values,array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
| 624 | + $query_values = array_merge($query_values, array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
|
| 625 | 625 | } |
| 626 | 626 | } |
| 627 | 627 | |
@@ -637,25 +637,25 @@ discard block |
||
| 637 | 637 | |
| 638 | 638 | if ($airline_icao != "") |
| 639 | 639 | { |
| 640 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 640 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 641 | 641 | if (!is_string($airline_icao)) |
| 642 | 642 | { |
| 643 | 643 | return false; |
| 644 | 644 | } else { |
| 645 | 645 | $additional_query .= " AND spotter_output.airline_icao = :airline_icao"; |
| 646 | - $query_values = array_merge($query_values,array(':airline_icao' => $airline_icao)); |
|
| 646 | + $query_values = array_merge($query_values, array(':airline_icao' => $airline_icao)); |
|
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | if ($airline_country != "") |
| 651 | 651 | { |
| 652 | - $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING); |
|
| 652 | + $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING); |
|
| 653 | 653 | if (!is_string($airline_country)) |
| 654 | 654 | { |
| 655 | 655 | return false; |
| 656 | 656 | } else { |
| 657 | 657 | $additional_query .= " AND spotter_output.airline_country = :airline_country"; |
| 658 | - $query_values = array_merge($query_values,array(':airline_country' => $airline_country)); |
|
| 658 | + $query_values = array_merge($query_values, array(':airline_country' => $airline_country)); |
|
| 659 | 659 | } |
| 660 | 660 | } |
| 661 | 661 | |
@@ -682,31 +682,31 @@ discard block |
||
| 682 | 682 | |
| 683 | 683 | if ($airport != "") |
| 684 | 684 | { |
| 685 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 685 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 686 | 686 | if (!is_string($airport)) |
| 687 | 687 | { |
| 688 | 688 | return false; |
| 689 | 689 | } else { |
| 690 | 690 | $additional_query .= " AND (spotter_output.departure_airport_icao = :airport OR spotter_output.arrival_airport_icao = :airport)"; |
| 691 | - $query_values = array_merge($query_values,array(':airport' => $airport)); |
|
| 691 | + $query_values = array_merge($query_values, array(':airport' => $airport)); |
|
| 692 | 692 | } |
| 693 | 693 | } |
| 694 | 694 | |
| 695 | 695 | if ($airport_country != "") |
| 696 | 696 | { |
| 697 | - $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING); |
|
| 697 | + $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING); |
|
| 698 | 698 | if (!is_string($airport_country)) |
| 699 | 699 | { |
| 700 | 700 | return false; |
| 701 | 701 | } else { |
| 702 | 702 | $additional_query .= " AND (spotter_output.departure_airport_country = :airport_country OR spotter_output.arrival_airport_country = :airport_country)"; |
| 703 | - $query_values = array_merge($query_values,array(':airport_country' => $airport_country)); |
|
| 703 | + $query_values = array_merge($query_values, array(':airport_country' => $airport_country)); |
|
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | if ($callsign != "") |
| 708 | 708 | { |
| 709 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 709 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 710 | 710 | if (!is_string($callsign)) |
| 711 | 711 | { |
| 712 | 712 | return false; |
@@ -714,79 +714,79 @@ discard block |
||
| 714 | 714 | $translate = $Translation->ident2icao($callsign); |
| 715 | 715 | if ($translate != $callsign) { |
| 716 | 716 | $additional_query .= " AND (spotter_output.ident = :callsign OR spotter_output.ident = :translate)"; |
| 717 | - $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate)); |
|
| 717 | + $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate)); |
|
| 718 | 718 | } else { |
| 719 | 719 | $additional_query .= " AND spotter_output.ident = :callsign"; |
| 720 | - $query_values = array_merge($query_values,array(':callsign' => $callsign)); |
|
| 720 | + $query_values = array_merge($query_values, array(':callsign' => $callsign)); |
|
| 721 | 721 | } |
| 722 | 722 | } |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | if ($owner != "") |
| 726 | 726 | { |
| 727 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 727 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 728 | 728 | if (!is_string($owner)) |
| 729 | 729 | { |
| 730 | 730 | return false; |
| 731 | 731 | } else { |
| 732 | 732 | $additional_query .= " AND spotter_output.owner_name = :owner"; |
| 733 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 733 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 734 | 734 | } |
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | if ($pilot_name != "") |
| 738 | 738 | { |
| 739 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 739 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 740 | 740 | if (!is_string($pilot_name)) |
| 741 | 741 | { |
| 742 | 742 | return false; |
| 743 | 743 | } else { |
| 744 | 744 | $additional_query .= " AND spotter_output.pilot_name = :pilot_name"; |
| 745 | - $query_values = array_merge($query_values,array(':pilot_name' => $pilot_name)); |
|
| 745 | + $query_values = array_merge($query_values, array(':pilot_name' => $pilot_name)); |
|
| 746 | 746 | } |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | 749 | if ($pilot_id != "") |
| 750 | 750 | { |
| 751 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 751 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 752 | 752 | if (!is_string($pilot_id)) |
| 753 | 753 | { |
| 754 | 754 | return false; |
| 755 | 755 | } else { |
| 756 | 756 | $additional_query .= " AND spotter_output.pilot_id = :pilot_id"; |
| 757 | - $query_values = array_merge($query_values,array(':pilot_id' => $pilot_id)); |
|
| 757 | + $query_values = array_merge($query_values, array(':pilot_id' => $pilot_id)); |
|
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | if ($departure_airport_route != "") |
| 762 | 762 | { |
| 763 | - $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING); |
|
| 763 | + $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING); |
|
| 764 | 764 | if (!is_string($departure_airport_route)) |
| 765 | 765 | { |
| 766 | 766 | return false; |
| 767 | 767 | } else { |
| 768 | 768 | $additional_query .= " AND spotter_output.departure_airport_icao = :departure_airport_route"; |
| 769 | - $query_values = array_merge($query_values,array(':departure_airport_route' => $departure_airport_route)); |
|
| 769 | + $query_values = array_merge($query_values, array(':departure_airport_route' => $departure_airport_route)); |
|
| 770 | 770 | } |
| 771 | 771 | } |
| 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; |
| 779 | 779 | } else { |
| 780 | 780 | $additional_query .= " AND spotter_output.arrival_airport_icao = :arrival_airport_route"; |
| 781 | - $query_values = array_merge($query_values,array(':arrival_airport_route' => $arrival_airport_route)); |
|
| 781 | + $query_values = array_merge($query_values, array(':arrival_airport_route' => $arrival_airport_route)); |
|
| 782 | 782 | } |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | 785 | if ($altitude != "") |
| 786 | 786 | { |
| 787 | 787 | $altitude_array = explode(",", $altitude); |
| 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 | if ($altitude_array[1] != "") |
| 792 | 792 | { |
@@ -802,8 +802,8 @@ discard block |
||
| 802 | 802 | if ($date_posted != "") |
| 803 | 803 | { |
| 804 | 804 | $date_array = explode(",", $date_posted); |
| 805 | - $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING); |
|
| 806 | - $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING); |
|
| 805 | + $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING); |
|
| 806 | + $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING); |
|
| 807 | 807 | |
| 808 | 808 | if ($globalTimezone != '') { |
| 809 | 809 | date_default_timezone_set($globalTimezone); |
@@ -834,8 +834,8 @@ discard block |
||
| 834 | 834 | { |
| 835 | 835 | $limit_array = explode(",", $limit); |
| 836 | 836 | |
| 837 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 838 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 837 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 838 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 839 | 839 | |
| 840 | 840 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 841 | 841 | { |
@@ -864,23 +864,23 @@ discard block |
||
| 864 | 864 | |
| 865 | 865 | |
| 866 | 866 | if ($origLat != "" && $origLon != "" && $dist != "") { |
| 867 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 867 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 868 | 868 | |
| 869 | 869 | if ($globalDBdriver == 'mysql') { |
| 870 | - $query="SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance |
|
| 870 | + $query = "SELECT spotter_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2))) as distance |
|
| 871 | 871 | FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND spotter_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and spotter_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 872 | 872 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - spotter_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(spotter_archive.latitude*pi()/180)*POWER(SIN(($origLon-spotter_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query; |
| 873 | 873 | } else { |
| 874 | - $query="SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 874 | + $query = "SELECT spotter_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance |
|
| 875 | 875 | FROM spotter_archive,spotter_output".$filter_query." spotter_output.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 876 | 876 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(spotter_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(spotter_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query; |
| 877 | 877 | } |
| 878 | 878 | } else { |
| 879 | - $query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' |
|
| 879 | + $query = "SELECT spotter_output.* FROM spotter_output".$filter_query." spotter_output.ident <> '' |
|
| 880 | 880 | ".$additional_query." |
| 881 | 881 | ".$orderby_query; |
| 882 | 882 | } |
| 883 | - $spotter_array = $this->getDataFromDB($query, $query_values,$limit_query); |
|
| 883 | + $spotter_array = $this->getDataFromDB($query, $query_values, $limit_query); |
|
| 884 | 884 | return $spotter_array; |
| 885 | 885 | } |
| 886 | 886 | |
@@ -903,8 +903,8 @@ discard block |
||
| 903 | 903 | { |
| 904 | 904 | $limit_array = explode(",", $limit); |
| 905 | 905 | |
| 906 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 907 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 906 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 907 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 908 | 908 | |
| 909 | 909 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 910 | 910 | { |
@@ -921,9 +921,9 @@ discard block |
||
| 921 | 921 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - $query = $global_query.$filter_query." ".$orderby_query; |
|
| 924 | + $query = $global_query.$filter_query." ".$orderby_query; |
|
| 925 | 925 | |
| 926 | - $spotter_array = $this->getDataFromDB($query, array(),$limit_query,true); |
|
| 926 | + $spotter_array = $this->getDataFromDB($query, array(), $limit_query, true); |
|
| 927 | 927 | |
| 928 | 928 | return $spotter_array; |
| 929 | 929 | } |
@@ -969,34 +969,34 @@ discard block |
||
| 969 | 969 | { |
| 970 | 970 | return false; |
| 971 | 971 | } else { |
| 972 | - if ($interval == "30m"){ |
|
| 972 | + if ($interval == "30m") { |
|
| 973 | 973 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) <= $this_output.date '; |
| 974 | - } else if ($interval == "1h"){ |
|
| 974 | + } else if ($interval == "1h") { |
|
| 975 | 975 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) <= $this_output.date '; |
| 976 | - } else if ($interval == "3h"){ |
|
| 976 | + } else if ($interval == "3h") { |
|
| 977 | 977 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 3 HOUR) <= $this_output.date '; |
| 978 | - } else if ($interval == "6h"){ |
|
| 978 | + } else if ($interval == "6h") { |
|
| 979 | 979 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 6 HOUR) <= $this_output.date '; |
| 980 | - } else if ($interval == "12h"){ |
|
| 980 | + } else if ($interval == "12h") { |
|
| 981 | 981 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 HOUR) <= $this_output.date '; |
| 982 | - } else if ($interval == "24h"){ |
|
| 982 | + } else if ($interval == "24h") { |
|
| 983 | 983 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 24 HOUR) <= $this_output.date '; |
| 984 | - } else if ($interval == "7d"){ |
|
| 984 | + } else if ($interval == "7d") { |
|
| 985 | 985 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) <= $this_output.date '; |
| 986 | - } else if ($interval == "30d"){ |
|
| 986 | + } else if ($interval == "30d") { |
|
| 987 | 987 | $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 DAY) <= $this_output.date '; |
| 988 | 988 | } |
| 989 | 989 | } |
| 990 | 990 | } |
| 991 | 991 | |
| 992 | - $query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output |
|
| 992 | + $query = "SELECT spotter_output.*, ( 6371 * acos( cos( radians($lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_output |
|
| 993 | 993 | WHERE spotter_output.latitude <> '' |
| 994 | 994 | AND spotter_output.longitude <> '' |
| 995 | 995 | ".$additional_query." |
| 996 | 996 | HAVING distance < :radius |
| 997 | 997 | ORDER BY distance"; |
| 998 | 998 | |
| 999 | - $spotter_array = $this->getDataFromDB($query, array(':radius' => $radius),$limit_query); |
|
| 999 | + $spotter_array = $this->getDataFromDB($query, array(':radius' => $radius), $limit_query); |
|
| 1000 | 1000 | |
| 1001 | 1001 | return $spotter_array; |
| 1002 | 1002 | } |
@@ -1008,21 +1008,21 @@ discard block |
||
| 1008 | 1008 | * @return Array the spotter information |
| 1009 | 1009 | * |
| 1010 | 1010 | */ |
| 1011 | - public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '',$filter = array()) |
|
| 1011 | + public function getNewestSpotterDataSortedByAircraftType($limit = '', $sort = '', $filter = array()) |
|
| 1012 | 1012 | { |
| 1013 | 1013 | global $global_query; |
| 1014 | 1014 | |
| 1015 | 1015 | date_default_timezone_set('UTC'); |
| 1016 | 1016 | |
| 1017 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1017 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1018 | 1018 | |
| 1019 | 1019 | $limit_query = ''; |
| 1020 | 1020 | if ($limit != "") |
| 1021 | 1021 | { |
| 1022 | 1022 | $limit_array = explode(",", $limit); |
| 1023 | 1023 | |
| 1024 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1025 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1024 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1025 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1026 | 1026 | |
| 1027 | 1027 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1028 | 1028 | { |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | - $query = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1042 | + $query = $global_query." ".$filter_query." spotter_output.aircraft_name <> '' GROUP BY spotter_output.aircraft_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1043 | 1043 | |
| 1044 | 1044 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
| 1045 | 1045 | |
@@ -1058,15 +1058,15 @@ discard block |
||
| 1058 | 1058 | global $global_query; |
| 1059 | 1059 | |
| 1060 | 1060 | date_default_timezone_set('UTC'); |
| 1061 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1061 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1062 | 1062 | |
| 1063 | 1063 | $limit_query = ''; |
| 1064 | 1064 | if ($limit != "") |
| 1065 | 1065 | { |
| 1066 | 1066 | $limit_array = explode(",", $limit); |
| 1067 | 1067 | |
| 1068 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1069 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1068 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1069 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1070 | 1070 | |
| 1071 | 1071 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1072 | 1072 | { |
@@ -1083,7 +1083,7 @@ discard block |
||
| 1083 | 1083 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | - $query = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1086 | + $query = $global_query." ".$filter_query." spotter_output.registration <> '' GROUP BY spotter_output.registration,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1087 | 1087 | |
| 1088 | 1088 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
| 1089 | 1089 | |
@@ -1097,20 +1097,20 @@ discard block |
||
| 1097 | 1097 | * @return Array the spotter information |
| 1098 | 1098 | * |
| 1099 | 1099 | */ |
| 1100 | - public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '',$filter = array()) |
|
| 1100 | + public function getNewestSpotterDataSortedByAirline($limit = '', $sort = '', $filter = array()) |
|
| 1101 | 1101 | { |
| 1102 | 1102 | global $global_query; |
| 1103 | 1103 | |
| 1104 | 1104 | date_default_timezone_set('UTC'); |
| 1105 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1105 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1106 | 1106 | |
| 1107 | 1107 | $limit_query = ''; |
| 1108 | 1108 | if ($limit != "") |
| 1109 | 1109 | { |
| 1110 | 1110 | $limit_array = explode(",", $limit); |
| 1111 | 1111 | |
| 1112 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1113 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1112 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1113 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1114 | 1114 | |
| 1115 | 1115 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1116 | 1116 | { |
@@ -1127,7 +1127,7 @@ discard block |
||
| 1127 | 1127 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | - $query = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1130 | + $query = $global_query." ".$filter_query." spotter_output.airline_name <> '' GROUP BY spotter_output.airline_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1131 | 1131 | |
| 1132 | 1132 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
| 1133 | 1133 | |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | |
| 1148 | 1148 | date_default_timezone_set('UTC'); |
| 1149 | 1149 | |
| 1150 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1150 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1151 | 1151 | |
| 1152 | 1152 | $limit_query = ''; |
| 1153 | 1153 | |
@@ -1155,8 +1155,8 @@ discard block |
||
| 1155 | 1155 | { |
| 1156 | 1156 | $limit_array = explode(",", $limit); |
| 1157 | 1157 | |
| 1158 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1159 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1158 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1159 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1160 | 1160 | |
| 1161 | 1161 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1162 | 1162 | { |
@@ -1173,7 +1173,7 @@ discard block |
||
| 1173 | 1173 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | - $query = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1176 | + $query = $global_query." ".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' GROUP BY spotter_output.departure_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1177 | 1177 | |
| 1178 | 1178 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
| 1179 | 1179 | |
@@ -1192,14 +1192,14 @@ discard block |
||
| 1192 | 1192 | global $global_query; |
| 1193 | 1193 | |
| 1194 | 1194 | date_default_timezone_set('UTC'); |
| 1195 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1195 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1196 | 1196 | $limit_query = ''; |
| 1197 | 1197 | if ($limit != "") |
| 1198 | 1198 | { |
| 1199 | 1199 | $limit_array = explode(",", $limit); |
| 1200 | 1200 | |
| 1201 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1202 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1201 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1202 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1203 | 1203 | |
| 1204 | 1204 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1205 | 1205 | { |
@@ -1216,7 +1216,7 @@ discard block |
||
| 1216 | 1216 | $orderby_query = " ORDER BY spotter_output.date DESC "; |
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | - $query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1219 | + $query = $global_query.$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' GROUP BY spotter_output.arrival_airport_icao,spotter_output.ident,spotter_output.spotter_id, spotter_output.flightaware_id, spotter_output.registration,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.aircraft_icao,spotter_output.aircraft_name,spotter_output.aircraft_manufacturer,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time,spotter_output.route_stop,spotter_output.date,spotter_output.latitude,spotter_output.longitude,spotter_output.waypoints,spotter_output.altitude,spotter_output.heading,spotter_output.ground_speed,spotter_output.highlight,spotter_output.squawk,spotter_output.ModeS,spotter_output.pilot_id,spotter_output.pilot_name,spotter_output.verticalrate,spotter_output.owner_name,spotter_output.format_source,spotter_output.source_name,spotter_output.ground,spotter_output.last_ground,spotter_output.last_seen,spotter_output.last_latitude,spotter_output.last_longitude,spotter_output.last_altitude,spotter_output.last_ground_speed,spotter_output.real_arrival_airport_icao,spotter_output.real_arrival_airport_time ".$orderby_query; |
|
| 1220 | 1220 | |
| 1221 | 1221 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
| 1222 | 1222 | |
@@ -1240,9 +1240,9 @@ discard block |
||
| 1240 | 1240 | $query_values = array(':id' => $id); |
| 1241 | 1241 | |
| 1242 | 1242 | //$query = $global_query." WHERE spotter_output.ident <> '' ".$additional_query." "; |
| 1243 | - $query = $global_query." WHERE ".$additional_query." "; |
|
| 1243 | + $query = $global_query." WHERE ".$additional_query." "; |
|
| 1244 | 1244 | |
| 1245 | - $spotter_array = $this->getDataFromDB($query,$query_values); |
|
| 1245 | + $spotter_array = $this->getDataFromDB($query, $query_values); |
|
| 1246 | 1246 | |
| 1247 | 1247 | return $spotter_array; |
| 1248 | 1248 | } |
@@ -1265,7 +1265,7 @@ discard block |
||
| 1265 | 1265 | $query_values = array(); |
| 1266 | 1266 | $limit_query = ''; |
| 1267 | 1267 | $additional_query = ''; |
| 1268 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1268 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1269 | 1269 | if ($ident != "") |
| 1270 | 1270 | { |
| 1271 | 1271 | if (!is_string($ident)) |
@@ -1281,8 +1281,8 @@ discard block |
||
| 1281 | 1281 | { |
| 1282 | 1282 | $limit_array = explode(",", $limit); |
| 1283 | 1283 | |
| 1284 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1285 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1284 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1285 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1286 | 1286 | |
| 1287 | 1287 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1288 | 1288 | { |
@@ -1321,7 +1321,7 @@ discard block |
||
| 1321 | 1321 | $query_values = array(); |
| 1322 | 1322 | $limit_query = ''; |
| 1323 | 1323 | $additional_query = ''; |
| 1324 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1324 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1325 | 1325 | if ($owner != "") |
| 1326 | 1326 | { |
| 1327 | 1327 | if (!is_string($owner)) |
@@ -1337,8 +1337,8 @@ discard block |
||
| 1337 | 1337 | { |
| 1338 | 1338 | $limit_array = explode(",", $limit); |
| 1339 | 1339 | |
| 1340 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1341 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1340 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1341 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1342 | 1342 | |
| 1343 | 1343 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1344 | 1344 | { |
@@ -1378,7 +1378,7 @@ discard block |
||
| 1378 | 1378 | $query_values = array(); |
| 1379 | 1379 | $limit_query = ''; |
| 1380 | 1380 | $additional_query = ''; |
| 1381 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1381 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1382 | 1382 | if ($pilot != "") |
| 1383 | 1383 | { |
| 1384 | 1384 | $additional_query = " AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)"; |
@@ -1389,8 +1389,8 @@ discard block |
||
| 1389 | 1389 | { |
| 1390 | 1390 | $limit_array = explode(",", $limit); |
| 1391 | 1391 | |
| 1392 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1393 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1392 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1393 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1394 | 1394 | |
| 1395 | 1395 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1396 | 1396 | { |
@@ -1431,7 +1431,7 @@ discard block |
||
| 1431 | 1431 | $query_values = array(); |
| 1432 | 1432 | $limit_query = ''; |
| 1433 | 1433 | $additional_query = ''; |
| 1434 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1434 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1435 | 1435 | |
| 1436 | 1436 | if ($aircraft_type != "") |
| 1437 | 1437 | { |
@@ -1448,8 +1448,8 @@ discard block |
||
| 1448 | 1448 | { |
| 1449 | 1449 | $limit_array = explode(",", $limit); |
| 1450 | 1450 | |
| 1451 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1452 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1451 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1452 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1453 | 1453 | |
| 1454 | 1454 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1455 | 1455 | { |
@@ -1505,8 +1505,8 @@ discard block |
||
| 1505 | 1505 | { |
| 1506 | 1506 | $limit_array = explode(",", $limit); |
| 1507 | 1507 | |
| 1508 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1509 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1508 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1509 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1510 | 1510 | |
| 1511 | 1511 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1512 | 1512 | { |
@@ -1522,7 +1522,7 @@ discard block |
||
| 1522 | 1522 | } else { |
| 1523 | 1523 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
| 1524 | 1524 | } |
| 1525 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1525 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1526 | 1526 | |
| 1527 | 1527 | //$query = $global_query.$filter_query." spotter_output.ident <> '' ".$additional_query." ".$orderby_query; |
| 1528 | 1528 | $query = $global_query.$filter_query." ".$additional_query." ".$orderby_query; |
@@ -1541,7 +1541,7 @@ discard block |
||
| 1541 | 1541 | * @return Array the spotter information |
| 1542 | 1542 | * |
| 1543 | 1543 | */ |
| 1544 | - public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '',$filters = array()) |
|
| 1544 | + public function getSpotterDataByAirline($airline = '', $limit = '', $sort = '', $filters = array()) |
|
| 1545 | 1545 | { |
| 1546 | 1546 | global $global_query; |
| 1547 | 1547 | |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | $query_values = array(); |
| 1551 | 1551 | $limit_query = ''; |
| 1552 | 1552 | $additional_query = ''; |
| 1553 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1553 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1554 | 1554 | |
| 1555 | 1555 | if ($airline != "") |
| 1556 | 1556 | { |
@@ -1567,8 +1567,8 @@ discard block |
||
| 1567 | 1567 | { |
| 1568 | 1568 | $limit_array = explode(",", $limit); |
| 1569 | 1569 | |
| 1570 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1571 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1570 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1571 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1572 | 1572 | |
| 1573 | 1573 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1574 | 1574 | { |
@@ -1598,7 +1598,7 @@ discard block |
||
| 1598 | 1598 | * @return Array the spotter information |
| 1599 | 1599 | * |
| 1600 | 1600 | */ |
| 1601 | - public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array()) |
|
| 1601 | + public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array()) |
|
| 1602 | 1602 | { |
| 1603 | 1603 | global $global_query; |
| 1604 | 1604 | |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | $query_values = array(); |
| 1607 | 1607 | $limit_query = ''; |
| 1608 | 1608 | $additional_query = ''; |
| 1609 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1609 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1610 | 1610 | |
| 1611 | 1611 | if ($airport != "") |
| 1612 | 1612 | { |
@@ -1623,8 +1623,8 @@ discard block |
||
| 1623 | 1623 | { |
| 1624 | 1624 | $limit_array = explode(",", $limit); |
| 1625 | 1625 | |
| 1626 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1627 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1626 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1627 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1628 | 1628 | |
| 1629 | 1629 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1630 | 1630 | { |
@@ -1656,7 +1656,7 @@ discard block |
||
| 1656 | 1656 | * @return Array the spotter information |
| 1657 | 1657 | * |
| 1658 | 1658 | */ |
| 1659 | - public function getSpotterDataByDate($date = '', $limit = '', $sort = '',$filter = array()) |
|
| 1659 | + public function getSpotterDataByDate($date = '', $limit = '', $sort = '', $filter = array()) |
|
| 1660 | 1660 | { |
| 1661 | 1661 | global $global_query, $globalTimezone, $globalDBdriver; |
| 1662 | 1662 | |
@@ -1664,7 +1664,7 @@ discard block |
||
| 1664 | 1664 | $limit_query = ''; |
| 1665 | 1665 | $additional_query = ''; |
| 1666 | 1666 | |
| 1667 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1667 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1668 | 1668 | |
| 1669 | 1669 | if ($date != "") |
| 1670 | 1670 | { |
@@ -1693,8 +1693,8 @@ discard block |
||
| 1693 | 1693 | { |
| 1694 | 1694 | $limit_array = explode(",", $limit); |
| 1695 | 1695 | |
| 1696 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1697 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1696 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1697 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1698 | 1698 | |
| 1699 | 1699 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1700 | 1700 | { |
@@ -1724,7 +1724,7 @@ discard block |
||
| 1724 | 1724 | * @return Array the spotter information |
| 1725 | 1725 | * |
| 1726 | 1726 | */ |
| 1727 | - public function getSpotterDataByCountry($country = '', $limit = '', $sort = '',$filters = array()) |
|
| 1727 | + public function getSpotterDataByCountry($country = '', $limit = '', $sort = '', $filters = array()) |
|
| 1728 | 1728 | { |
| 1729 | 1729 | global $global_query; |
| 1730 | 1730 | |
@@ -1733,7 +1733,7 @@ discard block |
||
| 1733 | 1733 | $query_values = array(); |
| 1734 | 1734 | $limit_query = ''; |
| 1735 | 1735 | $additional_query = ''; |
| 1736 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1736 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1737 | 1737 | if ($country != "") |
| 1738 | 1738 | { |
| 1739 | 1739 | if (!is_string($country)) |
@@ -1750,8 +1750,8 @@ discard block |
||
| 1750 | 1750 | { |
| 1751 | 1751 | $limit_array = explode(",", $limit); |
| 1752 | 1752 | |
| 1753 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1754 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1753 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1754 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1755 | 1755 | |
| 1756 | 1756 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1757 | 1757 | { |
@@ -1791,7 +1791,7 @@ discard block |
||
| 1791 | 1791 | $query_values = array(); |
| 1792 | 1792 | $additional_query = ''; |
| 1793 | 1793 | $limit_query = ''; |
| 1794 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1794 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1795 | 1795 | |
| 1796 | 1796 | if ($aircraft_manufacturer != "") |
| 1797 | 1797 | { |
@@ -1808,8 +1808,8 @@ discard block |
||
| 1808 | 1808 | { |
| 1809 | 1809 | $limit_array = explode(",", $limit); |
| 1810 | 1810 | |
| 1811 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1812 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1811 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1812 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1813 | 1813 | |
| 1814 | 1814 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1815 | 1815 | { |
@@ -1851,14 +1851,14 @@ discard block |
||
| 1851 | 1851 | $query_values = array(); |
| 1852 | 1852 | $additional_query = ''; |
| 1853 | 1853 | $limit_query = ''; |
| 1854 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 1854 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 1855 | 1855 | if ($departure_airport_icao != "") |
| 1856 | 1856 | { |
| 1857 | 1857 | if (!is_string($departure_airport_icao)) |
| 1858 | 1858 | { |
| 1859 | 1859 | return false; |
| 1860 | 1860 | } else { |
| 1861 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1861 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1862 | 1862 | $additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao)"; |
| 1863 | 1863 | //$additional_query .= " AND (spotter_output.departure_airport_icao = :departure_airport_icao AND spotter_output.real_departure_airport_icao IS NULL) OR spotter_output.real_departure_airport_icao = :departure_airport_icao"; |
| 1864 | 1864 | $query_values = array(':departure_airport_icao' => $departure_airport_icao); |
@@ -1871,10 +1871,10 @@ discard block |
||
| 1871 | 1871 | { |
| 1872 | 1872 | return false; |
| 1873 | 1873 | } else { |
| 1874 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 1874 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 1875 | 1875 | $additional_query .= " AND (spotter_output.arrival_airport_icao = :arrival_airport_icao)"; |
| 1876 | 1876 | //$additional_query .= " AND ((spotter_output.arrival_airport_icao = :arrival_airport_icao AND spotter_output.real_arrival_airport_icao IS NULL) OR spotter_output.real_arrival_airport_icao = :arrival_airport_icao)"; |
| 1877 | - $query_values = array_merge($query_values,array(':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 1877 | + $query_values = array_merge($query_values, array(':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 1878 | 1878 | } |
| 1879 | 1879 | } |
| 1880 | 1880 | |
@@ -1882,8 +1882,8 @@ discard block |
||
| 1882 | 1882 | { |
| 1883 | 1883 | $limit_array = explode(",", $limit); |
| 1884 | 1884 | |
| 1885 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1886 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1885 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1886 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1887 | 1887 | |
| 1888 | 1888 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1889 | 1889 | { |
@@ -1922,15 +1922,15 @@ discard block |
||
| 1922 | 1922 | global $global_query; |
| 1923 | 1923 | |
| 1924 | 1924 | date_default_timezone_set('UTC'); |
| 1925 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1925 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1926 | 1926 | $limit_query = ''; |
| 1927 | 1927 | |
| 1928 | 1928 | if ($limit != "") |
| 1929 | 1929 | { |
| 1930 | 1930 | $limit_array = explode(",", $limit); |
| 1931 | 1931 | |
| 1932 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 1933 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 1932 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 1933 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 1934 | 1934 | |
| 1935 | 1935 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 1936 | 1936 | { |
@@ -1947,7 +1947,7 @@ discard block |
||
| 1947 | 1947 | $orderby_query = " ORDER BY spotter_output.date DESC"; |
| 1948 | 1948 | } |
| 1949 | 1949 | |
| 1950 | - $query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query; |
|
| 1950 | + $query = $global_query.$filter_query." spotter_output.highlight <> '' ".$orderby_query; |
|
| 1951 | 1951 | |
| 1952 | 1952 | $spotter_array = $this->getDataFromDB($query, array(), $limit_query); |
| 1953 | 1953 | |
@@ -1960,19 +1960,19 @@ discard block |
||
| 1960 | 1960 | * @return String the highlight text |
| 1961 | 1961 | * |
| 1962 | 1962 | */ |
| 1963 | - public function getHighlightByRegistration($registration,$filter = array()) |
|
| 1963 | + public function getHighlightByRegistration($registration, $filter = array()) |
|
| 1964 | 1964 | { |
| 1965 | 1965 | global $global_query; |
| 1966 | 1966 | |
| 1967 | 1967 | date_default_timezone_set('UTC'); |
| 1968 | - $filter_query = $this->getFilter($filter,true,true); |
|
| 1969 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 1968 | + $filter_query = $this->getFilter($filter, true, true); |
|
| 1969 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 1970 | 1970 | |
| 1971 | - $query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration"; |
|
| 1971 | + $query = $global_query.$filter_query." spotter_output.highlight <> '' AND spotter_output.registration = :registration"; |
|
| 1972 | 1972 | $sth = $this->db->prepare($query); |
| 1973 | 1973 | $sth->execute(array(':registration' => $registration)); |
| 1974 | 1974 | |
| 1975 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1975 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 1976 | 1976 | { |
| 1977 | 1977 | $highlight = $row['highlight']; |
| 1978 | 1978 | } |
@@ -1988,14 +1988,14 @@ discard block |
||
| 1988 | 1988 | * @return String usage |
| 1989 | 1989 | * |
| 1990 | 1990 | */ |
| 1991 | - public function getSquawkUsage($squawk = '',$country = 'FR') |
|
| 1991 | + public function getSquawkUsage($squawk = '', $country = 'FR') |
|
| 1992 | 1992 | { |
| 1993 | 1993 | |
| 1994 | - $squawk = filter_var($squawk,FILTER_SANITIZE_STRING); |
|
| 1995 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 1994 | + $squawk = filter_var($squawk, FILTER_SANITIZE_STRING); |
|
| 1995 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 1996 | 1996 | |
| 1997 | 1997 | $query = "SELECT squawk.* FROM squawk WHERE squawk.code = :squawk AND squawk.country = :country LIMIT 1"; |
| 1998 | - $query_values = array(':squawk' => ltrim($squawk,'0'), ':country' => $country); |
|
| 1998 | + $query_values = array(':squawk' => ltrim($squawk, '0'), ':country' => $country); |
|
| 1999 | 1999 | |
| 2000 | 2000 | $sth = $this->db->prepare($query); |
| 2001 | 2001 | $sth->execute($query_values); |
@@ -2017,9 +2017,9 @@ discard block |
||
| 2017 | 2017 | public function getAirportIcao($airport_iata = '') |
| 2018 | 2018 | { |
| 2019 | 2019 | |
| 2020 | - $airport_iata = filter_var($airport_iata,FILTER_SANITIZE_STRING); |
|
| 2020 | + $airport_iata = filter_var($airport_iata, FILTER_SANITIZE_STRING); |
|
| 2021 | 2021 | |
| 2022 | - $query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1"; |
|
| 2022 | + $query = "SELECT airport.* FROM airport WHERE airport.iata = :airport LIMIT 1"; |
|
| 2023 | 2023 | $query_values = array(':airport' => $airport_iata); |
| 2024 | 2024 | |
| 2025 | 2025 | $sth = $this->db->prepare($query); |
@@ -2041,12 +2041,12 @@ discard block |
||
| 2041 | 2041 | * @return Float distance to the airport |
| 2042 | 2042 | * |
| 2043 | 2043 | */ |
| 2044 | - public function getAirportDistance($airport_icao,$latitude,$longitude) |
|
| 2044 | + public function getAirportDistance($airport_icao, $latitude, $longitude) |
|
| 2045 | 2045 | { |
| 2046 | 2046 | |
| 2047 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 2047 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 2048 | 2048 | |
| 2049 | - $query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1"; |
|
| 2049 | + $query = "SELECT airport.latitude, airport.longitude FROM airport WHERE airport.icao = :airport LIMIT 1"; |
|
| 2050 | 2050 | $query_values = array(':airport' => $airport_icao); |
| 2051 | 2051 | $sth = $this->db->prepare($query); |
| 2052 | 2052 | $sth->execute($query_values); |
@@ -2056,7 +2056,7 @@ discard block |
||
| 2056 | 2056 | $airport_latitude = $row['latitude']; |
| 2057 | 2057 | $airport_longitude = $row['longitude']; |
| 2058 | 2058 | $Common = new Common(); |
| 2059 | - return $Common->distance($latitude,$longitude,$airport_latitude,$airport_longitude); |
|
| 2059 | + return $Common->distance($latitude, $longitude, $airport_latitude, $airport_longitude); |
|
| 2060 | 2060 | } else return ''; |
| 2061 | 2061 | } |
| 2062 | 2062 | |
@@ -2070,11 +2070,11 @@ discard block |
||
| 2070 | 2070 | public function getAllAirportInfo($airport = '') |
| 2071 | 2071 | { |
| 2072 | 2072 | |
| 2073 | - $airport = filter_var($airport,FILTER_SANITIZE_STRING); |
|
| 2073 | + $airport = filter_var($airport, FILTER_SANITIZE_STRING); |
|
| 2074 | 2074 | |
| 2075 | 2075 | $query_values = array(); |
| 2076 | 2076 | if ($airport == 'NA') { |
| 2077 | - return array(array('name' => 'Not available','city' => 'N/A', 'country' => 'N/A','iata' => 'NA','icao' => 'NA','altitude' => NULL,'latitude' => 0,'longitude' => 0,'type' => 'NA','home_link' => '','wikipedia_link' => '','image_thumb' => '', 'image' => '')); |
|
| 2077 | + return array(array('name' => 'Not available', 'city' => 'N/A', 'country' => 'N/A', 'iata' => 'NA', 'icao' => 'NA', 'altitude' => NULL, 'latitude' => 0, 'longitude' => 0, 'type' => 'NA', 'home_link' => '', 'wikipedia_link' => '', 'image_thumb' => '', 'image' => '')); |
|
| 2078 | 2078 | } elseif ($airport == '') { |
| 2079 | 2079 | $query = "SELECT airport.name, airport.city, airport.country, airport.iata, airport.icao, airport.latitude, airport.longitude, airport.altitude, airport.type, airport.home_link, airport.wikipedia_link, airport.image_thumb, airport.image FROM airport"; |
| 2080 | 2080 | } else { |
@@ -2122,14 +2122,14 @@ discard block |
||
| 2122 | 2122 | { |
| 2123 | 2123 | $lst_countries = ''; |
| 2124 | 2124 | foreach ($countries as $country) { |
| 2125 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 2125 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 2126 | 2126 | if ($lst_countries == '') { |
| 2127 | 2127 | $lst_countries = "'".$country."'"; |
| 2128 | 2128 | } else { |
| 2129 | 2129 | $lst_countries .= ",'".$country."'"; |
| 2130 | 2130 | } |
| 2131 | 2131 | } |
| 2132 | - $query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")"; |
|
| 2132 | + $query = "SELECT airport.* FROM airport WHERE airport.country IN (".$lst_countries.")"; |
|
| 2133 | 2133 | |
| 2134 | 2134 | $sth = $this->db->prepare($query); |
| 2135 | 2135 | $sth->execute(); |
@@ -2137,7 +2137,7 @@ discard block |
||
| 2137 | 2137 | $airport_array = array(); |
| 2138 | 2138 | $temp_array = array(); |
| 2139 | 2139 | |
| 2140 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2140 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2141 | 2141 | { |
| 2142 | 2142 | $temp_array['name'] = $row['name']; |
| 2143 | 2143 | $temp_array['city'] = $row['city']; |
@@ -2165,10 +2165,10 @@ discard block |
||
| 2165 | 2165 | { |
| 2166 | 2166 | global $globalDBdriver; |
| 2167 | 2167 | if (is_array($coord)) { |
| 2168 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2169 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2170 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2171 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2168 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2169 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2170 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2171 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2172 | 2172 | } else return array(); |
| 2173 | 2173 | if ($globalDBdriver == 'mysql') { |
| 2174 | 2174 | $query = "SELECT airport.* FROM airport WHERE airport.latitude BETWEEN ".$minlat." AND ".$maxlat." AND airport.longitude BETWEEN ".$minlong." AND ".$maxlong." AND airport.type != 'closed'"; |
@@ -2180,7 +2180,7 @@ discard block |
||
| 2180 | 2180 | |
| 2181 | 2181 | $airport_array = array(); |
| 2182 | 2182 | |
| 2183 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2183 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2184 | 2184 | { |
| 2185 | 2185 | $temp_array = $row; |
| 2186 | 2186 | |
@@ -2200,13 +2200,13 @@ discard block |
||
| 2200 | 2200 | public function getAllWaypointsInfobyCoord($coord) |
| 2201 | 2201 | { |
| 2202 | 2202 | if (is_array($coord)) { |
| 2203 | - $minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2204 | - $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2205 | - $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2206 | - $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 2203 | + $minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2204 | + $minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2205 | + $maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2206 | + $maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 2207 | 2207 | } else return array(); |
| 2208 | 2208 | //$query = "SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
| 2209 | - $query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 2209 | + $query = "SELECT waypoints.* FROM waypoints WHERE (waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") OR (waypoints.latitude_end BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_end BETWEEN ".$minlong." AND ".$maxlong.")"; |
|
| 2210 | 2210 | //$query = "SELECT waypoints.* FROM waypoints"; |
| 2211 | 2211 | //$query = "SELECT waypoints.* FROM waypoints INNER JOIN (SELECT waypoints.* FROM waypoints WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong.") w ON w.name_end = waypoints.name_begin OR w.name_begin = waypoints.name_begin OR w.name_begin = waypoints.name_end OR w.name_end = waypoints.name_end"; |
| 2212 | 2212 | //$query = "SELECT * FROM waypoints LEFT JOIN waypoints w ON waypoints.name_end = w.name_begin WHERE waypoints.latitude_begin BETWEEN ".$minlat." AND ".$maxlat." AND waypoints.longitude_begin BETWEEN ".$minlong." AND ".$maxlong; |
@@ -2218,7 +2218,7 @@ discard block |
||
| 2218 | 2218 | |
| 2219 | 2219 | $waypoints_array = array(); |
| 2220 | 2220 | |
| 2221 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2221 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2222 | 2222 | { |
| 2223 | 2223 | $temp_array = $row; |
| 2224 | 2224 | |
@@ -2240,10 +2240,10 @@ discard block |
||
| 2240 | 2240 | { |
| 2241 | 2241 | global $globalUseRealAirlines; |
| 2242 | 2242 | if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
| 2243 | - $airline_icao = strtoupper(filter_var($airline_icao,FILTER_SANITIZE_STRING)); |
|
| 2243 | + $airline_icao = strtoupper(filter_var($airline_icao, FILTER_SANITIZE_STRING)); |
|
| 2244 | 2244 | if ($airline_icao == 'NA') { |
| 2245 | 2245 | $airline_array = array(); |
| 2246 | - $airline_array[] = array('name' => 'Not Available','iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>''); |
|
| 2246 | + $airline_array[] = array('name' => 'Not Available', 'iata' => 'NA', 'icao' => 'NA', 'callsign' => '', 'country' => 'NA', 'type' =>''); |
|
| 2247 | 2247 | return $airline_array; |
| 2248 | 2248 | } else { |
| 2249 | 2249 | if (strlen($airline_icao) == 2) { |
@@ -2264,7 +2264,7 @@ discard block |
||
| 2264 | 2264 | if ($fromsource === NULL) { |
| 2265 | 2265 | $sth->execute(array(':airline_icao' => $airline_icao)); |
| 2266 | 2266 | } else { |
| 2267 | - $sth->execute(array(':airline_icao' => $airline_icao,':fromsource' => $fromsource)); |
|
| 2267 | + $sth->execute(array(':airline_icao' => $airline_icao, ':fromsource' => $fromsource)); |
|
| 2268 | 2268 | } |
| 2269 | 2269 | /* |
| 2270 | 2270 | $airline_array = array(); |
@@ -2309,13 +2309,13 @@ discard block |
||
| 2309 | 2309 | { |
| 2310 | 2310 | global $globalUseRealAirlines; |
| 2311 | 2311 | if (isset($globalUseRealAirlines) && $globalUseRealAirlines) $fromsource = NULL; |
| 2312 | - $airline_name = strtolower(filter_var($airline_name,FILTER_SANITIZE_STRING)); |
|
| 2313 | - $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
|
| 2312 | + $airline_name = strtolower(filter_var($airline_name, FILTER_SANITIZE_STRING)); |
|
| 2313 | + $query = "SELECT airlines.name, airlines.iata, airlines.icao, airlines.callsign, airlines.country, airlines.type FROM airlines WHERE lower(airlines.name) = :airline_name AND airlines.active = 'Y' AND airlines.forsource IS NULL LIMIT 1"; |
|
| 2314 | 2314 | $sth = $this->db->prepare($query); |
| 2315 | 2315 | if ($fromsource === NULL) { |
| 2316 | 2316 | $sth->execute(array(':airline_name' => $airline_name)); |
| 2317 | 2317 | } else { |
| 2318 | - $sth->execute(array(':airline_name' => $airline_name,':fromsource' => $fromsource)); |
|
| 2318 | + $sth->execute(array(':airline_name' => $airline_name, ':fromsource' => $fromsource)); |
|
| 2319 | 2319 | } |
| 2320 | 2320 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2321 | 2321 | if (empty($result) && $fromsource !== NULL) { |
@@ -2340,12 +2340,12 @@ discard block |
||
| 2340 | 2340 | */ |
| 2341 | 2341 | public function getAllAircraftInfo($aircraft_type) |
| 2342 | 2342 | { |
| 2343 | - $aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
|
| 2343 | + $aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING); |
|
| 2344 | 2344 | |
| 2345 | 2345 | if ($aircraft_type == 'NA') { |
| 2346 | - return array(array('icao' => 'NA','type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL)); |
|
| 2346 | + return array(array('icao' => 'NA', 'type' => 'Not Available', 'manufacturer' => 'Not Available', 'aircraft_shadow' => NULL)); |
|
| 2347 | 2347 | } |
| 2348 | - $query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type"; |
|
| 2348 | + $query = "SELECT aircraft.icao, aircraft.type,aircraft.manufacturer,aircraft.aircraft_shadow, aircraft.official_page, aircraft.aircraft_description, aircraft.engine_type, aircraft.engine_count, aircraft.wake_category FROM aircraft WHERE aircraft.icao = :aircraft_type"; |
|
| 2349 | 2349 | |
| 2350 | 2350 | $sth = $this->db->prepare($query); |
| 2351 | 2351 | $sth->execute(array(':aircraft_type' => $aircraft_type)); |
@@ -2377,7 +2377,7 @@ discard block |
||
| 2377 | 2377 | */ |
| 2378 | 2378 | public function getAircraftIcao($aircraft_type) |
| 2379 | 2379 | { |
| 2380 | - $aircraft_type = filter_var($aircraft_type,FILTER_SANITIZE_STRING); |
|
| 2380 | + $aircraft_type = filter_var($aircraft_type, FILTER_SANITIZE_STRING); |
|
| 2381 | 2381 | $all_aircraft = array('737-300' => 'B733', |
| 2382 | 2382 | '777-200' => 'B772', |
| 2383 | 2383 | '777-200ER' => 'B772', |
@@ -2389,10 +2389,10 @@ discard block |
||
| 2389 | 2389 | 'A380' => 'A388'); |
| 2390 | 2390 | if (isset($all_aircraft[$aircraft_type])) return $all_aircraft[$aircraft_type]; |
| 2391 | 2391 | |
| 2392 | - $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
|
| 2392 | + $query = "SELECT aircraft.icao FROM aircraft WHERE aircraft.type LIKE :saircraft_type OR aircraft.type = :aircraft_type OR aircraft.icao = :aircraft_type LIMIT 1"; |
|
| 2393 | 2393 | $aircraft_type = strtoupper($aircraft_type); |
| 2394 | 2394 | $sth = $this->db->prepare($query); |
| 2395 | - $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%',':aircraft_type' => $aircraft_type,)); |
|
| 2395 | + $sth->execute(array(':saircraft_type' => '%'.$aircraft_type.'%', ':aircraft_type' => $aircraft_type,)); |
|
| 2396 | 2396 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 2397 | 2397 | if (isset($result[0]['icao'])) return $result[0]['icao']; |
| 2398 | 2398 | else return ''; |
@@ -2407,9 +2407,9 @@ discard block |
||
| 2407 | 2407 | */ |
| 2408 | 2408 | public function getAllAircraftType($aircraft_modes) |
| 2409 | 2409 | { |
| 2410 | - $aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
|
| 2410 | + $aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING); |
|
| 2411 | 2411 | |
| 2412 | - $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
| 2412 | + $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
| 2413 | 2413 | |
| 2414 | 2414 | $sth = $this->db->prepare($query); |
| 2415 | 2415 | $sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
@@ -2432,9 +2432,9 @@ discard block |
||
| 2432 | 2432 | */ |
| 2433 | 2433 | public function getAllAircraftTypeByRegistration($registration) |
| 2434 | 2434 | { |
| 2435 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 2435 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 2436 | 2436 | |
| 2437 | - $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1"; |
|
| 2437 | + $query = "SELECT aircraft_modes.ICAOTypeCode FROM aircraft_modes WHERE aircraft_modes.registration = :registration ORDER BY FirstCreated DESC LIMIT 1"; |
|
| 2438 | 2438 | |
| 2439 | 2439 | $sth = $this->db->prepare($query); |
| 2440 | 2440 | $sth->execute(array(':registration' => $registration)); |
@@ -2455,9 +2455,9 @@ discard block |
||
| 2455 | 2455 | */ |
| 2456 | 2456 | public function getAllIDByRegistration($registration) |
| 2457 | 2457 | { |
| 2458 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 2458 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 2459 | 2459 | |
| 2460 | - $query = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration"; |
|
| 2460 | + $query = "SELECT spotter_id,flightaware_id, date FROM spotter_output WHERE spotter_output.registration = :registration"; |
|
| 2461 | 2461 | |
| 2462 | 2462 | $sth = $this->db->prepare($query); |
| 2463 | 2463 | $sth->execute(array(':registration' => $registration)); |
@@ -2465,7 +2465,7 @@ discard block |
||
| 2465 | 2465 | $idarray = array(); |
| 2466 | 2466 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 2467 | 2467 | $date = $row['date']; |
| 2468 | - $idarray[$date] = array('flightaware_id' => $row['flightaware_id'],'spotter_id' => $row['spotter_id']); |
|
| 2468 | + $idarray[$date] = array('flightaware_id' => $row['flightaware_id'], 'spotter_id' => $row['spotter_id']); |
|
| 2469 | 2469 | } |
| 2470 | 2470 | return $idarray; |
| 2471 | 2471 | } |
@@ -2479,8 +2479,8 @@ discard block |
||
| 2479 | 2479 | */ |
| 2480 | 2480 | public function getOperator($operator) |
| 2481 | 2481 | { |
| 2482 | - $operator = filter_var($operator,FILTER_SANITIZE_STRING); |
|
| 2483 | - $query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1"; |
|
| 2482 | + $operator = filter_var($operator, FILTER_SANITIZE_STRING); |
|
| 2483 | + $query = "SELECT translation.operator_correct FROM translation WHERE translation.operator = :operator LIMIT 1"; |
|
| 2484 | 2484 | |
| 2485 | 2485 | $sth = $this->db->prepare($query); |
| 2486 | 2486 | $sth->execute(array(':operator' => $operator)); |
@@ -2501,9 +2501,9 @@ discard block |
||
| 2501 | 2501 | */ |
| 2502 | 2502 | public function getRouteInfo($callsign) |
| 2503 | 2503 | { |
| 2504 | - $callsign = filter_var($callsign,FILTER_SANITIZE_STRING); |
|
| 2504 | + $callsign = filter_var($callsign, FILTER_SANITIZE_STRING); |
|
| 2505 | 2505 | if ($callsign == '') return array(); |
| 2506 | - $query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; |
|
| 2506 | + $query = "SELECT routes.Operator_ICAO, routes.FromAirport_ICAO, routes.ToAirport_ICAO, routes.RouteStop, routes.FromAirport_Time, routes.ToAirport_Time FROM routes WHERE CallSign = :callsign LIMIT 1"; |
|
| 2507 | 2507 | |
| 2508 | 2508 | $sth = $this->db->prepare($query); |
| 2509 | 2509 | $sth->execute(array(':callsign' => $callsign)); |
@@ -2524,9 +2524,9 @@ discard block |
||
| 2524 | 2524 | */ |
| 2525 | 2525 | public function getAircraftInfoByRegistration($registration) |
| 2526 | 2526 | { |
| 2527 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 2527 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 2528 | 2528 | |
| 2529 | - $query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration"; |
|
| 2529 | + $query = "SELECT spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_icao FROM spotter_output WHERE spotter_output.registration = :registration"; |
|
| 2530 | 2530 | |
| 2531 | 2531 | $sth = $this->db->prepare($query); |
| 2532 | 2532 | $sth->execute(array(':registration' => $registration)); |
@@ -2534,7 +2534,7 @@ discard block |
||
| 2534 | 2534 | $aircraft_array = array(); |
| 2535 | 2535 | $temp_array = array(); |
| 2536 | 2536 | |
| 2537 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2537 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2538 | 2538 | { |
| 2539 | 2539 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 2540 | 2540 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
@@ -2556,7 +2556,7 @@ discard block |
||
| 2556 | 2556 | */ |
| 2557 | 2557 | public function getAircraftOwnerByRegistration($registration) |
| 2558 | 2558 | { |
| 2559 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 2559 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 2560 | 2560 | $Connection = new Connection($this->db); |
| 2561 | 2561 | if ($Connection->tableExists('aircraft_owner')) { |
| 2562 | 2562 | $query = "SELECT aircraft_owner.base, aircraft_owner.owner, aircraft_owner.date_first_reg FROM aircraft_owner WHERE registration = :registration LIMIT 1"; |
@@ -2578,7 +2578,7 @@ discard block |
||
| 2578 | 2578 | public function getAllFlightsforSitemap() |
| 2579 | 2579 | { |
| 2580 | 2580 | //$query = "SELECT spotter_output.spotter_id, spotter_output.ident, spotter_output.airline_name, spotter_output.aircraft_name, spotter_output.aircraft_icao FROM spotter_output ORDER BY LIMIT "; |
| 2581 | - $query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0"; |
|
| 2581 | + $query = "SELECT spotter_output.spotter_id FROM spotter_output ORDER BY spotter_id DESC LIMIT 200 OFFSET 0"; |
|
| 2582 | 2582 | |
| 2583 | 2583 | $sth = $this->db->prepare($query); |
| 2584 | 2584 | $sth->execute(); |
@@ -2625,7 +2625,7 @@ discard block |
||
| 2625 | 2625 | $manufacturer_array = array(); |
| 2626 | 2626 | $temp_array = array(); |
| 2627 | 2627 | |
| 2628 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2628 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2629 | 2629 | { |
| 2630 | 2630 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
| 2631 | 2631 | |
@@ -2662,7 +2662,7 @@ discard block |
||
| 2662 | 2662 | $aircraft_array = array(); |
| 2663 | 2663 | $temp_array = array(); |
| 2664 | 2664 | |
| 2665 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2665 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2666 | 2666 | { |
| 2667 | 2667 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 2668 | 2668 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
@@ -2683,8 +2683,8 @@ discard block |
||
| 2683 | 2683 | */ |
| 2684 | 2684 | public function getAllAircraftRegistrations($filters = array()) |
| 2685 | 2685 | { |
| 2686 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2687 | - $query = "SELECT DISTINCT spotter_output.registration |
|
| 2686 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2687 | + $query = "SELECT DISTINCT spotter_output.registration |
|
| 2688 | 2688 | FROM spotter_output".$filter_query." spotter_output.registration <> '' |
| 2689 | 2689 | ORDER BY spotter_output.registration ASC"; |
| 2690 | 2690 | |
@@ -2694,7 +2694,7 @@ discard block |
||
| 2694 | 2694 | $aircraft_array = array(); |
| 2695 | 2695 | $temp_array = array(); |
| 2696 | 2696 | |
| 2697 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2697 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2698 | 2698 | { |
| 2699 | 2699 | $temp_array['registration'] = $row['registration']; |
| 2700 | 2700 | |
@@ -2711,11 +2711,11 @@ discard block |
||
| 2711 | 2711 | * @return Array list of source name |
| 2712 | 2712 | * |
| 2713 | 2713 | */ |
| 2714 | - public function getAllSourceName($type = '',$filters = array()) |
|
| 2714 | + public function getAllSourceName($type = '', $filters = array()) |
|
| 2715 | 2715 | { |
| 2716 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2716 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2717 | 2717 | $query_values = array(); |
| 2718 | - $query = "SELECT DISTINCT spotter_output.source_name |
|
| 2718 | + $query = "SELECT DISTINCT spotter_output.source_name |
|
| 2719 | 2719 | FROM spotter_output".$filter_query." spotter_output.source_name <> ''"; |
| 2720 | 2720 | if ($type != '') { |
| 2721 | 2721 | $query_values = array(':type' => $type); |
@@ -2730,7 +2730,7 @@ discard block |
||
| 2730 | 2730 | $source_array = array(); |
| 2731 | 2731 | $temp_array = array(); |
| 2732 | 2732 | |
| 2733 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2733 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2734 | 2734 | { |
| 2735 | 2735 | $temp_array['source_name'] = $row['source_name']; |
| 2736 | 2736 | $source_array[] = $temp_array; |
@@ -2746,11 +2746,11 @@ discard block |
||
| 2746 | 2746 | * @return Array list of airline names |
| 2747 | 2747 | * |
| 2748 | 2748 | */ |
| 2749 | - public function getAllAirlineNames($airline_type = '',$forsource = NULL,$filters = array()) |
|
| 2749 | + public function getAllAirlineNames($airline_type = '', $forsource = NULL, $filters = array()) |
|
| 2750 | 2750 | { |
| 2751 | - global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
|
| 2752 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2753 | - $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING); |
|
| 2751 | + global $globalAirlinesSource, $globalVATSIM, $globalIVAO; |
|
| 2752 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2753 | + $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING); |
|
| 2754 | 2754 | if ($airline_type == '' || $airline_type == 'all') { |
| 2755 | 2755 | /* |
| 2756 | 2756 | $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
@@ -2769,7 +2769,7 @@ discard block |
||
| 2769 | 2769 | $query_data = array(':forsource' => $forsource); |
| 2770 | 2770 | } |
| 2771 | 2771 | } else { |
| 2772 | - $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
|
| 2772 | + $query = "SELECT DISTINCT spotter_output.airline_icao AS airline_icao, spotter_output.airline_name AS airline_name, spotter_output.airline_type AS airline_type |
|
| 2773 | 2773 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
| 2774 | 2774 | AND spotter_output.airline_type = :airline_type |
| 2775 | 2775 | ORDER BY spotter_output.airline_icao ASC"; |
@@ -2782,7 +2782,7 @@ discard block |
||
| 2782 | 2782 | $airline_array = array(); |
| 2783 | 2783 | $temp_array = array(); |
| 2784 | 2784 | |
| 2785 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2785 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2786 | 2786 | { |
| 2787 | 2787 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 2788 | 2788 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -2799,10 +2799,10 @@ discard block |
||
| 2799 | 2799 | * @return Array list of alliance names |
| 2800 | 2800 | * |
| 2801 | 2801 | */ |
| 2802 | - public function getAllAllianceNames($forsource = NULL,$filters = array()) |
|
| 2802 | + public function getAllAllianceNames($forsource = NULL, $filters = array()) |
|
| 2803 | 2803 | { |
| 2804 | - global $globalAirlinesSource,$globalVATSIM, $globalIVAO; |
|
| 2805 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2804 | + global $globalAirlinesSource, $globalVATSIM, $globalIVAO; |
|
| 2805 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2806 | 2806 | if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $forsource = $globalAirlinesSource; |
| 2807 | 2807 | elseif (isset($globalVATSIM) && $globalVATSIM) $forsource = 'vatsim'; |
| 2808 | 2808 | elseif (isset($globalIVAO) && $globalIVAO) $forsource = 'ivao'; |
@@ -2830,8 +2830,8 @@ discard block |
||
| 2830 | 2830 | */ |
| 2831 | 2831 | public function getAllAirlineCountries($filters = array()) |
| 2832 | 2832 | { |
| 2833 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2834 | - $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
|
| 2833 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2834 | + $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
|
| 2835 | 2835 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' |
| 2836 | 2836 | ORDER BY spotter_output.airline_country ASC"; |
| 2837 | 2837 | |
@@ -2842,7 +2842,7 @@ discard block |
||
| 2842 | 2842 | $airline_array = array(); |
| 2843 | 2843 | $temp_array = array(); |
| 2844 | 2844 | |
| 2845 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2845 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2846 | 2846 | { |
| 2847 | 2847 | $temp_array['airline_country'] = $row['airline_country']; |
| 2848 | 2848 | |
@@ -2862,9 +2862,9 @@ discard block |
||
| 2862 | 2862 | */ |
| 2863 | 2863 | public function getAllAirportNames($filters = array()) |
| 2864 | 2864 | { |
| 2865 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2865 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2866 | 2866 | $airport_array = array(); |
| 2867 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country |
|
| 2867 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao AS airport_icao, spotter_output.departure_airport_name AS airport_name, spotter_output.departure_airport_city AS airport_city, spotter_output.departure_airport_country AS airport_country |
|
| 2868 | 2868 | FROM spotter_output".$filter_query." spotter_output.departure_airport_icao <> '' AND spotter_output.departure_airport_icao <> 'NA' |
| 2869 | 2869 | ORDER BY spotter_output.departure_airport_city ASC"; |
| 2870 | 2870 | |
@@ -2873,7 +2873,7 @@ discard block |
||
| 2873 | 2873 | $sth->execute(); |
| 2874 | 2874 | |
| 2875 | 2875 | $temp_array = array(); |
| 2876 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2876 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2877 | 2877 | { |
| 2878 | 2878 | $temp_array['airport_icao'] = $row['airport_icao']; |
| 2879 | 2879 | $temp_array['airport_name'] = $row['airport_name']; |
@@ -2883,14 +2883,14 @@ discard block |
||
| 2883 | 2883 | $airport_array[$row['airport_city'].",".$row['airport_name']] = $temp_array; |
| 2884 | 2884 | } |
| 2885 | 2885 | |
| 2886 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country |
|
| 2886 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao AS airport_icao, spotter_output.arrival_airport_name AS airport_name, spotter_output.arrival_airport_city AS airport_city, spotter_output.arrival_airport_country AS airport_country |
|
| 2887 | 2887 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' |
| 2888 | 2888 | ORDER BY spotter_output.arrival_airport_city ASC"; |
| 2889 | 2889 | |
| 2890 | 2890 | $sth = $this->db->prepare($query); |
| 2891 | 2891 | $sth->execute(); |
| 2892 | 2892 | |
| 2893 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2893 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2894 | 2894 | { |
| 2895 | 2895 | // if ($airport_array[$row['airport_city'].",".$row['airport_name']]['airport_icao'] != $row['airport_icao']) |
| 2896 | 2896 | // { |
@@ -2914,8 +2914,8 @@ discard block |
||
| 2914 | 2914 | */ |
| 2915 | 2915 | public function getAllOwnerNames($filters = array()) |
| 2916 | 2916 | { |
| 2917 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2918 | - $query = "SELECT DISTINCT spotter_output.owner_name |
|
| 2917 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2918 | + $query = "SELECT DISTINCT spotter_output.owner_name |
|
| 2919 | 2919 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' |
| 2920 | 2920 | ORDER BY spotter_output.owner_name ASC"; |
| 2921 | 2921 | |
@@ -2932,8 +2932,8 @@ discard block |
||
| 2932 | 2932 | */ |
| 2933 | 2933 | public function getAllPilotNames($filters = array()) |
| 2934 | 2934 | { |
| 2935 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2936 | - $query = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id |
|
| 2935 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2936 | + $query = "SELECT DISTINCT spotter_output.pilot_name, spotter_output.pilot_id |
|
| 2937 | 2937 | FROM spotter_output".$filter_query." spotter_output.pilot_name <> '' |
| 2938 | 2938 | ORDER BY spotter_output.pilot_name ASC"; |
| 2939 | 2939 | |
@@ -2966,21 +2966,21 @@ discard block |
||
| 2966 | 2966 | |
| 2967 | 2967 | $temp_array = array(); |
| 2968 | 2968 | |
| 2969 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2969 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2970 | 2970 | { |
| 2971 | 2971 | $temp_array['airport_country'] = $row['airport_country']; |
| 2972 | 2972 | |
| 2973 | 2973 | $airport_array[$row['airport_country']] = $temp_array; |
| 2974 | 2974 | } |
| 2975 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 2976 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
|
| 2975 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 2976 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
|
| 2977 | 2977 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' |
| 2978 | 2978 | ORDER BY spotter_output.arrival_airport_country ASC"; |
| 2979 | 2979 | |
| 2980 | 2980 | $sth = $this->db->prepare($query); |
| 2981 | 2981 | $sth->execute(); |
| 2982 | 2982 | |
| 2983 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2983 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 2984 | 2984 | { |
| 2985 | 2985 | if (isset($airport_array[$row['airport_country']]['airport_country']) && $airport_array[$row['airport_country']]['airport_country'] != $row['airport_country']) |
| 2986 | 2986 | { |
@@ -3003,9 +3003,9 @@ discard block |
||
| 3003 | 3003 | */ |
| 3004 | 3004 | public function getAllCountries($filters = array()) |
| 3005 | 3005 | { |
| 3006 | - $Connection= new Connection($this->db); |
|
| 3006 | + $Connection = new Connection($this->db); |
|
| 3007 | 3007 | if ($Connection->tableExists('countries')) { |
| 3008 | - $query = "SELECT countries.name AS airport_country |
|
| 3008 | + $query = "SELECT countries.name AS airport_country |
|
| 3009 | 3009 | FROM countries |
| 3010 | 3010 | ORDER BY countries.name ASC"; |
| 3011 | 3011 | $sth = $this->db->prepare($query); |
@@ -3014,14 +3014,14 @@ discard block |
||
| 3014 | 3014 | $temp_array = array(); |
| 3015 | 3015 | $country_array = array(); |
| 3016 | 3016 | |
| 3017 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3017 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3018 | 3018 | { |
| 3019 | 3019 | $temp_array['country'] = $row['airport_country']; |
| 3020 | 3020 | $country_array[$row['airport_country']] = $temp_array; |
| 3021 | 3021 | } |
| 3022 | 3022 | } else { |
| 3023 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 3024 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
|
| 3023 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 3024 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country AS airport_country |
|
| 3025 | 3025 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' |
| 3026 | 3026 | ORDER BY spotter_output.departure_airport_country ASC"; |
| 3027 | 3027 | |
@@ -3030,20 +3030,20 @@ discard block |
||
| 3030 | 3030 | |
| 3031 | 3031 | $temp_array = array(); |
| 3032 | 3032 | $country_array = array(); |
| 3033 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3033 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3034 | 3034 | { |
| 3035 | 3035 | $temp_array['country'] = $row['airport_country']; |
| 3036 | 3036 | $country_array[$row['airport_country']] = $temp_array; |
| 3037 | 3037 | } |
| 3038 | 3038 | |
| 3039 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
|
| 3039 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country AS airport_country |
|
| 3040 | 3040 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' |
| 3041 | 3041 | ORDER BY spotter_output.arrival_airport_country ASC"; |
| 3042 | 3042 | |
| 3043 | 3043 | $sth = $this->db->prepare($query); |
| 3044 | 3044 | $sth->execute(); |
| 3045 | 3045 | |
| 3046 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3046 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3047 | 3047 | { |
| 3048 | 3048 | if ($country_array[$row['airport_country']]['country'] != $row['airport_country']) |
| 3049 | 3049 | { |
@@ -3053,14 +3053,14 @@ discard block |
||
| 3053 | 3053 | } |
| 3054 | 3054 | } |
| 3055 | 3055 | |
| 3056 | - $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
|
| 3056 | + $query = "SELECT DISTINCT spotter_output.airline_country AS airline_country |
|
| 3057 | 3057 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' |
| 3058 | 3058 | ORDER BY spotter_output.airline_country ASC"; |
| 3059 | 3059 | |
| 3060 | 3060 | $sth = $this->db->prepare($query); |
| 3061 | 3061 | $sth->execute(); |
| 3062 | 3062 | |
| 3063 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3063 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3064 | 3064 | { |
| 3065 | 3065 | if (isset($country_array[$row['airline_country']]['country']) && $country_array[$row['airline_country']]['country'] != $row['airline_country']) |
| 3066 | 3066 | { |
@@ -3084,8 +3084,8 @@ discard block |
||
| 3084 | 3084 | */ |
| 3085 | 3085 | public function getAllIdents($filters = array()) |
| 3086 | 3086 | { |
| 3087 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 3088 | - $query = "SELECT DISTINCT spotter_output.ident |
|
| 3087 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 3088 | + $query = "SELECT DISTINCT spotter_output.ident |
|
| 3089 | 3089 | FROM spotter_output".$filter_query." spotter_output.ident <> '' |
| 3090 | 3090 | ORDER BY spotter_output.date ASC LIMIT 700 OFFSET 0"; |
| 3091 | 3091 | |
@@ -3095,7 +3095,7 @@ discard block |
||
| 3095 | 3095 | $ident_array = array(); |
| 3096 | 3096 | $temp_array = array(); |
| 3097 | 3097 | |
| 3098 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3098 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3099 | 3099 | { |
| 3100 | 3100 | $temp_array['ident'] = $row['ident']; |
| 3101 | 3101 | $ident_array[] = $temp_array; |
@@ -3109,9 +3109,9 @@ discard block |
||
| 3109 | 3109 | * @return Array number, icao, name and city of airports |
| 3110 | 3110 | */ |
| 3111 | 3111 | |
| 3112 | - public function getLast7DaysAirportsDeparture($airport_icao = '',$filters = array()) { |
|
| 3112 | + public function getLast7DaysAirportsDeparture($airport_icao = '', $filters = array()) { |
|
| 3113 | 3113 | global $globalTimezone, $globalDBdriver; |
| 3114 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 3114 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 3115 | 3115 | if ($globalTimezone != '') { |
| 3116 | 3116 | date_default_timezone_set($globalTimezone); |
| 3117 | 3117 | $datetime = new DateTime(); |
@@ -3176,7 +3176,7 @@ discard block |
||
| 3176 | 3176 | |
| 3177 | 3177 | public function getLast7DaysDetectedAirportsDeparture($airport_icao = '', $filters = array()) { |
| 3178 | 3178 | global $globalTimezone, $globalDBdriver; |
| 3179 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 3179 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 3180 | 3180 | if ($globalTimezone != '') { |
| 3181 | 3181 | date_default_timezone_set($globalTimezone); |
| 3182 | 3182 | $datetime = new DateTime(); |
@@ -3260,7 +3260,7 @@ discard block |
||
| 3260 | 3260 | |
| 3261 | 3261 | public function getLast7DaysAirportsArrival($airport_icao = '', $filters = array()) { |
| 3262 | 3262 | global $globalTimezone, $globalDBdriver; |
| 3263 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 3263 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 3264 | 3264 | if ($globalTimezone != '') { |
| 3265 | 3265 | date_default_timezone_set($globalTimezone); |
| 3266 | 3266 | $datetime = new DateTime(); |
@@ -3293,9 +3293,9 @@ discard block |
||
| 3293 | 3293 | * @return Array number, icao, name and city of airports |
| 3294 | 3294 | */ |
| 3295 | 3295 | |
| 3296 | - public function getLast7DaysDetectedAirportsArrival($airport_icao = '',$filters = array()) { |
|
| 3296 | + public function getLast7DaysDetectedAirportsArrival($airport_icao = '', $filters = array()) { |
|
| 3297 | 3297 | global $globalTimezone, $globalDBdriver; |
| 3298 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 3298 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 3299 | 3299 | if ($globalTimezone != '') { |
| 3300 | 3300 | date_default_timezone_set($globalTimezone); |
| 3301 | 3301 | $datetime = new DateTime(); |
@@ -3427,12 +3427,12 @@ discard block |
||
| 3427 | 3427 | } else $offset = '+00:00'; |
| 3428 | 3428 | |
| 3429 | 3429 | if ($globalDBdriver == 'mysql') { |
| 3430 | - $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
|
| 3430 | + $query = "SELECT DISTINCT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) as date |
|
| 3431 | 3431 | FROM spotter_output |
| 3432 | 3432 | WHERE spotter_output.date <> '' |
| 3433 | 3433 | ORDER BY spotter_output.date ASC LIMIT 0,200"; |
| 3434 | 3434 | } else { |
| 3435 | - $query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 3435 | + $query = "SELECT DISTINCT to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date |
|
| 3436 | 3436 | FROM spotter_output |
| 3437 | 3437 | WHERE spotter_output.date <> '' |
| 3438 | 3438 | ORDER BY spotter_output.date ASC LIMIT 0,200"; |
@@ -3444,7 +3444,7 @@ discard block |
||
| 3444 | 3444 | $date_array = array(); |
| 3445 | 3445 | $temp_array = array(); |
| 3446 | 3446 | |
| 3447 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3447 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3448 | 3448 | { |
| 3449 | 3449 | $temp_array['date'] = $row['date']; |
| 3450 | 3450 | |
@@ -3464,7 +3464,7 @@ discard block |
||
| 3464 | 3464 | */ |
| 3465 | 3465 | public function getAllRoutes() |
| 3466 | 3466 | { |
| 3467 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao |
|
| 3467 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao |
|
| 3468 | 3468 | FROM spotter_output |
| 3469 | 3469 | WHERE spotter_output.ident <> '' |
| 3470 | 3470 | GROUP BY route |
@@ -3475,7 +3475,7 @@ discard block |
||
| 3475 | 3475 | |
| 3476 | 3476 | $routes_array = array(); |
| 3477 | 3477 | $temp_array = array(); |
| 3478 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3478 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3479 | 3479 | { |
| 3480 | 3480 | $temp_array['route'] = $row['route']; |
| 3481 | 3481 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -3494,21 +3494,21 @@ discard block |
||
| 3494 | 3494 | * @return String success or false |
| 3495 | 3495 | * |
| 3496 | 3496 | */ |
| 3497 | - public function updateIdentSpotterData($flightaware_id = '', $ident = '',$fromsource = NULL) |
|
| 3497 | + public function updateIdentSpotterData($flightaware_id = '', $ident = '', $fromsource = NULL) |
|
| 3498 | 3498 | { |
| 3499 | 3499 | if (!is_numeric(substr($ident, 0, 3))) |
| 3500 | 3500 | { |
| 3501 | 3501 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
| 3502 | - $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
|
| 3502 | + $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource); |
|
| 3503 | 3503 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
| 3504 | - $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
|
| 3504 | + $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource); |
|
| 3505 | 3505 | } else { |
| 3506 | 3506 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 3507 | 3507 | } |
| 3508 | 3508 | if (count($airline_array) == 0) { |
| 3509 | 3509 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 3510 | 3510 | } |
| 3511 | - if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
|
| 3511 | + if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") { |
|
| 3512 | 3512 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 3513 | 3513 | } |
| 3514 | 3514 | } else { |
@@ -3521,7 +3521,7 @@ discard block |
||
| 3521 | 3521 | |
| 3522 | 3522 | |
| 3523 | 3523 | $query = 'UPDATE spotter_output SET ident = :ident, airline_name = :airline_name, airline_icao = :airline_icao, airline_country = :airline_country, airline_type = :airline_type WHERE flightaware_id = :flightaware_id'; |
| 3524 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type); |
|
| 3524 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type); |
|
| 3525 | 3525 | |
| 3526 | 3526 | try { |
| 3527 | 3527 | $sth = $this->db->prepare($query); |
@@ -3542,11 +3542,11 @@ discard block |
||
| 3542 | 3542 | * @return String success or false |
| 3543 | 3543 | * |
| 3544 | 3544 | */ |
| 3545 | - public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '',$arrival_airport_time = '') |
|
| 3545 | + public function updateLatestSpotterData($flightaware_id = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $ground = false, $groundspeed = NULL, $date = '', $arrival_airport_icao = '', $arrival_airport_time = '') |
|
| 3546 | 3546 | { |
| 3547 | 3547 | if ($groundspeed == '') $groundspeed = NULL; |
| 3548 | 3548 | $query = 'UPDATE spotter_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_altitude = :last_altitude, last_ground = :last_ground, last_seen = :last_seen, real_arrival_airport_icao = :real_arrival_airport_icao, real_arrival_airport_time = :real_arrival_airport_time, last_ground_speed = :last_ground_speed WHERE flightaware_id = :flightaware_id'; |
| 3549 | - $query_values = array(':flightaware_id' => $flightaware_id,':real_arrival_airport_icao' => $arrival_airport_icao,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_altitude' => $altitude,':last_ground_speed' => $groundspeed,':last_seen' => $date,':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); |
|
| 3549 | + $query_values = array(':flightaware_id' => $flightaware_id, ':real_arrival_airport_icao' => $arrival_airport_icao, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_altitude' => $altitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':real_arrival_airport_time' => $arrival_airport_time, ':last_ground' => $ground, ':ident' => $ident); |
|
| 3550 | 3550 | |
| 3551 | 3551 | try { |
| 3552 | 3552 | $sth = $this->db->prepare($query); |
@@ -3586,7 +3586,7 @@ discard block |
||
| 3586 | 3586 | * @param String $verticalrate vertival rate of flight |
| 3587 | 3587 | * @return String success or false |
| 3588 | 3588 | */ |
| 3589 | - public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '',$squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false,$format_source = '', $source_name = '') |
|
| 3589 | + public function addSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $highlight = '', $ModeS = '', $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $ground = false, $format_source = '', $source_name = '') |
|
| 3590 | 3590 | { |
| 3591 | 3591 | global $globalURL, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalDebugTimeElapsed, $globalAirlinesSource, $globalVAM; |
| 3592 | 3592 | |
@@ -3610,13 +3610,13 @@ discard block |
||
| 3610 | 3610 | if ($ModeS != '') { |
| 3611 | 3611 | $timeelapsed = microtime(true); |
| 3612 | 3612 | $registration = $this->getAircraftRegistrationBymodeS($ModeS); |
| 3613 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3613 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3614 | 3614 | } else { |
| 3615 | - $myhex = explode('-',$flightaware_id); |
|
| 3615 | + $myhex = explode('-', $flightaware_id); |
|
| 3616 | 3616 | if (count($myhex) > 0) { |
| 3617 | 3617 | $timeelapsed = microtime(true); |
| 3618 | 3618 | $registration = $this->getAircraftRegistrationBymodeS($myhex[0]); |
| 3619 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3619 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftRegistrationBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3620 | 3620 | } |
| 3621 | 3621 | } |
| 3622 | 3622 | } |
@@ -3638,24 +3638,24 @@ discard block |
||
| 3638 | 3638 | { |
| 3639 | 3639 | $timeelapsed = microtime(true); |
| 3640 | 3640 | if (is_numeric(substr(substr($ident, 0, 3), -1, 1))) { |
| 3641 | - $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2),$fromsource); |
|
| 3641 | + $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 2), $fromsource); |
|
| 3642 | 3642 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
| 3643 | - $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3),$fromsource); |
|
| 3643 | + $airline_array = $this->getAllAirlineInfo(substr($ident, 0, 3), $fromsource); |
|
| 3644 | 3644 | } else { |
| 3645 | 3645 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 3646 | 3646 | } |
| 3647 | 3647 | if (count($airline_array) == 0) { |
| 3648 | 3648 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 3649 | 3649 | } |
| 3650 | - if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == ""){ |
|
| 3650 | + if (!isset($airline_array[0]['icao']) || $airline_array[0]['icao'] == "") { |
|
| 3651 | 3651 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 3652 | 3652 | } |
| 3653 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3653 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3654 | 3654 | |
| 3655 | 3655 | } else { |
| 3656 | 3656 | $timeelapsed = microtime(true); |
| 3657 | 3657 | $airline_array = $this->getAllAirlineInfo("NA"); |
| 3658 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3658 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAirlineInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3659 | 3659 | } |
| 3660 | 3660 | } |
| 3661 | 3661 | } else $airline_array = array(); |
@@ -3672,27 +3672,27 @@ discard block |
||
| 3672 | 3672 | { |
| 3673 | 3673 | $timeelapsed = microtime(true); |
| 3674 | 3674 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
| 3675 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3675 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3676 | 3676 | } else { |
| 3677 | 3677 | $timeelapsed = microtime(true); |
| 3678 | 3678 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
| 3679 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3679 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3680 | 3680 | } |
| 3681 | 3681 | } |
| 3682 | 3682 | } else { |
| 3683 | 3683 | if ($ModeS != '') { |
| 3684 | 3684 | $timeelapsed = microtime(true); |
| 3685 | 3685 | $aircraft_icao = $this->getAllAircraftType($ModeS); |
| 3686 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3686 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAircraftType : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3687 | 3687 | if ($aircraft_icao == "" || $aircraft_icao == "XXXX") |
| 3688 | 3688 | { |
| 3689 | 3689 | $timeelapsed = microtime(true); |
| 3690 | 3690 | $aircraft_array = $this->getAllAircraftInfo("NA"); |
| 3691 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3691 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo(NA) : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3692 | 3692 | } else { |
| 3693 | 3693 | $timeelapsed = microtime(true); |
| 3694 | 3694 | $aircraft_array = $this->getAllAircraftInfo($aircraft_icao); |
| 3695 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3695 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3696 | 3696 | } |
| 3697 | 3697 | } |
| 3698 | 3698 | } |
@@ -3708,7 +3708,7 @@ discard block |
||
| 3708 | 3708 | } else { |
| 3709 | 3709 | $timeelapsed = microtime(true); |
| 3710 | 3710 | $departure_airport_array = $this->getAllAirportInfo($departure_airport_icao); |
| 3711 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3711 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3712 | 3712 | } |
| 3713 | 3713 | } |
| 3714 | 3714 | |
@@ -3723,7 +3723,7 @@ discard block |
||
| 3723 | 3723 | } else { |
| 3724 | 3724 | $timeelapsed = microtime(true); |
| 3725 | 3725 | $arrival_airport_array = $this->getAllAirportInfo($arrival_airport_icao); |
| 3726 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3726 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAllAirportInfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3727 | 3727 | } |
| 3728 | 3728 | } |
| 3729 | 3729 | |
@@ -3776,7 +3776,7 @@ discard block |
||
| 3776 | 3776 | } |
| 3777 | 3777 | |
| 3778 | 3778 | |
| 3779 | - if ($date == "" || strtotime($date) < time()-20*60) |
|
| 3779 | + if ($date == "" || strtotime($date) < time() - 20*60) |
|
| 3780 | 3780 | { |
| 3781 | 3781 | $date = date("Y-m-d H:i:s", time()); |
| 3782 | 3782 | } |
@@ -3786,7 +3786,7 @@ discard block |
||
| 3786 | 3786 | { |
| 3787 | 3787 | $timeelapsed = microtime(true); |
| 3788 | 3788 | $image_array = $Image->getSpotterImage($registration); |
| 3789 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3789 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getSpotterImage : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3790 | 3790 | if (!isset($image_array[0]['registration'])) |
| 3791 | 3791 | { |
| 3792 | 3792 | //echo "Add image !!!! \n"; |
@@ -3794,7 +3794,7 @@ discard block |
||
| 3794 | 3794 | } |
| 3795 | 3795 | $timeelapsed = microtime(true); |
| 3796 | 3796 | $owner_info = $this->getAircraftOwnerByRegistration($registration); |
| 3797 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3797 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftOwnerByRegistration : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3798 | 3798 | if ($owner_info['owner'] != '') $aircraft_owner = ucwords(strtolower($owner_info['owner'])); |
| 3799 | 3799 | } |
| 3800 | 3800 | |
@@ -3802,33 +3802,33 @@ discard block |
||
| 3802 | 3802 | { |
| 3803 | 3803 | if (isset($airline_array[0]['icao'])) $airline_icao = $airline_array[0]['icao']; |
| 3804 | 3804 | else $airline_icao = ''; |
| 3805 | - $image_array = $Image->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 3805 | + $image_array = $Image->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
| 3806 | 3806 | if (!isset($image_array[0]['registration'])) |
| 3807 | 3807 | { |
| 3808 | 3808 | //echo "Add image !!!! \n"; |
| 3809 | - $Image->addSpotterImage('',$aircraft_icao,$airline_icao); |
|
| 3809 | + $Image->addSpotterImage('', $aircraft_icao, $airline_icao); |
|
| 3810 | 3810 | } |
| 3811 | 3811 | } |
| 3812 | 3812 | |
| 3813 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 3814 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 3815 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 3816 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 3817 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 3818 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 3819 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 3820 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 3821 | - $waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING); |
|
| 3822 | - $altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 3823 | - $heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT); |
|
| 3824 | - $groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 3825 | - $squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT); |
|
| 3826 | - $route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING); |
|
| 3827 | - $ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING); |
|
| 3828 | - $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING); |
|
| 3829 | - $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING); |
|
| 3830 | - $format_source = filter_var($format_source,FILTER_SANITIZE_STRING); |
|
| 3831 | - $verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT); |
|
| 3813 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 3814 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 3815 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 3816 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 3817 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 3818 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 3819 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 3820 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 3821 | + $waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING); |
|
| 3822 | + $altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 3823 | + $heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT); |
|
| 3824 | + $groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 3825 | + $squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT); |
|
| 3826 | + $route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING); |
|
| 3827 | + $ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING); |
|
| 3828 | + $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING); |
|
| 3829 | + $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING); |
|
| 3830 | + $format_source = filter_var($format_source, FILTER_SANITIZE_STRING); |
|
| 3831 | + $verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT); |
|
| 3832 | 3832 | |
| 3833 | 3833 | if (count($airline_array) == 0) |
| 3834 | 3834 | { |
@@ -3856,7 +3856,7 @@ discard block |
||
| 3856 | 3856 | if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0; |
| 3857 | 3857 | if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0; |
| 3858 | 3858 | if (!isset($aircraft_owner)) $aircraft_owner = NULL; |
| 3859 | - $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) |
|
| 3859 | + $query = "INSERT INTO spotter_output (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop,highlight,ModeS, pilot_id, pilot_name, verticalrate, owner_name, ground, format_source, source_name) |
|
| 3860 | 3860 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name,:departure_airport_city,:departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date, :departure_airport_time, :arrival_airport_time, :squawk, :route_stop, :highlight, :ModeS, :pilot_id, :pilot_name, :verticalrate, :owner_name,:ground, :format_source, :source_name)"; |
| 3861 | 3861 | |
| 3862 | 3862 | $airline_name = $airline_array[0]['name']; |
@@ -3866,7 +3866,7 @@ discard block |
||
| 3866 | 3866 | if ($airline_type == '') { |
| 3867 | 3867 | $timeelapsed = microtime(true); |
| 3868 | 3868 | $airline_type = $this->getAircraftTypeBymodeS($ModeS); |
| 3869 | - if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true)-$timeelapsed,2).'s'."\n"; |
|
| 3869 | + if ($globalDebugTimeElapsed) echo 'ADD SPOTTER DATA : Time elapsed for getAircraftTypeBymodes : '.round(microtime(true) - $timeelapsed, 2).'s'."\n"; |
|
| 3870 | 3870 | } |
| 3871 | 3871 | if ($airline_type == null) $airline_type = ''; |
| 3872 | 3872 | $aircraft_type = $aircraft_array[0]['type']; |
@@ -3878,7 +3878,7 @@ discard block |
||
| 3878 | 3878 | $arrival_airport_name = $arrival_airport_array[0]['name']; |
| 3879 | 3879 | $arrival_airport_city = $arrival_airport_array[0]['city']; |
| 3880 | 3880 | $arrival_airport_country = $arrival_airport_array[0]['country']; |
| 3881 | - $query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date,':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name); |
|
| 3881 | + $query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':highlight' => $highlight, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':owner_name' => $aircraft_owner, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name); |
|
| 3882 | 3882 | |
| 3883 | 3883 | try { |
| 3884 | 3884 | |
@@ -3904,13 +3904,13 @@ discard block |
||
| 3904 | 3904 | { |
| 3905 | 3905 | global $globalDBdriver, $globalTimezone; |
| 3906 | 3906 | if ($globalDBdriver == 'mysql') { |
| 3907 | - $query = "SELECT spotter_output.ident FROM spotter_output |
|
| 3907 | + $query = "SELECT spotter_output.ident FROM spotter_output |
|
| 3908 | 3908 | WHERE spotter_output.ident = :ident |
| 3909 | 3909 | AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) |
| 3910 | 3910 | AND spotter_output.date < UTC_TIMESTAMP()"; |
| 3911 | 3911 | $query_data = array(':ident' => $ident); |
| 3912 | 3912 | } else { |
| 3913 | - $query = "SELECT spotter_output.ident FROM spotter_output |
|
| 3913 | + $query = "SELECT spotter_output.ident FROM spotter_output |
|
| 3914 | 3914 | WHERE spotter_output.ident = :ident |
| 3915 | 3915 | AND spotter_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS' |
| 3916 | 3916 | AND spotter_output.date < now() AT TIME ZONE 'UTC'"; |
@@ -3919,8 +3919,8 @@ discard block |
||
| 3919 | 3919 | |
| 3920 | 3920 | $sth = $this->db->prepare($query); |
| 3921 | 3921 | $sth->execute($query_data); |
| 3922 | - $ident_result=''; |
|
| 3923 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3922 | + $ident_result = ''; |
|
| 3923 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 3924 | 3924 | { |
| 3925 | 3925 | $ident_result = $row['ident']; |
| 3926 | 3926 | } |
@@ -3946,8 +3946,8 @@ discard block |
||
| 3946 | 3946 | return false; |
| 3947 | 3947 | } else { |
| 3948 | 3948 | $q_array = explode(" ", $q); |
| 3949 | - foreach ($q_array as $q_item){ |
|
| 3950 | - $q_item = filter_var($q_item,FILTER_SANITIZE_STRING); |
|
| 3949 | + foreach ($q_array as $q_item) { |
|
| 3950 | + $q_item = filter_var($q_item, FILTER_SANITIZE_STRING); |
|
| 3951 | 3951 | $additional_query .= " AND ("; |
| 3952 | 3952 | $additional_query .= "(spotter_output.aircraft_icao like '%".$q_item."%') OR "; |
| 3953 | 3953 | $additional_query .= "(spotter_output.aircraft_name like '%".$q_item."%') OR "; |
@@ -3962,11 +3962,11 @@ discard block |
||
| 3962 | 3962 | } |
| 3963 | 3963 | } |
| 3964 | 3964 | if ($globalDBdriver == 'mysql') { |
| 3965 | - $query = "SELECT spotter_output.* FROM spotter_output |
|
| 3965 | + $query = "SELECT spotter_output.* FROM spotter_output |
|
| 3966 | 3966 | WHERE spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." |
| 3967 | 3967 | AND spotter_output.date < UTC_TIMESTAMP()"; |
| 3968 | 3968 | } else { |
| 3969 | - $query = "SELECT spotter_output.* FROM spotter_output |
|
| 3969 | + $query = "SELECT spotter_output.* FROM spotter_output |
|
| 3970 | 3970 | WHERE spotter_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." |
| 3971 | 3971 | AND spotter_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'"; |
| 3972 | 3972 | } |
@@ -3983,11 +3983,11 @@ discard block |
||
| 3983 | 3983 | * @return Array the airline list |
| 3984 | 3984 | * |
| 3985 | 3985 | */ |
| 3986 | - public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(), $year = '', $month = '', $day = '') |
|
| 3986 | + public function countAllAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 3987 | 3987 | { |
| 3988 | 3988 | global $globalDBdriver; |
| 3989 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 3990 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 3989 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 3990 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 3991 | 3991 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.airline_icao <> 'NA'"; |
| 3992 | 3992 | if ($olderthanmonths > 0) { |
| 3993 | 3993 | if ($globalDBdriver == 'mysql') { |
@@ -4007,28 +4007,28 @@ discard block |
||
| 4007 | 4007 | if ($year != '') { |
| 4008 | 4008 | if ($globalDBdriver == 'mysql') { |
| 4009 | 4009 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 4010 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4010 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4011 | 4011 | } else { |
| 4012 | 4012 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 4013 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4013 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4014 | 4014 | } |
| 4015 | 4015 | } |
| 4016 | 4016 | if ($month != '') { |
| 4017 | 4017 | if ($globalDBdriver == 'mysql') { |
| 4018 | 4018 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 4019 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4019 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4020 | 4020 | } else { |
| 4021 | 4021 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 4022 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4022 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4023 | 4023 | } |
| 4024 | 4024 | } |
| 4025 | 4025 | if ($day != '') { |
| 4026 | 4026 | if ($globalDBdriver == 'mysql') { |
| 4027 | 4027 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 4028 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4028 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4029 | 4029 | } else { |
| 4030 | 4030 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 4031 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4031 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4032 | 4032 | } |
| 4033 | 4033 | } |
| 4034 | 4034 | $query .= " GROUP BY spotter_output.airline_name,spotter_output.airline_icao, spotter_output.airline_country ORDER BY airline_count DESC"; |
@@ -4038,7 +4038,7 @@ discard block |
||
| 4038 | 4038 | $sth->execute($query_values); |
| 4039 | 4039 | $airline_array = array(); |
| 4040 | 4040 | $temp_array = array(); |
| 4041 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4041 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4042 | 4042 | { |
| 4043 | 4043 | $temp_array['airline_name'] = $row['airline_name']; |
| 4044 | 4044 | $temp_array['airline_icao'] = $row['airline_icao']; |
@@ -4055,11 +4055,11 @@ discard block |
||
| 4055 | 4055 | * @return Array the pilots list |
| 4056 | 4056 | * |
| 4057 | 4057 | */ |
| 4058 | - public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '',$day = '') |
|
| 4058 | + public function countAllPilots($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 4059 | 4059 | { |
| 4060 | 4060 | global $globalDBdriver; |
| 4061 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4062 | - $query = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source |
|
| 4061 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4062 | + $query = "SELECT DISTINCT spotter_output.pilot_id, s.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source |
|
| 4063 | 4063 | FROM spotter_output LEFT JOIN (SELECT DISTINCT pilot_id, pilot_name, max(date) as date FROM spotter_output GROUP BY pilot_id, pilot_name) s ON s.pilot_id = spotter_output.pilot_id".$filter_query." spotter_output.pilot_id <> ''"; |
| 4064 | 4064 | if ($olderthanmonths > 0) { |
| 4065 | 4065 | if ($globalDBdriver == 'mysql') { |
@@ -4079,28 +4079,28 @@ discard block |
||
| 4079 | 4079 | if ($year != '') { |
| 4080 | 4080 | if ($globalDBdriver == 'mysql') { |
| 4081 | 4081 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 4082 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4082 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4083 | 4083 | } else { |
| 4084 | 4084 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 4085 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4085 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4086 | 4086 | } |
| 4087 | 4087 | } |
| 4088 | 4088 | if ($month != '') { |
| 4089 | 4089 | if ($globalDBdriver == 'mysql') { |
| 4090 | 4090 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 4091 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4091 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4092 | 4092 | } else { |
| 4093 | 4093 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 4094 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4094 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4095 | 4095 | } |
| 4096 | 4096 | } |
| 4097 | 4097 | if ($day != '') { |
| 4098 | 4098 | if ($globalDBdriver == 'mysql') { |
| 4099 | 4099 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 4100 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4100 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4101 | 4101 | } else { |
| 4102 | 4102 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 4103 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4103 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4104 | 4104 | } |
| 4105 | 4105 | } |
| 4106 | 4106 | |
@@ -4112,7 +4112,7 @@ discard block |
||
| 4112 | 4112 | $sth->execute($query_values); |
| 4113 | 4113 | $airline_array = array(); |
| 4114 | 4114 | $temp_array = array(); |
| 4115 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4115 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4116 | 4116 | { |
| 4117 | 4117 | $temp_array['pilot_name'] = $row['pilot_name']; |
| 4118 | 4118 | $temp_array['pilot_id'] = $row['pilot_id']; |
@@ -4132,7 +4132,7 @@ discard block |
||
| 4132 | 4132 | public function countAllPilotsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '') |
| 4133 | 4133 | { |
| 4134 | 4134 | global $globalDBdriver; |
| 4135 | - $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source |
|
| 4135 | + $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.pilot_id, spotter_output.pilot_name, COUNT(spotter_output.pilot_id) AS pilot_count, spotter_output.format_source |
|
| 4136 | 4136 | FROM spotter_output WHERE spotter_output.pilot_id <> '' "; |
| 4137 | 4137 | if ($olderthanmonths > 0) { |
| 4138 | 4138 | if ($globalDBdriver == 'mysql') { |
@@ -4158,7 +4158,7 @@ discard block |
||
| 4158 | 4158 | $airline_array = array(); |
| 4159 | 4159 | $temp_array = array(); |
| 4160 | 4160 | |
| 4161 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4161 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4162 | 4162 | { |
| 4163 | 4163 | $temp_array['pilot_name'] = $row['pilot_name']; |
| 4164 | 4164 | $temp_array['pilot_id'] = $row['pilot_id']; |
@@ -4176,11 +4176,11 @@ discard block |
||
| 4176 | 4176 | * @return Array the pilots list |
| 4177 | 4177 | * |
| 4178 | 4178 | */ |
| 4179 | - public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 4179 | + public function countAllOwners($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 4180 | 4180 | { |
| 4181 | 4181 | global $globalDBdriver; |
| 4182 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4183 | - $query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
|
| 4182 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4183 | + $query = "SELECT DISTINCT spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
|
| 4184 | 4184 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL"; |
| 4185 | 4185 | if ($olderthanmonths > 0) { |
| 4186 | 4186 | if ($globalDBdriver == 'mysql') { |
@@ -4200,28 +4200,28 @@ discard block |
||
| 4200 | 4200 | if ($year != '') { |
| 4201 | 4201 | if ($globalDBdriver == 'mysql') { |
| 4202 | 4202 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 4203 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4203 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4204 | 4204 | } else { |
| 4205 | 4205 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 4206 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4206 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4207 | 4207 | } |
| 4208 | 4208 | } |
| 4209 | 4209 | if ($month != '') { |
| 4210 | 4210 | if ($globalDBdriver == 'mysql') { |
| 4211 | 4211 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 4212 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4212 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4213 | 4213 | } else { |
| 4214 | 4214 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 4215 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4215 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4216 | 4216 | } |
| 4217 | 4217 | } |
| 4218 | 4218 | if ($day != '') { |
| 4219 | 4219 | if ($globalDBdriver == 'mysql') { |
| 4220 | 4220 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 4221 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4221 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4222 | 4222 | } else { |
| 4223 | 4223 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 4224 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4224 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4225 | 4225 | } |
| 4226 | 4226 | } |
| 4227 | 4227 | $query .= " GROUP BY spotter_output.owner_name ORDER BY owner_count DESC"; |
@@ -4231,7 +4231,7 @@ discard block |
||
| 4231 | 4231 | $sth->execute($query_values); |
| 4232 | 4232 | $airline_array = array(); |
| 4233 | 4233 | $temp_array = array(); |
| 4234 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4234 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4235 | 4235 | { |
| 4236 | 4236 | $temp_array['owner_name'] = $row['owner_name']; |
| 4237 | 4237 | $temp_array['owner_count'] = $row['owner_count']; |
@@ -4246,11 +4246,11 @@ discard block |
||
| 4246 | 4246 | * @return Array the pilots list |
| 4247 | 4247 | * |
| 4248 | 4248 | */ |
| 4249 | - public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
| 4249 | + public function countAllOwnersByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 4250 | 4250 | { |
| 4251 | 4251 | global $globalDBdriver; |
| 4252 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4253 | - $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
|
| 4252 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4253 | + $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.owner_name, COUNT(spotter_output.owner_name) AS owner_count |
|
| 4254 | 4254 | FROM spotter_output".$filter_query." spotter_output.owner_name <> '' AND spotter_output.owner_name IS NOT NULL "; |
| 4255 | 4255 | if ($olderthanmonths > 0) { |
| 4256 | 4256 | if ($globalDBdriver == 'mysql') { |
@@ -4276,7 +4276,7 @@ discard block |
||
| 4276 | 4276 | $airline_array = array(); |
| 4277 | 4277 | $temp_array = array(); |
| 4278 | 4278 | |
| 4279 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4279 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4280 | 4280 | { |
| 4281 | 4281 | $temp_array['owner_name'] = $row['owner_name']; |
| 4282 | 4282 | $temp_array['owner_count'] = $row['owner_count']; |
@@ -4292,11 +4292,11 @@ discard block |
||
| 4292 | 4292 | * @return Array the airline list |
| 4293 | 4293 | * |
| 4294 | 4294 | */ |
| 4295 | - public function countAllAirlinesByAircraft($aircraft_icao,$filters = array()) |
|
| 4295 | + public function countAllAirlinesByAircraft($aircraft_icao, $filters = array()) |
|
| 4296 | 4296 | { |
| 4297 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 4298 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4299 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4297 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 4298 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4299 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4300 | 4300 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
| 4301 | 4301 | GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
| 4302 | 4302 | ORDER BY airline_count DESC"; |
@@ -4308,7 +4308,7 @@ discard block |
||
| 4308 | 4308 | $airline_array = array(); |
| 4309 | 4309 | $temp_array = array(); |
| 4310 | 4310 | |
| 4311 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4311 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4312 | 4312 | { |
| 4313 | 4313 | $temp_array['airline_name'] = $row['airline_name']; |
| 4314 | 4314 | $temp_array['airline_icao'] = $row['airline_icao']; |
@@ -4328,11 +4328,11 @@ discard block |
||
| 4328 | 4328 | * @return Array the airline country list |
| 4329 | 4329 | * |
| 4330 | 4330 | */ |
| 4331 | - public function countAllAirlineCountriesByAircraft($aircraft_icao,$filters = array()) |
|
| 4331 | + public function countAllAirlineCountriesByAircraft($aircraft_icao, $filters = array()) |
|
| 4332 | 4332 | { |
| 4333 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 4334 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4335 | - $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4333 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 4334 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4335 | + $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4336 | 4336 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
| 4337 | 4337 | GROUP BY spotter_output.airline_country |
| 4338 | 4338 | ORDER BY airline_country_count DESC |
@@ -4345,7 +4345,7 @@ discard block |
||
| 4345 | 4345 | $airline_country_array = array(); |
| 4346 | 4346 | $temp_array = array(); |
| 4347 | 4347 | |
| 4348 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4348 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4349 | 4349 | { |
| 4350 | 4350 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
| 4351 | 4351 | $temp_array['airline_country'] = $row['airline_country']; |
@@ -4364,11 +4364,11 @@ discard block |
||
| 4364 | 4364 | * @return Array the airline list |
| 4365 | 4365 | * |
| 4366 | 4366 | */ |
| 4367 | - public function countAllAirlinesByAirport($airport_icao,$filters = array()) |
|
| 4367 | + public function countAllAirlinesByAirport($airport_icao, $filters = array()) |
|
| 4368 | 4368 | { |
| 4369 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 4370 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4371 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4369 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 4370 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4371 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4372 | 4372 | FROM spotter_output".$filter_query." spotter_output.airline_name <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) |
| 4373 | 4373 | GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
| 4374 | 4374 | ORDER BY airline_count DESC"; |
@@ -4380,7 +4380,7 @@ discard block |
||
| 4380 | 4380 | $airline_array = array(); |
| 4381 | 4381 | $temp_array = array(); |
| 4382 | 4382 | |
| 4383 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4383 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4384 | 4384 | { |
| 4385 | 4385 | $temp_array['airline_name'] = $row['airline_name']; |
| 4386 | 4386 | $temp_array['airline_icao'] = $row['airline_icao']; |
@@ -4399,11 +4399,11 @@ discard block |
||
| 4399 | 4399 | * @return Array the airline country list |
| 4400 | 4400 | * |
| 4401 | 4401 | */ |
| 4402 | - public function countAllAirlineCountriesByAirport($airport_icao,$filters = array()) |
|
| 4402 | + public function countAllAirlineCountriesByAirport($airport_icao, $filters = array()) |
|
| 4403 | 4403 | { |
| 4404 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 4405 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4406 | - $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4404 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 4405 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4406 | + $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4407 | 4407 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao ) |
| 4408 | 4408 | GROUP BY spotter_output.airline_country |
| 4409 | 4409 | ORDER BY airline_country_count DESC |
@@ -4416,7 +4416,7 @@ discard block |
||
| 4416 | 4416 | $airline_country_array = array(); |
| 4417 | 4417 | $temp_array = array(); |
| 4418 | 4418 | |
| 4419 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4419 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4420 | 4420 | { |
| 4421 | 4421 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
| 4422 | 4422 | $temp_array['airline_country'] = $row['airline_country']; |
@@ -4433,11 +4433,11 @@ discard block |
||
| 4433 | 4433 | * @return Array the airline list |
| 4434 | 4434 | * |
| 4435 | 4435 | */ |
| 4436 | - public function countAllAirlinesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
| 4436 | + public function countAllAirlinesByManufacturer($aircraft_manufacturer, $filters = array()) |
|
| 4437 | 4437 | { |
| 4438 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 4439 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4440 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4438 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 4439 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4440 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4441 | 4441 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 4442 | 4442 | GROUP BY spotter_output.airline_name |
| 4443 | 4443 | ORDER BY airline_count DESC"; |
@@ -4448,7 +4448,7 @@ discard block |
||
| 4448 | 4448 | $airline_array = array(); |
| 4449 | 4449 | $temp_array = array(); |
| 4450 | 4450 | |
| 4451 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4451 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4452 | 4452 | { |
| 4453 | 4453 | $temp_array['airline_name'] = $row['airline_name']; |
| 4454 | 4454 | $temp_array['airline_icao'] = $row['airline_icao']; |
@@ -4468,11 +4468,11 @@ discard block |
||
| 4468 | 4468 | * @return Array the airline country list |
| 4469 | 4469 | * |
| 4470 | 4470 | */ |
| 4471 | - public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
| 4471 | + public function countAllAirlineCountriesByManufacturer($aircraft_manufacturer, $filters = array()) |
|
| 4472 | 4472 | { |
| 4473 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 4474 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4475 | - $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4473 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 4474 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4475 | + $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4476 | 4476 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 4477 | 4477 | GROUP BY spotter_output.airline_country |
| 4478 | 4478 | ORDER BY airline_country_count DESC |
@@ -4485,7 +4485,7 @@ discard block |
||
| 4485 | 4485 | $airline_country_array = array(); |
| 4486 | 4486 | $temp_array = array(); |
| 4487 | 4487 | |
| 4488 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4488 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4489 | 4489 | { |
| 4490 | 4490 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
| 4491 | 4491 | $temp_array['airline_country'] = $row['airline_country']; |
@@ -4501,11 +4501,11 @@ discard block |
||
| 4501 | 4501 | * @return Array the airline list |
| 4502 | 4502 | * |
| 4503 | 4503 | */ |
| 4504 | - public function countAllAirlinesByDate($date,$filters = array()) |
|
| 4504 | + public function countAllAirlinesByDate($date, $filters = array()) |
|
| 4505 | 4505 | { |
| 4506 | 4506 | global $globalTimezone, $globalDBdriver; |
| 4507 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4508 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 4507 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4508 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 4509 | 4509 | if ($globalTimezone != '') { |
| 4510 | 4510 | date_default_timezone_set($globalTimezone); |
| 4511 | 4511 | $datetime = new DateTime($date); |
@@ -4513,12 +4513,12 @@ discard block |
||
| 4513 | 4513 | } else $offset = '+00:00'; |
| 4514 | 4514 | |
| 4515 | 4515 | if ($globalDBdriver == 'mysql') { |
| 4516 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4516 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4517 | 4517 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 4518 | 4518 | GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country |
| 4519 | 4519 | ORDER BY airline_count DESC"; |
| 4520 | 4520 | } else { |
| 4521 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4521 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4522 | 4522 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 4523 | 4523 | GROUP BY spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country |
| 4524 | 4524 | ORDER BY airline_count DESC"; |
@@ -4529,7 +4529,7 @@ discard block |
||
| 4529 | 4529 | |
| 4530 | 4530 | $airline_array = array(); |
| 4531 | 4531 | $temp_array = array(); |
| 4532 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4532 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4533 | 4533 | { |
| 4534 | 4534 | $temp_array['airline_name'] = $row['airline_name']; |
| 4535 | 4535 | $temp_array['airline_icao'] = $row['airline_icao']; |
@@ -4549,11 +4549,11 @@ discard block |
||
| 4549 | 4549 | * @return Array the airline country list |
| 4550 | 4550 | * |
| 4551 | 4551 | */ |
| 4552 | - public function countAllAirlineCountriesByDate($date,$filters = array()) |
|
| 4552 | + public function countAllAirlineCountriesByDate($date, $filters = array()) |
|
| 4553 | 4553 | { |
| 4554 | 4554 | global $globalTimezone, $globalDBdriver; |
| 4555 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4556 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 4555 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4556 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 4557 | 4557 | if ($globalTimezone != '') { |
| 4558 | 4558 | date_default_timezone_set($globalTimezone); |
| 4559 | 4559 | $datetime = new DateTime($date); |
@@ -4561,13 +4561,13 @@ discard block |
||
| 4561 | 4561 | } else $offset = '+00:00'; |
| 4562 | 4562 | |
| 4563 | 4563 | if ($globalDBdriver == 'mysql') { |
| 4564 | - $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4564 | + $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4565 | 4565 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 4566 | 4566 | GROUP BY spotter_output.airline_country |
| 4567 | 4567 | ORDER BY airline_country_count DESC |
| 4568 | 4568 | LIMIT 10 OFFSET 0"; |
| 4569 | 4569 | } else { |
| 4570 | - $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4570 | + $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4571 | 4571 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 4572 | 4572 | GROUP BY spotter_output.airline_country |
| 4573 | 4573 | ORDER BY airline_country_count DESC |
@@ -4579,7 +4579,7 @@ discard block |
||
| 4579 | 4579 | |
| 4580 | 4580 | $airline_country_array = array(); |
| 4581 | 4581 | $temp_array = array(); |
| 4582 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4582 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4583 | 4583 | { |
| 4584 | 4584 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
| 4585 | 4585 | $temp_array['airline_country'] = $row['airline_country']; |
@@ -4596,11 +4596,11 @@ discard block |
||
| 4596 | 4596 | * @return Array the airline list |
| 4597 | 4597 | * |
| 4598 | 4598 | */ |
| 4599 | - public function countAllAirlinesByIdent($ident,$filters = array()) |
|
| 4599 | + public function countAllAirlinesByIdent($ident, $filters = array()) |
|
| 4600 | 4600 | { |
| 4601 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 4602 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4603 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4601 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 4602 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4603 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4604 | 4604 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
| 4605 | 4605 | GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country |
| 4606 | 4606 | ORDER BY airline_count DESC"; |
@@ -4617,11 +4617,11 @@ discard block |
||
| 4617 | 4617 | * @return Array the airline list |
| 4618 | 4618 | * |
| 4619 | 4619 | */ |
| 4620 | - public function countAllAirlinesByOwner($owner,$filters = array()) |
|
| 4620 | + public function countAllAirlinesByOwner($owner, $filters = array()) |
|
| 4621 | 4621 | { |
| 4622 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 4623 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4624 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4622 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 4623 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4624 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4625 | 4625 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner |
| 4626 | 4626 | GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country |
| 4627 | 4627 | ORDER BY airline_count DESC"; |
@@ -4638,47 +4638,47 @@ discard block |
||
| 4638 | 4638 | * @return String Duration of all flights |
| 4639 | 4639 | * |
| 4640 | 4640 | */ |
| 4641 | - public function getFlightDurationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '') |
|
| 4641 | + public function getFlightDurationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '') |
|
| 4642 | 4642 | { |
| 4643 | 4643 | global $globalDBdriver; |
| 4644 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 4645 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4646 | - $query = "SELECT SUM(last_seen - date) AS duration |
|
| 4644 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 4645 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4646 | + $query = "SELECT SUM(last_seen - date) AS duration |
|
| 4647 | 4647 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner |
| 4648 | 4648 | AND last_seen > date"; |
| 4649 | 4649 | $query_values = array(); |
| 4650 | 4650 | if ($year != '') { |
| 4651 | 4651 | if ($globalDBdriver == 'mysql') { |
| 4652 | 4652 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 4653 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4653 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4654 | 4654 | } else { |
| 4655 | 4655 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 4656 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4656 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4657 | 4657 | } |
| 4658 | 4658 | } |
| 4659 | 4659 | if ($month != '') { |
| 4660 | 4660 | if ($globalDBdriver == 'mysql') { |
| 4661 | 4661 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 4662 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4662 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4663 | 4663 | } else { |
| 4664 | 4664 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 4665 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4665 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4666 | 4666 | } |
| 4667 | 4667 | } |
| 4668 | 4668 | if ($day != '') { |
| 4669 | 4669 | if ($globalDBdriver == 'mysql') { |
| 4670 | 4670 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 4671 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4671 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4672 | 4672 | } else { |
| 4673 | 4673 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 4674 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4674 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4675 | 4675 | } |
| 4676 | 4676 | } |
| 4677 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 4677 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 4678 | 4678 | $sth = $this->db->prepare($query); |
| 4679 | 4679 | $sth->execute($query_values); |
| 4680 | 4680 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 4681 | - if (is_numeric($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 4681 | + if (is_numeric($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']); |
|
| 4682 | 4682 | elseif ($result[0]['duration'] == '') return 0; |
| 4683 | 4683 | else return $result[0]['duration']; |
| 4684 | 4684 | } |
@@ -4689,14 +4689,14 @@ discard block |
||
| 4689 | 4689 | * @return String Duration of all flights |
| 4690 | 4690 | * |
| 4691 | 4691 | */ |
| 4692 | - public function countFlightsByOwner($owner,$filters = array()) |
|
| 4692 | + public function countFlightsByOwner($owner, $filters = array()) |
|
| 4693 | 4693 | { |
| 4694 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 4695 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4696 | - $query = "SELECT COUNT(*) AS nb |
|
| 4694 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 4695 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4696 | + $query = "SELECT COUNT(*) AS nb |
|
| 4697 | 4697 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner"; |
| 4698 | 4698 | $query_values = array(); |
| 4699 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 4699 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 4700 | 4700 | $sth = $this->db->prepare($query); |
| 4701 | 4701 | $sth->execute($query_values); |
| 4702 | 4702 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -4709,14 +4709,14 @@ discard block |
||
| 4709 | 4709 | * @return String Duration of all flights |
| 4710 | 4710 | * |
| 4711 | 4711 | */ |
| 4712 | - public function countFlightsByPilot($pilot,$filters = array()) |
|
| 4712 | + public function countFlightsByPilot($pilot, $filters = array()) |
|
| 4713 | 4713 | { |
| 4714 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 4715 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4716 | - $query = "SELECT COUNT(*) AS nb |
|
| 4714 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 4715 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4716 | + $query = "SELECT COUNT(*) AS nb |
|
| 4717 | 4717 | FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilod_id = :pilot)"; |
| 4718 | 4718 | $query_values = array(); |
| 4719 | - $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
|
| 4719 | + $query_values = array_merge($query_values, array(':pilot' => $pilot)); |
|
| 4720 | 4720 | $sth = $this->db->prepare($query); |
| 4721 | 4721 | $sth->execute($query_values); |
| 4722 | 4722 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -4729,47 +4729,47 @@ discard block |
||
| 4729 | 4729 | * @return String Duration of all flights |
| 4730 | 4730 | * |
| 4731 | 4731 | */ |
| 4732 | - public function getFlightDurationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '') |
|
| 4732 | + public function getFlightDurationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '') |
|
| 4733 | 4733 | { |
| 4734 | 4734 | global $globalDBdriver; |
| 4735 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 4736 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4737 | - $query = "SELECT SUM(last_seen - date) AS duration |
|
| 4735 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 4736 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4737 | + $query = "SELECT SUM(last_seen - date) AS duration |
|
| 4738 | 4738 | FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 4739 | 4739 | AND last_seen > date"; |
| 4740 | 4740 | $query_values = array(); |
| 4741 | 4741 | if ($year != '') { |
| 4742 | 4742 | if ($globalDBdriver == 'mysql') { |
| 4743 | 4743 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 4744 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4744 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4745 | 4745 | } else { |
| 4746 | 4746 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 4747 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4747 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4748 | 4748 | } |
| 4749 | 4749 | } |
| 4750 | 4750 | if ($month != '') { |
| 4751 | 4751 | if ($globalDBdriver == 'mysql') { |
| 4752 | 4752 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 4753 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4753 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4754 | 4754 | } else { |
| 4755 | 4755 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 4756 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4756 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4757 | 4757 | } |
| 4758 | 4758 | } |
| 4759 | 4759 | if ($day != '') { |
| 4760 | 4760 | if ($globalDBdriver == 'mysql') { |
| 4761 | 4761 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 4762 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4762 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4763 | 4763 | } else { |
| 4764 | 4764 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 4765 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4765 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4766 | 4766 | } |
| 4767 | 4767 | } |
| 4768 | - $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
|
| 4768 | + $query_values = array_merge($query_values, array(':pilot' => $pilot)); |
|
| 4769 | 4769 | $sth = $this->db->prepare($query); |
| 4770 | 4770 | $sth->execute($query_values); |
| 4771 | 4771 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 4772 | - if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']); |
|
| 4772 | + if (is_int($result[0]['duration'])) return gmdate('H:i:s', $result[0]['duration']); |
|
| 4773 | 4773 | else return $result[0]['duration']; |
| 4774 | 4774 | } |
| 4775 | 4775 | |
@@ -4779,11 +4779,11 @@ discard block |
||
| 4779 | 4779 | * @return Array the airline list |
| 4780 | 4780 | * |
| 4781 | 4781 | */ |
| 4782 | - public function countAllAirlinesByPilot($pilot,$filters = array()) |
|
| 4782 | + public function countAllAirlinesByPilot($pilot, $filters = array()) |
|
| 4783 | 4783 | { |
| 4784 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 4785 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4786 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4784 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 4785 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4786 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4787 | 4787 | FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 4788 | 4788 | GROUP BY spotter_output.airline_icao, spotter_output.airline_name, spotter_output.airline_country |
| 4789 | 4789 | ORDER BY airline_count DESC"; |
@@ -4800,25 +4800,25 @@ discard block |
||
| 4800 | 4800 | * @return Array the airline list |
| 4801 | 4801 | * |
| 4802 | 4802 | */ |
| 4803 | - public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
|
| 4803 | + public function countAllAirlinesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array()) |
|
| 4804 | 4804 | { |
| 4805 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4806 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 4807 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 4805 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4806 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 4807 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 4808 | 4808 | |
| 4809 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4809 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4810 | 4810 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
| 4811 | 4811 | GROUP BY spotter_output.airline_name |
| 4812 | 4812 | ORDER BY airline_count DESC"; |
| 4813 | 4813 | |
| 4814 | 4814 | |
| 4815 | 4815 | $sth = $this->db->prepare($query); |
| 4816 | - $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 4816 | + $sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 4817 | 4817 | |
| 4818 | 4818 | $airline_array = array(); |
| 4819 | 4819 | $temp_array = array(); |
| 4820 | 4820 | |
| 4821 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4821 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4822 | 4822 | { |
| 4823 | 4823 | $temp_array['airline_name'] = $row['airline_name']; |
| 4824 | 4824 | $temp_array['airline_icao'] = $row['airline_icao']; |
@@ -4836,13 +4836,13 @@ discard block |
||
| 4836 | 4836 | * @return Array the airline country list |
| 4837 | 4837 | * |
| 4838 | 4838 | */ |
| 4839 | - public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao,$filters= array()) |
|
| 4839 | + public function countAllAirlineCountriesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array()) |
|
| 4840 | 4840 | { |
| 4841 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4842 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 4843 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 4841 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4842 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 4843 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 4844 | 4844 | |
| 4845 | - $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4845 | + $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4846 | 4846 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
| 4847 | 4847 | GROUP BY spotter_output.airline_country |
| 4848 | 4848 | ORDER BY airline_country_count DESC |
@@ -4850,11 +4850,11 @@ discard block |
||
| 4850 | 4850 | |
| 4851 | 4851 | |
| 4852 | 4852 | $sth = $this->db->prepare($query); |
| 4853 | - $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 4853 | + $sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 4854 | 4854 | |
| 4855 | 4855 | $airline_country_array = array(); |
| 4856 | 4856 | $temp_array = array(); |
| 4857 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4857 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4858 | 4858 | { |
| 4859 | 4859 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
| 4860 | 4860 | $temp_array['airline_country'] = $row['airline_country']; |
@@ -4872,11 +4872,11 @@ discard block |
||
| 4872 | 4872 | * @return Array the airline list |
| 4873 | 4873 | * |
| 4874 | 4874 | */ |
| 4875 | - public function countAllAirlinesByCountry($country,$filters = array()) |
|
| 4875 | + public function countAllAirlinesByCountry($country, $filters = array()) |
|
| 4876 | 4876 | { |
| 4877 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 4878 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4879 | - $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4877 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 4878 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4879 | + $query = "SELECT DISTINCT spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country, COUNT(spotter_output.airline_name) AS airline_count |
|
| 4880 | 4880 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 4881 | 4881 | GROUP BY spotter_output.airline_name, spotter_output.airline_icao, spotter_output.airline_country |
| 4882 | 4882 | ORDER BY airline_count DESC"; |
@@ -4887,7 +4887,7 @@ discard block |
||
| 4887 | 4887 | |
| 4888 | 4888 | $airline_array = array(); |
| 4889 | 4889 | $temp_array = array(); |
| 4890 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4890 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4891 | 4891 | { |
| 4892 | 4892 | $temp_array['airline_name'] = $row['airline_name']; |
| 4893 | 4893 | $temp_array['airline_icao'] = $row['airline_icao']; |
@@ -4906,11 +4906,11 @@ discard block |
||
| 4906 | 4906 | * @return Array the airline country list |
| 4907 | 4907 | * |
| 4908 | 4908 | */ |
| 4909 | - public function countAllAirlineCountriesByCountry($country,$filters = array()) |
|
| 4909 | + public function countAllAirlineCountriesByCountry($country, $filters = array()) |
|
| 4910 | 4910 | { |
| 4911 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4912 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 4913 | - $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4911 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4912 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 4913 | + $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4914 | 4914 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 4915 | 4915 | GROUP BY spotter_output.airline_country |
| 4916 | 4916 | ORDER BY airline_country_count DESC |
@@ -4922,7 +4922,7 @@ discard block |
||
| 4922 | 4922 | |
| 4923 | 4923 | $airline_country_array = array(); |
| 4924 | 4924 | $temp_array = array(); |
| 4925 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4925 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4926 | 4926 | { |
| 4927 | 4927 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
| 4928 | 4928 | $temp_array['airline_country'] = $row['airline_country']; |
@@ -4942,35 +4942,35 @@ discard block |
||
| 4942 | 4942 | public function countAllAirlineCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '') |
| 4943 | 4943 | { |
| 4944 | 4944 | global $globalDBdriver; |
| 4945 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 4946 | - $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4945 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 4946 | + $query = "SELECT DISTINCT spotter_output.airline_country, COUNT(spotter_output.airline_country) AS airline_country_count |
|
| 4947 | 4947 | FROM spotter_output".$filter_query." spotter_output.airline_country <> '' AND spotter_output.airline_country <> 'NA'"; |
| 4948 | 4948 | $query_values = array(); |
| 4949 | 4949 | if ($year != '') { |
| 4950 | 4950 | if ($globalDBdriver == 'mysql') { |
| 4951 | 4951 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 4952 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4952 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4953 | 4953 | } else { |
| 4954 | 4954 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 4955 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 4955 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 4956 | 4956 | } |
| 4957 | 4957 | } |
| 4958 | 4958 | if ($month != '') { |
| 4959 | 4959 | if ($globalDBdriver == 'mysql') { |
| 4960 | 4960 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 4961 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4961 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4962 | 4962 | } else { |
| 4963 | 4963 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 4964 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 4964 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 4965 | 4965 | } |
| 4966 | 4966 | } |
| 4967 | 4967 | if ($day != '') { |
| 4968 | 4968 | if ($globalDBdriver == 'mysql') { |
| 4969 | 4969 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 4970 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4970 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4971 | 4971 | } else { |
| 4972 | 4972 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 4973 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 4973 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 4974 | 4974 | } |
| 4975 | 4975 | } |
| 4976 | 4976 | $query .= " GROUP BY spotter_output.airline_country |
@@ -4982,7 +4982,7 @@ discard block |
||
| 4982 | 4982 | |
| 4983 | 4983 | $airline_array = array(); |
| 4984 | 4984 | $temp_array = array(); |
| 4985 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4985 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 4986 | 4986 | { |
| 4987 | 4987 | $temp_array['airline_country_count'] = $row['airline_country_count']; |
| 4988 | 4988 | $temp_array['airline_country'] = $row['airline_country']; |
@@ -4998,11 +4998,11 @@ discard block |
||
| 4998 | 4998 | * @return Array the airline country list |
| 4999 | 4999 | * |
| 5000 | 5000 | */ |
| 5001 | - public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 5001 | + public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 5002 | 5002 | { |
| 5003 | 5003 | global $globalDBdriver; |
| 5004 | 5004 | //$filter_query = $this->getFilter($filters,true,true); |
| 5005 | - $Connection= new Connection($this->db); |
|
| 5005 | + $Connection = new Connection($this->db); |
|
| 5006 | 5006 | if (!$Connection->tableExists('countries')) return array(); |
| 5007 | 5007 | /* |
| 5008 | 5008 | $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb |
@@ -5017,7 +5017,7 @@ discard block |
||
| 5017 | 5017 | */ |
| 5018 | 5018 | require_once('class.SpotterLive.php'); |
| 5019 | 5019 | $SpotterLive = new SpotterLive(); |
| 5020 | - $filter_query = $SpotterLive->getFilter($filters,true,true); |
|
| 5020 | + $filter_query = $SpotterLive->getFilter($filters, true, true); |
|
| 5021 | 5021 | $filter_query .= ' over_country IS NOT NULL'; |
| 5022 | 5022 | if ($olderthanmonths > 0) { |
| 5023 | 5023 | if ($globalDBdriver == 'mysql') { |
@@ -5044,7 +5044,7 @@ discard block |
||
| 5044 | 5044 | $flight_array = array(); |
| 5045 | 5045 | $temp_array = array(); |
| 5046 | 5046 | |
| 5047 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5047 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5048 | 5048 | { |
| 5049 | 5049 | $temp_array['flight_count'] = $row['nb']; |
| 5050 | 5050 | $temp_array['flight_country'] = $row['name']; |
@@ -5062,11 +5062,11 @@ discard block |
||
| 5062 | 5062 | * @return Array the aircraft list |
| 5063 | 5063 | * |
| 5064 | 5064 | */ |
| 5065 | - public function countAllAircraftTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 5065 | + public function countAllAircraftTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 5066 | 5066 | { |
| 5067 | 5067 | global $globalDBdriver; |
| 5068 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5069 | - $query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
| 5068 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5069 | + $query = "SELECT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
| 5070 | 5070 | FROM spotter_output ".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> ''"; |
| 5071 | 5071 | if ($olderthanmonths > 0) { |
| 5072 | 5072 | if ($globalDBdriver == 'mysql') { |
@@ -5086,28 +5086,28 @@ discard block |
||
| 5086 | 5086 | if ($year != '') { |
| 5087 | 5087 | if ($globalDBdriver == 'mysql') { |
| 5088 | 5088 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 5089 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5089 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5090 | 5090 | } else { |
| 5091 | 5091 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 5092 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5092 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5093 | 5093 | } |
| 5094 | 5094 | } |
| 5095 | 5095 | if ($month != '') { |
| 5096 | 5096 | if ($globalDBdriver == 'mysql') { |
| 5097 | 5097 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 5098 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5098 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5099 | 5099 | } else { |
| 5100 | 5100 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 5101 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5101 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5102 | 5102 | } |
| 5103 | 5103 | } |
| 5104 | 5104 | if ($day != '') { |
| 5105 | 5105 | if ($globalDBdriver == 'mysql') { |
| 5106 | 5106 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 5107 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5107 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5108 | 5108 | } else { |
| 5109 | 5109 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 5110 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5110 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5111 | 5111 | } |
| 5112 | 5112 | } |
| 5113 | 5113 | |
@@ -5119,7 +5119,7 @@ discard block |
||
| 5119 | 5119 | |
| 5120 | 5120 | $aircraft_array = array(); |
| 5121 | 5121 | $temp_array = array(); |
| 5122 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5122 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5123 | 5123 | { |
| 5124 | 5124 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5125 | 5125 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -5136,11 +5136,11 @@ discard block |
||
| 5136 | 5136 | * @return Array the aircraft list |
| 5137 | 5137 | * |
| 5138 | 5138 | */ |
| 5139 | - public function countAllAircraftTypesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '', $day = '') |
|
| 5139 | + public function countAllAircraftTypesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 5140 | 5140 | { |
| 5141 | 5141 | global $globalDBdriver; |
| 5142 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5143 | - $query = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
| 5142 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5143 | + $query = "SELECT spotter_output.airline_icao, spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
| 5144 | 5144 | FROM spotter_output".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA'"; |
| 5145 | 5145 | if ($olderthanmonths > 0) { |
| 5146 | 5146 | if ($globalDBdriver == 'mysql') { |
@@ -5160,28 +5160,28 @@ discard block |
||
| 5160 | 5160 | if ($year != '') { |
| 5161 | 5161 | if ($globalDBdriver == 'mysql') { |
| 5162 | 5162 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 5163 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5163 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5164 | 5164 | } else { |
| 5165 | 5165 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 5166 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5166 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5167 | 5167 | } |
| 5168 | 5168 | } |
| 5169 | 5169 | if ($month != '') { |
| 5170 | 5170 | if ($globalDBdriver == 'mysql') { |
| 5171 | 5171 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 5172 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5172 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5173 | 5173 | } else { |
| 5174 | 5174 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 5175 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5175 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5176 | 5176 | } |
| 5177 | 5177 | } |
| 5178 | 5178 | if ($day != '') { |
| 5179 | 5179 | if ($globalDBdriver == 'mysql') { |
| 5180 | 5180 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 5181 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5181 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5182 | 5182 | } else { |
| 5183 | 5183 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 5184 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5184 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5185 | 5185 | } |
| 5186 | 5186 | } |
| 5187 | 5187 | |
@@ -5193,7 +5193,7 @@ discard block |
||
| 5193 | 5193 | |
| 5194 | 5194 | $aircraft_array = array(); |
| 5195 | 5195 | $temp_array = array(); |
| 5196 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5196 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5197 | 5197 | { |
| 5198 | 5198 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 5199 | 5199 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
@@ -5211,11 +5211,11 @@ discard block |
||
| 5211 | 5211 | * @return Array the aircraft list |
| 5212 | 5212 | * |
| 5213 | 5213 | */ |
| 5214 | - public function countAllAircraftTypesByMonths($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 5214 | + public function countAllAircraftTypesByMonths($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 5215 | 5215 | { |
| 5216 | 5216 | global $globalDBdriver; |
| 5217 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5218 | - $query = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
| 5217 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5218 | + $query = "SELECT EXTRACT(month from spotter_output.date) as month, EXTRACT(year from spotter_output.date) as year,spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
| 5219 | 5219 | FROM spotter_output".$filter_query." spotter_output.aircraft_name <> '' AND spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao <>'' AND spotter_output.airline_icao <> 'NA' "; |
| 5220 | 5220 | if ($olderthanmonths > 0) { |
| 5221 | 5221 | if ($globalDBdriver == 'mysql') { |
@@ -5240,7 +5240,7 @@ discard block |
||
| 5240 | 5240 | |
| 5241 | 5241 | $aircraft_array = array(); |
| 5242 | 5242 | $temp_array = array(); |
| 5243 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5243 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5244 | 5244 | { |
| 5245 | 5245 | //$temp_array['airline_icao'] = $row['airline_icao']; |
| 5246 | 5246 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
@@ -5259,13 +5259,13 @@ discard block |
||
| 5259 | 5259 | * @return Array the aircraft list |
| 5260 | 5260 | * |
| 5261 | 5261 | */ |
| 5262 | - public function countAllAircraftRegistrationByAircraft($aircraft_icao,$filters = array()) |
|
| 5262 | + public function countAllAircraftRegistrationByAircraft($aircraft_icao, $filters = array()) |
|
| 5263 | 5263 | { |
| 5264 | 5264 | $Image = new Image($this->db); |
| 5265 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5266 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 5265 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5266 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 5267 | 5267 | |
| 5268 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5268 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5269 | 5269 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
| 5270 | 5270 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
| 5271 | 5271 | ORDER BY registration_count DESC"; |
@@ -5276,14 +5276,14 @@ discard block |
||
| 5276 | 5276 | $aircraft_array = array(); |
| 5277 | 5277 | $temp_array = array(); |
| 5278 | 5278 | |
| 5279 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5279 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5280 | 5280 | { |
| 5281 | 5281 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5282 | 5282 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 5283 | 5283 | $temp_array['registration'] = $row['registration']; |
| 5284 | 5284 | $temp_array['airline_name'] = $row['airline_name']; |
| 5285 | 5285 | $temp_array['image_thumbnail'] = ""; |
| 5286 | - if($row['registration'] != "") |
|
| 5286 | + if ($row['registration'] != "") |
|
| 5287 | 5287 | { |
| 5288 | 5288 | $image_array = $Image->getSpotterImage($row['registration']); |
| 5289 | 5289 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -5302,11 +5302,11 @@ discard block |
||
| 5302 | 5302 | * @return Array the aircraft list |
| 5303 | 5303 | * |
| 5304 | 5304 | */ |
| 5305 | - public function countAllAircraftTypesByAirline($airline_icao,$filters = array()) |
|
| 5305 | + public function countAllAircraftTypesByAirline($airline_icao, $filters = array()) |
|
| 5306 | 5306 | { |
| 5307 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5308 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 5309 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5307 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5308 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 5309 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5310 | 5310 | FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND spotter_output.airline_icao = :airline_icao |
| 5311 | 5311 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
| 5312 | 5312 | ORDER BY aircraft_icao_count DESC"; |
@@ -5317,7 +5317,7 @@ discard block |
||
| 5317 | 5317 | $aircraft_array = array(); |
| 5318 | 5318 | $temp_array = array(); |
| 5319 | 5319 | |
| 5320 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5320 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5321 | 5321 | { |
| 5322 | 5322 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5323 | 5323 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -5335,13 +5335,13 @@ discard block |
||
| 5335 | 5335 | * @return Array the aircraft list |
| 5336 | 5336 | * |
| 5337 | 5337 | */ |
| 5338 | - public function countAllAircraftRegistrationByAirline($airline_icao,$filters = array()) |
|
| 5338 | + public function countAllAircraftRegistrationByAirline($airline_icao, $filters = array()) |
|
| 5339 | 5339 | { |
| 5340 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5340 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5341 | 5341 | $Image = new Image($this->db); |
| 5342 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 5342 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 5343 | 5343 | |
| 5344 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5344 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5345 | 5345 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.airline_icao = :airline_icao |
| 5346 | 5346 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
| 5347 | 5347 | ORDER BY registration_count DESC"; |
@@ -5351,14 +5351,14 @@ discard block |
||
| 5351 | 5351 | |
| 5352 | 5352 | $aircraft_array = array(); |
| 5353 | 5353 | $temp_array = array(); |
| 5354 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5354 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5355 | 5355 | { |
| 5356 | 5356 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5357 | 5357 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 5358 | 5358 | $temp_array['registration'] = $row['registration']; |
| 5359 | 5359 | $temp_array['airline_name'] = $row['airline_name']; |
| 5360 | 5360 | $temp_array['image_thumbnail'] = ""; |
| 5361 | - if($row['registration'] != "") |
|
| 5361 | + if ($row['registration'] != "") |
|
| 5362 | 5362 | { |
| 5363 | 5363 | $image_array = $Image->getSpotterImage($row['registration']); |
| 5364 | 5364 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -5377,11 +5377,11 @@ discard block |
||
| 5377 | 5377 | * @return Array the aircraft list |
| 5378 | 5378 | * |
| 5379 | 5379 | */ |
| 5380 | - public function countAllAircraftManufacturerByAirline($airline_icao,$filters = array()) |
|
| 5380 | + public function countAllAircraftManufacturerByAirline($airline_icao, $filters = array()) |
|
| 5381 | 5381 | { |
| 5382 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5383 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 5384 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 5382 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5383 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 5384 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 5385 | 5385 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.airline_icao = :airline_icao |
| 5386 | 5386 | GROUP BY spotter_output.aircraft_manufacturer |
| 5387 | 5387 | ORDER BY aircraft_manufacturer_count DESC"; |
@@ -5392,7 +5392,7 @@ discard block |
||
| 5392 | 5392 | $aircraft_array = array(); |
| 5393 | 5393 | $temp_array = array(); |
| 5394 | 5394 | |
| 5395 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5395 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5396 | 5396 | { |
| 5397 | 5397 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
| 5398 | 5398 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
@@ -5409,12 +5409,12 @@ discard block |
||
| 5409 | 5409 | * @return Array the aircraft list |
| 5410 | 5410 | * |
| 5411 | 5411 | */ |
| 5412 | - public function countAllAircraftTypesByAirport($airport_icao,$filters = array()) |
|
| 5412 | + public function countAllAircraftTypesByAirport($airport_icao, $filters = array()) |
|
| 5413 | 5413 | { |
| 5414 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5415 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 5414 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5415 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 5416 | 5416 | |
| 5417 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5417 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5418 | 5418 | FROM spotter_output".$filter_query." spotter_output.aircraft_icao <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
| 5419 | 5419 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
| 5420 | 5420 | ORDER BY aircraft_icao_count DESC"; |
@@ -5424,7 +5424,7 @@ discard block |
||
| 5424 | 5424 | |
| 5425 | 5425 | $aircraft_array = array(); |
| 5426 | 5426 | $temp_array = array(); |
| 5427 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5427 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5428 | 5428 | { |
| 5429 | 5429 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5430 | 5430 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -5442,13 +5442,13 @@ discard block |
||
| 5442 | 5442 | * @return Array the aircraft list |
| 5443 | 5443 | * |
| 5444 | 5444 | */ |
| 5445 | - public function countAllAircraftRegistrationByAirport($airport_icao,$filters = array()) |
|
| 5445 | + public function countAllAircraftRegistrationByAirport($airport_icao, $filters = array()) |
|
| 5446 | 5446 | { |
| 5447 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5447 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5448 | 5448 | $Image = new Image($this->db); |
| 5449 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 5449 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 5450 | 5450 | |
| 5451 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5451 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5452 | 5452 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
| 5453 | 5453 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
| 5454 | 5454 | ORDER BY registration_count DESC"; |
@@ -5458,14 +5458,14 @@ discard block |
||
| 5458 | 5458 | |
| 5459 | 5459 | $aircraft_array = array(); |
| 5460 | 5460 | $temp_array = array(); |
| 5461 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5461 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5462 | 5462 | { |
| 5463 | 5463 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5464 | 5464 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 5465 | 5465 | $temp_array['registration'] = $row['registration']; |
| 5466 | 5466 | $temp_array['airline_name'] = $row['airline_name']; |
| 5467 | 5467 | $temp_array['image_thumbnail'] = ""; |
| 5468 | - if($row['registration'] != "") |
|
| 5468 | + if ($row['registration'] != "") |
|
| 5469 | 5469 | { |
| 5470 | 5470 | $image_array = $Image->getSpotterImage($row['registration']); |
| 5471 | 5471 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -5483,11 +5483,11 @@ discard block |
||
| 5483 | 5483 | * @return Array the aircraft list |
| 5484 | 5484 | * |
| 5485 | 5485 | */ |
| 5486 | - public function countAllAircraftManufacturerByAirport($airport_icao,$filters = array()) |
|
| 5486 | + public function countAllAircraftManufacturerByAirport($airport_icao, $filters = array()) |
|
| 5487 | 5487 | { |
| 5488 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5489 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 5490 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 5488 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5489 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 5490 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 5491 | 5491 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
| 5492 | 5492 | GROUP BY spotter_output.aircraft_manufacturer |
| 5493 | 5493 | ORDER BY aircraft_manufacturer_count DESC"; |
@@ -5498,7 +5498,7 @@ discard block |
||
| 5498 | 5498 | |
| 5499 | 5499 | $aircraft_array = array(); |
| 5500 | 5500 | $temp_array = array(); |
| 5501 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5501 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5502 | 5502 | { |
| 5503 | 5503 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
| 5504 | 5504 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
@@ -5513,12 +5513,12 @@ discard block |
||
| 5513 | 5513 | * @return Array the aircraft list |
| 5514 | 5514 | * |
| 5515 | 5515 | */ |
| 5516 | - public function countAllAircraftTypesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
| 5516 | + public function countAllAircraftTypesByManufacturer($aircraft_manufacturer, $filters = array()) |
|
| 5517 | 5517 | { |
| 5518 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5519 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 5518 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5519 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 5520 | 5520 | |
| 5521 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5521 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5522 | 5522 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 5523 | 5523 | GROUP BY spotter_output.aircraft_name |
| 5524 | 5524 | ORDER BY aircraft_icao_count DESC"; |
@@ -5527,7 +5527,7 @@ discard block |
||
| 5527 | 5527 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
| 5528 | 5528 | $aircraft_array = array(); |
| 5529 | 5529 | $temp_array = array(); |
| 5530 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5530 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5531 | 5531 | { |
| 5532 | 5532 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5533 | 5533 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -5546,11 +5546,11 @@ discard block |
||
| 5546 | 5546 | */ |
| 5547 | 5547 | public function countAllAircraftRegistrationByManufacturer($aircraft_manufacturer, $filters = array()) |
| 5548 | 5548 | { |
| 5549 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5549 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5550 | 5550 | $Image = new Image($this->db); |
| 5551 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 5551 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 5552 | 5552 | |
| 5553 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5553 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5554 | 5554 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 5555 | 5555 | GROUP BY spotter_output.registration |
| 5556 | 5556 | ORDER BY registration_count DESC"; |
@@ -5560,14 +5560,14 @@ discard block |
||
| 5560 | 5560 | $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer)); |
| 5561 | 5561 | $aircraft_array = array(); |
| 5562 | 5562 | $temp_array = array(); |
| 5563 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5563 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5564 | 5564 | { |
| 5565 | 5565 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5566 | 5566 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 5567 | 5567 | $temp_array['registration'] = $row['registration']; |
| 5568 | 5568 | $temp_array['airline_name'] = $row['airline_name']; |
| 5569 | 5569 | $temp_array['image_thumbnail'] = ""; |
| 5570 | - if($row['registration'] != "") |
|
| 5570 | + if ($row['registration'] != "") |
|
| 5571 | 5571 | { |
| 5572 | 5572 | $image_array = $Image->getSpotterImage($row['registration']); |
| 5573 | 5573 | $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -5584,11 +5584,11 @@ discard block |
||
| 5584 | 5584 | * @return Array the aircraft list |
| 5585 | 5585 | * |
| 5586 | 5586 | */ |
| 5587 | - public function countAllAircraftTypesByDate($date,$filters = array()) |
|
| 5587 | + public function countAllAircraftTypesByDate($date, $filters = array()) |
|
| 5588 | 5588 | { |
| 5589 | 5589 | global $globalTimezone, $globalDBdriver; |
| 5590 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5591 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 5590 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5591 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 5592 | 5592 | if ($globalTimezone != '') { |
| 5593 | 5593 | date_default_timezone_set($globalTimezone); |
| 5594 | 5594 | $datetime = new DateTime($date); |
@@ -5596,12 +5596,12 @@ discard block |
||
| 5596 | 5596 | } else $offset = '+00:00'; |
| 5597 | 5597 | |
| 5598 | 5598 | if ($globalDBdriver == 'mysql') { |
| 5599 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5599 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5600 | 5600 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 5601 | 5601 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
| 5602 | 5602 | ORDER BY aircraft_icao_count DESC"; |
| 5603 | 5603 | } else { |
| 5604 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5604 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5605 | 5605 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 5606 | 5606 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
| 5607 | 5607 | ORDER BY aircraft_icao_count DESC"; |
@@ -5612,7 +5612,7 @@ discard block |
||
| 5612 | 5612 | |
| 5613 | 5613 | $aircraft_array = array(); |
| 5614 | 5614 | $temp_array = array(); |
| 5615 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5615 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5616 | 5616 | { |
| 5617 | 5617 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5618 | 5618 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -5630,12 +5630,12 @@ discard block |
||
| 5630 | 5630 | * @return Array the aircraft list |
| 5631 | 5631 | * |
| 5632 | 5632 | */ |
| 5633 | - public function countAllAircraftRegistrationByDate($date,$filters = array()) |
|
| 5633 | + public function countAllAircraftRegistrationByDate($date, $filters = array()) |
|
| 5634 | 5634 | { |
| 5635 | 5635 | global $globalTimezone, $globalDBdriver; |
| 5636 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5636 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5637 | 5637 | $Image = new Image($this->db); |
| 5638 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 5638 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 5639 | 5639 | if ($globalTimezone != '') { |
| 5640 | 5640 | date_default_timezone_set($globalTimezone); |
| 5641 | 5641 | $datetime = new DateTime($date); |
@@ -5643,12 +5643,12 @@ discard block |
||
| 5643 | 5643 | } else $offset = '+00:00'; |
| 5644 | 5644 | |
| 5645 | 5645 | if ($globalDBdriver == 'mysql') { |
| 5646 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5646 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5647 | 5647 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 5648 | 5648 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
| 5649 | 5649 | ORDER BY registration_count DESC"; |
| 5650 | 5650 | } else { |
| 5651 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5651 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5652 | 5652 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 5653 | 5653 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
| 5654 | 5654 | ORDER BY registration_count DESC"; |
@@ -5659,14 +5659,14 @@ discard block |
||
| 5659 | 5659 | |
| 5660 | 5660 | $aircraft_array = array(); |
| 5661 | 5661 | $temp_array = array(); |
| 5662 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5662 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5663 | 5663 | { |
| 5664 | 5664 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5665 | 5665 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 5666 | 5666 | $temp_array['registration'] = $row['registration']; |
| 5667 | 5667 | $temp_array['airline_name'] = $row['airline_name']; |
| 5668 | 5668 | $temp_array['image_thumbnail'] = ""; |
| 5669 | - if($row['registration'] != "") |
|
| 5669 | + if ($row['registration'] != "") |
|
| 5670 | 5670 | { |
| 5671 | 5671 | $image_array = $Image->getSpotterImage($row['registration']); |
| 5672 | 5672 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -5685,11 +5685,11 @@ discard block |
||
| 5685 | 5685 | * @return Array the aircraft manufacturer list |
| 5686 | 5686 | * |
| 5687 | 5687 | */ |
| 5688 | - public function countAllAircraftManufacturerByDate($date,$filters = array()) |
|
| 5688 | + public function countAllAircraftManufacturerByDate($date, $filters = array()) |
|
| 5689 | 5689 | { |
| 5690 | 5690 | global $globalTimezone, $globalDBdriver; |
| 5691 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5692 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 5691 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5692 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 5693 | 5693 | if ($globalTimezone != '') { |
| 5694 | 5694 | date_default_timezone_set($globalTimezone); |
| 5695 | 5695 | $datetime = new DateTime($date); |
@@ -5697,12 +5697,12 @@ discard block |
||
| 5697 | 5697 | } else $offset = '+00:00'; |
| 5698 | 5698 | |
| 5699 | 5699 | if ($globalDBdriver == 'mysql') { |
| 5700 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 5700 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 5701 | 5701 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 5702 | 5702 | GROUP BY spotter_output.aircraft_manufacturer |
| 5703 | 5703 | ORDER BY aircraft_manufacturer_count DESC"; |
| 5704 | 5704 | } else { |
| 5705 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 5705 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 5706 | 5706 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 5707 | 5707 | GROUP BY spotter_output.aircraft_manufacturer |
| 5708 | 5708 | ORDER BY aircraft_manufacturer_count DESC"; |
@@ -5714,7 +5714,7 @@ discard block |
||
| 5714 | 5714 | $aircraft_array = array(); |
| 5715 | 5715 | $temp_array = array(); |
| 5716 | 5716 | |
| 5717 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5717 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5718 | 5718 | { |
| 5719 | 5719 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
| 5720 | 5720 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
@@ -5731,11 +5731,11 @@ discard block |
||
| 5731 | 5731 | * @return Array the aircraft list |
| 5732 | 5732 | * |
| 5733 | 5733 | */ |
| 5734 | - public function countAllAircraftTypesByIdent($ident,$filters = array()) |
|
| 5734 | + public function countAllAircraftTypesByIdent($ident, $filters = array()) |
|
| 5735 | 5735 | { |
| 5736 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5737 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 5738 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5736 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5737 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 5738 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5739 | 5739 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
| 5740 | 5740 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
| 5741 | 5741 | ORDER BY aircraft_icao_count DESC"; |
@@ -5746,7 +5746,7 @@ discard block |
||
| 5746 | 5746 | $aircraft_array = array(); |
| 5747 | 5747 | $temp_array = array(); |
| 5748 | 5748 | |
| 5749 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5749 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5750 | 5750 | { |
| 5751 | 5751 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5752 | 5752 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -5763,45 +5763,45 @@ discard block |
||
| 5763 | 5763 | * @return Array the aircraft list |
| 5764 | 5764 | * |
| 5765 | 5765 | */ |
| 5766 | - public function countAllAircraftTypesByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '') |
|
| 5766 | + public function countAllAircraftTypesByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '') |
|
| 5767 | 5767 | { |
| 5768 | 5768 | global $globalDBdriver; |
| 5769 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5770 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 5771 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5769 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5770 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 5771 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 5772 | 5772 | FROM spotter_output".$filter_query." (spotter_output.pilot_id = :pilot OR spotter_output.pilot_name = :pilot)"; |
| 5773 | 5773 | $query_values = array(); |
| 5774 | 5774 | if ($year != '') { |
| 5775 | 5775 | if ($globalDBdriver == 'mysql') { |
| 5776 | 5776 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 5777 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5777 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5778 | 5778 | } else { |
| 5779 | 5779 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 5780 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5780 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5781 | 5781 | } |
| 5782 | 5782 | } |
| 5783 | 5783 | if ($month != '') { |
| 5784 | 5784 | if ($globalDBdriver == 'mysql') { |
| 5785 | 5785 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 5786 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5786 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5787 | 5787 | } else { |
| 5788 | 5788 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 5789 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5789 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5790 | 5790 | } |
| 5791 | 5791 | } |
| 5792 | 5792 | if ($day != '') { |
| 5793 | 5793 | if ($globalDBdriver == 'mysql') { |
| 5794 | 5794 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 5795 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5795 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5796 | 5796 | } else { |
| 5797 | 5797 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 5798 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5798 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5799 | 5799 | } |
| 5800 | 5800 | } |
| 5801 | 5801 | |
| 5802 | 5802 | $query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
| 5803 | 5803 | ORDER BY aircraft_icao_count DESC"; |
| 5804 | - $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
|
| 5804 | + $query_values = array_merge($query_values, array(':pilot' => $pilot)); |
|
| 5805 | 5805 | $sth = $this->db->prepare($query); |
| 5806 | 5806 | $sth->execute($query_values); |
| 5807 | 5807 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -5813,44 +5813,44 @@ discard block |
||
| 5813 | 5813 | * @return Array the aircraft list |
| 5814 | 5814 | * |
| 5815 | 5815 | */ |
| 5816 | - public function countAllAircraftTypesByOwner($owner,$filters = array(),$year = '',$month = '',$day = '') |
|
| 5816 | + public function countAllAircraftTypesByOwner($owner, $filters = array(), $year = '', $month = '', $day = '') |
|
| 5817 | 5817 | { |
| 5818 | 5818 | global $globalDBdriver; |
| 5819 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5820 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 5821 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
| 5819 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5820 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 5821 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer |
|
| 5822 | 5822 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner"; |
| 5823 | 5823 | $query_values = array(); |
| 5824 | 5824 | if ($year != '') { |
| 5825 | 5825 | if ($globalDBdriver == 'mysql') { |
| 5826 | 5826 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 5827 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5827 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5828 | 5828 | } else { |
| 5829 | 5829 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 5830 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5830 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5831 | 5831 | } |
| 5832 | 5832 | } |
| 5833 | 5833 | if ($month != '') { |
| 5834 | 5834 | if ($globalDBdriver == 'mysql') { |
| 5835 | 5835 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 5836 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5836 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5837 | 5837 | } else { |
| 5838 | 5838 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 5839 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5839 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5840 | 5840 | } |
| 5841 | 5841 | } |
| 5842 | 5842 | if ($day != '') { |
| 5843 | 5843 | if ($globalDBdriver == 'mysql') { |
| 5844 | 5844 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 5845 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5845 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5846 | 5846 | } else { |
| 5847 | 5847 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 5848 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5848 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5849 | 5849 | } |
| 5850 | 5850 | } |
| 5851 | 5851 | $query .= " GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.aircraft_icao |
| 5852 | 5852 | ORDER BY aircraft_icao_count DESC"; |
| 5853 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 5853 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 5854 | 5854 | $sth = $this->db->prepare($query); |
| 5855 | 5855 | $sth->execute($query_values); |
| 5856 | 5856 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -5862,13 +5862,13 @@ discard block |
||
| 5862 | 5862 | * @return Array the aircraft list |
| 5863 | 5863 | * |
| 5864 | 5864 | */ |
| 5865 | - public function countAllAircraftRegistrationByIdent($ident,$filters = array()) |
|
| 5865 | + public function countAllAircraftRegistrationByIdent($ident, $filters = array()) |
|
| 5866 | 5866 | { |
| 5867 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5867 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5868 | 5868 | $Image = new Image($this->db); |
| 5869 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 5869 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 5870 | 5870 | |
| 5871 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5871 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 5872 | 5872 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.ident = :ident |
| 5873 | 5873 | GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
| 5874 | 5874 | ORDER BY registration_count DESC"; |
@@ -5880,14 +5880,14 @@ discard block |
||
| 5880 | 5880 | $aircraft_array = array(); |
| 5881 | 5881 | $temp_array = array(); |
| 5882 | 5882 | |
| 5883 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5883 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5884 | 5884 | { |
| 5885 | 5885 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5886 | 5886 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 5887 | 5887 | $temp_array['registration'] = $row['registration']; |
| 5888 | 5888 | $temp_array['airline_name'] = $row['airline_name']; |
| 5889 | 5889 | $temp_array['image_thumbnail'] = ""; |
| 5890 | - if($row['registration'] != "") |
|
| 5890 | + if ($row['registration'] != "") |
|
| 5891 | 5891 | { |
| 5892 | 5892 | $image_array = $Image->getSpotterImage($row['registration']); |
| 5893 | 5893 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -5905,44 +5905,44 @@ discard block |
||
| 5905 | 5905 | * @return Array the aircraft list |
| 5906 | 5906 | * |
| 5907 | 5907 | */ |
| 5908 | - public function countAllAircraftRegistrationByOwner($owner,$filters = array(),$year = '',$month = '',$day = '') |
|
| 5908 | + public function countAllAircraftRegistrationByOwner($owner, $filters = array(), $year = '', $month = '', $day = '') |
|
| 5909 | 5909 | { |
| 5910 | 5910 | global $globalDBdriver; |
| 5911 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5911 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5912 | 5912 | $Image = new Image($this->db); |
| 5913 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 5913 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 5914 | 5914 | |
| 5915 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name |
|
| 5915 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name |
|
| 5916 | 5916 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND spotter_output.owner_name = :owner"; |
| 5917 | 5917 | $query_values = array(); |
| 5918 | 5918 | if ($year != '') { |
| 5919 | 5919 | if ($globalDBdriver == 'mysql') { |
| 5920 | 5920 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 5921 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5921 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5922 | 5922 | } else { |
| 5923 | 5923 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 5924 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5924 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5925 | 5925 | } |
| 5926 | 5926 | } |
| 5927 | 5927 | if ($month != '') { |
| 5928 | 5928 | if ($globalDBdriver == 'mysql') { |
| 5929 | 5929 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 5930 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5930 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5931 | 5931 | } else { |
| 5932 | 5932 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 5933 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 5933 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 5934 | 5934 | } |
| 5935 | 5935 | } |
| 5936 | 5936 | if ($day != '') { |
| 5937 | 5937 | if ($globalDBdriver == 'mysql') { |
| 5938 | 5938 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 5939 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5939 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5940 | 5940 | } else { |
| 5941 | 5941 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 5942 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 5942 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 5943 | 5943 | } |
| 5944 | 5944 | } |
| 5945 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 5945 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 5946 | 5946 | |
| 5947 | 5947 | $query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name |
| 5948 | 5948 | ORDER BY registration_count DESC"; |
@@ -5954,7 +5954,7 @@ discard block |
||
| 5954 | 5954 | $aircraft_array = array(); |
| 5955 | 5955 | $temp_array = array(); |
| 5956 | 5956 | |
| 5957 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5957 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 5958 | 5958 | { |
| 5959 | 5959 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 5960 | 5960 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -5962,7 +5962,7 @@ discard block |
||
| 5962 | 5962 | $temp_array['registration'] = $row['registration']; |
| 5963 | 5963 | $temp_array['airline_name'] = $row['airline_name']; |
| 5964 | 5964 | $temp_array['image_thumbnail'] = ""; |
| 5965 | - if($row['registration'] != "") |
|
| 5965 | + if ($row['registration'] != "") |
|
| 5966 | 5966 | { |
| 5967 | 5967 | $image_array = $Image->getSpotterImage($row['registration']); |
| 5968 | 5968 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -5980,44 +5980,44 @@ discard block |
||
| 5980 | 5980 | * @return Array the aircraft list |
| 5981 | 5981 | * |
| 5982 | 5982 | */ |
| 5983 | - public function countAllAircraftRegistrationByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '') |
|
| 5983 | + public function countAllAircraftRegistrationByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '') |
|
| 5984 | 5984 | { |
| 5985 | 5985 | global $globalDBdriver; |
| 5986 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 5986 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 5987 | 5987 | $Image = new Image($this->db); |
| 5988 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 5988 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 5989 | 5989 | |
| 5990 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name |
|
| 5990 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.registration, spotter_output.airline_name |
|
| 5991 | 5991 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)"; |
| 5992 | 5992 | $query_values = array(); |
| 5993 | 5993 | if ($year != '') { |
| 5994 | 5994 | if ($globalDBdriver == 'mysql') { |
| 5995 | 5995 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 5996 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5996 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 5997 | 5997 | } else { |
| 5998 | 5998 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 5999 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 5999 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6000 | 6000 | } |
| 6001 | 6001 | } |
| 6002 | 6002 | if ($month != '') { |
| 6003 | 6003 | if ($globalDBdriver == 'mysql') { |
| 6004 | 6004 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 6005 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6005 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6006 | 6006 | } else { |
| 6007 | 6007 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 6008 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6008 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6009 | 6009 | } |
| 6010 | 6010 | } |
| 6011 | 6011 | if ($day != '') { |
| 6012 | 6012 | if ($globalDBdriver == 'mysql') { |
| 6013 | 6013 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 6014 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6014 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6015 | 6015 | } else { |
| 6016 | 6016 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 6017 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6017 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6018 | 6018 | } |
| 6019 | 6019 | } |
| 6020 | - $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
|
| 6020 | + $query_values = array_merge($query_values, array(':pilot' => $pilot)); |
|
| 6021 | 6021 | |
| 6022 | 6022 | $query .= " GROUP BY spotter_output.registration,spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.aircraft_manufacturer, spotter_output.airline_name |
| 6023 | 6023 | ORDER BY registration_count DESC"; |
@@ -6029,7 +6029,7 @@ discard block |
||
| 6029 | 6029 | $aircraft_array = array(); |
| 6030 | 6030 | $temp_array = array(); |
| 6031 | 6031 | |
| 6032 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6032 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6033 | 6033 | { |
| 6034 | 6034 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 6035 | 6035 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -6037,7 +6037,7 @@ discard block |
||
| 6037 | 6037 | $temp_array['registration'] = $row['registration']; |
| 6038 | 6038 | $temp_array['airline_name'] = $row['airline_name']; |
| 6039 | 6039 | $temp_array['image_thumbnail'] = ""; |
| 6040 | - if($row['registration'] != "") |
|
| 6040 | + if ($row['registration'] != "") |
|
| 6041 | 6041 | { |
| 6042 | 6042 | $image_array = $Image->getSpotterImage($row['registration']); |
| 6043 | 6043 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -6056,11 +6056,11 @@ discard block |
||
| 6056 | 6056 | * @return Array the aircraft manufacturer list |
| 6057 | 6057 | * |
| 6058 | 6058 | */ |
| 6059 | - public function countAllAircraftManufacturerByIdent($ident,$filters = array()) |
|
| 6059 | + public function countAllAircraftManufacturerByIdent($ident, $filters = array()) |
|
| 6060 | 6060 | { |
| 6061 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6062 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 6063 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6061 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6062 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 6063 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6064 | 6064 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.ident = :ident |
| 6065 | 6065 | GROUP BY spotter_output.aircraft_manufacturer |
| 6066 | 6066 | ORDER BY aircraft_manufacturer_count DESC"; |
@@ -6070,7 +6070,7 @@ discard block |
||
| 6070 | 6070 | $sth->execute(array(':ident' => $ident)); |
| 6071 | 6071 | $aircraft_array = array(); |
| 6072 | 6072 | $temp_array = array(); |
| 6073 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6073 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6074 | 6074 | { |
| 6075 | 6075 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
| 6076 | 6076 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
@@ -6085,42 +6085,42 @@ discard block |
||
| 6085 | 6085 | * @return Array the aircraft manufacturer list |
| 6086 | 6086 | * |
| 6087 | 6087 | */ |
| 6088 | - public function countAllAircraftManufacturerByOwner($owner,$filters = array(),$year = '',$month = '',$day = '') |
|
| 6088 | + public function countAllAircraftManufacturerByOwner($owner, $filters = array(), $year = '', $month = '', $day = '') |
|
| 6089 | 6089 | { |
| 6090 | 6090 | global $globalDBdriver; |
| 6091 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6092 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 6093 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6091 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6092 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 6093 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6094 | 6094 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.owner_name = :owner"; |
| 6095 | 6095 | $query_values = array(); |
| 6096 | 6096 | if ($year != '') { |
| 6097 | 6097 | if ($globalDBdriver == 'mysql') { |
| 6098 | 6098 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 6099 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6099 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6100 | 6100 | } else { |
| 6101 | 6101 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 6102 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6102 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6103 | 6103 | } |
| 6104 | 6104 | } |
| 6105 | 6105 | if ($month != '') { |
| 6106 | 6106 | if ($globalDBdriver == 'mysql') { |
| 6107 | 6107 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 6108 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6108 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6109 | 6109 | } else { |
| 6110 | 6110 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 6111 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6111 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6112 | 6112 | } |
| 6113 | 6113 | } |
| 6114 | 6114 | if ($day != '') { |
| 6115 | 6115 | if ($globalDBdriver == 'mysql') { |
| 6116 | 6116 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 6117 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6117 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6118 | 6118 | } else { |
| 6119 | 6119 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 6120 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6120 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6121 | 6121 | } |
| 6122 | 6122 | } |
| 6123 | - $query_values = array_merge($query_values,array(':owner' => $owner)); |
|
| 6123 | + $query_values = array_merge($query_values, array(':owner' => $owner)); |
|
| 6124 | 6124 | |
| 6125 | 6125 | $query .= " GROUP BY spotter_output.aircraft_manufacturer |
| 6126 | 6126 | ORDER BY aircraft_manufacturer_count DESC"; |
@@ -6137,42 +6137,42 @@ discard block |
||
| 6137 | 6137 | * @return Array the aircraft manufacturer list |
| 6138 | 6138 | * |
| 6139 | 6139 | */ |
| 6140 | - public function countAllAircraftManufacturerByPilot($pilot,$filters = array(),$year = '',$month = '',$day = '') |
|
| 6140 | + public function countAllAircraftManufacturerByPilot($pilot, $filters = array(), $year = '', $month = '', $day = '') |
|
| 6141 | 6141 | { |
| 6142 | 6142 | global $globalDBdriver; |
| 6143 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6144 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 6145 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6143 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6144 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 6145 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6146 | 6146 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot)"; |
| 6147 | 6147 | $query_values = array(); |
| 6148 | 6148 | if ($year != '') { |
| 6149 | 6149 | if ($globalDBdriver == 'mysql') { |
| 6150 | 6150 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 6151 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6151 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6152 | 6152 | } else { |
| 6153 | 6153 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 6154 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6154 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6155 | 6155 | } |
| 6156 | 6156 | } |
| 6157 | 6157 | if ($month != '') { |
| 6158 | 6158 | if ($globalDBdriver == 'mysql') { |
| 6159 | 6159 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 6160 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6160 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6161 | 6161 | } else { |
| 6162 | 6162 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 6163 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6163 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6164 | 6164 | } |
| 6165 | 6165 | } |
| 6166 | 6166 | if ($day != '') { |
| 6167 | 6167 | if ($globalDBdriver == 'mysql') { |
| 6168 | 6168 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 6169 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6169 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6170 | 6170 | } else { |
| 6171 | 6171 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 6172 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6172 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6173 | 6173 | } |
| 6174 | 6174 | } |
| 6175 | - $query_values = array_merge($query_values,array(':pilot' => $pilot)); |
|
| 6175 | + $query_values = array_merge($query_values, array(':pilot' => $pilot)); |
|
| 6176 | 6176 | |
| 6177 | 6177 | $query .= " GROUP BY spotter_output.aircraft_manufacturer |
| 6178 | 6178 | ORDER BY aircraft_manufacturer_count DESC"; |
@@ -6190,24 +6190,24 @@ discard block |
||
| 6190 | 6190 | * @return Array the aircraft list |
| 6191 | 6191 | * |
| 6192 | 6192 | */ |
| 6193 | - public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
|
| 6193 | + public function countAllAircraftTypesByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array()) |
|
| 6194 | 6194 | { |
| 6195 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6196 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 6197 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 6195 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6196 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 6197 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 6198 | 6198 | |
| 6199 | 6199 | |
| 6200 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 6200 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 6201 | 6201 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
| 6202 | 6202 | GROUP BY spotter_output.aircraft_name |
| 6203 | 6203 | ORDER BY aircraft_icao_count DESC"; |
| 6204 | 6204 | |
| 6205 | 6205 | |
| 6206 | 6206 | $sth = $this->db->prepare($query); |
| 6207 | - $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 6207 | + $sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 6208 | 6208 | $aircraft_array = array(); |
| 6209 | 6209 | $temp_array = array(); |
| 6210 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6210 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6211 | 6211 | { |
| 6212 | 6212 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 6213 | 6213 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -6223,33 +6223,33 @@ discard block |
||
| 6223 | 6223 | * @return Array the aircraft list |
| 6224 | 6224 | * |
| 6225 | 6225 | */ |
| 6226 | - public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
|
| 6226 | + public function countAllAircraftRegistrationByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array()) |
|
| 6227 | 6227 | { |
| 6228 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6228 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6229 | 6229 | $Image = new Image($this->db); |
| 6230 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 6231 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 6230 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 6231 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 6232 | 6232 | |
| 6233 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 6233 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 6234 | 6234 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
| 6235 | 6235 | GROUP BY spotter_output.registration |
| 6236 | 6236 | ORDER BY registration_count DESC"; |
| 6237 | 6237 | |
| 6238 | 6238 | |
| 6239 | 6239 | $sth = $this->db->prepare($query); |
| 6240 | - $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 6240 | + $sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 6241 | 6241 | |
| 6242 | 6242 | $aircraft_array = array(); |
| 6243 | 6243 | $temp_array = array(); |
| 6244 | 6244 | |
| 6245 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6245 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6246 | 6246 | { |
| 6247 | 6247 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 6248 | 6248 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 6249 | 6249 | $temp_array['registration'] = $row['registration']; |
| 6250 | 6250 | $temp_array['airline_name'] = $row['airline_name']; |
| 6251 | 6251 | $temp_array['image_thumbnail'] = ""; |
| 6252 | - if($row['registration'] != "") |
|
| 6252 | + if ($row['registration'] != "") |
|
| 6253 | 6253 | { |
| 6254 | 6254 | $image_array = $Image->getSpotterImage($row['registration']); |
| 6255 | 6255 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -6269,25 +6269,25 @@ discard block |
||
| 6269 | 6269 | * @return Array the aircraft manufacturer list |
| 6270 | 6270 | * |
| 6271 | 6271 | */ |
| 6272 | - public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao,$filters = array()) |
|
| 6272 | + public function countAllAircraftManufacturerByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array()) |
|
| 6273 | 6273 | { |
| 6274 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6275 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 6276 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 6274 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6275 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 6276 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 6277 | 6277 | |
| 6278 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6278 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6279 | 6279 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
| 6280 | 6280 | GROUP BY spotter_output.aircraft_manufacturer |
| 6281 | 6281 | ORDER BY aircraft_manufacturer_count DESC"; |
| 6282 | 6282 | |
| 6283 | 6283 | |
| 6284 | 6284 | $sth = $this->db->prepare($query); |
| 6285 | - $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 6285 | + $sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao)); |
|
| 6286 | 6286 | |
| 6287 | 6287 | $aircraft_array = array(); |
| 6288 | 6288 | $temp_array = array(); |
| 6289 | 6289 | |
| 6290 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6290 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6291 | 6291 | { |
| 6292 | 6292 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
| 6293 | 6293 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
@@ -6307,11 +6307,11 @@ discard block |
||
| 6307 | 6307 | * @return Array the aircraft list |
| 6308 | 6308 | * |
| 6309 | 6309 | */ |
| 6310 | - public function countAllAircraftTypesByCountry($country,$filters = array()) |
|
| 6310 | + public function countAllAircraftTypesByCountry($country, $filters = array()) |
|
| 6311 | 6311 | { |
| 6312 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6313 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 6314 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 6312 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6313 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 6314 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.aircraft_icao) AS aircraft_icao_count, spotter_output.aircraft_name |
|
| 6315 | 6315 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 6316 | 6316 | GROUP BY spotter_output.aircraft_name, spotter_output.aircraft_icao |
| 6317 | 6317 | ORDER BY aircraft_icao_count DESC"; |
@@ -6323,7 +6323,7 @@ discard block |
||
| 6323 | 6323 | $aircraft_array = array(); |
| 6324 | 6324 | $temp_array = array(); |
| 6325 | 6325 | |
| 6326 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6326 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6327 | 6327 | { |
| 6328 | 6328 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 6329 | 6329 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
@@ -6342,12 +6342,12 @@ discard block |
||
| 6342 | 6342 | * @return Array the aircraft list |
| 6343 | 6343 | * |
| 6344 | 6344 | */ |
| 6345 | - public function countAllAircraftRegistrationByCountry($country,$filters = array()) |
|
| 6345 | + public function countAllAircraftRegistrationByCountry($country, $filters = array()) |
|
| 6346 | 6346 | { |
| 6347 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6347 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6348 | 6348 | $Image = new Image($this->db); |
| 6349 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 6350 | - $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 6349 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 6350 | + $query = "SELECT DISTINCT spotter_output.aircraft_icao, COUNT(spotter_output.registration) AS registration_count, spotter_output.aircraft_name, spotter_output.registration, spotter_output.airline_name |
|
| 6351 | 6351 | FROM spotter_output".$filter_query." spotter_output.registration <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) |
| 6352 | 6352 | GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
| 6353 | 6353 | ORDER BY registration_count DESC"; |
@@ -6359,14 +6359,14 @@ discard block |
||
| 6359 | 6359 | $aircraft_array = array(); |
| 6360 | 6360 | $temp_array = array(); |
| 6361 | 6361 | |
| 6362 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6362 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6363 | 6363 | { |
| 6364 | 6364 | $temp_array['aircraft_icao'] = $row['aircraft_icao']; |
| 6365 | 6365 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 6366 | 6366 | $temp_array['registration'] = $row['registration']; |
| 6367 | 6367 | $temp_array['airline_name'] = $row['airline_name']; |
| 6368 | 6368 | $temp_array['image_thumbnail'] = ""; |
| 6369 | - if($row['registration'] != "") |
|
| 6369 | + if ($row['registration'] != "") |
|
| 6370 | 6370 | { |
| 6371 | 6371 | $image_array = $Image->getSpotterImage($row['registration']); |
| 6372 | 6372 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -6386,11 +6386,11 @@ discard block |
||
| 6386 | 6386 | * @return Array the aircraft manufacturer list |
| 6387 | 6387 | * |
| 6388 | 6388 | */ |
| 6389 | - public function countAllAircraftManufacturerByCountry($country,$filters = array()) |
|
| 6389 | + public function countAllAircraftManufacturerByCountry($country, $filters = array()) |
|
| 6390 | 6390 | { |
| 6391 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6392 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 6393 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6391 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6392 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 6393 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6394 | 6394 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer <> '' AND (((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country) |
| 6395 | 6395 | GROUP BY spotter_output.aircraft_manufacturer |
| 6396 | 6396 | ORDER BY aircraft_manufacturer_count DESC"; |
@@ -6402,7 +6402,7 @@ discard block |
||
| 6402 | 6402 | $aircraft_array = array(); |
| 6403 | 6403 | $temp_array = array(); |
| 6404 | 6404 | |
| 6405 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6405 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6406 | 6406 | { |
| 6407 | 6407 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
| 6408 | 6408 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
@@ -6421,38 +6421,38 @@ discard block |
||
| 6421 | 6421 | * @return Array the aircraft list |
| 6422 | 6422 | * |
| 6423 | 6423 | */ |
| 6424 | - public function countAllAircraftManufacturers($filters = array(),$year = '',$month = '',$day = '') |
|
| 6424 | + public function countAllAircraftManufacturers($filters = array(), $year = '', $month = '', $day = '') |
|
| 6425 | 6425 | { |
| 6426 | 6426 | global $globalDBdriver; |
| 6427 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6428 | - $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6427 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6428 | + $query = "SELECT DISTINCT spotter_output.aircraft_manufacturer, COUNT(spotter_output.aircraft_manufacturer) AS aircraft_manufacturer_count |
|
| 6429 | 6429 | FROM spotter_output ".$filter_query." spotter_output.aircraft_manufacturer <> '' AND spotter_output.aircraft_manufacturer <> 'Not Available'"; |
| 6430 | 6430 | $query_values = array(); |
| 6431 | 6431 | if ($year != '') { |
| 6432 | 6432 | if ($globalDBdriver == 'mysql') { |
| 6433 | 6433 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 6434 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6434 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6435 | 6435 | } else { |
| 6436 | 6436 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 6437 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6437 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6438 | 6438 | } |
| 6439 | 6439 | } |
| 6440 | 6440 | if ($month != '') { |
| 6441 | 6441 | if ($globalDBdriver == 'mysql') { |
| 6442 | 6442 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 6443 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6443 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6444 | 6444 | } else { |
| 6445 | 6445 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 6446 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6446 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6447 | 6447 | } |
| 6448 | 6448 | } |
| 6449 | 6449 | if ($day != '') { |
| 6450 | 6450 | if ($globalDBdriver == 'mysql') { |
| 6451 | 6451 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 6452 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6452 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6453 | 6453 | } else { |
| 6454 | 6454 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 6455 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6455 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6456 | 6456 | } |
| 6457 | 6457 | } |
| 6458 | 6458 | $query .= " GROUP BY spotter_output.aircraft_manufacturer |
@@ -6466,7 +6466,7 @@ discard block |
||
| 6466 | 6466 | $manufacturer_array = array(); |
| 6467 | 6467 | $temp_array = array(); |
| 6468 | 6468 | |
| 6469 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6469 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6470 | 6470 | { |
| 6471 | 6471 | $temp_array['aircraft_manufacturer'] = $row['aircraft_manufacturer']; |
| 6472 | 6472 | $temp_array['aircraft_manufacturer_count'] = $row['aircraft_manufacturer_count']; |
@@ -6485,12 +6485,12 @@ discard block |
||
| 6485 | 6485 | * @return Array the aircraft list |
| 6486 | 6486 | * |
| 6487 | 6487 | */ |
| 6488 | - public function countAllAircraftRegistrations($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 6488 | + public function countAllAircraftRegistrations($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 6489 | 6489 | { |
| 6490 | 6490 | global $globalDBdriver; |
| 6491 | 6491 | $Image = new Image($this->db); |
| 6492 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6493 | - $query = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
| 6492 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6493 | + $query = "SELECT DISTINCT spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
| 6494 | 6494 | FROM spotter_output ".$filter_query." spotter_output.registration <> '' AND spotter_output.registration <> 'NA'"; |
| 6495 | 6495 | if ($olderthanmonths > 0) { |
| 6496 | 6496 | if ($globalDBdriver == 'mysql') { |
@@ -6510,28 +6510,28 @@ discard block |
||
| 6510 | 6510 | if ($year != '') { |
| 6511 | 6511 | if ($globalDBdriver == 'mysql') { |
| 6512 | 6512 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 6513 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6513 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6514 | 6514 | } else { |
| 6515 | 6515 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 6516 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6516 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6517 | 6517 | } |
| 6518 | 6518 | } |
| 6519 | 6519 | if ($month != '') { |
| 6520 | 6520 | if ($globalDBdriver == 'mysql') { |
| 6521 | 6521 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 6522 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6522 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6523 | 6523 | } else { |
| 6524 | 6524 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 6525 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6525 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6526 | 6526 | } |
| 6527 | 6527 | } |
| 6528 | 6528 | if ($day != '') { |
| 6529 | 6529 | if ($globalDBdriver == 'mysql') { |
| 6530 | 6530 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 6531 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6531 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6532 | 6532 | } else { |
| 6533 | 6533 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 6534 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6534 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6535 | 6535 | } |
| 6536 | 6536 | } |
| 6537 | 6537 | $query .= " GROUP BY spotter_output.registration, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name ORDER BY aircraft_registration_count DESC"; |
@@ -6543,7 +6543,7 @@ discard block |
||
| 6543 | 6543 | $aircraft_array = array(); |
| 6544 | 6544 | $temp_array = array(); |
| 6545 | 6545 | |
| 6546 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6546 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6547 | 6547 | { |
| 6548 | 6548 | $temp_array['registration'] = $row['registration']; |
| 6549 | 6549 | $temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; |
@@ -6551,7 +6551,7 @@ discard block |
||
| 6551 | 6551 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 6552 | 6552 | $temp_array['airline_name'] = $row['airline_name']; |
| 6553 | 6553 | $temp_array['image_thumbnail'] = ""; |
| 6554 | - if($row['registration'] != "") |
|
| 6554 | + if ($row['registration'] != "") |
|
| 6555 | 6555 | { |
| 6556 | 6556 | $image_array = $Image->getSpotterImage($row['registration']); |
| 6557 | 6557 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -6570,12 +6570,12 @@ discard block |
||
| 6570 | 6570 | * @return Array the aircraft list |
| 6571 | 6571 | * |
| 6572 | 6572 | */ |
| 6573 | - public function countAllAircraftRegistrationsByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array()) |
|
| 6573 | + public function countAllAircraftRegistrationsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 6574 | 6574 | { |
| 6575 | 6575 | global $globalDBdriver; |
| 6576 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6576 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6577 | 6577 | $Image = new Image($this->db); |
| 6578 | - $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
| 6578 | + $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.registration, COUNT(spotter_output.registration) AS aircraft_registration_count, spotter_output.aircraft_icao, spotter_output.aircraft_name, spotter_output.airline_name |
|
| 6579 | 6579 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.registration <> '' AND spotter_output.registration <> 'NA' "; |
| 6580 | 6580 | if ($olderthanmonths > 0) { |
| 6581 | 6581 | if ($globalDBdriver == 'mysql') { |
@@ -6603,7 +6603,7 @@ discard block |
||
| 6603 | 6603 | $aircraft_array = array(); |
| 6604 | 6604 | $temp_array = array(); |
| 6605 | 6605 | |
| 6606 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6606 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6607 | 6607 | { |
| 6608 | 6608 | $temp_array['registration'] = $row['registration']; |
| 6609 | 6609 | $temp_array['aircraft_registration_count'] = $row['aircraft_registration_count']; |
@@ -6612,7 +6612,7 @@ discard block |
||
| 6612 | 6612 | $temp_array['aircraft_name'] = $row['aircraft_name']; |
| 6613 | 6613 | $temp_array['airline_name'] = $row['airline_name']; |
| 6614 | 6614 | $temp_array['image_thumbnail'] = ""; |
| 6615 | - if($row['registration'] != "") |
|
| 6615 | + if ($row['registration'] != "") |
|
| 6616 | 6616 | { |
| 6617 | 6617 | $image_array = $Image->getSpotterImage($row['registration']); |
| 6618 | 6618 | if (isset($image_array[0]['image_thumbnail'])) $temp_array['image_thumbnail'] = $image_array[0]['image_thumbnail']; |
@@ -6631,11 +6631,11 @@ discard block |
||
| 6631 | 6631 | * @return Array the airport list |
| 6632 | 6632 | * |
| 6633 | 6633 | */ |
| 6634 | - public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 6634 | + public function countAllDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 6635 | 6635 | { |
| 6636 | 6636 | global $globalDBdriver; |
| 6637 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6638 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 6637 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6638 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 6639 | 6639 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''"; |
| 6640 | 6640 | if ($olderthanmonths > 0) { |
| 6641 | 6641 | if ($globalDBdriver == 'mysql') { |
@@ -6655,28 +6655,28 @@ discard block |
||
| 6655 | 6655 | if ($year != '') { |
| 6656 | 6656 | if ($globalDBdriver == 'mysql') { |
| 6657 | 6657 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 6658 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6658 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6659 | 6659 | } else { |
| 6660 | 6660 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 6661 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6661 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6662 | 6662 | } |
| 6663 | 6663 | } |
| 6664 | 6664 | if ($month != '') { |
| 6665 | 6665 | if ($globalDBdriver == 'mysql') { |
| 6666 | 6666 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 6667 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6667 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6668 | 6668 | } else { |
| 6669 | 6669 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 6670 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6670 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6671 | 6671 | } |
| 6672 | 6672 | } |
| 6673 | 6673 | if ($day != '') { |
| 6674 | 6674 | if ($globalDBdriver == 'mysql') { |
| 6675 | 6675 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 6676 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6676 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6677 | 6677 | } else { |
| 6678 | 6678 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 6679 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6679 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6680 | 6680 | } |
| 6681 | 6681 | } |
| 6682 | 6682 | $query .= " GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
@@ -6688,7 +6688,7 @@ discard block |
||
| 6688 | 6688 | |
| 6689 | 6689 | $airport_array = array(); |
| 6690 | 6690 | $temp_array = array(); |
| 6691 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6691 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6692 | 6692 | { |
| 6693 | 6693 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 6694 | 6694 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -6707,11 +6707,11 @@ discard block |
||
| 6707 | 6707 | * @return Array the airport list |
| 6708 | 6708 | * |
| 6709 | 6709 | */ |
| 6710 | - public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
| 6710 | + public function countAllDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 6711 | 6711 | { |
| 6712 | 6712 | global $globalDBdriver; |
| 6713 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6714 | - $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 6713 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6714 | + $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 6715 | 6715 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' "; |
| 6716 | 6716 | if ($olderthanmonths > 0) { |
| 6717 | 6717 | if ($globalDBdriver == 'mysql') { |
@@ -6740,7 +6740,7 @@ discard block |
||
| 6740 | 6740 | $airport_array = array(); |
| 6741 | 6741 | $temp_array = array(); |
| 6742 | 6742 | |
| 6743 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6743 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6744 | 6744 | { |
| 6745 | 6745 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 6746 | 6746 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -6760,11 +6760,11 @@ discard block |
||
| 6760 | 6760 | * @return Array the airport list |
| 6761 | 6761 | * |
| 6762 | 6762 | */ |
| 6763 | - public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '',$month = '',$day = '') |
|
| 6763 | + public function countAllDetectedDepartureAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 6764 | 6764 | { |
| 6765 | 6765 | global $globalDBdriver; |
| 6766 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6767 | - $query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country |
|
| 6766 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6767 | + $query = "SELECT DISTINCT spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country |
|
| 6768 | 6768 | FROM airport, spotter_output".$filter_query." spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao"; |
| 6769 | 6769 | if ($olderthanmonths > 0) { |
| 6770 | 6770 | if ($globalDBdriver == 'mysql') { |
@@ -6784,28 +6784,28 @@ discard block |
||
| 6784 | 6784 | if ($year != '') { |
| 6785 | 6785 | if ($globalDBdriver == 'mysql') { |
| 6786 | 6786 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 6787 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6787 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6788 | 6788 | } else { |
| 6789 | 6789 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 6790 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 6790 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 6791 | 6791 | } |
| 6792 | 6792 | } |
| 6793 | 6793 | if ($month != '') { |
| 6794 | 6794 | if ($globalDBdriver == 'mysql') { |
| 6795 | 6795 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 6796 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6796 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6797 | 6797 | } else { |
| 6798 | 6798 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 6799 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 6799 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 6800 | 6800 | } |
| 6801 | 6801 | } |
| 6802 | 6802 | if ($day != '') { |
| 6803 | 6803 | if ($globalDBdriver == 'mysql') { |
| 6804 | 6804 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 6805 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6805 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6806 | 6806 | } else { |
| 6807 | 6807 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 6808 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 6808 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 6809 | 6809 | } |
| 6810 | 6810 | } |
| 6811 | 6811 | $query .= " GROUP BY spotter_output.real_departure_airport_icao, airport.name, airport.city, airport.country |
@@ -6818,7 +6818,7 @@ discard block |
||
| 6818 | 6818 | $airport_array = array(); |
| 6819 | 6819 | $temp_array = array(); |
| 6820 | 6820 | |
| 6821 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6821 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6822 | 6822 | { |
| 6823 | 6823 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 6824 | 6824 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -6837,11 +6837,11 @@ discard block |
||
| 6837 | 6837 | * @return Array the airport list |
| 6838 | 6838 | * |
| 6839 | 6839 | */ |
| 6840 | - public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array()) |
|
| 6840 | + public function countAllDetectedDepartureAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
|
| 6841 | 6841 | { |
| 6842 | 6842 | global $globalDBdriver; |
| 6843 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6844 | - $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country |
|
| 6843 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6844 | + $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_departure_airport_icao AS departure_airport_icao, COUNT(spotter_output.real_departure_airport_icao) AS airport_departure_icao_count, airport.name as departure_airport_name, airport.city as departure_airport_city, airport.country as departure_airport_country |
|
| 6845 | 6845 | FROM airport, spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_departure_airport_icao <> '' AND spotter_output.real_departure_airport_icao <> 'NA' AND airport.icao = spotter_output.real_departure_airport_icao "; |
| 6846 | 6846 | if ($olderthanmonths > 0) { |
| 6847 | 6847 | if ($globalDBdriver == 'mysql') { |
@@ -6870,7 +6870,7 @@ discard block |
||
| 6870 | 6870 | $airport_array = array(); |
| 6871 | 6871 | $temp_array = array(); |
| 6872 | 6872 | |
| 6873 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6873 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6874 | 6874 | { |
| 6875 | 6875 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 6876 | 6876 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -6890,11 +6890,11 @@ discard block |
||
| 6890 | 6890 | * @return Array the airport list |
| 6891 | 6891 | * |
| 6892 | 6892 | */ |
| 6893 | - public function countAllDepartureAirportsByAirline($airline_icao,$filters = array()) |
|
| 6893 | + public function countAllDepartureAirportsByAirline($airline_icao, $filters = array()) |
|
| 6894 | 6894 | { |
| 6895 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6896 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 6897 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 6895 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6896 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 6897 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 6898 | 6898 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.airline_icao = :airline_icao AND spotter_output.departure_airport_icao <> '' |
| 6899 | 6899 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 6900 | 6900 | ORDER BY airport_departure_icao_count DESC"; |
@@ -6906,7 +6906,7 @@ discard block |
||
| 6906 | 6906 | $airport_array = array(); |
| 6907 | 6907 | $temp_array = array(); |
| 6908 | 6908 | |
| 6909 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6909 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6910 | 6910 | { |
| 6911 | 6911 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 6912 | 6912 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -6928,11 +6928,11 @@ discard block |
||
| 6928 | 6928 | * @return Array the airport list |
| 6929 | 6929 | * |
| 6930 | 6930 | */ |
| 6931 | - public function countAllDepartureAirportCountriesByAirline($airline_icao,$filters = array()) |
|
| 6931 | + public function countAllDepartureAirportCountriesByAirline($airline_icao, $filters = array()) |
|
| 6932 | 6932 | { |
| 6933 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6934 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 6935 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 6933 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6934 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 6935 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 6936 | 6936 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.airline_icao = :airline_icao |
| 6937 | 6937 | GROUP BY spotter_output.departure_airport_country |
| 6938 | 6938 | ORDER BY airport_departure_country_count DESC"; |
@@ -6944,7 +6944,7 @@ discard block |
||
| 6944 | 6944 | $airport_array = array(); |
| 6945 | 6945 | $temp_array = array(); |
| 6946 | 6946 | |
| 6947 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6947 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6948 | 6948 | { |
| 6949 | 6949 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 6950 | 6950 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
@@ -6963,11 +6963,11 @@ discard block |
||
| 6963 | 6963 | * @return Array the airport list |
| 6964 | 6964 | * |
| 6965 | 6965 | */ |
| 6966 | - public function countAllDepartureAirportsByAircraft($aircraft_icao,$filters = array()) |
|
| 6966 | + public function countAllDepartureAirportsByAircraft($aircraft_icao, $filters = array()) |
|
| 6967 | 6967 | { |
| 6968 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 6969 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 6970 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 6968 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 6969 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 6970 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 6971 | 6971 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_icao = :aircraft_icao AND spotter_output.departure_airport_icao <> '' |
| 6972 | 6972 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 6973 | 6973 | ORDER BY airport_departure_icao_count DESC"; |
@@ -6979,7 +6979,7 @@ discard block |
||
| 6979 | 6979 | $airport_array = array(); |
| 6980 | 6980 | $temp_array = array(); |
| 6981 | 6981 | |
| 6982 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6982 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 6983 | 6983 | { |
| 6984 | 6984 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 6985 | 6985 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7000,11 +7000,11 @@ discard block |
||
| 7000 | 7000 | * @return Array the airport list |
| 7001 | 7001 | * |
| 7002 | 7002 | */ |
| 7003 | - public function countAllDepartureAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
|
| 7003 | + public function countAllDepartureAirportCountriesByAircraft($aircraft_icao, $filters = array()) |
|
| 7004 | 7004 | { |
| 7005 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7006 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 7007 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7005 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7006 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 7007 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7008 | 7008 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
| 7009 | 7009 | GROUP BY spotter_output.departure_airport_country |
| 7010 | 7010 | ORDER BY airport_departure_country_count DESC"; |
@@ -7016,7 +7016,7 @@ discard block |
||
| 7016 | 7016 | $airport_array = array(); |
| 7017 | 7017 | $temp_array = array(); |
| 7018 | 7018 | |
| 7019 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7019 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7020 | 7020 | { |
| 7021 | 7021 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 7022 | 7022 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
@@ -7034,11 +7034,11 @@ discard block |
||
| 7034 | 7034 | * @return Array the airport list |
| 7035 | 7035 | * |
| 7036 | 7036 | */ |
| 7037 | - public function countAllDepartureAirportsByRegistration($registration,$filters = array()) |
|
| 7037 | + public function countAllDepartureAirportsByRegistration($registration, $filters = array()) |
|
| 7038 | 7038 | { |
| 7039 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7040 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 7041 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7039 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7040 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 7041 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7042 | 7042 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.registration = :registration AND spotter_output.departure_airport_icao <> '' |
| 7043 | 7043 | GROUP BY spotter_output.departure_airport_icao |
| 7044 | 7044 | ORDER BY airport_departure_icao_count DESC"; |
@@ -7050,7 +7050,7 @@ discard block |
||
| 7050 | 7050 | $airport_array = array(); |
| 7051 | 7051 | $temp_array = array(); |
| 7052 | 7052 | |
| 7053 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7053 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7054 | 7054 | { |
| 7055 | 7055 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 7056 | 7056 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7071,11 +7071,11 @@ discard block |
||
| 7071 | 7071 | * @return Array the airport list |
| 7072 | 7072 | * |
| 7073 | 7073 | */ |
| 7074 | - public function countAllDepartureAirportCountriesByRegistration($registration,$filters = array()) |
|
| 7074 | + public function countAllDepartureAirportCountriesByRegistration($registration, $filters = array()) |
|
| 7075 | 7075 | { |
| 7076 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7077 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 7078 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7076 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7077 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 7078 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7079 | 7079 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.registration = :registration |
| 7080 | 7080 | GROUP BY spotter_output.departure_airport_country |
| 7081 | 7081 | ORDER BY airport_departure_country_count DESC"; |
@@ -7087,7 +7087,7 @@ discard block |
||
| 7087 | 7087 | $airport_array = array(); |
| 7088 | 7088 | $temp_array = array(); |
| 7089 | 7089 | |
| 7090 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7090 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7091 | 7091 | { |
| 7092 | 7092 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 7093 | 7093 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
@@ -7105,11 +7105,11 @@ discard block |
||
| 7105 | 7105 | * @return Array the airport list |
| 7106 | 7106 | * |
| 7107 | 7107 | */ |
| 7108 | - public function countAllDepartureAirportsByAirport($airport_icao,$filters = array()) |
|
| 7108 | + public function countAllDepartureAirportsByAirport($airport_icao, $filters = array()) |
|
| 7109 | 7109 | { |
| 7110 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7111 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 7112 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7110 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7111 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 7112 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7113 | 7113 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao = :airport_icao AND spotter_output.departure_airport_icao <> '' |
| 7114 | 7114 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 7115 | 7115 | ORDER BY airport_departure_icao_count DESC"; |
@@ -7121,7 +7121,7 @@ discard block |
||
| 7121 | 7121 | $airport_array = array(); |
| 7122 | 7122 | $temp_array = array(); |
| 7123 | 7123 | |
| 7124 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7124 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7125 | 7125 | { |
| 7126 | 7126 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 7127 | 7127 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7142,11 +7142,11 @@ discard block |
||
| 7142 | 7142 | * @return Array the airport list |
| 7143 | 7143 | * |
| 7144 | 7144 | */ |
| 7145 | - public function countAllDepartureAirportCountriesByAirport($airport_icao,$filters = array()) |
|
| 7145 | + public function countAllDepartureAirportCountriesByAirport($airport_icao, $filters = array()) |
|
| 7146 | 7146 | { |
| 7147 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7148 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 7149 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7147 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7148 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 7149 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7150 | 7150 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.arrival_airport_icao = :airport_icao |
| 7151 | 7151 | GROUP BY spotter_output.departure_airport_country |
| 7152 | 7152 | ORDER BY airport_departure_country_count DESC"; |
@@ -7158,7 +7158,7 @@ discard block |
||
| 7158 | 7158 | $airport_array = array(); |
| 7159 | 7159 | $temp_array = array(); |
| 7160 | 7160 | |
| 7161 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7161 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7162 | 7162 | { |
| 7163 | 7163 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 7164 | 7164 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
@@ -7177,11 +7177,11 @@ discard block |
||
| 7177 | 7177 | * @return Array the airport list |
| 7178 | 7178 | * |
| 7179 | 7179 | */ |
| 7180 | - public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
|
| 7180 | + public function countAllDepartureAirportsByManufacturer($aircraft_manufacturer, $filters = array()) |
|
| 7181 | 7181 | { |
| 7182 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7183 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 7184 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7182 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7183 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 7184 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7185 | 7185 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer AND spotter_output.departure_airport_icao <> '' |
| 7186 | 7186 | GROUP BY spotter_output.departure_airport_icao |
| 7187 | 7187 | ORDER BY airport_departure_icao_count DESC"; |
@@ -7193,7 +7193,7 @@ discard block |
||
| 7193 | 7193 | $airport_array = array(); |
| 7194 | 7194 | $temp_array = array(); |
| 7195 | 7195 | |
| 7196 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7196 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7197 | 7197 | { |
| 7198 | 7198 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 7199 | 7199 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7214,11 +7214,11 @@ discard block |
||
| 7214 | 7214 | * @return Array the airport list |
| 7215 | 7215 | * |
| 7216 | 7216 | */ |
| 7217 | - public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
| 7217 | + public function countAllDepartureAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array()) |
|
| 7218 | 7218 | { |
| 7219 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7220 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 7221 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7219 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7220 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 7221 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7222 | 7222 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 7223 | 7223 | GROUP BY spotter_output.departure_airport_country |
| 7224 | 7224 | ORDER BY airport_departure_country_count DESC"; |
@@ -7230,7 +7230,7 @@ discard block |
||
| 7230 | 7230 | $airport_array = array(); |
| 7231 | 7231 | $temp_array = array(); |
| 7232 | 7232 | |
| 7233 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7233 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7234 | 7234 | { |
| 7235 | 7235 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 7236 | 7236 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
@@ -7248,11 +7248,11 @@ discard block |
||
| 7248 | 7248 | * @return Array the airport list |
| 7249 | 7249 | * |
| 7250 | 7250 | */ |
| 7251 | - public function countAllDepartureAirportsByDate($date,$filters = array()) |
|
| 7251 | + public function countAllDepartureAirportsByDate($date, $filters = array()) |
|
| 7252 | 7252 | { |
| 7253 | 7253 | global $globalTimezone, $globalDBdriver; |
| 7254 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7255 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 7254 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7255 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 7256 | 7256 | if ($globalTimezone != '') { |
| 7257 | 7257 | date_default_timezone_set($globalTimezone); |
| 7258 | 7258 | $datetime = new DateTime($date); |
@@ -7260,12 +7260,12 @@ discard block |
||
| 7260 | 7260 | } else $offset = '+00:00'; |
| 7261 | 7261 | |
| 7262 | 7262 | if ($globalDBdriver == 'mysql') { |
| 7263 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7263 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7264 | 7264 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 7265 | 7265 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 7266 | 7266 | ORDER BY airport_departure_icao_count DESC"; |
| 7267 | 7267 | } else { |
| 7268 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7268 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7269 | 7269 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 7270 | 7270 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 7271 | 7271 | ORDER BY airport_departure_icao_count DESC"; |
@@ -7277,7 +7277,7 @@ discard block |
||
| 7277 | 7277 | $airport_array = array(); |
| 7278 | 7278 | $temp_array = array(); |
| 7279 | 7279 | |
| 7280 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7280 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7281 | 7281 | { |
| 7282 | 7282 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 7283 | 7283 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7298,11 +7298,11 @@ discard block |
||
| 7298 | 7298 | * @return Array the airport list |
| 7299 | 7299 | * |
| 7300 | 7300 | */ |
| 7301 | - public function countAllDepartureAirportCountriesByDate($date,$filters = array()) |
|
| 7301 | + public function countAllDepartureAirportCountriesByDate($date, $filters = array()) |
|
| 7302 | 7302 | { |
| 7303 | 7303 | global $globalTimezone, $globalDBdriver; |
| 7304 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7305 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 7304 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7305 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 7306 | 7306 | if ($globalTimezone != '') { |
| 7307 | 7307 | date_default_timezone_set($globalTimezone); |
| 7308 | 7308 | $datetime = new DateTime($date); |
@@ -7310,12 +7310,12 @@ discard block |
||
| 7310 | 7310 | } else $offset = '+00:00'; |
| 7311 | 7311 | |
| 7312 | 7312 | if ($globalDBdriver == 'mysql') { |
| 7313 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7313 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7314 | 7314 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 7315 | 7315 | GROUP BY spotter_output.departure_airport_country |
| 7316 | 7316 | ORDER BY airport_departure_country_count DESC"; |
| 7317 | 7317 | } else { |
| 7318 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7318 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7319 | 7319 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 7320 | 7320 | GROUP BY spotter_output.departure_airport_country |
| 7321 | 7321 | ORDER BY airport_departure_country_count DESC"; |
@@ -7327,7 +7327,7 @@ discard block |
||
| 7327 | 7327 | $airport_array = array(); |
| 7328 | 7328 | $temp_array = array(); |
| 7329 | 7329 | |
| 7330 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7330 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7331 | 7331 | { |
| 7332 | 7332 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 7333 | 7333 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
@@ -7345,11 +7345,11 @@ discard block |
||
| 7345 | 7345 | * @return Array the airport list |
| 7346 | 7346 | * |
| 7347 | 7347 | */ |
| 7348 | - public function countAllDepartureAirportsByIdent($ident,$filters = array()) |
|
| 7348 | + public function countAllDepartureAirportsByIdent($ident, $filters = array()) |
|
| 7349 | 7349 | { |
| 7350 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7351 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 7352 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7350 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7351 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 7352 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7353 | 7353 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.ident = :ident |
| 7354 | 7354 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 7355 | 7355 | ORDER BY airport_departure_icao_count DESC"; |
@@ -7361,7 +7361,7 @@ discard block |
||
| 7361 | 7361 | $airport_array = array(); |
| 7362 | 7362 | $temp_array = array(); |
| 7363 | 7363 | |
| 7364 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7364 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7365 | 7365 | { |
| 7366 | 7366 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 7367 | 7367 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7381,11 +7381,11 @@ discard block |
||
| 7381 | 7381 | * @return Array the airport list |
| 7382 | 7382 | * |
| 7383 | 7383 | */ |
| 7384 | - public function countAllDepartureAirportsByOwner($owner,$filters = array()) |
|
| 7384 | + public function countAllDepartureAirportsByOwner($owner, $filters = array()) |
|
| 7385 | 7385 | { |
| 7386 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7387 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 7388 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7386 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7387 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 7388 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7389 | 7389 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.owner_name = :owner |
| 7390 | 7390 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 7391 | 7391 | ORDER BY airport_departure_icao_count DESC"; |
@@ -7397,7 +7397,7 @@ discard block |
||
| 7397 | 7397 | $airport_array = array(); |
| 7398 | 7398 | $temp_array = array(); |
| 7399 | 7399 | |
| 7400 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7400 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7401 | 7401 | { |
| 7402 | 7402 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 7403 | 7403 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7417,11 +7417,11 @@ discard block |
||
| 7417 | 7417 | * @return Array the airport list |
| 7418 | 7418 | * |
| 7419 | 7419 | */ |
| 7420 | - public function countAllDepartureAirportsByPilot($pilot,$filters = array()) |
|
| 7420 | + public function countAllDepartureAirportsByPilot($pilot, $filters = array()) |
|
| 7421 | 7421 | { |
| 7422 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7423 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 7424 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7422 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7423 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 7424 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7425 | 7425 | FROM spotter_output".$filter_query." spotter_output.departure_airport_name <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 7426 | 7426 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 7427 | 7427 | ORDER BY airport_departure_icao_count DESC"; |
@@ -7432,7 +7432,7 @@ discard block |
||
| 7432 | 7432 | $airport_array = array(); |
| 7433 | 7433 | $temp_array = array(); |
| 7434 | 7434 | |
| 7435 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7435 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7436 | 7436 | { |
| 7437 | 7437 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 7438 | 7438 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7454,11 +7454,11 @@ discard block |
||
| 7454 | 7454 | * @return Array the airport list |
| 7455 | 7455 | * |
| 7456 | 7456 | */ |
| 7457 | - public function countAllDepartureAirportCountriesByIdent($ident,$filters = array()) |
|
| 7457 | + public function countAllDepartureAirportCountriesByIdent($ident, $filters = array()) |
|
| 7458 | 7458 | { |
| 7459 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7460 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 7461 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7459 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7460 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 7461 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7462 | 7462 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.ident = :ident |
| 7463 | 7463 | GROUP BY spotter_output.departure_airport_country |
| 7464 | 7464 | ORDER BY airport_departure_country_count DESC"; |
@@ -7470,7 +7470,7 @@ discard block |
||
| 7470 | 7470 | $airport_array = array(); |
| 7471 | 7471 | $temp_array = array(); |
| 7472 | 7472 | |
| 7473 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7473 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7474 | 7474 | { |
| 7475 | 7475 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 7476 | 7476 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
@@ -7487,11 +7487,11 @@ discard block |
||
| 7487 | 7487 | * @return Array the airport list |
| 7488 | 7488 | * |
| 7489 | 7489 | */ |
| 7490 | - public function countAllDepartureAirportCountriesByOwner($owner,$filters = array()) |
|
| 7490 | + public function countAllDepartureAirportCountriesByOwner($owner, $filters = array()) |
|
| 7491 | 7491 | { |
| 7492 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7493 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 7494 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7492 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7493 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 7494 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7495 | 7495 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.owner_name = :owner |
| 7496 | 7496 | GROUP BY spotter_output.departure_airport_country |
| 7497 | 7497 | ORDER BY airport_departure_country_count DESC"; |
@@ -7507,11 +7507,11 @@ discard block |
||
| 7507 | 7507 | * @return Array the airport list |
| 7508 | 7508 | * |
| 7509 | 7509 | */ |
| 7510 | - public function countAllDepartureAirportCountriesByPilot($pilot,$filters = array()) |
|
| 7510 | + public function countAllDepartureAirportCountriesByPilot($pilot, $filters = array()) |
|
| 7511 | 7511 | { |
| 7512 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7513 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 7514 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7512 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7513 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 7514 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7515 | 7515 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 7516 | 7516 | GROUP BY spotter_output.departure_airport_country |
| 7517 | 7517 | ORDER BY airport_departure_country_count DESC"; |
@@ -7529,12 +7529,12 @@ discard block |
||
| 7529 | 7529 | * @return Array the airport list |
| 7530 | 7530 | * |
| 7531 | 7531 | */ |
| 7532 | - public function countAllDepartureAirportsByCountry($country,$filters = array()) |
|
| 7532 | + public function countAllDepartureAirportsByCountry($country, $filters = array()) |
|
| 7533 | 7533 | { |
| 7534 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7535 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 7534 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7535 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 7536 | 7536 | |
| 7537 | - $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7537 | + $query = "SELECT DISTINCT spotter_output.departure_airport_icao, COUNT(spotter_output.departure_airport_icao) AS airport_departure_icao_count, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
|
| 7538 | 7538 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 7539 | 7539 | GROUP BY spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 7540 | 7540 | ORDER BY airport_departure_icao_count DESC"; |
@@ -7546,7 +7546,7 @@ discard block |
||
| 7546 | 7546 | $airport_array = array(); |
| 7547 | 7547 | $temp_array = array(); |
| 7548 | 7548 | |
| 7549 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7549 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7550 | 7550 | { |
| 7551 | 7551 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
| 7552 | 7552 | $temp_array['airport_departure_icao_count'] = $row['airport_departure_icao_count']; |
@@ -7567,11 +7567,11 @@ discard block |
||
| 7567 | 7567 | * @return Array the airport list |
| 7568 | 7568 | * |
| 7569 | 7569 | */ |
| 7570 | - public function countAllDepartureAirportCountriesByCountry($country,$filters = array()) |
|
| 7570 | + public function countAllDepartureAirportCountriesByCountry($country, $filters = array()) |
|
| 7571 | 7571 | { |
| 7572 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7573 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 7574 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7572 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7573 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 7574 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 7575 | 7575 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 7576 | 7576 | GROUP BY spotter_output.departure_airport_country |
| 7577 | 7577 | ORDER BY airport_departure_country_count DESC"; |
@@ -7583,7 +7583,7 @@ discard block |
||
| 7583 | 7583 | $airport_array = array(); |
| 7584 | 7584 | $temp_array = array(); |
| 7585 | 7585 | |
| 7586 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7586 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7587 | 7587 | { |
| 7588 | 7588 | $temp_array['departure_airport_country'] = $row['departure_airport_country']; |
| 7589 | 7589 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
@@ -7606,11 +7606,11 @@ discard block |
||
| 7606 | 7606 | * @return Array the airport list |
| 7607 | 7607 | * |
| 7608 | 7608 | */ |
| 7609 | - public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '') |
|
| 7609 | + public function countAllArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '') |
|
| 7610 | 7610 | { |
| 7611 | 7611 | global $globalDBdriver; |
| 7612 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7613 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 7612 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7613 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 7614 | 7614 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''"; |
| 7615 | 7615 | if ($olderthanmonths > 0) { |
| 7616 | 7616 | if ($globalDBdriver == 'mysql') { |
@@ -7630,28 +7630,28 @@ discard block |
||
| 7630 | 7630 | if ($year != '') { |
| 7631 | 7631 | if ($globalDBdriver == 'mysql') { |
| 7632 | 7632 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 7633 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 7633 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 7634 | 7634 | } else { |
| 7635 | 7635 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 7636 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 7636 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 7637 | 7637 | } |
| 7638 | 7638 | } |
| 7639 | 7639 | if ($month != '') { |
| 7640 | 7640 | if ($globalDBdriver == 'mysql') { |
| 7641 | 7641 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 7642 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 7642 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 7643 | 7643 | } else { |
| 7644 | 7644 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 7645 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 7645 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 7646 | 7646 | } |
| 7647 | 7647 | } |
| 7648 | 7648 | if ($day != '') { |
| 7649 | 7649 | if ($globalDBdriver == 'mysql') { |
| 7650 | 7650 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 7651 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 7651 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 7652 | 7652 | } else { |
| 7653 | 7653 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 7654 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 7654 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 7655 | 7655 | } |
| 7656 | 7656 | } |
| 7657 | 7657 | $query .= " GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
@@ -7665,7 +7665,7 @@ discard block |
||
| 7665 | 7665 | $airport_array = array(); |
| 7666 | 7666 | $temp_array = array(); |
| 7667 | 7667 | |
| 7668 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7668 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7669 | 7669 | { |
| 7670 | 7670 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 7671 | 7671 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -7688,11 +7688,11 @@ discard block |
||
| 7688 | 7688 | * @return Array the airport list |
| 7689 | 7689 | * |
| 7690 | 7690 | */ |
| 7691 | - public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false,$filters = array()) |
|
| 7691 | + public function countAllArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array()) |
|
| 7692 | 7692 | { |
| 7693 | 7693 | global $globalDBdriver; |
| 7694 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7695 | - $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 7694 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7695 | + $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 7696 | 7696 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' "; |
| 7697 | 7697 | if ($olderthanmonths > 0) { |
| 7698 | 7698 | if ($globalDBdriver == 'mysql') { |
@@ -7722,7 +7722,7 @@ discard block |
||
| 7722 | 7722 | $airport_array = array(); |
| 7723 | 7723 | $temp_array = array(); |
| 7724 | 7724 | |
| 7725 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7725 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7726 | 7726 | { |
| 7727 | 7727 | $temp_array['airline_icao'] = $row['airline_icao']; |
| 7728 | 7728 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
@@ -7747,11 +7747,11 @@ discard block |
||
| 7747 | 7747 | * @return Array the airport list |
| 7748 | 7748 | * |
| 7749 | 7749 | */ |
| 7750 | - public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array(),$year = '',$month = '',$day = '') |
|
| 7750 | + public function countAllDetectedArrivalAirports($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array(), $year = '', $month = '', $day = '') |
|
| 7751 | 7751 | { |
| 7752 | 7752 | global $globalDBdriver; |
| 7753 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7754 | - $query = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country |
|
| 7753 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7754 | + $query = "SELECT DISTINCT spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country |
|
| 7755 | 7755 | FROM airport,spotter_output".$filter_query." spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao"; |
| 7756 | 7756 | if ($olderthanmonths > 0) { |
| 7757 | 7757 | if ($globalDBdriver == 'mysql') { |
@@ -7771,28 +7771,28 @@ discard block |
||
| 7771 | 7771 | if ($year != '') { |
| 7772 | 7772 | if ($globalDBdriver == 'mysql') { |
| 7773 | 7773 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 7774 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 7774 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 7775 | 7775 | } else { |
| 7776 | 7776 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 7777 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 7777 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 7778 | 7778 | } |
| 7779 | 7779 | } |
| 7780 | 7780 | if ($month != '') { |
| 7781 | 7781 | if ($globalDBdriver == 'mysql') { |
| 7782 | 7782 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 7783 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 7783 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 7784 | 7784 | } else { |
| 7785 | 7785 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 7786 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 7786 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 7787 | 7787 | } |
| 7788 | 7788 | } |
| 7789 | 7789 | if ($day != '') { |
| 7790 | 7790 | if ($globalDBdriver == 'mysql') { |
| 7791 | 7791 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 7792 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 7792 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 7793 | 7793 | } else { |
| 7794 | 7794 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 7795 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 7795 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 7796 | 7796 | } |
| 7797 | 7797 | } |
| 7798 | 7798 | $query .= " GROUP BY spotter_output.real_arrival_airport_icao, airport.name, airport.city, airport.country |
@@ -7805,7 +7805,7 @@ discard block |
||
| 7805 | 7805 | |
| 7806 | 7806 | $airport_array = array(); |
| 7807 | 7807 | $temp_array = array(); |
| 7808 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7808 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7809 | 7809 | { |
| 7810 | 7810 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 7811 | 7811 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -7828,11 +7828,11 @@ discard block |
||
| 7828 | 7828 | * @return Array the airport list |
| 7829 | 7829 | * |
| 7830 | 7830 | */ |
| 7831 | - public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '',$icaoaskey = false,$filters = array()) |
|
| 7831 | + public function countAllDetectedArrivalAirportsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $icaoaskey = false, $filters = array()) |
|
| 7832 | 7832 | { |
| 7833 | 7833 | global $globalDBdriver; |
| 7834 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7835 | - $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country |
|
| 7834 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7835 | + $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.real_arrival_airport_icao as arrival_airport_icao, COUNT(spotter_output.real_arrival_airport_icao) AS airport_arrival_icao_count, airport.name AS arrival_airport_name, airport.city AS arrival_airport_city, airport.country AS arrival_airport_country |
|
| 7836 | 7836 | FROM airport,spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.real_arrival_airport_icao <> '' AND spotter_output.real_arrival_airport_icao <> 'NA' AND airport.icao = spotter_output.real_arrival_airport_icao "; |
| 7837 | 7837 | if ($olderthanmonths > 0) { |
| 7838 | 7838 | if ($globalDBdriver == 'mysql') { |
@@ -7862,7 +7862,7 @@ discard block |
||
| 7862 | 7862 | $airport_array = array(); |
| 7863 | 7863 | $temp_array = array(); |
| 7864 | 7864 | |
| 7865 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7865 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7866 | 7866 | { |
| 7867 | 7867 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 7868 | 7868 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -7888,9 +7888,9 @@ discard block |
||
| 7888 | 7888 | */ |
| 7889 | 7889 | public function countAllArrivalAirportsByAirline($airline_icao, $filters = array()) |
| 7890 | 7890 | { |
| 7891 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7892 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 7893 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 7891 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7892 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 7893 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 7894 | 7894 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.airline_icao = :airline_icao |
| 7895 | 7895 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 7896 | 7896 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -7901,7 +7901,7 @@ discard block |
||
| 7901 | 7901 | $airport_array = array(); |
| 7902 | 7902 | $temp_array = array(); |
| 7903 | 7903 | |
| 7904 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7904 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7905 | 7905 | { |
| 7906 | 7906 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 7907 | 7907 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -7922,12 +7922,12 @@ discard block |
||
| 7922 | 7922 | * @return Array the airport list |
| 7923 | 7923 | * |
| 7924 | 7924 | */ |
| 7925 | - public function countAllArrivalAirportCountriesByAirline($airline_icao,$filters = array()) |
|
| 7925 | + public function countAllArrivalAirportCountriesByAirline($airline_icao, $filters = array()) |
|
| 7926 | 7926 | { |
| 7927 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7928 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 7927 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7928 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 7929 | 7929 | |
| 7930 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 7930 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 7931 | 7931 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.airline_icao = :airline_icao |
| 7932 | 7932 | GROUP BY spotter_output.arrival_airport_country |
| 7933 | 7933 | ORDER BY airport_arrival_country_count DESC"; |
@@ -7939,7 +7939,7 @@ discard block |
||
| 7939 | 7939 | $airport_array = array(); |
| 7940 | 7940 | $temp_array = array(); |
| 7941 | 7941 | |
| 7942 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7942 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7943 | 7943 | { |
| 7944 | 7944 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
| 7945 | 7945 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
@@ -7957,11 +7957,11 @@ discard block |
||
| 7957 | 7957 | * @return Array the airport list |
| 7958 | 7958 | * |
| 7959 | 7959 | */ |
| 7960 | - public function countAllArrivalAirportsByAircraft($aircraft_icao,$filters = array()) |
|
| 7960 | + public function countAllArrivalAirportsByAircraft($aircraft_icao, $filters = array()) |
|
| 7961 | 7961 | { |
| 7962 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 7963 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 7964 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 7962 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 7963 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 7964 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 7965 | 7965 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
| 7966 | 7966 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 7967 | 7967 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -7973,7 +7973,7 @@ discard block |
||
| 7973 | 7973 | $airport_array = array(); |
| 7974 | 7974 | $temp_array = array(); |
| 7975 | 7975 | |
| 7976 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7976 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 7977 | 7977 | { |
| 7978 | 7978 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 7979 | 7979 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -7995,11 +7995,11 @@ discard block |
||
| 7995 | 7995 | * @return Array the airport list |
| 7996 | 7996 | * |
| 7997 | 7997 | */ |
| 7998 | - public function countAllArrivalAirportCountriesByAircraft($aircraft_icao,$filters = array()) |
|
| 7998 | + public function countAllArrivalAirportCountriesByAircraft($aircraft_icao, $filters = array()) |
|
| 7999 | 7999 | { |
| 8000 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8001 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 8002 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8000 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8001 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 8002 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8003 | 8003 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
| 8004 | 8004 | GROUP BY spotter_output.arrival_airport_country |
| 8005 | 8005 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8011,7 +8011,7 @@ discard block |
||
| 8011 | 8011 | $airport_array = array(); |
| 8012 | 8012 | $temp_array = array(); |
| 8013 | 8013 | |
| 8014 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8014 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8015 | 8015 | { |
| 8016 | 8016 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
| 8017 | 8017 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
@@ -8029,12 +8029,12 @@ discard block |
||
| 8029 | 8029 | * @return Array the airport list |
| 8030 | 8030 | * |
| 8031 | 8031 | */ |
| 8032 | - public function countAllArrivalAirportsByRegistration($registration,$filters = array()) |
|
| 8032 | + public function countAllArrivalAirportsByRegistration($registration, $filters = array()) |
|
| 8033 | 8033 | { |
| 8034 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8035 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 8034 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8035 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 8036 | 8036 | |
| 8037 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8037 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8038 | 8038 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.registration = :registration |
| 8039 | 8039 | GROUP BY spotter_output.arrival_airport_icao |
| 8040 | 8040 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -8046,7 +8046,7 @@ discard block |
||
| 8046 | 8046 | $airport_array = array(); |
| 8047 | 8047 | $temp_array = array(); |
| 8048 | 8048 | |
| 8049 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8049 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8050 | 8050 | { |
| 8051 | 8051 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 8052 | 8052 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -8067,11 +8067,11 @@ discard block |
||
| 8067 | 8067 | * @return Array the airport list |
| 8068 | 8068 | * |
| 8069 | 8069 | */ |
| 8070 | - public function countAllArrivalAirportCountriesByRegistration($registration,$filters = array()) |
|
| 8070 | + public function countAllArrivalAirportCountriesByRegistration($registration, $filters = array()) |
|
| 8071 | 8071 | { |
| 8072 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8073 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 8074 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8072 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8073 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 8074 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8075 | 8075 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.registration = :registration |
| 8076 | 8076 | GROUP BY spotter_output.arrival_airport_country |
| 8077 | 8077 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8083,7 +8083,7 @@ discard block |
||
| 8083 | 8083 | $airport_array = array(); |
| 8084 | 8084 | $temp_array = array(); |
| 8085 | 8085 | |
| 8086 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8086 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8087 | 8087 | { |
| 8088 | 8088 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
| 8089 | 8089 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
@@ -8102,11 +8102,11 @@ discard block |
||
| 8102 | 8102 | * @return Array the airport list |
| 8103 | 8103 | * |
| 8104 | 8104 | */ |
| 8105 | - public function countAllArrivalAirportsByAirport($airport_icao,$filters = array()) |
|
| 8105 | + public function countAllArrivalAirportsByAirport($airport_icao, $filters = array()) |
|
| 8106 | 8106 | { |
| 8107 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8108 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 8109 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8107 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8108 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 8109 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8110 | 8110 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.departure_airport_icao = :airport_icao |
| 8111 | 8111 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8112 | 8112 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -8118,7 +8118,7 @@ discard block |
||
| 8118 | 8118 | $airport_array = array(); |
| 8119 | 8119 | $temp_array = array(); |
| 8120 | 8120 | |
| 8121 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8121 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8122 | 8122 | { |
| 8123 | 8123 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 8124 | 8124 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -8139,11 +8139,11 @@ discard block |
||
| 8139 | 8139 | * @return Array the airport list |
| 8140 | 8140 | * |
| 8141 | 8141 | */ |
| 8142 | - public function countAllArrivalAirportCountriesByAirport($airport_icao,$filters = array()) |
|
| 8142 | + public function countAllArrivalAirportCountriesByAirport($airport_icao, $filters = array()) |
|
| 8143 | 8143 | { |
| 8144 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8145 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 8146 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8144 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8145 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 8146 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8147 | 8147 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.departure_airport_icao = :airport_icao |
| 8148 | 8148 | GROUP BY spotter_output.arrival_airport_country |
| 8149 | 8149 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8155,7 +8155,7 @@ discard block |
||
| 8155 | 8155 | $airport_array = array(); |
| 8156 | 8156 | $temp_array = array(); |
| 8157 | 8157 | |
| 8158 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8158 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8159 | 8159 | { |
| 8160 | 8160 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
| 8161 | 8161 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
@@ -8173,11 +8173,11 @@ discard block |
||
| 8173 | 8173 | * @return Array the airport list |
| 8174 | 8174 | * |
| 8175 | 8175 | */ |
| 8176 | - public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer,$filters = array()) |
|
| 8176 | + public function countAllArrivalAirportsByManufacturer($aircraft_manufacturer, $filters = array()) |
|
| 8177 | 8177 | { |
| 8178 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8179 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 8180 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8178 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8179 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 8180 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8181 | 8181 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 8182 | 8182 | GROUP BY spotter_output.arrival_airport_icao |
| 8183 | 8183 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -8189,7 +8189,7 @@ discard block |
||
| 8189 | 8189 | $airport_array = array(); |
| 8190 | 8190 | $temp_array = array(); |
| 8191 | 8191 | |
| 8192 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8192 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8193 | 8193 | { |
| 8194 | 8194 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 8195 | 8195 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -8211,11 +8211,11 @@ discard block |
||
| 8211 | 8211 | * @return Array the airport list |
| 8212 | 8212 | * |
| 8213 | 8213 | */ |
| 8214 | - public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer,$filters = array()) |
|
| 8214 | + public function countAllArrivalAirportCountriesByManufacturer($aircraft_manufacturer, $filters = array()) |
|
| 8215 | 8215 | { |
| 8216 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8217 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 8218 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8216 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8217 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 8218 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8219 | 8219 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 8220 | 8220 | GROUP BY spotter_output.arrival_airport_country |
| 8221 | 8221 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8227,7 +8227,7 @@ discard block |
||
| 8227 | 8227 | $airport_array = array(); |
| 8228 | 8228 | $temp_array = array(); |
| 8229 | 8229 | |
| 8230 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8230 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8231 | 8231 | { |
| 8232 | 8232 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
| 8233 | 8233 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
@@ -8246,11 +8246,11 @@ discard block |
||
| 8246 | 8246 | * @return Array the airport list |
| 8247 | 8247 | * |
| 8248 | 8248 | */ |
| 8249 | - public function countAllArrivalAirportsByDate($date,$filters = array()) |
|
| 8249 | + public function countAllArrivalAirportsByDate($date, $filters = array()) |
|
| 8250 | 8250 | { |
| 8251 | 8251 | global $globalTimezone, $globalDBdriver; |
| 8252 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8253 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 8252 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8253 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 8254 | 8254 | if ($globalTimezone != '') { |
| 8255 | 8255 | date_default_timezone_set($globalTimezone); |
| 8256 | 8256 | $datetime = new DateTime($date); |
@@ -8258,12 +8258,12 @@ discard block |
||
| 8258 | 8258 | } else $offset = '+00:00'; |
| 8259 | 8259 | |
| 8260 | 8260 | if ($globalDBdriver == 'mysql') { |
| 8261 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8261 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8262 | 8262 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 8263 | 8263 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8264 | 8264 | ORDER BY airport_arrival_icao_count DESC"; |
| 8265 | 8265 | } else { |
| 8266 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8266 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8267 | 8267 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 8268 | 8268 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8269 | 8269 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -8275,7 +8275,7 @@ discard block |
||
| 8275 | 8275 | $airport_array = array(); |
| 8276 | 8276 | $temp_array = array(); |
| 8277 | 8277 | |
| 8278 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8278 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8279 | 8279 | { |
| 8280 | 8280 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 8281 | 8281 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -8299,8 +8299,8 @@ discard block |
||
| 8299 | 8299 | public function countAllArrivalAirportCountriesByDate($date, $filters = array()) |
| 8300 | 8300 | { |
| 8301 | 8301 | global $globalTimezone, $globalDBdriver; |
| 8302 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8303 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 8302 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8303 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 8304 | 8304 | if ($globalTimezone != '') { |
| 8305 | 8305 | date_default_timezone_set($globalTimezone); |
| 8306 | 8306 | $datetime = new DateTime($date); |
@@ -8308,12 +8308,12 @@ discard block |
||
| 8308 | 8308 | } else $offset = '+00:00'; |
| 8309 | 8309 | |
| 8310 | 8310 | if ($globalDBdriver == 'mysql') { |
| 8311 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8311 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8312 | 8312 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 8313 | 8313 | GROUP BY spotter_output.arrival_airport_country |
| 8314 | 8314 | ORDER BY airport_arrival_country_count DESC"; |
| 8315 | 8315 | } else { |
| 8316 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8316 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8317 | 8317 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 8318 | 8318 | GROUP BY spotter_output.arrival_airport_country |
| 8319 | 8319 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8325,7 +8325,7 @@ discard block |
||
| 8325 | 8325 | $airport_array = array(); |
| 8326 | 8326 | $temp_array = array(); |
| 8327 | 8327 | |
| 8328 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8328 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8329 | 8329 | { |
| 8330 | 8330 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
| 8331 | 8331 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
@@ -8343,11 +8343,11 @@ discard block |
||
| 8343 | 8343 | * @return Array the airport list |
| 8344 | 8344 | * |
| 8345 | 8345 | */ |
| 8346 | - public function countAllArrivalAirportsByIdent($ident,$filters = array()) |
|
| 8346 | + public function countAllArrivalAirportsByIdent($ident, $filters = array()) |
|
| 8347 | 8347 | { |
| 8348 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8349 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 8350 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8348 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8349 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 8350 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8351 | 8351 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.ident = :ident |
| 8352 | 8352 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8353 | 8353 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -8359,7 +8359,7 @@ discard block |
||
| 8359 | 8359 | $airport_array = array(); |
| 8360 | 8360 | $temp_array = array(); |
| 8361 | 8361 | |
| 8362 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8362 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8363 | 8363 | { |
| 8364 | 8364 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 8365 | 8365 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -8379,11 +8379,11 @@ discard block |
||
| 8379 | 8379 | * @return Array the airport list |
| 8380 | 8380 | * |
| 8381 | 8381 | */ |
| 8382 | - public function countAllArrivalAirportsByOwner($owner,$filters = array()) |
|
| 8382 | + public function countAllArrivalAirportsByOwner($owner, $filters = array()) |
|
| 8383 | 8383 | { |
| 8384 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8385 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 8386 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8384 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8385 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 8386 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8387 | 8387 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND spotter_output.owner_name = :owner |
| 8388 | 8388 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8389 | 8389 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -8394,7 +8394,7 @@ discard block |
||
| 8394 | 8394 | $airport_array = array(); |
| 8395 | 8395 | $temp_array = array(); |
| 8396 | 8396 | |
| 8397 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8397 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8398 | 8398 | { |
| 8399 | 8399 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 8400 | 8400 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -8414,11 +8414,11 @@ discard block |
||
| 8414 | 8414 | * @return Array the airport list |
| 8415 | 8415 | * |
| 8416 | 8416 | */ |
| 8417 | - public function countAllArrivalAirportsByPilot($pilot,$filters = array()) |
|
| 8417 | + public function countAllArrivalAirportsByPilot($pilot, $filters = array()) |
|
| 8418 | 8418 | { |
| 8419 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8420 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 8421 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8419 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8420 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 8421 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8422 | 8422 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_name <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 8423 | 8423 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8424 | 8424 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -8429,7 +8429,7 @@ discard block |
||
| 8429 | 8429 | $airport_array = array(); |
| 8430 | 8430 | $temp_array = array(); |
| 8431 | 8431 | |
| 8432 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8432 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8433 | 8433 | { |
| 8434 | 8434 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 8435 | 8435 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -8451,9 +8451,9 @@ discard block |
||
| 8451 | 8451 | */ |
| 8452 | 8452 | public function countAllArrivalAirportCountriesByIdent($ident, $filters = array()) |
| 8453 | 8453 | { |
| 8454 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8455 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 8456 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8454 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8455 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 8456 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8457 | 8457 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.ident = :ident |
| 8458 | 8458 | GROUP BY spotter_output.arrival_airport_country |
| 8459 | 8459 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8465,7 +8465,7 @@ discard block |
||
| 8465 | 8465 | $airport_array = array(); |
| 8466 | 8466 | $temp_array = array(); |
| 8467 | 8467 | |
| 8468 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8468 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8469 | 8469 | { |
| 8470 | 8470 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
| 8471 | 8471 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
@@ -8484,9 +8484,9 @@ discard block |
||
| 8484 | 8484 | */ |
| 8485 | 8485 | public function countAllArrivalAirportCountriesByOwner($owner, $filters = array()) |
| 8486 | 8486 | { |
| 8487 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8488 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 8489 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8487 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8488 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 8489 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8490 | 8490 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.owner_name = :owner |
| 8491 | 8491 | GROUP BY spotter_output.arrival_airport_country |
| 8492 | 8492 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8504,9 +8504,9 @@ discard block |
||
| 8504 | 8504 | */ |
| 8505 | 8505 | public function countAllArrivalAirportCountriesByPilot($pilot, $filters = array()) |
| 8506 | 8506 | { |
| 8507 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8508 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 8509 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8507 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8508 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 8509 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8510 | 8510 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 8511 | 8511 | GROUP BY spotter_output.arrival_airport_country |
| 8512 | 8512 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8524,11 +8524,11 @@ discard block |
||
| 8524 | 8524 | * @return Array the airport list |
| 8525 | 8525 | * |
| 8526 | 8526 | */ |
| 8527 | - public function countAllArrivalAirportsByCountry($country,$filters = array()) |
|
| 8527 | + public function countAllArrivalAirportsByCountry($country, $filters = array()) |
|
| 8528 | 8528 | { |
| 8529 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8530 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 8531 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8529 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8530 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 8531 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_icao, COUNT(spotter_output.arrival_airport_icao) AS airport_arrival_icao_count, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
|
| 8532 | 8532 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 8533 | 8533 | GROUP BY spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8534 | 8534 | ORDER BY airport_arrival_icao_count DESC"; |
@@ -8540,7 +8540,7 @@ discard block |
||
| 8540 | 8540 | $airport_array = array(); |
| 8541 | 8541 | $temp_array = array(); |
| 8542 | 8542 | |
| 8543 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8543 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8544 | 8544 | { |
| 8545 | 8545 | $temp_array['airport_arrival_icao'] = $row['arrival_airport_icao']; |
| 8546 | 8546 | $temp_array['airport_arrival_icao_count'] = $row['airport_arrival_icao_count']; |
@@ -8561,12 +8561,12 @@ discard block |
||
| 8561 | 8561 | * @return Array the airport list |
| 8562 | 8562 | * |
| 8563 | 8563 | */ |
| 8564 | - public function countAllArrivalAirportCountriesByCountry($country,$filters = array()) |
|
| 8564 | + public function countAllArrivalAirportCountriesByCountry($country, $filters = array()) |
|
| 8565 | 8565 | { |
| 8566 | 8566 | global $globalDBdriver; |
| 8567 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8568 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 8569 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8567 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8568 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 8569 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8570 | 8570 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 8571 | 8571 | GROUP BY spotter_output.arrival_airport_country |
| 8572 | 8572 | ORDER BY airport_arrival_country_count DESC"; |
@@ -8578,7 +8578,7 @@ discard block |
||
| 8578 | 8578 | $airport_array = array(); |
| 8579 | 8579 | $temp_array = array(); |
| 8580 | 8580 | |
| 8581 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8581 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8582 | 8582 | { |
| 8583 | 8583 | $temp_array['arrival_airport_country'] = $row['arrival_airport_country']; |
| 8584 | 8584 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
@@ -8597,38 +8597,38 @@ discard block |
||
| 8597 | 8597 | * @return Array the airport departure list |
| 8598 | 8598 | * |
| 8599 | 8599 | */ |
| 8600 | - public function countAllDepartureCountries($filters = array(),$year = '',$month = '', $day = '') |
|
| 8600 | + public function countAllDepartureCountries($filters = array(), $year = '', $month = '', $day = '') |
|
| 8601 | 8601 | { |
| 8602 | 8602 | global $globalDBdriver; |
| 8603 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8604 | - $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 8603 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8604 | + $query = "SELECT DISTINCT spotter_output.departure_airport_country, COUNT(spotter_output.departure_airport_country) AS airport_departure_country_count |
|
| 8605 | 8605 | FROM spotter_output".$filter_query." spotter_output.departure_airport_country <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> ''"; |
| 8606 | 8606 | $query_values = array(); |
| 8607 | 8607 | if ($year != '') { |
| 8608 | 8608 | if ($globalDBdriver == 'mysql') { |
| 8609 | 8609 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 8610 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 8610 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 8611 | 8611 | } else { |
| 8612 | 8612 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 8613 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 8613 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 8614 | 8614 | } |
| 8615 | 8615 | } |
| 8616 | 8616 | if ($month != '') { |
| 8617 | 8617 | if ($globalDBdriver == 'mysql') { |
| 8618 | 8618 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 8619 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 8619 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 8620 | 8620 | } else { |
| 8621 | 8621 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 8622 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 8622 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 8623 | 8623 | } |
| 8624 | 8624 | } |
| 8625 | 8625 | if ($day != '') { |
| 8626 | 8626 | if ($globalDBdriver == 'mysql') { |
| 8627 | 8627 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 8628 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 8628 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 8629 | 8629 | } else { |
| 8630 | 8630 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 8631 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 8631 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 8632 | 8632 | } |
| 8633 | 8633 | } |
| 8634 | 8634 | $query .= " GROUP BY spotter_output.departure_airport_country |
@@ -8642,7 +8642,7 @@ discard block |
||
| 8642 | 8642 | $airport_array = array(); |
| 8643 | 8643 | $temp_array = array(); |
| 8644 | 8644 | |
| 8645 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8645 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8646 | 8646 | { |
| 8647 | 8647 | $temp_array['airport_departure_country_count'] = $row['airport_departure_country_count']; |
| 8648 | 8648 | $temp_array['airport_departure_country'] = $row['departure_airport_country']; |
@@ -8660,38 +8660,38 @@ discard block |
||
| 8660 | 8660 | * @return Array the airport arrival list |
| 8661 | 8661 | * |
| 8662 | 8662 | */ |
| 8663 | - public function countAllArrivalCountries($limit = true,$filters = array(),$year = '',$month = '',$day = '') |
|
| 8663 | + public function countAllArrivalCountries($limit = true, $filters = array(), $year = '', $month = '', $day = '') |
|
| 8664 | 8664 | { |
| 8665 | 8665 | global $globalDBdriver; |
| 8666 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8667 | - $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8666 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8667 | + $query = "SELECT DISTINCT spotter_output.arrival_airport_country, COUNT(spotter_output.arrival_airport_country) AS airport_arrival_country_count |
|
| 8668 | 8668 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_country <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> ''"; |
| 8669 | 8669 | $query_values = array(); |
| 8670 | 8670 | if ($year != '') { |
| 8671 | 8671 | if ($globalDBdriver == 'mysql') { |
| 8672 | 8672 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 8673 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 8673 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 8674 | 8674 | } else { |
| 8675 | 8675 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 8676 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 8676 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 8677 | 8677 | } |
| 8678 | 8678 | } |
| 8679 | 8679 | if ($month != '') { |
| 8680 | 8680 | if ($globalDBdriver == 'mysql') { |
| 8681 | 8681 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 8682 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 8682 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 8683 | 8683 | } else { |
| 8684 | 8684 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 8685 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 8685 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 8686 | 8686 | } |
| 8687 | 8687 | } |
| 8688 | 8688 | if ($day != '') { |
| 8689 | 8689 | if ($globalDBdriver == 'mysql') { |
| 8690 | 8690 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 8691 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 8691 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 8692 | 8692 | } else { |
| 8693 | 8693 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 8694 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 8694 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 8695 | 8695 | } |
| 8696 | 8696 | } |
| 8697 | 8697 | $query .= " GROUP BY spotter_output.arrival_airport_country |
@@ -8705,7 +8705,7 @@ discard block |
||
| 8705 | 8705 | $airport_array = array(); |
| 8706 | 8706 | $temp_array = array(); |
| 8707 | 8707 | |
| 8708 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8708 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8709 | 8709 | { |
| 8710 | 8710 | $temp_array['airport_arrival_country_count'] = $row['airport_arrival_country_count']; |
| 8711 | 8711 | $temp_array['airport_arrival_country'] = $row['arrival_airport_country']; |
@@ -8728,8 +8728,8 @@ discard block |
||
| 8728 | 8728 | */ |
| 8729 | 8729 | public function countAllRoutes($filters = array()) |
| 8730 | 8730 | { |
| 8731 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8732 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8731 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8732 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8733 | 8733 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.departure_airport_icao <> 'NA' AND spotter_output.departure_airport_icao <> '' AND spotter_output.arrival_airport_icao <> 'NA' AND spotter_output.arrival_airport_icao <> '' |
| 8734 | 8734 | GROUP BY route,spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country |
| 8735 | 8735 | ORDER BY route_count DESC |
@@ -8742,7 +8742,7 @@ discard block |
||
| 8742 | 8742 | $routes_array = array(); |
| 8743 | 8743 | $temp_array = array(); |
| 8744 | 8744 | |
| 8745 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8745 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8746 | 8746 | { |
| 8747 | 8747 | $temp_array['route_count'] = $row['route_count']; |
| 8748 | 8748 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -8769,11 +8769,11 @@ discard block |
||
| 8769 | 8769 | * @return Array the route list |
| 8770 | 8770 | * |
| 8771 | 8771 | */ |
| 8772 | - public function countAllRoutesByAircraft($aircraft_icao,$filters = array()) |
|
| 8772 | + public function countAllRoutesByAircraft($aircraft_icao, $filters = array()) |
|
| 8773 | 8773 | { |
| 8774 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8775 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 8776 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8774 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8775 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 8776 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8777 | 8777 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_icao = :aircraft_icao |
| 8778 | 8778 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8779 | 8779 | ORDER BY route_count DESC"; |
@@ -8784,7 +8784,7 @@ discard block |
||
| 8784 | 8784 | $routes_array = array(); |
| 8785 | 8785 | $temp_array = array(); |
| 8786 | 8786 | |
| 8787 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8787 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8788 | 8788 | { |
| 8789 | 8789 | $temp_array['route_count'] = $row['route_count']; |
| 8790 | 8790 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -8811,9 +8811,9 @@ discard block |
||
| 8811 | 8811 | */ |
| 8812 | 8812 | public function countAllRoutesByRegistration($registration, $filters = array()) |
| 8813 | 8813 | { |
| 8814 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8814 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8815 | 8815 | $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
| 8816 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8816 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8817 | 8817 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.registration = :registration |
| 8818 | 8818 | GROUP BY route |
| 8819 | 8819 | ORDER BY route_count DESC"; |
@@ -8825,7 +8825,7 @@ discard block |
||
| 8825 | 8825 | $routes_array = array(); |
| 8826 | 8826 | $temp_array = array(); |
| 8827 | 8827 | |
| 8828 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8828 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8829 | 8829 | { |
| 8830 | 8830 | $temp_array['route_count'] = $row['route_count']; |
| 8831 | 8831 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -8853,9 +8853,9 @@ discard block |
||
| 8853 | 8853 | */ |
| 8854 | 8854 | public function countAllRoutesByAirline($airline_icao, $filters = array()) |
| 8855 | 8855 | { |
| 8856 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8857 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 8858 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8856 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8857 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 8858 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8859 | 8859 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao = :airline_icao |
| 8860 | 8860 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8861 | 8861 | ORDER BY route_count DESC"; |
@@ -8867,7 +8867,7 @@ discard block |
||
| 8867 | 8867 | $routes_array = array(); |
| 8868 | 8868 | $temp_array = array(); |
| 8869 | 8869 | |
| 8870 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8870 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8871 | 8871 | { |
| 8872 | 8872 | $temp_array['route_count'] = $row['route_count']; |
| 8873 | 8873 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -8895,9 +8895,9 @@ discard block |
||
| 8895 | 8895 | */ |
| 8896 | 8896 | public function countAllRoutesByAirport($airport_icao, $filters = array()) |
| 8897 | 8897 | { |
| 8898 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8899 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 8900 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8898 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8899 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 8900 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8901 | 8901 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
| 8902 | 8902 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8903 | 8903 | ORDER BY route_count DESC"; |
@@ -8908,7 +8908,7 @@ discard block |
||
| 8908 | 8908 | $routes_array = array(); |
| 8909 | 8909 | $temp_array = array(); |
| 8910 | 8910 | |
| 8911 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8911 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8912 | 8912 | { |
| 8913 | 8913 | $temp_array['route_count'] = $row['route_count']; |
| 8914 | 8914 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -8936,9 +8936,9 @@ discard block |
||
| 8936 | 8936 | */ |
| 8937 | 8937 | public function countAllRoutesByCountry($country, $filters = array()) |
| 8938 | 8938 | { |
| 8939 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8940 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 8941 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8939 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8940 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 8941 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8942 | 8942 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 8943 | 8943 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8944 | 8944 | ORDER BY route_count DESC"; |
@@ -8949,7 +8949,7 @@ discard block |
||
| 8949 | 8949 | $routes_array = array(); |
| 8950 | 8950 | $temp_array = array(); |
| 8951 | 8951 | |
| 8952 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8952 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 8953 | 8953 | { |
| 8954 | 8954 | $temp_array['route_count'] = $row['route_count']; |
| 8955 | 8955 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -8977,8 +8977,8 @@ discard block |
||
| 8977 | 8977 | public function countAllRoutesByDate($date, $filters = array()) |
| 8978 | 8978 | { |
| 8979 | 8979 | global $globalTimezone, $globalDBdriver; |
| 8980 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 8981 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 8980 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 8981 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 8982 | 8982 | if ($globalTimezone != '') { |
| 8983 | 8983 | date_default_timezone_set($globalTimezone); |
| 8984 | 8984 | $datetime = new DateTime($date); |
@@ -8986,12 +8986,12 @@ discard block |
||
| 8986 | 8986 | } else $offset = '+00:00'; |
| 8987 | 8987 | |
| 8988 | 8988 | if ($globalDBdriver == 'mysql') { |
| 8989 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8989 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8990 | 8990 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 8991 | 8991 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8992 | 8992 | ORDER BY route_count DESC"; |
| 8993 | 8993 | } else { |
| 8994 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8994 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 8995 | 8995 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = :date |
| 8996 | 8996 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 8997 | 8997 | ORDER BY route_count DESC"; |
@@ -9003,7 +9003,7 @@ discard block |
||
| 9003 | 9003 | $routes_array = array(); |
| 9004 | 9004 | $temp_array = array(); |
| 9005 | 9005 | |
| 9006 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9006 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9007 | 9007 | { |
| 9008 | 9008 | $temp_array['route_count'] = $row['route_count']; |
| 9009 | 9009 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -9030,9 +9030,9 @@ discard block |
||
| 9030 | 9030 | */ |
| 9031 | 9031 | public function countAllRoutesByIdent($ident, $filters = array()) |
| 9032 | 9032 | { |
| 9033 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9034 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 9035 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9033 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9034 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 9035 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9036 | 9036 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.ident = :ident |
| 9037 | 9037 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 9038 | 9038 | ORDER BY route_count DESC"; |
@@ -9044,7 +9044,7 @@ discard block |
||
| 9044 | 9044 | $routes_array = array(); |
| 9045 | 9045 | $temp_array = array(); |
| 9046 | 9046 | |
| 9047 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9047 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9048 | 9048 | { |
| 9049 | 9049 | $temp_array['route_count'] = $row['route_count']; |
| 9050 | 9050 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -9068,11 +9068,11 @@ discard block |
||
| 9068 | 9068 | * @return Array the route list |
| 9069 | 9069 | * |
| 9070 | 9070 | */ |
| 9071 | - public function countAllRoutesByOwner($owner,$filters = array()) |
|
| 9071 | + public function countAllRoutesByOwner($owner, $filters = array()) |
|
| 9072 | 9072 | { |
| 9073 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9074 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 9075 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9073 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9074 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 9075 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9076 | 9076 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.owner_name = :owner |
| 9077 | 9077 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 9078 | 9078 | ORDER BY route_count DESC"; |
@@ -9084,7 +9084,7 @@ discard block |
||
| 9084 | 9084 | $routes_array = array(); |
| 9085 | 9085 | $temp_array = array(); |
| 9086 | 9086 | |
| 9087 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9087 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9088 | 9088 | { |
| 9089 | 9089 | $temp_array['route_count'] = $row['route_count']; |
| 9090 | 9090 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -9108,11 +9108,11 @@ discard block |
||
| 9108 | 9108 | * @return Array the route list |
| 9109 | 9109 | * |
| 9110 | 9110 | */ |
| 9111 | - public function countAllRoutesByPilot($pilot,$filters = array()) |
|
| 9111 | + public function countAllRoutesByPilot($pilot, $filters = array()) |
|
| 9112 | 9112 | { |
| 9113 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9114 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 9115 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9113 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9114 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 9115 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9116 | 9116 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 9117 | 9117 | GROUP BY route, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 9118 | 9118 | ORDER BY route_count DESC"; |
@@ -9124,7 +9124,7 @@ discard block |
||
| 9124 | 9124 | $routes_array = array(); |
| 9125 | 9125 | $temp_array = array(); |
| 9126 | 9126 | |
| 9127 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9127 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9128 | 9128 | { |
| 9129 | 9129 | $temp_array['route_count'] = $row['route_count']; |
| 9130 | 9130 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -9151,9 +9151,9 @@ discard block |
||
| 9151 | 9151 | */ |
| 9152 | 9152 | public function countAllRoutesByManufacturer($aircraft_manufacturer, $filters = array()) |
| 9153 | 9153 | { |
| 9154 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9155 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 9156 | - $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9154 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9155 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 9156 | + $query = "SELECT DISTINCT concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao) AS route, count(concat(spotter_output.departure_airport_icao, ' - ', spotter_output.arrival_airport_icao)) AS route_count, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9157 | 9157 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 9158 | 9158 | GROUP BY route |
| 9159 | 9159 | ORDER BY route_count DESC"; |
@@ -9165,7 +9165,7 @@ discard block |
||
| 9165 | 9165 | $routes_array = array(); |
| 9166 | 9166 | $temp_array = array(); |
| 9167 | 9167 | |
| 9168 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9168 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9169 | 9169 | { |
| 9170 | 9170 | $temp_array['route_count'] = $row['route_count']; |
| 9171 | 9171 | $temp_array['airport_departure_icao'] = $row['departure_airport_icao']; |
@@ -9193,8 +9193,8 @@ discard block |
||
| 9193 | 9193 | */ |
| 9194 | 9194 | public function countAllRoutesWithWaypoints($filters = array()) |
| 9195 | 9195 | { |
| 9196 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9197 | - $query = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9196 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9197 | + $query = "SELECT DISTINCT spotter_output.waypoints AS route, count(spotter_output.waypoints) AS route_count, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name AS airport_departure_name, spotter_output.departure_airport_city AS airport_departure_city, spotter_output.departure_airport_country AS airport_departure_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name AS airport_arrival_name, spotter_output.arrival_airport_city AS airport_arrival_city, spotter_output.arrival_airport_country AS airport_arrival_country |
|
| 9198 | 9198 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.waypoints <> '' |
| 9199 | 9199 | GROUP BY route, spotter_output.spotter_id, spotter_output.departure_airport_icao, spotter_output.departure_airport_name, spotter_output.departure_airport_city, spotter_output.departure_airport_country, spotter_output.arrival_airport_icao, spotter_output.arrival_airport_name, spotter_output.arrival_airport_city, spotter_output.arrival_airport_country |
| 9200 | 9200 | ORDER BY route_count DESC |
@@ -9207,7 +9207,7 @@ discard block |
||
| 9207 | 9207 | $routes_array = array(); |
| 9208 | 9208 | $temp_array = array(); |
| 9209 | 9209 | |
| 9210 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9210 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9211 | 9211 | { |
| 9212 | 9212 | $temp_array['spotter_id'] = $row['spotter_id']; |
| 9213 | 9213 | $temp_array['route_count'] = $row['route_count']; |
@@ -9232,11 +9232,11 @@ discard block |
||
| 9232 | 9232 | * @return Array the callsign list |
| 9233 | 9233 | * |
| 9234 | 9234 | */ |
| 9235 | - public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '') |
|
| 9235 | + public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '') |
|
| 9236 | 9236 | { |
| 9237 | 9237 | global $globalDBdriver; |
| 9238 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9239 | - $query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao |
|
| 9238 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9239 | + $query = "SELECT DISTINCT spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name, spotter_output.airline_icao |
|
| 9240 | 9240 | FROM spotter_output".$filter_query." spotter_output.ident <> ''"; |
| 9241 | 9241 | if ($olderthanmonths > 0) { |
| 9242 | 9242 | if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)'; |
@@ -9250,28 +9250,28 @@ discard block |
||
| 9250 | 9250 | if ($year != '') { |
| 9251 | 9251 | if ($globalDBdriver == 'mysql') { |
| 9252 | 9252 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 9253 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 9253 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 9254 | 9254 | } else { |
| 9255 | 9255 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 9256 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 9256 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 9257 | 9257 | } |
| 9258 | 9258 | } |
| 9259 | 9259 | if ($month != '') { |
| 9260 | 9260 | if ($globalDBdriver == 'mysql') { |
| 9261 | 9261 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 9262 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 9262 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 9263 | 9263 | } else { |
| 9264 | 9264 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 9265 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 9265 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 9266 | 9266 | } |
| 9267 | 9267 | } |
| 9268 | 9268 | if ($day != '') { |
| 9269 | 9269 | if ($globalDBdriver == 'mysql') { |
| 9270 | 9270 | $query .= " AND DAY(spotter_output.date) = :day"; |
| 9271 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 9271 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 9272 | 9272 | } else { |
| 9273 | 9273 | $query .= " AND EXTRACT(DAY FROM spotter_output.date) = :day"; |
| 9274 | - $query_values = array_merge($query_values,array(':day' => $day)); |
|
| 9274 | + $query_values = array_merge($query_values, array(':day' => $day)); |
|
| 9275 | 9275 | } |
| 9276 | 9276 | } |
| 9277 | 9277 | $query .= " GROUP BY spotter_output.ident, spotter_output.airline_name, spotter_output.airline_icao ORDER BY callsign_icao_count DESC"; |
@@ -9283,7 +9283,7 @@ discard block |
||
| 9283 | 9283 | $callsign_array = array(); |
| 9284 | 9284 | $temp_array = array(); |
| 9285 | 9285 | |
| 9286 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9286 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9287 | 9287 | { |
| 9288 | 9288 | $temp_array['callsign_icao'] = $row['ident']; |
| 9289 | 9289 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -9305,8 +9305,8 @@ discard block |
||
| 9305 | 9305 | public function countAllCallsignsByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array()) |
| 9306 | 9306 | { |
| 9307 | 9307 | global $globalDBdriver; |
| 9308 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9309 | - $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name |
|
| 9308 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9309 | + $query = "SELECT DISTINCT spotter_output.airline_icao, spotter_output.ident, COUNT(spotter_output.ident) AS callsign_icao_count, spotter_output.airline_name |
|
| 9310 | 9310 | FROM spotter_output".$filter_query." spotter_output.ident <> '' AND spotter_output.airline_icao <> '' "; |
| 9311 | 9311 | if ($olderthanmonths > 0) { |
| 9312 | 9312 | if ($globalDBdriver == 'mysql') $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) '; |
@@ -9325,7 +9325,7 @@ discard block |
||
| 9325 | 9325 | $callsign_array = array(); |
| 9326 | 9326 | $temp_array = array(); |
| 9327 | 9327 | |
| 9328 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9328 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9329 | 9329 | { |
| 9330 | 9330 | $temp_array['callsign_icao'] = $row['ident']; |
| 9331 | 9331 | $temp_array['airline_name'] = $row['airline_name']; |
@@ -9379,7 +9379,7 @@ discard block |
||
| 9379 | 9379 | $date_array = array(); |
| 9380 | 9380 | $temp_array = array(); |
| 9381 | 9381 | |
| 9382 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9382 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9383 | 9383 | { |
| 9384 | 9384 | $temp_array['date_name'] = $row['date_name']; |
| 9385 | 9385 | $temp_array['date_count'] = $row['date_count']; |
@@ -9404,15 +9404,15 @@ discard block |
||
| 9404 | 9404 | $datetime = new DateTime(); |
| 9405 | 9405 | $offset = $datetime->format('P'); |
| 9406 | 9406 | } else $offset = '+00:00'; |
| 9407 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9407 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9408 | 9408 | if ($globalDBdriver == 'mysql') { |
| 9409 | - $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
| 9409 | + $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
| 9410 | 9410 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
| 9411 | 9411 | GROUP BY spotter_output.airline_icao, date_name |
| 9412 | 9412 | ORDER BY date_count DESC |
| 9413 | 9413 | LIMIT 10 OFFSET 0"; |
| 9414 | 9414 | } else { |
| 9415 | - $query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
| 9415 | + $query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
| 9416 | 9416 | FROM spotter_output |
| 9417 | 9417 | WHERE spotter_output.airline_icao <> '' |
| 9418 | 9418 | GROUP BY spotter_output.airline_icao, date_name |
@@ -9427,7 +9427,7 @@ discard block |
||
| 9427 | 9427 | $date_array = array(); |
| 9428 | 9428 | $temp_array = array(); |
| 9429 | 9429 | |
| 9430 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9430 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9431 | 9431 | { |
| 9432 | 9432 | $temp_array['date_name'] = $row['date_name']; |
| 9433 | 9433 | $temp_array['date_count'] = $row['date_count']; |
@@ -9453,7 +9453,7 @@ discard block |
||
| 9453 | 9453 | $datetime = new DateTime(); |
| 9454 | 9454 | $offset = $datetime->format('P'); |
| 9455 | 9455 | } else $offset = '+00:00'; |
| 9456 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9456 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9457 | 9457 | if ($globalDBdriver == 'mysql') { |
| 9458 | 9458 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 9459 | 9459 | FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)"; |
@@ -9474,7 +9474,7 @@ discard block |
||
| 9474 | 9474 | $date_array = array(); |
| 9475 | 9475 | $temp_array = array(); |
| 9476 | 9476 | |
| 9477 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9477 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9478 | 9478 | { |
| 9479 | 9479 | $temp_array['date_name'] = $row['date_name']; |
| 9480 | 9480 | $temp_array['date_count'] = $row['date_count']; |
@@ -9499,7 +9499,7 @@ discard block |
||
| 9499 | 9499 | $datetime = new DateTime(); |
| 9500 | 9500 | $offset = $datetime->format('P'); |
| 9501 | 9501 | } else $offset = '+00:00'; |
| 9502 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9502 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9503 | 9503 | if ($globalDBdriver == 'mysql') { |
| 9504 | 9504 | $query = "SELECT DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
| 9505 | 9505 | FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)"; |
@@ -9520,7 +9520,7 @@ discard block |
||
| 9520 | 9520 | $date_array = array(); |
| 9521 | 9521 | $temp_array = array(); |
| 9522 | 9522 | |
| 9523 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9523 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9524 | 9524 | { |
| 9525 | 9525 | $temp_array['date_name'] = $row['date_name']; |
| 9526 | 9526 | $temp_array['date_count'] = $row['date_count']; |
@@ -9541,7 +9541,7 @@ discard block |
||
| 9541 | 9541 | public function countAllDatesLastMonthByAirlines($filters = array()) |
| 9542 | 9542 | { |
| 9543 | 9543 | global $globalTimezone, $globalDBdriver; |
| 9544 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9544 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9545 | 9545 | if ($globalTimezone != '') { |
| 9546 | 9546 | date_default_timezone_set($globalTimezone); |
| 9547 | 9547 | $datetime = new DateTime(); |
@@ -9549,13 +9549,13 @@ discard block |
||
| 9549 | 9549 | } else $offset = '+00:00'; |
| 9550 | 9550 | |
| 9551 | 9551 | if ($globalDBdriver == 'mysql') { |
| 9552 | - $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
| 9552 | + $query = "SELECT spotter_output.airline_icao, DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count |
|
| 9553 | 9553 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH) |
| 9554 | 9554 | GROUP BY spotter_output.airline_icao, date_name |
| 9555 | 9555 | ORDER BY spotter_output.date ASC"; |
| 9556 | 9556 | $query_data = array(':offset' => $offset); |
| 9557 | 9557 | } else { |
| 9558 | - $query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
| 9558 | + $query = "SELECT spotter_output.airline_icao, to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') AS date_name, count(*) as date_count |
|
| 9559 | 9559 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND spotter_output.date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 MONTHS' |
| 9560 | 9560 | GROUP BY spotter_output.airline_icao, date_name |
| 9561 | 9561 | ORDER BY date_name ASC"; |
@@ -9568,7 +9568,7 @@ discard block |
||
| 9568 | 9568 | $date_array = array(); |
| 9569 | 9569 | $temp_array = array(); |
| 9570 | 9570 | |
| 9571 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9571 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9572 | 9572 | { |
| 9573 | 9573 | $temp_array['date_name'] = $row['date_name']; |
| 9574 | 9574 | $temp_array['date_count'] = $row['date_count']; |
@@ -9615,7 +9615,7 @@ discard block |
||
| 9615 | 9615 | $date_array = array(); |
| 9616 | 9616 | $temp_array = array(); |
| 9617 | 9617 | |
| 9618 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9618 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9619 | 9619 | { |
| 9620 | 9620 | $temp_array['month_name'] = $row['month_name']; |
| 9621 | 9621 | $temp_array['year_name'] = $row['year_name']; |
@@ -9636,7 +9636,7 @@ discard block |
||
| 9636 | 9636 | public function countAllMonthsByAirlines($filters = array()) |
| 9637 | 9637 | { |
| 9638 | 9638 | global $globalTimezone, $globalDBdriver; |
| 9639 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9639 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9640 | 9640 | if ($globalTimezone != '') { |
| 9641 | 9641 | date_default_timezone_set($globalTimezone); |
| 9642 | 9642 | $datetime = new DateTime(); |
@@ -9644,12 +9644,12 @@ discard block |
||
| 9644 | 9644 | } else $offset = '+00:00'; |
| 9645 | 9645 | |
| 9646 | 9646 | if ($globalDBdriver == 'mysql') { |
| 9647 | - $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
|
| 9647 | + $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
|
| 9648 | 9648 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
| 9649 | 9649 | GROUP BY spotter_output.airline_icao, year_name, month_name |
| 9650 | 9650 | ORDER BY date_count DESC"; |
| 9651 | 9651 | } else { |
| 9652 | - $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count |
|
| 9652 | + $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count |
|
| 9653 | 9653 | FROM spotter_output |
| 9654 | 9654 | WHERE spotter_output.airline_icao <> '' |
| 9655 | 9655 | GROUP BY spotter_output.airline_icao, year_name, month_name |
@@ -9663,7 +9663,7 @@ discard block |
||
| 9663 | 9663 | $date_array = array(); |
| 9664 | 9664 | $temp_array = array(); |
| 9665 | 9665 | |
| 9666 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9666 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9667 | 9667 | { |
| 9668 | 9668 | $temp_array['month_name'] = $row['month_name']; |
| 9669 | 9669 | $temp_array['year_name'] = $row['year_name']; |
@@ -9690,14 +9690,14 @@ discard block |
||
| 9690 | 9690 | $datetime = new DateTime(); |
| 9691 | 9691 | $offset = $datetime->format('P'); |
| 9692 | 9692 | } else $offset = '+00:00'; |
| 9693 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9693 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9694 | 9694 | if ($globalDBdriver == 'mysql') { |
| 9695 | - $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
|
| 9695 | + $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count |
|
| 9696 | 9696 | FROM spotter_output".$filter_query." spotter_output.airline_type = 'military' |
| 9697 | 9697 | GROUP BY year_name, month_name |
| 9698 | 9698 | ORDER BY date_count DESC"; |
| 9699 | 9699 | } else { |
| 9700 | - $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count |
|
| 9700 | + $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(*) as date_count |
|
| 9701 | 9701 | FROM spotter_output".$filter_query." spotter_output.airline_type = 'military' |
| 9702 | 9702 | GROUP BY year_name, month_name |
| 9703 | 9703 | ORDER BY date_count DESC"; |
@@ -9709,7 +9709,7 @@ discard block |
||
| 9709 | 9709 | $date_array = array(); |
| 9710 | 9710 | $temp_array = array(); |
| 9711 | 9711 | |
| 9712 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9712 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9713 | 9713 | { |
| 9714 | 9714 | $temp_array['month_name'] = $row['month_name']; |
| 9715 | 9715 | $temp_array['year_name'] = $row['year_name']; |
@@ -9735,15 +9735,15 @@ discard block |
||
| 9735 | 9735 | $datetime = new DateTime(); |
| 9736 | 9736 | $offset = $datetime->format('P'); |
| 9737 | 9737 | } else $offset = '+00:00'; |
| 9738 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9738 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9739 | 9739 | |
| 9740 | 9740 | if ($globalDBdriver == 'mysql') { |
| 9741 | - $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
|
| 9741 | + $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
|
| 9742 | 9742 | FROM spotter_output".$filter_query." owner_name <> '' |
| 9743 | 9743 | GROUP BY year_name, month_name |
| 9744 | 9744 | ORDER BY date_count DESC"; |
| 9745 | 9745 | } else { |
| 9746 | - $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count |
|
| 9746 | + $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count |
|
| 9747 | 9747 | FROM spotter_output".$filter_query." owner_name <> '' |
| 9748 | 9748 | GROUP BY year_name, month_name |
| 9749 | 9749 | ORDER BY date_count DESC"; |
@@ -9755,7 +9755,7 @@ discard block |
||
| 9755 | 9755 | $date_array = array(); |
| 9756 | 9756 | $temp_array = array(); |
| 9757 | 9757 | |
| 9758 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9758 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9759 | 9759 | { |
| 9760 | 9760 | $temp_array['month_name'] = $row['month_name']; |
| 9761 | 9761 | $temp_array['year_name'] = $row['year_name']; |
@@ -9776,7 +9776,7 @@ discard block |
||
| 9776 | 9776 | public function countAllMonthsOwnersByAirlines($filters = array()) |
| 9777 | 9777 | { |
| 9778 | 9778 | global $globalTimezone, $globalDBdriver; |
| 9779 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9779 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9780 | 9780 | if ($globalTimezone != '') { |
| 9781 | 9781 | date_default_timezone_set($globalTimezone); |
| 9782 | 9782 | $datetime = new DateTime(); |
@@ -9784,12 +9784,12 @@ discard block |
||
| 9784 | 9784 | } else $offset = '+00:00'; |
| 9785 | 9785 | |
| 9786 | 9786 | if ($globalDBdriver == 'mysql') { |
| 9787 | - $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
|
| 9787 | + $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct owner_name) as date_count |
|
| 9788 | 9788 | FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' |
| 9789 | 9789 | GROUP BY spotter_output.airline_icao, year_name, month_name |
| 9790 | 9790 | ORDER BY date_count DESC"; |
| 9791 | 9791 | } else { |
| 9792 | - $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count |
|
| 9792 | + $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct owner_name) as date_count |
|
| 9793 | 9793 | FROM spotter_output".$filter_query." owner_name <> '' AND spotter_output.airline_icao <> '' |
| 9794 | 9794 | GROUP BY spotter_output.airline_icao, year_name, month_name |
| 9795 | 9795 | ORDER BY date_count DESC"; |
@@ -9801,7 +9801,7 @@ discard block |
||
| 9801 | 9801 | $date_array = array(); |
| 9802 | 9802 | $temp_array = array(); |
| 9803 | 9803 | |
| 9804 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9804 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9805 | 9805 | { |
| 9806 | 9806 | $temp_array['month_name'] = $row['month_name']; |
| 9807 | 9807 | $temp_array['year_name'] = $row['year_name']; |
@@ -9828,15 +9828,15 @@ discard block |
||
| 9828 | 9828 | $datetime = new DateTime(); |
| 9829 | 9829 | $offset = $datetime->format('P'); |
| 9830 | 9830 | } else $offset = '+00:00'; |
| 9831 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9831 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9832 | 9832 | |
| 9833 | 9833 | if ($globalDBdriver == 'mysql') { |
| 9834 | - $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
|
| 9834 | + $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
|
| 9835 | 9835 | FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL |
| 9836 | 9836 | GROUP BY year_name, month_name |
| 9837 | 9837 | ORDER BY date_count DESC"; |
| 9838 | 9838 | } else { |
| 9839 | - $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count |
|
| 9839 | + $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count |
|
| 9840 | 9840 | FROM spotter_output".$filter_query." pilot_id <> '' AND pilot_id IS NOT NULL |
| 9841 | 9841 | GROUP BY year_name, month_name |
| 9842 | 9842 | ORDER BY date_count DESC"; |
@@ -9848,7 +9848,7 @@ discard block |
||
| 9848 | 9848 | $date_array = array(); |
| 9849 | 9849 | $temp_array = array(); |
| 9850 | 9850 | |
| 9851 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9851 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9852 | 9852 | { |
| 9853 | 9853 | $temp_array['month_name'] = $row['month_name']; |
| 9854 | 9854 | $temp_array['year_name'] = $row['year_name']; |
@@ -9869,7 +9869,7 @@ discard block |
||
| 9869 | 9869 | public function countAllMonthsPilotsByAirlines($filters = array()) |
| 9870 | 9870 | { |
| 9871 | 9871 | global $globalTimezone, $globalDBdriver; |
| 9872 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9872 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9873 | 9873 | if ($globalTimezone != '') { |
| 9874 | 9874 | date_default_timezone_set($globalTimezone); |
| 9875 | 9875 | $datetime = new DateTime(); |
@@ -9877,12 +9877,12 @@ discard block |
||
| 9877 | 9877 | } else $offset = '+00:00'; |
| 9878 | 9878 | |
| 9879 | 9879 | if ($globalDBdriver == 'mysql') { |
| 9880 | - $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
|
| 9880 | + $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct pilot_id) as date_count |
|
| 9881 | 9881 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL |
| 9882 | 9882 | GROUP BY spotter_output.airline_icao,year_name, month_name |
| 9883 | 9883 | ORDER BY date_count DESC"; |
| 9884 | 9884 | } else { |
| 9885 | - $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count |
|
| 9885 | + $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct pilot_id) as date_count |
|
| 9886 | 9886 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' AND pilot_id <> '' AND pilot_id IS NOT NULL |
| 9887 | 9887 | GROUP BY spotter_output.airline_icao, year_name, month_name |
| 9888 | 9888 | ORDER BY date_count DESC"; |
@@ -9894,7 +9894,7 @@ discard block |
||
| 9894 | 9894 | $date_array = array(); |
| 9895 | 9895 | $temp_array = array(); |
| 9896 | 9896 | |
| 9897 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9897 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9898 | 9898 | { |
| 9899 | 9899 | $temp_array['month_name'] = $row['month_name']; |
| 9900 | 9900 | $temp_array['year_name'] = $row['year_name']; |
@@ -9916,7 +9916,7 @@ discard block |
||
| 9916 | 9916 | public function countAllMonthsAirlines($filters = array()) |
| 9917 | 9917 | { |
| 9918 | 9918 | global $globalTimezone, $globalDBdriver; |
| 9919 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9919 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9920 | 9920 | if ($globalTimezone != '') { |
| 9921 | 9921 | date_default_timezone_set($globalTimezone); |
| 9922 | 9922 | $datetime = new DateTime(); |
@@ -9924,12 +9924,12 @@ discard block |
||
| 9924 | 9924 | } else $offset = '+00:00'; |
| 9925 | 9925 | |
| 9926 | 9926 | if ($globalDBdriver == 'mysql') { |
| 9927 | - $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count |
|
| 9927 | + $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct airline_icao) as date_count |
|
| 9928 | 9928 | FROM spotter_output".$filter_query." airline_icao <> '' |
| 9929 | 9929 | GROUP BY year_name, month_name |
| 9930 | 9930 | ORDER BY date_count DESC"; |
| 9931 | 9931 | } else { |
| 9932 | - $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count |
|
| 9932 | + $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct airline_icao) as date_count |
|
| 9933 | 9933 | FROM spotter_output".$filter_query." airline_icao <> '' |
| 9934 | 9934 | GROUP BY year_name, month_name |
| 9935 | 9935 | ORDER BY date_count DESC"; |
@@ -9941,7 +9941,7 @@ discard block |
||
| 9941 | 9941 | $date_array = array(); |
| 9942 | 9942 | $temp_array = array(); |
| 9943 | 9943 | |
| 9944 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9944 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9945 | 9945 | { |
| 9946 | 9946 | $temp_array['month_name'] = $row['month_name']; |
| 9947 | 9947 | $temp_array['year_name'] = $row['year_name']; |
@@ -9967,15 +9967,15 @@ discard block |
||
| 9967 | 9967 | $datetime = new DateTime(); |
| 9968 | 9968 | $offset = $datetime->format('P'); |
| 9969 | 9969 | } else $offset = '+00:00'; |
| 9970 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 9970 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 9971 | 9971 | |
| 9972 | 9972 | if ($globalDBdriver == 'mysql') { |
| 9973 | - $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
|
| 9973 | + $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
|
| 9974 | 9974 | FROM spotter_output".$filter_query." aircraft_icao <> '' |
| 9975 | 9975 | GROUP BY year_name, month_name |
| 9976 | 9976 | ORDER BY date_count DESC"; |
| 9977 | 9977 | } else { |
| 9978 | - $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count |
|
| 9978 | + $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count |
|
| 9979 | 9979 | FROM spotter_output".$filter_query." aircraft_icao <> '' |
| 9980 | 9980 | GROUP BY year_name, month_name |
| 9981 | 9981 | ORDER BY date_count DESC"; |
@@ -9987,7 +9987,7 @@ discard block |
||
| 9987 | 9987 | $date_array = array(); |
| 9988 | 9988 | $temp_array = array(); |
| 9989 | 9989 | |
| 9990 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9990 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 9991 | 9991 | { |
| 9992 | 9992 | $temp_array['month_name'] = $row['month_name']; |
| 9993 | 9993 | $temp_array['year_name'] = $row['year_name']; |
@@ -10009,7 +10009,7 @@ discard block |
||
| 10009 | 10009 | public function countAllMonthsAircraftsByAirlines($filters = array()) |
| 10010 | 10010 | { |
| 10011 | 10011 | global $globalTimezone, $globalDBdriver; |
| 10012 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10012 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10013 | 10013 | if ($globalTimezone != '') { |
| 10014 | 10014 | date_default_timezone_set($globalTimezone); |
| 10015 | 10015 | $datetime = new DateTime(); |
@@ -10017,12 +10017,12 @@ discard block |
||
| 10017 | 10017 | } else $offset = '+00:00'; |
| 10018 | 10018 | |
| 10019 | 10019 | if ($globalDBdriver == 'mysql') { |
| 10020 | - $query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
|
| 10020 | + $query = "SELECT spotter_output.airline_icao,YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(distinct aircraft_icao) as date_count |
|
| 10021 | 10021 | FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' |
| 10022 | 10022 | GROUP BY spotter_output.airline_icao, year_name, month_name |
| 10023 | 10023 | ORDER BY date_count DESC"; |
| 10024 | 10024 | } else { |
| 10025 | - $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count |
|
| 10025 | + $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(distinct aircraft_icao) as date_count |
|
| 10026 | 10026 | FROM spotter_output".$filter_query." aircraft_icao <> '' AND spotter_output.airline_icao <> '' |
| 10027 | 10027 | GROUP BY spotter_output.airline_icao, year_name, month_name |
| 10028 | 10028 | ORDER BY date_count DESC"; |
@@ -10034,7 +10034,7 @@ discard block |
||
| 10034 | 10034 | $date_array = array(); |
| 10035 | 10035 | $temp_array = array(); |
| 10036 | 10036 | |
| 10037 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10037 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10038 | 10038 | { |
| 10039 | 10039 | $temp_array['month_name'] = $row['month_name']; |
| 10040 | 10040 | $temp_array['year_name'] = $row['year_name']; |
@@ -10061,15 +10061,15 @@ discard block |
||
| 10061 | 10061 | $datetime = new DateTime(); |
| 10062 | 10062 | $offset = $datetime->format('P'); |
| 10063 | 10063 | } else $offset = '+00:00'; |
| 10064 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10064 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10065 | 10065 | |
| 10066 | 10066 | if ($globalDBdriver == 'mysql') { |
| 10067 | - $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
|
| 10067 | + $query = "SELECT YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
|
| 10068 | 10068 | FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' |
| 10069 | 10069 | GROUP BY year_name, month_name |
| 10070 | 10070 | ORDER BY date_count DESC"; |
| 10071 | 10071 | } else { |
| 10072 | - $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count |
|
| 10072 | + $query = "SELECT EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count |
|
| 10073 | 10073 | FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' |
| 10074 | 10074 | GROUP BY year_name, month_name |
| 10075 | 10075 | ORDER BY date_count DESC"; |
@@ -10081,7 +10081,7 @@ discard block |
||
| 10081 | 10081 | $date_array = array(); |
| 10082 | 10082 | $temp_array = array(); |
| 10083 | 10083 | |
| 10084 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10084 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10085 | 10085 | { |
| 10086 | 10086 | $temp_array['month_name'] = $row['month_name']; |
| 10087 | 10087 | $temp_array['year_name'] = $row['year_name']; |
@@ -10103,7 +10103,7 @@ discard block |
||
| 10103 | 10103 | public function countAllMonthsRealArrivalsByAirlines($filters = array()) |
| 10104 | 10104 | { |
| 10105 | 10105 | global $globalTimezone, $globalDBdriver; |
| 10106 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10106 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10107 | 10107 | if ($globalTimezone != '') { |
| 10108 | 10108 | date_default_timezone_set($globalTimezone); |
| 10109 | 10109 | $datetime = new DateTime(); |
@@ -10111,12 +10111,12 @@ discard block |
||
| 10111 | 10111 | } else $offset = '+00:00'; |
| 10112 | 10112 | |
| 10113 | 10113 | if ($globalDBdriver == 'mysql') { |
| 10114 | - $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
|
| 10114 | + $query = "SELECT spotter_output.airline_icao, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, count(real_arrival_airport_icao) as date_count |
|
| 10115 | 10115 | FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' |
| 10116 | 10116 | GROUP BY spotter_output.airline_icao, year_name, month_name |
| 10117 | 10117 | ORDER BY date_count DESC"; |
| 10118 | 10118 | } else { |
| 10119 | - $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count |
|
| 10119 | + $query = "SELECT spotter_output.airline_icao, EXTRACT(YEAR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS year_name,EXTRACT(MONTH FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS month_name, count(real_arrival_airport_icao) as date_count |
|
| 10120 | 10120 | FROM spotter_output".$filter_query." real_arrival_airport_icao <> '' AND spotter_output.airline_icao <> '' |
| 10121 | 10121 | GROUP BY spotter_output.airline_icao, year_name, month_name |
| 10122 | 10122 | ORDER BY date_count DESC"; |
@@ -10128,7 +10128,7 @@ discard block |
||
| 10128 | 10128 | $date_array = array(); |
| 10129 | 10129 | $temp_array = array(); |
| 10130 | 10130 | |
| 10131 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10131 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10132 | 10132 | { |
| 10133 | 10133 | $temp_array['month_name'] = $row['month_name']; |
| 10134 | 10134 | $temp_array['year_name'] = $row['year_name']; |
@@ -10156,7 +10156,7 @@ discard block |
||
| 10156 | 10156 | $datetime = new DateTime(); |
| 10157 | 10157 | $offset = $datetime->format('P'); |
| 10158 | 10158 | } else $offset = '+00:00'; |
| 10159 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10159 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10160 | 10160 | if ($globalDBdriver == 'mysql') { |
| 10161 | 10161 | $query = "SELECT MONTH(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count |
| 10162 | 10162 | FROM spotter_output".$filter_query." spotter_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)"; |
@@ -10177,7 +10177,7 @@ discard block |
||
| 10177 | 10177 | $date_array = array(); |
| 10178 | 10178 | $temp_array = array(); |
| 10179 | 10179 | |
| 10180 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10180 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10181 | 10181 | { |
| 10182 | 10182 | $temp_array['year_name'] = $row['year_name']; |
| 10183 | 10183 | $temp_array['month_name'] = $row['month_name']; |
@@ -10197,7 +10197,7 @@ discard block |
||
| 10197 | 10197 | * @return Array the hour list |
| 10198 | 10198 | * |
| 10199 | 10199 | */ |
| 10200 | - public function countAllHours($orderby,$filters = array()) |
|
| 10200 | + public function countAllHours($orderby, $filters = array()) |
|
| 10201 | 10201 | { |
| 10202 | 10202 | global $globalTimezone, $globalDBdriver; |
| 10203 | 10203 | if ($globalTimezone != '') { |
@@ -10245,7 +10245,7 @@ discard block |
||
| 10245 | 10245 | $hour_array = array(); |
| 10246 | 10246 | $temp_array = array(); |
| 10247 | 10247 | |
| 10248 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10248 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10249 | 10249 | { |
| 10250 | 10250 | $temp_array['hour_name'] = $row['hour_name']; |
| 10251 | 10251 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10265,7 +10265,7 @@ discard block |
||
| 10265 | 10265 | public function countAllHoursByAirlines($orderby, $filters = array()) |
| 10266 | 10266 | { |
| 10267 | 10267 | global $globalTimezone, $globalDBdriver; |
| 10268 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10268 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10269 | 10269 | if ($globalTimezone != '') { |
| 10270 | 10270 | date_default_timezone_set($globalTimezone); |
| 10271 | 10271 | $datetime = new DateTime(); |
@@ -10283,7 +10283,7 @@ discard block |
||
| 10283 | 10283 | } |
| 10284 | 10284 | |
| 10285 | 10285 | if ($globalDBdriver == 'mysql') { |
| 10286 | - $query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10286 | + $query = "SELECT spotter_output.airline_icao, HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10287 | 10287 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
| 10288 | 10288 | GROUP BY spotter_output.airline_icao, hour_name |
| 10289 | 10289 | ".$orderby_sql; |
@@ -10296,7 +10296,7 @@ discard block |
||
| 10296 | 10296 | */ |
| 10297 | 10297 | $query_data = array(':offset' => $offset); |
| 10298 | 10298 | } else { |
| 10299 | - $query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10299 | + $query = "SELECT spotter_output.airline_icao, EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10300 | 10300 | FROM spotter_output".$filter_query." spotter_output.airline_icao <> '' |
| 10301 | 10301 | GROUP BY spotter_output.airline_icao, hour_name |
| 10302 | 10302 | ".$orderby_sql; |
@@ -10309,7 +10309,7 @@ discard block |
||
| 10309 | 10309 | $hour_array = array(); |
| 10310 | 10310 | $temp_array = array(); |
| 10311 | 10311 | |
| 10312 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10312 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10313 | 10313 | { |
| 10314 | 10314 | $temp_array['hour_name'] = $row['hour_name']; |
| 10315 | 10315 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10332,34 +10332,34 @@ discard block |
||
| 10332 | 10332 | public function countAllHoursByAirline($airline_icao, $filters = array()) |
| 10333 | 10333 | { |
| 10334 | 10334 | global $globalTimezone, $globalDBdriver; |
| 10335 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10335 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10336 | 10336 | if ($globalTimezone != '') { |
| 10337 | 10337 | date_default_timezone_set($globalTimezone); |
| 10338 | 10338 | $datetime = new DateTime(); |
| 10339 | 10339 | $offset = $datetime->format('P'); |
| 10340 | 10340 | } else $offset = '+00:00'; |
| 10341 | 10341 | |
| 10342 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
| 10342 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
| 10343 | 10343 | |
| 10344 | 10344 | if ($globalDBdriver == 'mysql') { |
| 10345 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10345 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10346 | 10346 | FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao |
| 10347 | 10347 | GROUP BY hour_name |
| 10348 | 10348 | ORDER BY hour_name ASC"; |
| 10349 | 10349 | } else { |
| 10350 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10350 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10351 | 10351 | FROM spotter_output".$filter_query." spotter_output.airline_icao = :airline_icao |
| 10352 | 10352 | GROUP BY hour_name |
| 10353 | 10353 | ORDER BY hour_name ASC"; |
| 10354 | 10354 | } |
| 10355 | 10355 | |
| 10356 | 10356 | $sth = $this->db->prepare($query); |
| 10357 | - $sth->execute(array(':airline_icao' => $airline_icao,':offset' => $offset)); |
|
| 10357 | + $sth->execute(array(':airline_icao' => $airline_icao, ':offset' => $offset)); |
|
| 10358 | 10358 | |
| 10359 | 10359 | $hour_array = array(); |
| 10360 | 10360 | $temp_array = array(); |
| 10361 | 10361 | |
| 10362 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10362 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10363 | 10363 | { |
| 10364 | 10364 | $temp_array['hour_name'] = $row['hour_name']; |
| 10365 | 10365 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10382,8 +10382,8 @@ discard block |
||
| 10382 | 10382 | public function countAllHoursByAircraft($aircraft_icao, $filters = array()) |
| 10383 | 10383 | { |
| 10384 | 10384 | global $globalTimezone, $globalDBdriver; |
| 10385 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10386 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
| 10385 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10386 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
| 10387 | 10387 | if ($globalTimezone != '') { |
| 10388 | 10388 | date_default_timezone_set($globalTimezone); |
| 10389 | 10389 | $datetime = new DateTime(); |
@@ -10391,24 +10391,24 @@ discard block |
||
| 10391 | 10391 | } else $offset = '+00:00'; |
| 10392 | 10392 | |
| 10393 | 10393 | if ($globalDBdriver == 'mysql') { |
| 10394 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10394 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10395 | 10395 | FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao |
| 10396 | 10396 | GROUP BY hour_name |
| 10397 | 10397 | ORDER BY hour_name ASC"; |
| 10398 | 10398 | } else { |
| 10399 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10399 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10400 | 10400 | FROM spotter_output".$filter_query." spotter_output.aircraft_icao = :aircraft_icao |
| 10401 | 10401 | GROUP BY hour_name |
| 10402 | 10402 | ORDER BY hour_name ASC"; |
| 10403 | 10403 | } |
| 10404 | 10404 | |
| 10405 | 10405 | $sth = $this->db->prepare($query); |
| 10406 | - $sth->execute(array(':aircraft_icao' => $aircraft_icao,':offset' => $offset)); |
|
| 10406 | + $sth->execute(array(':aircraft_icao' => $aircraft_icao, ':offset' => $offset)); |
|
| 10407 | 10407 | |
| 10408 | 10408 | $hour_array = array(); |
| 10409 | 10409 | $temp_array = array(); |
| 10410 | 10410 | |
| 10411 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10411 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10412 | 10412 | { |
| 10413 | 10413 | $temp_array['hour_name'] = $row['hour_name']; |
| 10414 | 10414 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10429,8 +10429,8 @@ discard block |
||
| 10429 | 10429 | public function countAllHoursByRegistration($registration, $filters = array()) |
| 10430 | 10430 | { |
| 10431 | 10431 | global $globalTimezone, $globalDBdriver; |
| 10432 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10433 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 10432 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10433 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 10434 | 10434 | if ($globalTimezone != '') { |
| 10435 | 10435 | date_default_timezone_set($globalTimezone); |
| 10436 | 10436 | $datetime = new DateTime(); |
@@ -10438,24 +10438,24 @@ discard block |
||
| 10438 | 10438 | } else $offset = '+00:00'; |
| 10439 | 10439 | |
| 10440 | 10440 | if ($globalDBdriver == 'mysql') { |
| 10441 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10441 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10442 | 10442 | FROM spotter_output".$filter_query." spotter_output.registration = :registration |
| 10443 | 10443 | GROUP BY hour_name |
| 10444 | 10444 | ORDER BY hour_name ASC"; |
| 10445 | 10445 | } else { |
| 10446 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10446 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10447 | 10447 | FROM spotter_output".$filter_query." spotter_output.registration = :registration |
| 10448 | 10448 | GROUP BY hour_name |
| 10449 | 10449 | ORDER BY hour_name ASC"; |
| 10450 | 10450 | } |
| 10451 | 10451 | |
| 10452 | 10452 | $sth = $this->db->prepare($query); |
| 10453 | - $sth->execute(array(':registration' => $registration,':offset' => $offset)); |
|
| 10453 | + $sth->execute(array(':registration' => $registration, ':offset' => $offset)); |
|
| 10454 | 10454 | |
| 10455 | 10455 | $hour_array = array(); |
| 10456 | 10456 | $temp_array = array(); |
| 10457 | 10457 | |
| 10458 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10458 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10459 | 10459 | { |
| 10460 | 10460 | $temp_array['hour_name'] = $row['hour_name']; |
| 10461 | 10461 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10476,8 +10476,8 @@ discard block |
||
| 10476 | 10476 | public function countAllHoursByAirport($airport_icao, $filters = array()) |
| 10477 | 10477 | { |
| 10478 | 10478 | global $globalTimezone, $globalDBdriver; |
| 10479 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10480 | - $airport_icao = filter_var($airport_icao,FILTER_SANITIZE_STRING); |
|
| 10479 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10480 | + $airport_icao = filter_var($airport_icao, FILTER_SANITIZE_STRING); |
|
| 10481 | 10481 | if ($globalTimezone != '') { |
| 10482 | 10482 | date_default_timezone_set($globalTimezone); |
| 10483 | 10483 | $datetime = new DateTime(); |
@@ -10485,24 +10485,24 @@ discard block |
||
| 10485 | 10485 | } else $offset = '+00:00'; |
| 10486 | 10486 | |
| 10487 | 10487 | if ($globalDBdriver == 'mysql') { |
| 10488 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10488 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10489 | 10489 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
| 10490 | 10490 | GROUP BY hour_name |
| 10491 | 10491 | ORDER BY hour_name ASC"; |
| 10492 | 10492 | } else { |
| 10493 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10493 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10494 | 10494 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :airport_icao OR spotter_output.arrival_airport_icao = :airport_icao) |
| 10495 | 10495 | GROUP BY hour_name |
| 10496 | 10496 | ORDER BY hour_name ASC"; |
| 10497 | 10497 | } |
| 10498 | 10498 | |
| 10499 | 10499 | $sth = $this->db->prepare($query); |
| 10500 | - $sth->execute(array(':airport_icao' => $airport_icao,':offset' => $offset)); |
|
| 10500 | + $sth->execute(array(':airport_icao' => $airport_icao, ':offset' => $offset)); |
|
| 10501 | 10501 | |
| 10502 | 10502 | $hour_array = array(); |
| 10503 | 10503 | $temp_array = array(); |
| 10504 | 10504 | |
| 10505 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10505 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10506 | 10506 | { |
| 10507 | 10507 | $temp_array['hour_name'] = $row['hour_name']; |
| 10508 | 10508 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10521,11 +10521,11 @@ discard block |
||
| 10521 | 10521 | * @return Array the hour list |
| 10522 | 10522 | * |
| 10523 | 10523 | */ |
| 10524 | - public function countAllHoursByManufacturer($aircraft_manufacturer,$filters =array()) |
|
| 10524 | + public function countAllHoursByManufacturer($aircraft_manufacturer, $filters = array()) |
|
| 10525 | 10525 | { |
| 10526 | 10526 | global $globalTimezone, $globalDBdriver; |
| 10527 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10528 | - $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING); |
|
| 10527 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10528 | + $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING); |
|
| 10529 | 10529 | if ($globalTimezone != '') { |
| 10530 | 10530 | date_default_timezone_set($globalTimezone); |
| 10531 | 10531 | $datetime = new DateTime(); |
@@ -10533,24 +10533,24 @@ discard block |
||
| 10533 | 10533 | } else $offset = '+00:00'; |
| 10534 | 10534 | |
| 10535 | 10535 | if ($globalDBdriver == 'mysql') { |
| 10536 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10536 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10537 | 10537 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 10538 | 10538 | GROUP BY hour_name |
| 10539 | 10539 | ORDER BY hour_name ASC"; |
| 10540 | 10540 | } else { |
| 10541 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10541 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10542 | 10542 | FROM spotter_output".$filter_query." spotter_output.aircraft_manufacturer = :aircraft_manufacturer |
| 10543 | 10543 | GROUP BY hour_name |
| 10544 | 10544 | ORDER BY hour_name ASC"; |
| 10545 | 10545 | } |
| 10546 | 10546 | |
| 10547 | 10547 | $sth = $this->db->prepare($query); |
| 10548 | - $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer,':offset' => $offset)); |
|
| 10548 | + $sth->execute(array(':aircraft_manufacturer' => $aircraft_manufacturer, ':offset' => $offset)); |
|
| 10549 | 10549 | |
| 10550 | 10550 | $hour_array = array(); |
| 10551 | 10551 | $temp_array = array(); |
| 10552 | 10552 | |
| 10553 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10553 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10554 | 10554 | { |
| 10555 | 10555 | $temp_array['hour_name'] = $row['hour_name']; |
| 10556 | 10556 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10572,8 +10572,8 @@ discard block |
||
| 10572 | 10572 | public function countAllHoursByDate($date, $filters = array()) |
| 10573 | 10573 | { |
| 10574 | 10574 | global $globalTimezone, $globalDBdriver; |
| 10575 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10576 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 10575 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10576 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 10577 | 10577 | if ($globalTimezone != '') { |
| 10578 | 10578 | date_default_timezone_set($globalTimezone); |
| 10579 | 10579 | $datetime = new DateTime($date); |
@@ -10581,12 +10581,12 @@ discard block |
||
| 10581 | 10581 | } else $offset = '+00:00'; |
| 10582 | 10582 | |
| 10583 | 10583 | if ($globalDBdriver == 'mysql') { |
| 10584 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10584 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10585 | 10585 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = :date |
| 10586 | 10586 | GROUP BY hour_name |
| 10587 | 10587 | ORDER BY hour_name ASC"; |
| 10588 | 10588 | } else { |
| 10589 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10589 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10590 | 10590 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date |
| 10591 | 10591 | GROUP BY hour_name |
| 10592 | 10592 | ORDER BY hour_name ASC"; |
@@ -10598,7 +10598,7 @@ discard block |
||
| 10598 | 10598 | $hour_array = array(); |
| 10599 | 10599 | $temp_array = array(); |
| 10600 | 10600 | |
| 10601 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10601 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10602 | 10602 | { |
| 10603 | 10603 | $temp_array['hour_name'] = $row['hour_name']; |
| 10604 | 10604 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10620,8 +10620,8 @@ discard block |
||
| 10620 | 10620 | public function countAllHoursByIdent($ident, $filters = array()) |
| 10621 | 10621 | { |
| 10622 | 10622 | global $globalTimezone, $globalDBdriver; |
| 10623 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10624 | - $ident = filter_var($ident,FILTER_SANITIZE_STRING); |
|
| 10623 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10624 | + $ident = filter_var($ident, FILTER_SANITIZE_STRING); |
|
| 10625 | 10625 | if ($globalTimezone != '') { |
| 10626 | 10626 | date_default_timezone_set($globalTimezone); |
| 10627 | 10627 | $datetime = new DateTime(); |
@@ -10629,12 +10629,12 @@ discard block |
||
| 10629 | 10629 | } else $offset = '+00:00'; |
| 10630 | 10630 | |
| 10631 | 10631 | if ($globalDBdriver == 'mysql') { |
| 10632 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10632 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10633 | 10633 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
| 10634 | 10634 | GROUP BY hour_name |
| 10635 | 10635 | ORDER BY hour_name ASC"; |
| 10636 | 10636 | } else { |
| 10637 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10637 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10638 | 10638 | FROM spotter_output".$filter_query." spotter_output.ident = :ident |
| 10639 | 10639 | GROUP BY hour_name |
| 10640 | 10640 | ORDER BY hour_name ASC"; |
@@ -10642,12 +10642,12 @@ discard block |
||
| 10642 | 10642 | |
| 10643 | 10643 | |
| 10644 | 10644 | $sth = $this->db->prepare($query); |
| 10645 | - $sth->execute(array(':ident' => $ident,':offset' => $offset)); |
|
| 10645 | + $sth->execute(array(':ident' => $ident, ':offset' => $offset)); |
|
| 10646 | 10646 | |
| 10647 | 10647 | $hour_array = array(); |
| 10648 | 10648 | $temp_array = array(); |
| 10649 | 10649 | |
| 10650 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10650 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10651 | 10651 | { |
| 10652 | 10652 | $temp_array['hour_name'] = $row['hour_name']; |
| 10653 | 10653 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10667,8 +10667,8 @@ discard block |
||
| 10667 | 10667 | public function countAllHoursByOwner($owner, $filters = array()) |
| 10668 | 10668 | { |
| 10669 | 10669 | global $globalTimezone, $globalDBdriver; |
| 10670 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10671 | - $owner = filter_var($owner,FILTER_SANITIZE_STRING); |
|
| 10670 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10671 | + $owner = filter_var($owner, FILTER_SANITIZE_STRING); |
|
| 10672 | 10672 | if ($globalTimezone != '') { |
| 10673 | 10673 | date_default_timezone_set($globalTimezone); |
| 10674 | 10674 | $datetime = new DateTime(); |
@@ -10676,12 +10676,12 @@ discard block |
||
| 10676 | 10676 | } else $offset = '+00:00'; |
| 10677 | 10677 | |
| 10678 | 10678 | if ($globalDBdriver == 'mysql') { |
| 10679 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10679 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10680 | 10680 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner |
| 10681 | 10681 | GROUP BY hour_name |
| 10682 | 10682 | ORDER BY hour_name ASC"; |
| 10683 | 10683 | } else { |
| 10684 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10684 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10685 | 10685 | FROM spotter_output".$filter_query." spotter_output.owner_name = :owner |
| 10686 | 10686 | GROUP BY hour_name |
| 10687 | 10687 | ORDER BY hour_name ASC"; |
@@ -10689,12 +10689,12 @@ discard block |
||
| 10689 | 10689 | |
| 10690 | 10690 | |
| 10691 | 10691 | $sth = $this->db->prepare($query); |
| 10692 | - $sth->execute(array(':owner' => $owner,':offset' => $offset)); |
|
| 10692 | + $sth->execute(array(':owner' => $owner, ':offset' => $offset)); |
|
| 10693 | 10693 | |
| 10694 | 10694 | $hour_array = array(); |
| 10695 | 10695 | $temp_array = array(); |
| 10696 | 10696 | |
| 10697 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10697 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10698 | 10698 | { |
| 10699 | 10699 | $temp_array['hour_name'] = $row['hour_name']; |
| 10700 | 10700 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10714,8 +10714,8 @@ discard block |
||
| 10714 | 10714 | public function countAllHoursByPilot($pilot, $filters = array()) |
| 10715 | 10715 | { |
| 10716 | 10716 | global $globalTimezone, $globalDBdriver; |
| 10717 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10718 | - $pilot = filter_var($pilot,FILTER_SANITIZE_STRING); |
|
| 10717 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10718 | + $pilot = filter_var($pilot, FILTER_SANITIZE_STRING); |
|
| 10719 | 10719 | if ($globalTimezone != '') { |
| 10720 | 10720 | date_default_timezone_set($globalTimezone); |
| 10721 | 10721 | $datetime = new DateTime(); |
@@ -10723,12 +10723,12 @@ discard block |
||
| 10723 | 10723 | } else $offset = '+00:00'; |
| 10724 | 10724 | |
| 10725 | 10725 | if ($globalDBdriver == 'mysql') { |
| 10726 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10726 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10727 | 10727 | FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 10728 | 10728 | GROUP BY hour_name |
| 10729 | 10729 | ORDER BY hour_name ASC"; |
| 10730 | 10730 | } else { |
| 10731 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10731 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10732 | 10732 | FROM spotter_output".$filter_query." (spotter_output.pilot_name = :pilot OR spotter_output.pilot_id = :pilot) |
| 10733 | 10733 | GROUP BY hour_name |
| 10734 | 10734 | ORDER BY hour_name ASC"; |
@@ -10736,12 +10736,12 @@ discard block |
||
| 10736 | 10736 | |
| 10737 | 10737 | |
| 10738 | 10738 | $sth = $this->db->prepare($query); |
| 10739 | - $sth->execute(array(':pilot' => $pilot,':offset' => $offset)); |
|
| 10739 | + $sth->execute(array(':pilot' => $pilot, ':offset' => $offset)); |
|
| 10740 | 10740 | |
| 10741 | 10741 | $hour_array = array(); |
| 10742 | 10742 | $temp_array = array(); |
| 10743 | 10743 | |
| 10744 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10744 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10745 | 10745 | { |
| 10746 | 10746 | $temp_array['hour_name'] = $row['hour_name']; |
| 10747 | 10747 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10760,12 +10760,12 @@ discard block |
||
| 10760 | 10760 | * @return Array the hour list |
| 10761 | 10761 | * |
| 10762 | 10762 | */ |
| 10763 | - public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters =array()) |
|
| 10763 | + public function countAllHoursByRoute($departure_airport_icao, $arrival_airport_icao, $filters = array()) |
|
| 10764 | 10764 | { |
| 10765 | 10765 | global $globalTimezone, $globalDBdriver; |
| 10766 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10767 | - $departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING); |
|
| 10768 | - $arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING); |
|
| 10766 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10767 | + $departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING); |
|
| 10768 | + $arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING); |
|
| 10769 | 10769 | if ($globalTimezone != '') { |
| 10770 | 10770 | date_default_timezone_set($globalTimezone); |
| 10771 | 10771 | $datetime = new DateTime(); |
@@ -10773,24 +10773,24 @@ discard block |
||
| 10773 | 10773 | } else $offset = '+00:00'; |
| 10774 | 10774 | |
| 10775 | 10775 | if ($globalDBdriver == 'mysql') { |
| 10776 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10776 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10777 | 10777 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
| 10778 | 10778 | GROUP BY hour_name |
| 10779 | 10779 | ORDER BY hour_name ASC"; |
| 10780 | 10780 | } else { |
| 10781 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10781 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10782 | 10782 | FROM spotter_output".$filter_query." (spotter_output.departure_airport_icao = :departure_airport_icao) AND (spotter_output.arrival_airport_icao = :arrival_airport_icao) |
| 10783 | 10783 | GROUP BY hour_name |
| 10784 | 10784 | ORDER BY hour_name ASC"; |
| 10785 | 10785 | } |
| 10786 | 10786 | |
| 10787 | 10787 | $sth = $this->db->prepare($query); |
| 10788 | - $sth->execute(array(':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':offset' => $offset)); |
|
| 10788 | + $sth->execute(array(':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':offset' => $offset)); |
|
| 10789 | 10789 | |
| 10790 | 10790 | $hour_array = array(); |
| 10791 | 10791 | $temp_array = array(); |
| 10792 | 10792 | |
| 10793 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10793 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10794 | 10794 | { |
| 10795 | 10795 | $temp_array['hour_name'] = $row['hour_name']; |
| 10796 | 10796 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10811,8 +10811,8 @@ discard block |
||
| 10811 | 10811 | public function countAllHoursByCountry($country, $filters = array()) |
| 10812 | 10812 | { |
| 10813 | 10813 | global $globalTimezone, $globalDBdriver; |
| 10814 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10815 | - $country = filter_var($country,FILTER_SANITIZE_STRING); |
|
| 10814 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10815 | + $country = filter_var($country, FILTER_SANITIZE_STRING); |
|
| 10816 | 10816 | if ($globalTimezone != '') { |
| 10817 | 10817 | date_default_timezone_set($globalTimezone); |
| 10818 | 10818 | $datetime = new DateTime(); |
@@ -10820,24 +10820,24 @@ discard block |
||
| 10820 | 10820 | } else $offset = '+00:00'; |
| 10821 | 10821 | |
| 10822 | 10822 | if ($globalDBdriver == 'mysql') { |
| 10823 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10823 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 10824 | 10824 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 10825 | 10825 | GROUP BY hour_name |
| 10826 | 10826 | ORDER BY hour_name ASC"; |
| 10827 | 10827 | } else { |
| 10828 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10828 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 10829 | 10829 | FROM spotter_output".$filter_query." ((spotter_output.departure_airport_country = :country) OR (spotter_output.arrival_airport_country = :country)) OR spotter_output.airline_country = :country |
| 10830 | 10830 | GROUP BY hour_name |
| 10831 | 10831 | ORDER BY hour_name ASC"; |
| 10832 | 10832 | } |
| 10833 | 10833 | |
| 10834 | 10834 | $sth = $this->db->prepare($query); |
| 10835 | - $sth->execute(array(':country' => $country,':offset' => $offset)); |
|
| 10835 | + $sth->execute(array(':country' => $country, ':offset' => $offset)); |
|
| 10836 | 10836 | |
| 10837 | 10837 | $hour_array = array(); |
| 10838 | 10838 | $temp_array = array(); |
| 10839 | 10839 | |
| 10840 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10840 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 10841 | 10841 | { |
| 10842 | 10842 | $temp_array['hour_name'] = $row['hour_name']; |
| 10843 | 10843 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -10857,29 +10857,29 @@ discard block |
||
| 10857 | 10857 | * @return Integer the number of aircrafts |
| 10858 | 10858 | * |
| 10859 | 10859 | */ |
| 10860 | - public function countOverallAircrafts($filters = array(),$year = '',$month = '') |
|
| 10860 | + public function countOverallAircrafts($filters = array(), $year = '', $month = '') |
|
| 10861 | 10861 | { |
| 10862 | 10862 | global $globalDBdriver; |
| 10863 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10864 | - $query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count |
|
| 10863 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10864 | + $query = "SELECT COUNT(DISTINCT spotter_output.aircraft_icao) AS aircraft_count |
|
| 10865 | 10865 | FROM spotter_output".$filter_query." spotter_output.ident <> ''"; |
| 10866 | 10866 | $query_values = array(); |
| 10867 | 10867 | if ($year != '') { |
| 10868 | 10868 | if ($globalDBdriver == 'mysql') { |
| 10869 | 10869 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 10870 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 10870 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 10871 | 10871 | } else { |
| 10872 | 10872 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 10873 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 10873 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 10874 | 10874 | } |
| 10875 | 10875 | } |
| 10876 | 10876 | if ($month != '') { |
| 10877 | 10877 | if ($globalDBdriver == 'mysql') { |
| 10878 | 10878 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 10879 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 10879 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 10880 | 10880 | } else { |
| 10881 | 10881 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 10882 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 10882 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 10883 | 10883 | } |
| 10884 | 10884 | } |
| 10885 | 10885 | |
@@ -10894,29 +10894,29 @@ discard block |
||
| 10894 | 10894 | * @return Integer the number of aircrafts |
| 10895 | 10895 | * |
| 10896 | 10896 | */ |
| 10897 | - public function countOverallArrival($filters = array(),$year = '',$month = '') |
|
| 10897 | + public function countOverallArrival($filters = array(), $year = '', $month = '') |
|
| 10898 | 10898 | { |
| 10899 | 10899 | global $globalDBdriver; |
| 10900 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10901 | - $query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count |
|
| 10900 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10901 | + $query = "SELECT COUNT(spotter_output.real_arrival_airport_icao) AS arrival_count |
|
| 10902 | 10902 | FROM spotter_output".$filter_query." spotter_output.arrival_airport_icao <> ''"; |
| 10903 | 10903 | $query_values = array(); |
| 10904 | 10904 | if ($year != '') { |
| 10905 | 10905 | if ($globalDBdriver == 'mysql') { |
| 10906 | 10906 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 10907 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 10907 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 10908 | 10908 | } else { |
| 10909 | 10909 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 10910 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 10910 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 10911 | 10911 | } |
| 10912 | 10912 | } |
| 10913 | 10913 | if ($month != '') { |
| 10914 | 10914 | if ($globalDBdriver == 'mysql') { |
| 10915 | 10915 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 10916 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 10916 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 10917 | 10917 | } else { |
| 10918 | 10918 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 10919 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 10919 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 10920 | 10920 | } |
| 10921 | 10921 | } |
| 10922 | 10922 | |
@@ -10931,29 +10931,29 @@ discard block |
||
| 10931 | 10931 | * @return Integer the number of pilots |
| 10932 | 10932 | * |
| 10933 | 10933 | */ |
| 10934 | - public function countOverallPilots($filters = array(),$year = '',$month = '') |
|
| 10934 | + public function countOverallPilots($filters = array(), $year = '', $month = '') |
|
| 10935 | 10935 | { |
| 10936 | 10936 | global $globalDBdriver; |
| 10937 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10938 | - $query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count |
|
| 10937 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10938 | + $query = "SELECT COUNT(DISTINCT spotter_output.pilot_id) AS pilot_count |
|
| 10939 | 10939 | FROM spotter_output".$filter_query." spotter_output.pilot_id <> ''"; |
| 10940 | 10940 | $query_values = array(); |
| 10941 | 10941 | if ($year != '') { |
| 10942 | 10942 | if ($globalDBdriver == 'mysql') { |
| 10943 | 10943 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 10944 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 10944 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 10945 | 10945 | } else { |
| 10946 | 10946 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 10947 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 10947 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 10948 | 10948 | } |
| 10949 | 10949 | } |
| 10950 | 10950 | if ($month != '') { |
| 10951 | 10951 | if ($globalDBdriver == 'mysql') { |
| 10952 | 10952 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 10953 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 10953 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 10954 | 10954 | } else { |
| 10955 | 10955 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 10956 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 10956 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 10957 | 10957 | } |
| 10958 | 10958 | } |
| 10959 | 10959 | $sth = $this->db->prepare($query); |
@@ -10967,29 +10967,29 @@ discard block |
||
| 10967 | 10967 | * @return Integer the number of owners |
| 10968 | 10968 | * |
| 10969 | 10969 | */ |
| 10970 | - public function countOverallOwners($filters = array(),$year = '',$month = '') |
|
| 10970 | + public function countOverallOwners($filters = array(), $year = '', $month = '') |
|
| 10971 | 10971 | { |
| 10972 | 10972 | global $globalDBdriver; |
| 10973 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 10974 | - $query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count |
|
| 10973 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 10974 | + $query = "SELECT COUNT(DISTINCT spotter_output.owner_name) AS owner_count |
|
| 10975 | 10975 | FROM spotter_output".$filter_query." spotter_output.owner_name <> ''"; |
| 10976 | 10976 | $query_values = array(); |
| 10977 | 10977 | if ($year != '') { |
| 10978 | 10978 | if ($globalDBdriver == 'mysql') { |
| 10979 | 10979 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 10980 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 10980 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 10981 | 10981 | } else { |
| 10982 | 10982 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 10983 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 10983 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 10984 | 10984 | } |
| 10985 | 10985 | } |
| 10986 | 10986 | if ($month != '') { |
| 10987 | 10987 | if ($globalDBdriver == 'mysql') { |
| 10988 | 10988 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 10989 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 10989 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 10990 | 10990 | } else { |
| 10991 | 10991 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 10992 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 10992 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 10993 | 10993 | } |
| 10994 | 10994 | } |
| 10995 | 10995 | $sth = $this->db->prepare($query); |
@@ -11004,32 +11004,32 @@ discard block |
||
| 11004 | 11004 | * @return Integer the number of flights |
| 11005 | 11005 | * |
| 11006 | 11006 | */ |
| 11007 | - public function countOverallFlights($filters = array(),$year = '',$month = '') |
|
| 11007 | + public function countOverallFlights($filters = array(), $year = '', $month = '') |
|
| 11008 | 11008 | { |
| 11009 | 11009 | global $globalDBdriver; |
| 11010 | - $queryi = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output"; |
|
| 11010 | + $queryi = "SELECT COUNT(spotter_output.spotter_id) AS flight_count FROM spotter_output"; |
|
| 11011 | 11011 | $query_values = array(); |
| 11012 | 11012 | $query = ''; |
| 11013 | 11013 | if ($year != '') { |
| 11014 | 11014 | if ($globalDBdriver == 'mysql') { |
| 11015 | 11015 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 11016 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 11016 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 11017 | 11017 | } else { |
| 11018 | 11018 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 11019 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 11019 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 11020 | 11020 | } |
| 11021 | 11021 | } |
| 11022 | 11022 | if ($month != '') { |
| 11023 | 11023 | if ($globalDBdriver == 'mysql') { |
| 11024 | 11024 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 11025 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 11025 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 11026 | 11026 | } else { |
| 11027 | 11027 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 11028 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 11028 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 11029 | 11029 | } |
| 11030 | 11030 | } |
| 11031 | 11031 | if (empty($query_values)) $queryi .= $this->getFilter($filters); |
| 11032 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 11032 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 11033 | 11033 | |
| 11034 | 11034 | $sth = $this->db->prepare($queryi); |
| 11035 | 11035 | $sth->execute($query_values); |
@@ -11042,29 +11042,29 @@ discard block |
||
| 11042 | 11042 | * @return Integer the number of flights |
| 11043 | 11043 | * |
| 11044 | 11044 | */ |
| 11045 | - public function countOverallMilitaryFlights($filters = array(),$year = '',$month = '') |
|
| 11045 | + public function countOverallMilitaryFlights($filters = array(), $year = '', $month = '') |
|
| 11046 | 11046 | { |
| 11047 | 11047 | global $globalDBdriver; |
| 11048 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 11049 | - $query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count |
|
| 11048 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 11049 | + $query = "SELECT COUNT(spotter_output.spotter_id) AS flight_count |
|
| 11050 | 11050 | FROM airlines,spotter_output".$filter_query." spotter_output.airline_icao = airlines.icao AND airlines.type = 'military'"; |
| 11051 | 11051 | $query_values = array(); |
| 11052 | 11052 | if ($year != '') { |
| 11053 | 11053 | if ($globalDBdriver == 'mysql') { |
| 11054 | 11054 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 11055 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 11055 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 11056 | 11056 | } else { |
| 11057 | 11057 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 11058 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 11058 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 11059 | 11059 | } |
| 11060 | 11060 | } |
| 11061 | 11061 | if ($month != '') { |
| 11062 | 11062 | if ($globalDBdriver == 'mysql') { |
| 11063 | 11063 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 11064 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 11064 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 11065 | 11065 | } else { |
| 11066 | 11066 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 11067 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 11067 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 11068 | 11068 | } |
| 11069 | 11069 | } |
| 11070 | 11070 | |
@@ -11081,10 +11081,10 @@ discard block |
||
| 11081 | 11081 | * @return Integer the number of airlines |
| 11082 | 11082 | * |
| 11083 | 11083 | */ |
| 11084 | - public function countOverallAirlines($filters = array(),$year = '',$month = '') |
|
| 11084 | + public function countOverallAirlines($filters = array(), $year = '', $month = '') |
|
| 11085 | 11085 | { |
| 11086 | 11086 | global $globalDBdriver; |
| 11087 | - $queryi = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count |
|
| 11087 | + $queryi = "SELECT COUNT(DISTINCT spotter_output.airline_name) AS airline_count |
|
| 11088 | 11088 | FROM spotter_output"; |
| 11089 | 11089 | |
| 11090 | 11090 | $query_values = array(); |
@@ -11092,23 +11092,23 @@ discard block |
||
| 11092 | 11092 | if ($year != '') { |
| 11093 | 11093 | if ($globalDBdriver == 'mysql') { |
| 11094 | 11094 | $query .= " AND YEAR(spotter_output.date) = :year"; |
| 11095 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 11095 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 11096 | 11096 | } else { |
| 11097 | 11097 | $query .= " AND EXTRACT(YEAR FROM spotter_output.date) = :year"; |
| 11098 | - $query_values = array_merge($query_values,array(':year' => $year)); |
|
| 11098 | + $query_values = array_merge($query_values, array(':year' => $year)); |
|
| 11099 | 11099 | } |
| 11100 | 11100 | } |
| 11101 | 11101 | if ($month != '') { |
| 11102 | 11102 | if ($globalDBdriver == 'mysql') { |
| 11103 | 11103 | $query .= " AND MONTH(spotter_output.date) = :month"; |
| 11104 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 11104 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 11105 | 11105 | } else { |
| 11106 | 11106 | $query .= " AND EXTRACT(MONTH FROM spotter_output.date) = :month"; |
| 11107 | - $query_values = array_merge($query_values,array(':month' => $month)); |
|
| 11107 | + $query_values = array_merge($query_values, array(':month' => $month)); |
|
| 11108 | 11108 | } |
| 11109 | 11109 | } |
| 11110 | 11110 | if ($query == '') $queryi .= $this->getFilter($filters); |
| 11111 | - else $queryi .= $this->getFilter($filters,true,true).substr($query,4); |
|
| 11111 | + else $queryi .= $this->getFilter($filters, true, true).substr($query, 4); |
|
| 11112 | 11112 | |
| 11113 | 11113 | |
| 11114 | 11114 | $sth = $this->db->prepare($queryi); |
@@ -11126,7 +11126,7 @@ discard block |
||
| 11126 | 11126 | public function countAllHoursFromToday($filters = array()) |
| 11127 | 11127 | { |
| 11128 | 11128 | global $globalTimezone, $globalDBdriver; |
| 11129 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 11129 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 11130 | 11130 | if ($globalTimezone != '') { |
| 11131 | 11131 | date_default_timezone_set($globalTimezone); |
| 11132 | 11132 | $datetime = new DateTime(); |
@@ -11134,12 +11134,12 @@ discard block |
||
| 11134 | 11134 | } else $offset = '+00:00'; |
| 11135 | 11135 | |
| 11136 | 11136 | if ($globalDBdriver == 'mysql') { |
| 11137 | - $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 11137 | + $query = "SELECT HOUR(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count |
|
| 11138 | 11138 | FROM spotter_output".$filter_query." DATE(CONVERT_TZ(spotter_output.date,'+00:00', :offset)) = CURDATE() |
| 11139 | 11139 | GROUP BY hour_name |
| 11140 | 11140 | ORDER BY hour_name ASC"; |
| 11141 | 11141 | } else { |
| 11142 | - $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 11142 | + $query = "SELECT EXTRACT(HOUR FROM spotter_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count |
|
| 11143 | 11143 | FROM spotter_output".$filter_query." to_char(spotter_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date) |
| 11144 | 11144 | GROUP BY hour_name |
| 11145 | 11145 | ORDER BY hour_name ASC"; |
@@ -11151,7 +11151,7 @@ discard block |
||
| 11151 | 11151 | $hour_array = array(); |
| 11152 | 11152 | $temp_array = array(); |
| 11153 | 11153 | |
| 11154 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11154 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11155 | 11155 | { |
| 11156 | 11156 | $temp_array['hour_name'] = $row['hour_name']; |
| 11157 | 11157 | $temp_array['hour_count'] = $row['hour_count']; |
@@ -11170,14 +11170,14 @@ discard block |
||
| 11170 | 11170 | public function getUpcomingFlights($limit = '', $sort = '', $filters = array()) |
| 11171 | 11171 | { |
| 11172 | 11172 | global $global_query, $globalDBdriver, $globalTimezone; |
| 11173 | - $filter_query = $this->getFilter($filters,true,true); |
|
| 11173 | + $filter_query = $this->getFilter($filters, true, true); |
|
| 11174 | 11174 | date_default_timezone_set('UTC'); |
| 11175 | 11175 | $limit_query = ''; |
| 11176 | 11176 | if ($limit != "") |
| 11177 | 11177 | { |
| 11178 | 11178 | $limit_array = explode(",", $limit); |
| 11179 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 11180 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 11179 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 11180 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 11181 | 11181 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 11182 | 11182 | { |
| 11183 | 11183 | //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1]; |
@@ -11230,7 +11230,7 @@ discard block |
||
| 11230 | 11230 | GROUP BY spotter_output.ident,spotter_output.airline_name,spotter_output.airline_icao,spotter_output.airline_country,spotter_output.airline_type,spotter_output.departure_airport_icao,spotter_output.departure_airport_name,spotter_output.departure_airport_city,spotter_output.departure_airport_country,spotter_output.departure_airport_time,spotter_output.arrival_airport_icao,spotter_output.arrival_airport_name,spotter_output.arrival_airport_city,spotter_output.arrival_airport_country,spotter_output.arrival_airport_time, to_char(spotter_output.date,'HH') |
| 11231 | 11231 | HAVING count(spotter_output.ident) > 5$orderby_query"; |
| 11232 | 11232 | //echo $query; |
| 11233 | - $spotter_array = $this->getDataFromDB($query.$limit_query,array(':timezone' => $globalTimezone)); |
|
| 11233 | + $spotter_array = $this->getDataFromDB($query.$limit_query, array(':timezone' => $globalTimezone)); |
|
| 11234 | 11234 | /* |
| 11235 | 11235 | $sth = $this->db->prepare($query); |
| 11236 | 11236 | $sth->execute(array(':timezone' => $globalTimezone)); |
@@ -11249,9 +11249,9 @@ discard block |
||
| 11249 | 11249 | */ |
| 11250 | 11250 | public function getSpotterIDBasedOnFlightAwareID($flightaware_id) |
| 11251 | 11251 | { |
| 11252 | - $flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING); |
|
| 11252 | + $flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING); |
|
| 11253 | 11253 | |
| 11254 | - $query = "SELECT spotter_output.spotter_id |
|
| 11254 | + $query = "SELECT spotter_output.spotter_id |
|
| 11255 | 11255 | FROM spotter_output |
| 11256 | 11256 | WHERE spotter_output.flightaware_id = '".$flightaware_id."'"; |
| 11257 | 11257 | |
@@ -11259,7 +11259,7 @@ discard block |
||
| 11259 | 11259 | $sth = $this->db->prepare($query); |
| 11260 | 11260 | $sth->execute(); |
| 11261 | 11261 | |
| 11262 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11262 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11263 | 11263 | { |
| 11264 | 11264 | return $row['spotter_id']; |
| 11265 | 11265 | } |
@@ -11284,23 +11284,23 @@ discard block |
||
| 11284 | 11284 | } |
| 11285 | 11285 | |
| 11286 | 11286 | $current_date = date("Y-m-d H:i:s"); |
| 11287 | - $date = date("Y-m-d H:i:s",strtotime($dateString." UTC")); |
|
| 11287 | + $date = date("Y-m-d H:i:s", strtotime($dateString." UTC")); |
|
| 11288 | 11288 | |
| 11289 | 11289 | $diff = abs(strtotime($current_date) - strtotime($date)); |
| 11290 | 11290 | |
| 11291 | - $time_array['years'] = floor($diff / (365*60*60*24)); |
|
| 11291 | + $time_array['years'] = floor($diff/(365*60*60*24)); |
|
| 11292 | 11292 | $years = $time_array['years']; |
| 11293 | 11293 | |
| 11294 | - $time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24)); |
|
| 11294 | + $time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24)); |
|
| 11295 | 11295 | $months = $time_array['months']; |
| 11296 | 11296 | |
| 11297 | - $time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24)); |
|
| 11297 | + $time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24)); |
|
| 11298 | 11298 | $days = $time_array['days']; |
| 11299 | - $time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60)); |
|
| 11299 | + $time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60)); |
|
| 11300 | 11300 | $hours = $time_array['hours']; |
| 11301 | - $time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60); |
|
| 11301 | + $time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60); |
|
| 11302 | 11302 | $minutes = $time_array['minutes']; |
| 11303 | - $time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 11303 | + $time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60)); |
|
| 11304 | 11304 | |
| 11305 | 11305 | return $time_array; |
| 11306 | 11306 | } |
@@ -11326,63 +11326,63 @@ discard block |
||
| 11326 | 11326 | $temp_array['direction_degree'] = $direction; |
| 11327 | 11327 | $temp_array['direction_shortname'] = "N"; |
| 11328 | 11328 | $temp_array['direction_fullname'] = "North"; |
| 11329 | - } elseif ($direction >= 22.5 && $direction < 45){ |
|
| 11329 | + } elseif ($direction >= 22.5 && $direction < 45) { |
|
| 11330 | 11330 | $temp_array['direction_degree'] = $direction; |
| 11331 | 11331 | $temp_array['direction_shortname'] = "NNE"; |
| 11332 | 11332 | $temp_array['direction_fullname'] = "North-Northeast"; |
| 11333 | - } elseif ($direction >= 45 && $direction < 67.5){ |
|
| 11333 | + } elseif ($direction >= 45 && $direction < 67.5) { |
|
| 11334 | 11334 | $temp_array['direction_degree'] = $direction; |
| 11335 | 11335 | $temp_array['direction_shortname'] = "NE"; |
| 11336 | 11336 | $temp_array['direction_fullname'] = "Northeast"; |
| 11337 | - } elseif ($direction >= 67.5 && $direction < 90){ |
|
| 11337 | + } elseif ($direction >= 67.5 && $direction < 90) { |
|
| 11338 | 11338 | $temp_array['direction_degree'] = $direction; |
| 11339 | 11339 | $temp_array['direction_shortname'] = "ENE"; |
| 11340 | 11340 | $temp_array['direction_fullname'] = "East-Northeast"; |
| 11341 | - } elseif ($direction >= 90 && $direction < 112.5){ |
|
| 11341 | + } elseif ($direction >= 90 && $direction < 112.5) { |
|
| 11342 | 11342 | $temp_array['direction_degree'] = $direction; |
| 11343 | 11343 | $temp_array['direction_shortname'] = "E"; |
| 11344 | 11344 | $temp_array['direction_fullname'] = "East"; |
| 11345 | - } elseif ($direction >= 112.5 && $direction < 135){ |
|
| 11345 | + } elseif ($direction >= 112.5 && $direction < 135) { |
|
| 11346 | 11346 | $temp_array['direction_degree'] = $direction; |
| 11347 | 11347 | $temp_array['direction_shortname'] = "ESE"; |
| 11348 | 11348 | $temp_array['direction_fullname'] = "East-Southeast"; |
| 11349 | - } elseif ($direction >= 135 && $direction < 157.5){ |
|
| 11349 | + } elseif ($direction >= 135 && $direction < 157.5) { |
|
| 11350 | 11350 | $temp_array['direction_degree'] = $direction; |
| 11351 | 11351 | $temp_array['direction_shortname'] = "SE"; |
| 11352 | 11352 | $temp_array['direction_fullname'] = "Southeast"; |
| 11353 | - } elseif ($direction >= 157.5 && $direction < 180){ |
|
| 11353 | + } elseif ($direction >= 157.5 && $direction < 180) { |
|
| 11354 | 11354 | $temp_array['direction_degree'] = $direction; |
| 11355 | 11355 | $temp_array['direction_shortname'] = "SSE"; |
| 11356 | 11356 | $temp_array['direction_fullname'] = "South-Southeast"; |
| 11357 | - } elseif ($direction >= 180 && $direction < 202.5){ |
|
| 11357 | + } elseif ($direction >= 180 && $direction < 202.5) { |
|
| 11358 | 11358 | $temp_array['direction_degree'] = $direction; |
| 11359 | 11359 | $temp_array['direction_shortname'] = "S"; |
| 11360 | 11360 | $temp_array['direction_fullname'] = "South"; |
| 11361 | - } elseif ($direction >= 202.5 && $direction < 225){ |
|
| 11361 | + } elseif ($direction >= 202.5 && $direction < 225) { |
|
| 11362 | 11362 | $temp_array['direction_degree'] = $direction; |
| 11363 | 11363 | $temp_array['direction_shortname'] = "SSW"; |
| 11364 | 11364 | $temp_array['direction_fullname'] = "South-Southwest"; |
| 11365 | - } elseif ($direction >= 225 && $direction < 247.5){ |
|
| 11365 | + } elseif ($direction >= 225 && $direction < 247.5) { |
|
| 11366 | 11366 | $temp_array['direction_degree'] = $direction; |
| 11367 | 11367 | $temp_array['direction_shortname'] = "SW"; |
| 11368 | 11368 | $temp_array['direction_fullname'] = "Southwest"; |
| 11369 | - } elseif ($direction >= 247.5 && $direction < 270){ |
|
| 11369 | + } elseif ($direction >= 247.5 && $direction < 270) { |
|
| 11370 | 11370 | $temp_array['direction_degree'] = $direction; |
| 11371 | 11371 | $temp_array['direction_shortname'] = "WSW"; |
| 11372 | 11372 | $temp_array['direction_fullname'] = "West-Southwest"; |
| 11373 | - } elseif ($direction >= 270 && $direction < 292.5){ |
|
| 11373 | + } elseif ($direction >= 270 && $direction < 292.5) { |
|
| 11374 | 11374 | $temp_array['direction_degree'] = $direction; |
| 11375 | 11375 | $temp_array['direction_shortname'] = "W"; |
| 11376 | 11376 | $temp_array['direction_fullname'] = "West"; |
| 11377 | - } elseif ($direction >= 292.5 && $direction < 315){ |
|
| 11377 | + } elseif ($direction >= 292.5 && $direction < 315) { |
|
| 11378 | 11378 | $temp_array['direction_degree'] = $direction; |
| 11379 | 11379 | $temp_array['direction_shortname'] = "WNW"; |
| 11380 | 11380 | $temp_array['direction_fullname'] = "West-Northwest"; |
| 11381 | - } elseif ($direction >= 315 && $direction < 337.5){ |
|
| 11381 | + } elseif ($direction >= 315 && $direction < 337.5) { |
|
| 11382 | 11382 | $temp_array['direction_degree'] = $direction; |
| 11383 | 11383 | $temp_array['direction_shortname'] = "NW"; |
| 11384 | 11384 | $temp_array['direction_fullname'] = "Northwest"; |
| 11385 | - } elseif ($direction >= 337.5 && $direction < 360){ |
|
| 11385 | + } elseif ($direction >= 337.5 && $direction < 360) { |
|
| 11386 | 11386 | $temp_array['direction_degree'] = $direction; |
| 11387 | 11387 | $temp_array['direction_shortname'] = "NNW"; |
| 11388 | 11388 | $temp_array['direction_fullname'] = "North-Northwest"; |
@@ -11435,9 +11435,9 @@ discard block |
||
| 11435 | 11435 | */ |
| 11436 | 11436 | public function getAircraftRegistrationBymodeS($aircraft_modes) |
| 11437 | 11437 | { |
| 11438 | - $aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
|
| 11438 | + $aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING); |
|
| 11439 | 11439 | |
| 11440 | - $query = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
| 11440 | + $query = "SELECT aircraft_modes.Registration FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
| 11441 | 11441 | |
| 11442 | 11442 | $sth = $this->db->prepare($query); |
| 11443 | 11443 | $sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
@@ -11460,9 +11460,9 @@ discard block |
||
| 11460 | 11460 | */ |
| 11461 | 11461 | public function getAircraftTypeBymodeS($aircraft_modes) |
| 11462 | 11462 | { |
| 11463 | - $aircraft_modes = filter_var($aircraft_modes,FILTER_SANITIZE_STRING); |
|
| 11463 | + $aircraft_modes = filter_var($aircraft_modes, FILTER_SANITIZE_STRING); |
|
| 11464 | 11464 | |
| 11465 | - $query = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
| 11465 | + $query = "SELECT aircraft_modes.type_flight FROM aircraft_modes WHERE aircraft_modes.ModeS = :aircraft_modes ORDER BY FirstCreated DESC LIMIT 1"; |
|
| 11466 | 11466 | |
| 11467 | 11467 | $sth = $this->db->prepare($query); |
| 11468 | 11468 | $sth->execute(array(':aircraft_modes' => $aircraft_modes)); |
@@ -11483,11 +11483,11 @@ discard block |
||
| 11483 | 11483 | * @param Float $longitude longitute of the flight |
| 11484 | 11484 | * @return String the countrie |
| 11485 | 11485 | */ |
| 11486 | - public function getCountryFromLatitudeLongitude($latitude,$longitude) |
|
| 11486 | + public function getCountryFromLatitudeLongitude($latitude, $longitude) |
|
| 11487 | 11487 | { |
| 11488 | 11488 | global $globalDBdriver, $globalDebug; |
| 11489 | - $latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 11490 | - $longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
|
| 11489 | + $latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 11490 | + $longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); |
|
| 11491 | 11491 | |
| 11492 | 11492 | $Connection = new Connection($this->db); |
| 11493 | 11493 | if (!$Connection->tableExists('countries')) return ''; |
@@ -11527,7 +11527,7 @@ discard block |
||
| 11527 | 11527 | public function getCountryFromISO2($iso2) |
| 11528 | 11528 | { |
| 11529 | 11529 | global $globalDBdriver, $globalDebug; |
| 11530 | - $iso2 = filter_var($iso2,FILTER_SANITIZE_STRING); |
|
| 11530 | + $iso2 = filter_var($iso2, FILTER_SANITIZE_STRING); |
|
| 11531 | 11531 | |
| 11532 | 11532 | $Connection = new Connection($this->db); |
| 11533 | 11533 | if (!$Connection->tableExists('countries')) return ''; |
@@ -11559,19 +11559,19 @@ discard block |
||
| 11559 | 11559 | */ |
| 11560 | 11560 | public function convertAircraftRegistration($registration) |
| 11561 | 11561 | { |
| 11562 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 11562 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 11563 | 11563 | $registration_prefix = ''; |
| 11564 | 11564 | $registration_1 = substr($registration, 0, 1); |
| 11565 | 11565 | $registration_2 = substr($registration, 0, 2); |
| 11566 | 11566 | |
| 11567 | 11567 | //first get the prefix based on two characters |
| 11568 | - $query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2"; |
|
| 11568 | + $query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_2"; |
|
| 11569 | 11569 | |
| 11570 | 11570 | |
| 11571 | 11571 | $sth = $this->db->prepare($query); |
| 11572 | 11572 | $sth->execute(array(':registration_2' => $registration_2)); |
| 11573 | 11573 | |
| 11574 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11574 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11575 | 11575 | { |
| 11576 | 11576 | $registration_prefix = $row['registration_prefix']; |
| 11577 | 11577 | } |
@@ -11579,11 +11579,11 @@ discard block |
||
| 11579 | 11579 | //if we didn't find a two chracter prefix lets just search the one with one character |
| 11580 | 11580 | if ($registration_prefix == '') |
| 11581 | 11581 | { |
| 11582 | - $query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1"; |
|
| 11582 | + $query = "SELECT aircraft_registration.registration_prefix FROM aircraft_registration WHERE registration_prefix = :registration_1"; |
|
| 11583 | 11583 | $sth = $this->db->prepare($query); |
| 11584 | 11584 | $sth->execute(array(':registration_1' => $registration_1)); |
| 11585 | 11585 | |
| 11586 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11586 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11587 | 11587 | { |
| 11588 | 11588 | $registration_prefix = $row['registration_prefix']; |
| 11589 | 11589 | } |
@@ -11597,7 +11597,7 @@ discard block |
||
| 11597 | 11597 | } else { |
| 11598 | 11598 | $registration = preg_replace("/^(.{1})/", "$1-", $registration); |
| 11599 | 11599 | } |
| 11600 | - } else if(strlen($registration_prefix) == 2){ |
|
| 11600 | + } else if (strlen($registration_prefix) == 2) { |
|
| 11601 | 11601 | if (0 === strpos($registration, 'N')) { |
| 11602 | 11602 | $registration = preg_replace("/^(.{2})/", "$1", $registration); |
| 11603 | 11603 | } else { |
@@ -11616,17 +11616,17 @@ discard block |
||
| 11616 | 11616 | */ |
| 11617 | 11617 | public function countryFromAircraftRegistration($registration) |
| 11618 | 11618 | { |
| 11619 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 11619 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 11620 | 11620 | |
| 11621 | 11621 | $registration_prefix = ''; |
| 11622 | - $registration_test = explode('-',$registration); |
|
| 11622 | + $registration_test = explode('-', $registration); |
|
| 11623 | 11623 | $country = ''; |
| 11624 | 11624 | if ($registration_test[0] != $registration) { |
| 11625 | 11625 | $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
| 11626 | 11626 | |
| 11627 | 11627 | $sth = $this->db->prepare($query); |
| 11628 | 11628 | $sth->execute(array(':registration_1' => $registration_test[0])); |
| 11629 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11629 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11630 | 11630 | { |
| 11631 | 11631 | //$registration_prefix = $row['registration_prefix']; |
| 11632 | 11632 | $country = $row['country']; |
@@ -11637,13 +11637,13 @@ discard block |
||
| 11637 | 11637 | |
| 11638 | 11638 | $country = ''; |
| 11639 | 11639 | //first get the prefix based on two characters |
| 11640 | - $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1"; |
|
| 11640 | + $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1"; |
|
| 11641 | 11641 | |
| 11642 | 11642 | |
| 11643 | 11643 | $sth = $this->db->prepare($query); |
| 11644 | 11644 | $sth->execute(array(':registration_2' => $registration_2)); |
| 11645 | 11645 | |
| 11646 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11646 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11647 | 11647 | { |
| 11648 | 11648 | $registration_prefix = $row['registration_prefix']; |
| 11649 | 11649 | $country = $row['country']; |
@@ -11652,12 +11652,12 @@ discard block |
||
| 11652 | 11652 | //if we didn't find a two chracter prefix lets just search the one with one character |
| 11653 | 11653 | if ($registration_prefix == "") |
| 11654 | 11654 | { |
| 11655 | - $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
|
| 11655 | + $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
|
| 11656 | 11656 | |
| 11657 | 11657 | $sth = $this->db->prepare($query); |
| 11658 | 11658 | $sth->execute(array(':registration_1' => $registration_1)); |
| 11659 | 11659 | |
| 11660 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11660 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11661 | 11661 | { |
| 11662 | 11662 | //$registration_prefix = $row['registration_prefix']; |
| 11663 | 11663 | $country = $row['country']; |
@@ -11677,17 +11677,17 @@ discard block |
||
| 11677 | 11677 | */ |
| 11678 | 11678 | public function registrationPrefixFromAircraftRegistration($registration) |
| 11679 | 11679 | { |
| 11680 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 11680 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 11681 | 11681 | |
| 11682 | 11682 | $registration_prefix = ''; |
| 11683 | - $registration_test = explode('-',$registration); |
|
| 11683 | + $registration_test = explode('-', $registration); |
|
| 11684 | 11684 | //$country = ''; |
| 11685 | 11685 | if ($registration_test[0] != $registration) { |
| 11686 | - $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
|
| 11686 | + $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
|
| 11687 | 11687 | |
| 11688 | 11688 | $sth = $this->db->prepare($query); |
| 11689 | 11689 | $sth->execute(array(':registration_1' => $registration_test[0])); |
| 11690 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11690 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11691 | 11691 | { |
| 11692 | 11692 | $registration_prefix = $row['registration_prefix']; |
| 11693 | 11693 | //$country = $row['country']; |
@@ -11697,13 +11697,13 @@ discard block |
||
| 11697 | 11697 | $registration_2 = substr($registration, 0, 2); |
| 11698 | 11698 | |
| 11699 | 11699 | //first get the prefix based on two characters |
| 11700 | - $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1"; |
|
| 11700 | + $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_2 LIMIT 1"; |
|
| 11701 | 11701 | |
| 11702 | 11702 | |
| 11703 | 11703 | $sth = $this->db->prepare($query); |
| 11704 | 11704 | $sth->execute(array(':registration_2' => $registration_2)); |
| 11705 | 11705 | |
| 11706 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11706 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11707 | 11707 | { |
| 11708 | 11708 | $registration_prefix = $row['registration_prefix']; |
| 11709 | 11709 | //$country = $row['country']; |
@@ -11712,12 +11712,12 @@ discard block |
||
| 11712 | 11712 | //if we didn't find a two chracter prefix lets just search the one with one character |
| 11713 | 11713 | if ($registration_prefix == "") |
| 11714 | 11714 | { |
| 11715 | - $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
|
| 11715 | + $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration_1 LIMIT 1"; |
|
| 11716 | 11716 | |
| 11717 | 11717 | $sth = $this->db->prepare($query); |
| 11718 | 11718 | $sth->execute(array(':registration_1' => $registration_1)); |
| 11719 | 11719 | |
| 11720 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11720 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11721 | 11721 | { |
| 11722 | 11722 | $registration_prefix = $row['registration_prefix']; |
| 11723 | 11723 | //$country = $row['country']; |
@@ -11738,13 +11738,13 @@ discard block |
||
| 11738 | 11738 | */ |
| 11739 | 11739 | public function countryFromAircraftRegistrationCode($registration) |
| 11740 | 11740 | { |
| 11741 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
| 11741 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
| 11742 | 11742 | |
| 11743 | 11743 | $country = ''; |
| 11744 | - $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1"; |
|
| 11744 | + $query = "SELECT aircraft_registration.registration_prefix, aircraft_registration.country FROM aircraft_registration WHERE registration_prefix = :registration LIMIT 1"; |
|
| 11745 | 11745 | $sth = $this->db->prepare($query); |
| 11746 | 11746 | $sth->execute(array(':registration' => $registration)); |
| 11747 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11747 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11748 | 11748 | { |
| 11749 | 11749 | $country = $row['country']; |
| 11750 | 11750 | } |
@@ -11757,9 +11757,9 @@ discard block |
||
| 11757 | 11757 | * @param String $flightaware_id flightaware_id from spotter_output table |
| 11758 | 11758 | * @param String $highlight New highlight value |
| 11759 | 11759 | */ |
| 11760 | - public function setHighlightFlight($flightaware_id,$highlight) { |
|
| 11760 | + public function setHighlightFlight($flightaware_id, $highlight) { |
|
| 11761 | 11761 | |
| 11762 | - $query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id"; |
|
| 11762 | + $query = "UPDATE spotter_output SET highlight = :highlight WHERE flightaware_id = :flightaware_id"; |
|
| 11763 | 11763 | $sth = $this->db->prepare($query); |
| 11764 | 11764 | $sth->execute(array(':flightaware_id' => $flightaware_id, ':highlight' => $highlight)); |
| 11765 | 11765 | } |
@@ -11771,13 +11771,13 @@ discard block |
||
| 11771 | 11771 | * @param String $date Date of spotted aircraft |
| 11772 | 11772 | * @param String $highlight New highlight value |
| 11773 | 11773 | */ |
| 11774 | - public function setHighlightFlightByRegistration($registration,$highlight, $date = '') { |
|
| 11774 | + public function setHighlightFlightByRegistration($registration, $highlight, $date = '') { |
|
| 11775 | 11775 | if ($date == '') { |
| 11776 | 11776 | $query = "UPDATE spotter_output SET highlight = :highlight WHERE spotter_id IN (SELECT MAX(spotter_id) FROM spotter_output WHERE registration = :registration)"; |
| 11777 | 11777 | $query_values = array(':registration' => $registration, ':highlight' => $highlight); |
| 11778 | 11778 | } else { |
| 11779 | 11779 | $query = "UPDATE spotter_output SET highlight = :highlight WHERE registration = :registration AND date(date) = :date"; |
| 11780 | - $query_values = array(':registration' => $registration, ':highlight' => $highlight,':date' => $date); |
|
| 11780 | + $query_values = array(':registration' => $registration, ':highlight' => $highlight, ':date' => $date); |
|
| 11781 | 11781 | } |
| 11782 | 11782 | $sth = $this->db->prepare($query); |
| 11783 | 11783 | $sth->execute($query_values); |
@@ -11807,7 +11807,7 @@ discard block |
||
| 11807 | 11807 | |
| 11808 | 11808 | $bitly_data = json_decode($bitly_data); |
| 11809 | 11809 | $bitly_url = ''; |
| 11810 | - if ($bitly_data->status_txt = "OK"){ |
|
| 11810 | + if ($bitly_data->status_txt = "OK") { |
|
| 11811 | 11811 | $bitly_url = $bitly_data->data->url; |
| 11812 | 11812 | } |
| 11813 | 11813 | |
@@ -11817,7 +11817,7 @@ discard block |
||
| 11817 | 11817 | |
| 11818 | 11818 | public function getOrderBy() |
| 11819 | 11819 | { |
| 11820 | - $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_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")); |
|
| 11820 | + $orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_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")); |
|
| 11821 | 11821 | |
| 11822 | 11822 | return $orderby; |
| 11823 | 11823 | |
@@ -11951,14 +11951,14 @@ discard block |
||
| 11951 | 11951 | } |
| 11952 | 11952 | $sth = $this->db->prepare($query); |
| 11953 | 11953 | $sth->execute(); |
| 11954 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11954 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11955 | 11955 | { |
| 11956 | 11956 | $departure_airport_array = $this->getAllAirportInfo($row['fromairport_icao']); |
| 11957 | 11957 | $arrival_airport_array = $this->getAllAirportInfo($row['toairport_icao']); |
| 11958 | 11958 | if (count($departure_airport_array) > 0 && count($arrival_airport_array) > 0) { |
| 11959 | - $update_query="UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id"; |
|
| 11959 | + $update_query = "UPDATE spotter_output SET departure_airport_icao = :fromicao, arrival_airport_icao = :toicao, departure_airport_name = :departure_airport_name, departure_airport_city = :departure_airport_city, departure_airport_country = :departure_airport_country, arrival_airport_name = :arrival_airport_name, arrival_airport_city = :arrival_airport_city, arrival_airport_country = :arrival_airport_country WHERE spotter_id = :spotter_id"; |
|
| 11960 | 11960 | $sthu = $this->db->prepare($update_query); |
| 11961 | - $sthu->execute(array(':fromicao' => $row['fromairport_icao'],':toicao' => $row['toairport_icao'],':spotter_id' => $row['spotter_id'],':departure_airport_name' => $departure_airport_array[0]['name'],':departure_airport_city' => $departure_airport_array[0]['city'],':departure_airport_country' => $departure_airport_array[0]['country'],':arrival_airport_name' => $arrival_airport_array[0]['name'],':arrival_airport_city' => $arrival_airport_array[0]['city'],':arrival_airport_country' => $arrival_airport_array[0]['country'])); |
|
| 11961 | + $sthu->execute(array(':fromicao' => $row['fromairport_icao'], ':toicao' => $row['toairport_icao'], ':spotter_id' => $row['spotter_id'], ':departure_airport_name' => $departure_airport_array[0]['name'], ':departure_airport_city' => $departure_airport_array[0]['city'], ':departure_airport_country' => $departure_airport_array[0]['country'], ':arrival_airport_name' => $arrival_airport_array[0]['name'], ':arrival_airport_city' => $arrival_airport_array[0]['city'], ':arrival_airport_country' => $arrival_airport_array[0]['country'])); |
|
| 11962 | 11962 | } |
| 11963 | 11963 | } |
| 11964 | 11964 | |
@@ -11971,7 +11971,7 @@ discard block |
||
| 11971 | 11971 | } |
| 11972 | 11972 | $sth = $this->db->prepare($query); |
| 11973 | 11973 | $sth->execute(); |
| 11974 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11974 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 11975 | 11975 | { |
| 11976 | 11976 | if (is_numeric(substr($row['ident'], -1, 1))) |
| 11977 | 11977 | { |
@@ -11980,11 +11980,11 @@ discard block |
||
| 11980 | 11980 | elseif (isset($row['format_source']) && $row['format_source'] == 'whazzup') $fromsource = 'ivao'; |
| 11981 | 11981 | elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim'; |
| 11982 | 11982 | elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao'; |
| 11983 | - $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3),$fromsource); |
|
| 11983 | + $airline_array = $this->getAllAirlineInfo(substr($row['ident'], 0, 3), $fromsource); |
|
| 11984 | 11984 | if (isset($airline_array[0]['name'])) { |
| 11985 | - $update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id"; |
|
| 11985 | + $update_query = "UPDATE spotter_output SET spotter_output.airline_name = :airline_name, spotter_output.airline_icao = :airline_icao, spotter_output.airline_country = :airline_country, spotter_output.airline_type = :airline_type WHERE spotter_output.spotter_id = :spotter_id"; |
|
| 11986 | 11986 | $sthu = $this->db->prepare($update_query); |
| 11987 | - $sthu->execute(array(':airline_name' => $airline_array[0]['name'],':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id'])); |
|
| 11987 | + $sthu->execute(array(':airline_name' => $airline_array[0]['name'], ':airline_icao' => $airline_array[0]['icao'], ':airline_country' => $airline_array[0]['country'], ':airline_type' => $airline_array[0]['type'], ':spotter_id' => $row['spotter_id'])); |
|
| 11988 | 11988 | } |
| 11989 | 11989 | } |
| 11990 | 11990 | } |
@@ -12004,18 +12004,18 @@ discard block |
||
| 12004 | 12004 | } |
| 12005 | 12005 | $sth = $this->db->prepare($query); |
| 12006 | 12006 | $sth->execute(); |
| 12007 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 12007 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 12008 | 12008 | { |
| 12009 | 12009 | if ($row['aircraft_icao'] != '') { |
| 12010 | 12010 | $aircraft_name = $this->getAllAircraftInfo($row['aircraft_icao']); |
| 12011 | - if ($row['registration'] != ""){ |
|
| 12011 | + if ($row['registration'] != "") { |
|
| 12012 | 12012 | $image_array = $Image->getSpotterImage($row['registration']); |
| 12013 | 12013 | if (!isset($image_array[0]['registration'])) { |
| 12014 | 12014 | $Image->addSpotterImage($row['registration']); |
| 12015 | 12015 | } |
| 12016 | 12016 | } |
| 12017 | 12017 | if (count($aircraft_name) > 0) { |
| 12018 | - $update_query = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id"; |
|
| 12018 | + $update_query = "UPDATE spotter_output SET spotter_output.aircraft_name = :aircraft_name, spotter_output.aircraft_manufacturer = :aircraft_manufacturer WHERE spotter_output.spotter_id = :spotter_id"; |
|
| 12019 | 12019 | $sthu = $this->db->prepare($update_query); |
| 12020 | 12020 | $sthu->execute(array(':aircraft_name' => $aircraft_name[0]['type'], ':aircraft_manufacturer' => $aircraft_name[0]['manufacturer'], ':spotter_id' => $row['spotter_id'])); |
| 12021 | 12021 | } |
@@ -12030,10 +12030,10 @@ discard block |
||
| 12030 | 12030 | $query = "SELECT spotter_output.spotter_id, spotter_output.last_latitude, spotter_output.last_longitude, spotter_output.last_altitude, spotter_output.arrival_airport_icao, spotter_output.real_arrival_airport_icao FROM spotter_output"; |
| 12031 | 12031 | $sth = $this->db->prepare($query); |
| 12032 | 12032 | $sth->execute(); |
| 12033 | - while($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 12033 | + while ($row = $sth->fetch(PDO::FETCH_ASSOC)) |
|
| 12034 | 12034 | { |
| 12035 | 12035 | if ($row['last_latitude'] != '' && $row['last_longitude'] != '') { |
| 12036 | - $closestAirports = $this->closestAirports($row['last_latitude'],$row['last_longitude'],$globalClosestMinDist); |
|
| 12036 | + $closestAirports = $this->closestAirports($row['last_latitude'], $row['last_longitude'], $globalClosestMinDist); |
|
| 12037 | 12037 | $airport_icao = ''; |
| 12038 | 12038 | if (isset($closestAirports[0])) { |
| 12039 | 12039 | if ($row['arrival_airport_icao'] == $closestAirports[0]['icao']) { |
@@ -12047,7 +12047,7 @@ discard block |
||
| 12047 | 12047 | break; |
| 12048 | 12048 | } |
| 12049 | 12049 | } |
| 12050 | - } elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100+1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude']+5000))) { |
|
| 12050 | + } elseif ($row['last_altitude'] == 0 || ($row['last_altitude'] != '' && ($closestAirports[0]['altitude'] <= $row['last_altitude']*100 + 1000 && $row['last_altitude']*100 < $closestAirports[0]['altitude'] + 5000))) { |
|
| 12051 | 12051 | $airport_icao = $closestAirports[0]['icao']; |
| 12052 | 12052 | if ($globalDebug) echo "\o/ NP --++ Find arrival airport. Airport ICAO : ".$airport_icao." ! Latitude : ".$row['last_latitude'].' - Longitude : '.$row['last_longitude'].' - MinDist : '.$globalClosestMinDist." - Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.($row['last_altitude']*100)."\n"; |
| 12053 | 12053 | } else { |
@@ -12058,28 +12058,28 @@ discard block |
||
| 12058 | 12058 | } |
| 12059 | 12059 | if ($row['real_arrival_airport_icao'] != $airport_icao) { |
| 12060 | 12060 | if ($globalDebug) echo "Updating airport to ".$airport_icao."...\n"; |
| 12061 | - $update_query="UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; |
|
| 12061 | + $update_query = "UPDATE spotter_output SET real_arrival_airport_icao = :airport_icao WHERE spotter_id = :spotter_id"; |
|
| 12062 | 12062 | $sthu = $this->db->prepare($update_query); |
| 12063 | - $sthu->execute(array(':airport_icao' => $airport_icao,':spotter_id' => $row['spotter_id'])); |
|
| 12063 | + $sthu->execute(array(':airport_icao' => $airport_icao, ':spotter_id' => $row['spotter_id'])); |
|
| 12064 | 12064 | } |
| 12065 | 12065 | } |
| 12066 | 12066 | } |
| 12067 | 12067 | } |
| 12068 | 12068 | |
| 12069 | - public function closestAirports($origLat,$origLon,$dist = 10) { |
|
| 12069 | + public function closestAirports($origLat, $origLon, $dist = 10) { |
|
| 12070 | 12070 | global $globalDBdriver; |
| 12071 | - $dist = number_format($dist*0.621371,2,'.',''); // convert km to mile |
|
| 12071 | + $dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile |
|
| 12072 | 12072 | /* |
| 12073 | 12073 | $query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - abs(latitude))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(abs(latitude)*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance |
| 12074 | 12074 | FROM airport WHERE longitude between ($origLon-$dist/abs(cos(radians($origLat))*69)) and ($origLon+$dist/abs(cos(radians($origLat))*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 12075 | 12075 | having distance < $dist ORDER BY distance limit 100;"; |
| 12076 | 12076 | */ |
| 12077 | 12077 | if ($globalDBdriver == 'mysql') { |
| 12078 | - $query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance |
|
| 12078 | + $query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2))) as distance |
|
| 12079 | 12079 | FROM airport WHERE longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 12080 | 12080 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(latitude*pi()/180)*POWER(SIN(($origLon-longitude)*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;"; |
| 12081 | 12081 | } else { |
| 12082 | - $query="SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance |
|
| 12082 | + $query = "SELECT name, icao, latitude, longitude, altitude, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2))) as distance |
|
| 12083 | 12083 | FROM airport WHERE CAST(longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) |
| 12084 | 12084 | AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(longitude as double precision))*pi()/180/2),2)))) < $dist ORDER BY distance limit 100;"; |
| 12085 | 12085 | } |
@@ -12,7 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct($dbc = null) { |
| 14 | 14 | global $globalFilterName; |
| 15 | - if (isset($globalFilterName)) $this->filter_name = $globalFilterName; |
|
| 15 | + if (isset($globalFilterName)) { |
|
| 16 | + $this->filter_name = $globalFilterName; |
|
| 17 | + } |
|
| 16 | 18 | $Connection = new Connection($dbc); |
| 17 | 19 | $this->db = $Connection->db(); |
| 18 | 20 | } |
@@ -80,7 +82,9 @@ discard block |
||
| 80 | 82 | } |
| 81 | 83 | } |
| 82 | 84 | public function getAllAirlineNames($filter_name = '') { |
| 83 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 85 | + if ($filter_name == '') { |
|
| 86 | + $filter_name = $this->filter_name; |
|
| 87 | + } |
|
| 84 | 88 | $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC"; |
| 85 | 89 | try { |
| 86 | 90 | $sth = $this->db->prepare($query); |
@@ -92,7 +96,9 @@ discard block |
||
| 92 | 96 | return $all; |
| 93 | 97 | } |
| 94 | 98 | public function getAllAircraftTypes($stats_airline = '',$filter_name = '') { |
| 95 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 99 | + if ($filter_name == '') { |
|
| 100 | + $filter_name = $this->filter_name; |
|
| 101 | + } |
|
| 96 | 102 | $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC"; |
| 97 | 103 | try { |
| 98 | 104 | $sth = $this->db->prepare($query); |
@@ -104,7 +110,9 @@ discard block |
||
| 104 | 110 | return $all; |
| 105 | 111 | } |
| 106 | 112 | public function getAllManufacturers($stats_airline = '',$filter_name = '') { |
| 107 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 113 | + if ($filter_name == '') { |
|
| 114 | + $filter_name = $this->filter_name; |
|
| 115 | + } |
|
| 108 | 116 | $query = "SELECT DISTINCT(aircraft_manufacturer) FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND aircraft_manufacturer <> '' ORDER BY aircraft_manufacturer ASC"; |
| 109 | 117 | try { |
| 110 | 118 | $sth = $this->db->prepare($query); |
@@ -116,7 +124,9 @@ discard block |
||
| 116 | 124 | return $all; |
| 117 | 125 | } |
| 118 | 126 | public function getAllAirportNames($stats_airline = '',$filter_name = '') { |
| 119 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 127 | + if ($filter_name == '') { |
|
| 128 | + $filter_name = $this->filter_name; |
|
| 129 | + } |
|
| 120 | 130 | $query = "SELECT airport_icao, airport_name,airport_city,airport_country FROM stats_airport WHERE stats_airline = :stats_airline AND filter_name = :filter_name AND stats_type = 'daily' GROUP BY airport_icao,airport_name,airport_city,airport_country ORDER BY airport_city ASC"; |
| 121 | 131 | try { |
| 122 | 132 | $sth = $this->db->prepare($query); |
@@ -129,7 +139,9 @@ discard block |
||
| 129 | 139 | } |
| 130 | 140 | |
| 131 | 141 | public function getAllOwnerNames($stats_airline = '',$filter_name = '') { |
| 132 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 142 | + if ($filter_name == '') { |
|
| 143 | + $filter_name = $this->filter_name; |
|
| 144 | + } |
|
| 133 | 145 | $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC"; |
| 134 | 146 | try { |
| 135 | 147 | $sth = $this->db->prepare($query); |
@@ -142,7 +154,9 @@ discard block |
||
| 142 | 154 | } |
| 143 | 155 | |
| 144 | 156 | public function getAllPilotNames($stats_airline = '',$filter_name = '') { |
| 145 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 157 | + if ($filter_name == '') { |
|
| 158 | + $filter_name = $this->filter_name; |
|
| 159 | + } |
|
| 146 | 160 | $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC"; |
| 147 | 161 | try { |
| 148 | 162 | $sth = $this->db->prepare($query); |
@@ -157,10 +171,15 @@ discard block |
||
| 157 | 171 | |
| 158 | 172 | public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 159 | 173 | global $globalStatsFilters; |
| 160 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 174 | + if ($filter_name == '') { |
|
| 175 | + $filter_name = $this->filter_name; |
|
| 176 | + } |
|
| 161 | 177 | if ($year == '' && $month == '') { |
| 162 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 163 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 178 | + if ($limit) { |
|
| 179 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 180 | + } else { |
|
| 181 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name, aircraft_manufacturer FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_icao_count DESC"; |
|
| 182 | + } |
|
| 164 | 183 | try { |
| 165 | 184 | $sth = $this->db->prepare($query); |
| 166 | 185 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -168,7 +187,9 @@ discard block |
||
| 168 | 187 | echo "error : ".$e->getMessage(); |
| 169 | 188 | } |
| 170 | 189 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 171 | - } else $all = array(); |
|
| 190 | + } else { |
|
| 191 | + $all = array(); |
|
| 192 | + } |
|
| 172 | 193 | if (empty($all)) { |
| 173 | 194 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 174 | 195 | if ($filter_name != '') { |
@@ -182,10 +203,15 @@ discard block |
||
| 182 | 203 | } |
| 183 | 204 | public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') { |
| 184 | 205 | global $globalStatsFilters; |
| 185 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 206 | + if ($filter_name == '') { |
|
| 207 | + $filter_name = $this->filter_name; |
|
| 208 | + } |
|
| 186 | 209 | if ($year == '' && $month == '') { |
| 187 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 188 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
| 210 | + if ($limit) { |
|
| 211 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 212 | + } else { |
|
| 213 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao AND filter_name = :filter_name GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
| 214 | + } |
|
| 189 | 215 | try { |
| 190 | 216 | $sth = $this->db->prepare($query); |
| 191 | 217 | $sth->execute(array(':filter_name' => $filter_name)); |
@@ -193,7 +219,9 @@ discard block |
||
| 193 | 219 | echo "error : ".$e->getMessage(); |
| 194 | 220 | } |
| 195 | 221 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 196 | - } else $all = array(); |
|
| 222 | + } else { |
|
| 223 | + $all = array(); |
|
| 224 | + } |
|
| 197 | 225 | if (empty($all)) { |
| 198 | 226 | $Spotter = new Spotter($this->db); |
| 199 | 227 | $filters = array(); |
@@ -208,10 +236,15 @@ discard block |
||
| 208 | 236 | } |
| 209 | 237 | public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 210 | 238 | global $globalStatsFilters; |
| 211 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 239 | + if ($filter_name == '') { |
|
| 240 | + $filter_name = $this->filter_name; |
|
| 241 | + } |
|
| 212 | 242 | if ($year == '' && $month == '') { |
| 213 | - if ($limit) $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 214 | - else $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 243 | + if ($limit) { |
|
| 244 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
| 245 | + } else { |
|
| 246 | + $query = "SELECT aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY aircraft_manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
| 247 | + } |
|
| 215 | 248 | try { |
| 216 | 249 | $sth = $this->db->prepare($query); |
| 217 | 250 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -219,7 +252,9 @@ discard block |
||
| 219 | 252 | echo "error : ".$e->getMessage(); |
| 220 | 253 | } |
| 221 | 254 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 222 | - } else $all = array(); |
|
| 255 | + } else { |
|
| 256 | + $all = array(); |
|
| 257 | + } |
|
| 223 | 258 | if (empty($all)) { |
| 224 | 259 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 225 | 260 | if ($filter_name != '') { |
@@ -234,10 +269,15 @@ discard block |
||
| 234 | 269 | |
| 235 | 270 | public function countAllArrivalCountries($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') { |
| 236 | 271 | global $globalStatsFilters; |
| 237 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 272 | + if ($filter_name == '') { |
|
| 273 | + $filter_name = $this->filter_name; |
|
| 274 | + } |
|
| 238 | 275 | if ($year == '' && $month == '') { |
| 239 | - if ($limit) $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 240 | - else $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
| 276 | + if ($limit) { |
|
| 277 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 278 | + } else { |
|
| 279 | + $query = "SELECT airport_country AS airport_arrival_country, SUM(arrival) as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_arrival_country ORDER BY airport_arrival_country_count DESC"; |
|
| 280 | + } |
|
| 241 | 281 | try { |
| 242 | 282 | $sth = $this->db->prepare($query); |
| 243 | 283 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -245,7 +285,9 @@ discard block |
||
| 245 | 285 | echo "error : ".$e->getMessage(); |
| 246 | 286 | } |
| 247 | 287 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 248 | - } else $all = array(); |
|
| 288 | + } else { |
|
| 289 | + $all = array(); |
|
| 290 | + } |
|
| 249 | 291 | if (empty($all)) { |
| 250 | 292 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 251 | 293 | if ($filter_name != '') { |
@@ -259,9 +301,14 @@ discard block |
||
| 259 | 301 | } |
| 260 | 302 | public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') { |
| 261 | 303 | global $globalStatsFilters; |
| 262 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 263 | - if ($limit) $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 264 | - else $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
| 304 | + if ($filter_name == '') { |
|
| 305 | + $filter_name = $this->filter_name; |
|
| 306 | + } |
|
| 307 | + if ($limit) { |
|
| 308 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC LIMIT 10 OFFSET 0"; |
|
| 309 | + } else { |
|
| 310 | + $query = "SELECT airport_country AS airport_departure_country, SUM(departure) as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name GROUP BY airport_departure_country ORDER BY airport_departure_country_count DESC"; |
|
| 311 | + } |
|
| 265 | 312 | try { |
| 266 | 313 | $sth = $this->db->prepare($query); |
| 267 | 314 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -283,17 +330,29 @@ discard block |
||
| 283 | 330 | |
| 284 | 331 | public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') { |
| 285 | 332 | global $globalStatsFilters, $globalVATSIM, $globalIVAO; |
| 286 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 333 | + if ($filter_name == '') { |
|
| 334 | + $filter_name = $this->filter_name; |
|
| 335 | + } |
|
| 287 | 336 | if ($year == '' && $month == '') { |
| 288 | - if ($globalVATSIM) $forsource = 'vatsim'; |
|
| 289 | - if ($globalIVAO) $forsource = 'ivao'; |
|
| 337 | + if ($globalVATSIM) { |
|
| 338 | + $forsource = 'vatsim'; |
|
| 339 | + } |
|
| 340 | + if ($globalIVAO) { |
|
| 341 | + $forsource = 'ivao'; |
|
| 342 | + } |
|
| 290 | 343 | if (isset($forsource)) { |
| 291 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 292 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 344 | + if ($limit) { |
|
| 345 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 346 | + } else { |
|
| 347 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource = :forsource ORDER BY airline_count DESC"; |
|
| 348 | + } |
|
| 293 | 349 | $query_values = array(':filter_name' => $filter_name,':forsource' => $forsource); |
| 294 | 350 | } else { |
| 295 | - if ($limit) $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 296 | - else $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 351 | + if ($limit) { |
|
| 352 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
| 353 | + } else { |
|
| 354 | + $query = "SELECT DISTINCT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = stats_airline.airline_icao AND filter_name = :filter_name AND airlines.forsource IS NULL ORDER BY airline_count DESC"; |
|
| 355 | + } |
|
| 297 | 356 | $query_values = array(':filter_name' => $filter_name); |
| 298 | 357 | } |
| 299 | 358 | try { |
@@ -303,7 +362,9 @@ discard block |
||
| 303 | 362 | echo "error : ".$e->getMessage(); |
| 304 | 363 | } |
| 305 | 364 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 306 | - } else $all = array(); |
|
| 365 | + } else { |
|
| 366 | + $all = array(); |
|
| 367 | + } |
|
| 307 | 368 | if (empty($all)) { |
| 308 | 369 | $Spotter = new Spotter($this->db); |
| 309 | 370 | $filters = array(); |
@@ -318,10 +379,15 @@ discard block |
||
| 318 | 379 | } |
| 319 | 380 | public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 320 | 381 | global $globalStatsFilters; |
| 321 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 382 | + if ($filter_name == '') { |
|
| 383 | + $filter_name = $this->filter_name; |
|
| 384 | + } |
|
| 322 | 385 | if ($year == '' && $month == '') { |
| 323 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 324 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 386 | + if ($limit) { |
|
| 387 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
| 388 | + } else { |
|
| 389 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao AND s.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_registration_count DESC"; |
|
| 390 | + } |
|
| 325 | 391 | try { |
| 326 | 392 | $sth = $this->db->prepare($query); |
| 327 | 393 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -329,7 +395,9 @@ discard block |
||
| 329 | 395 | echo "error : ".$e->getMessage(); |
| 330 | 396 | } |
| 331 | 397 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 332 | - } else $all = array(); |
|
| 398 | + } else { |
|
| 399 | + $all = array(); |
|
| 400 | + } |
|
| 333 | 401 | if (empty($all)) { |
| 334 | 402 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 335 | 403 | if ($filter_name != '') { |
@@ -343,10 +411,15 @@ discard block |
||
| 343 | 411 | } |
| 344 | 412 | public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 345 | 413 | global $globalStatsFilters; |
| 346 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 414 | + if ($filter_name == '') { |
|
| 415 | + $filter_name = $this->filter_name; |
|
| 416 | + } |
|
| 347 | 417 | if ($year == '' && $month == '') { |
| 348 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 349 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 418 | + if ($limit) { |
|
| 419 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 420 | + } else { |
|
| 421 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao AND s.airline_icao = :stats_airline AND filter_name = :filter_name ORDER BY callsign_icao_count DESC"; |
|
| 422 | + } |
|
| 350 | 423 | try { |
| 351 | 424 | $sth = $this->db->prepare($query); |
| 352 | 425 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -354,7 +427,9 @@ discard block |
||
| 354 | 427 | echo "error : ".$e->getMessage(); |
| 355 | 428 | } |
| 356 | 429 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 357 | - } else $all = array(); |
|
| 430 | + } else { |
|
| 431 | + $all = array(); |
|
| 432 | + } |
|
| 358 | 433 | if (empty($all)) { |
| 359 | 434 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 360 | 435 | if ($filter_name != '') { |
@@ -368,11 +443,16 @@ discard block |
||
| 368 | 443 | } |
| 369 | 444 | public function countAllFlightOverCountries($limit = true, $stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 370 | 445 | $Connection = new Connection(); |
| 371 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 446 | + if ($filter_name == '') { |
|
| 447 | + $filter_name = $this->filter_name; |
|
| 448 | + } |
|
| 372 | 449 | if ($Connection->tableExists('countries')) { |
| 373 | 450 | if ($year == '' && $month == '') { |
| 374 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 375 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 451 | + if ($limit) { |
|
| 452 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
| 453 | + } else { |
|
| 454 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 AND stats_country.stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY flight_count DESC"; |
|
| 455 | + } |
|
| 376 | 456 | try { |
| 377 | 457 | $sth = $this->db->prepare($query); |
| 378 | 458 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -387,17 +467,24 @@ discard block |
||
| 387 | 467 | } |
| 388 | 468 | */ |
| 389 | 469 | return $all; |
| 390 | - } else return array(); |
|
| 470 | + } else { |
|
| 471 | + return array(); |
|
| 472 | + } |
|
| 391 | 473 | } else { |
| 392 | 474 | return array(); |
| 393 | 475 | } |
| 394 | 476 | } |
| 395 | 477 | public function countAllPilots($limit = true,$stats_airline = '',$filter_name = '', $year = '',$month = '') { |
| 396 | 478 | global $globalStatsFilters; |
| 397 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 479 | + if ($filter_name == '') { |
|
| 480 | + $filter_name = $this->filter_name; |
|
| 481 | + } |
|
| 398 | 482 | if ($year == '' && $month == '') { |
| 399 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 400 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 483 | + if ($limit) { |
|
| 484 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
| 485 | + } else { |
|
| 486 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name, format_source FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_count DESC"; |
|
| 487 | + } |
|
| 401 | 488 | try { |
| 402 | 489 | $sth = $this->db->prepare($query); |
| 403 | 490 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -405,7 +492,9 @@ discard block |
||
| 405 | 492 | echo "error : ".$e->getMessage(); |
| 406 | 493 | } |
| 407 | 494 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 408 | - } else $all = array(); |
|
| 495 | + } else { |
|
| 496 | + $all = array(); |
|
| 497 | + } |
|
| 409 | 498 | if (empty($all)) { |
| 410 | 499 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 411 | 500 | if ($filter_name != '') { |
@@ -420,10 +509,15 @@ discard block |
||
| 420 | 509 | |
| 421 | 510 | public function countAllOwners($limit = true,$stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 422 | 511 | global $globalStatsFilters; |
| 423 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 512 | + if ($filter_name == '') { |
|
| 513 | + $filter_name = $this->filter_name; |
|
| 514 | + } |
|
| 424 | 515 | if ($year == '' && $month == '') { |
| 425 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 426 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 516 | + if ($limit) { |
|
| 517 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
| 518 | + } else { |
|
| 519 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_count DESC"; |
|
| 520 | + } |
|
| 427 | 521 | try { |
| 428 | 522 | $sth = $this->db->prepare($query); |
| 429 | 523 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -431,7 +525,9 @@ discard block |
||
| 431 | 525 | echo "error : ".$e->getMessage(); |
| 432 | 526 | } |
| 433 | 527 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 434 | - } else $all = array(); |
|
| 528 | + } else { |
|
| 529 | + $all = array(); |
|
| 530 | + } |
|
| 435 | 531 | if (empty($all)) { |
| 436 | 532 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 437 | 533 | if ($filter_name != '') { |
@@ -445,10 +541,15 @@ discard block |
||
| 445 | 541 | } |
| 446 | 542 | public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 447 | 543 | global $globalStatsFilters; |
| 448 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 544 | + if ($filter_name == '') { |
|
| 545 | + $filter_name = $this->filter_name; |
|
| 546 | + } |
|
| 449 | 547 | if ($year == '' && $month == '') { |
| 450 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 451 | - else $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 548 | + if ($limit) { |
|
| 549 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 550 | + } else { |
|
| 551 | + $query = "SELECT DISTINCT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE departure > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_departure_icao_count DESC"; |
|
| 552 | + } |
|
| 452 | 553 | try { |
| 453 | 554 | $sth = $this->db->prepare($query); |
| 454 | 555 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -456,7 +557,9 @@ discard block |
||
| 456 | 557 | echo "error : ".$e->getMessage(); |
| 457 | 558 | } |
| 458 | 559 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 459 | - } else $all = array(); |
|
| 560 | + } else { |
|
| 561 | + $all = array(); |
|
| 562 | + } |
|
| 460 | 563 | if (empty($all)) { |
| 461 | 564 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 462 | 565 | if ($filter_name != '') { |
@@ -477,7 +580,9 @@ discard block |
||
| 477 | 580 | $icao = $value['airport_departure_icao']; |
| 478 | 581 | if (isset($all[$icao])) { |
| 479 | 582 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 480 | - } else $all[$icao] = $value; |
|
| 583 | + } else { |
|
| 584 | + $all[$icao] = $value; |
|
| 585 | + } |
|
| 481 | 586 | } |
| 482 | 587 | $count = array(); |
| 483 | 588 | foreach ($all as $key => $row) { |
@@ -489,10 +594,15 @@ discard block |
||
| 489 | 594 | } |
| 490 | 595 | public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 491 | 596 | global $globalStatsFilters; |
| 492 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 597 | + if ($filter_name == '') { |
|
| 598 | + $filter_name = $this->filter_name; |
|
| 599 | + } |
|
| 493 | 600 | if ($year == '' && $month == '') { |
| 494 | - if ($limit) $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 495 | - else $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 601 | + if ($limit) { |
|
| 602 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC LIMIT 10 OFFSET 0"; |
|
| 603 | + } else { |
|
| 604 | + $query = "SELECT DISTINCT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE arrival > 0 AND stats_type = 'yearly' AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY airport_arrival_icao_count DESC"; |
|
| 605 | + } |
|
| 496 | 606 | try { |
| 497 | 607 | $sth = $this->db->prepare($query); |
| 498 | 608 | $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name)); |
@@ -500,7 +610,9 @@ discard block |
||
| 500 | 610 | echo "error : ".$e->getMessage(); |
| 501 | 611 | } |
| 502 | 612 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 503 | - } else $all = array(); |
|
| 613 | + } else { |
|
| 614 | + $all = array(); |
|
| 615 | + } |
|
| 504 | 616 | if (empty($all)) { |
| 505 | 617 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 506 | 618 | if ($filter_name != '') { |
@@ -521,7 +633,9 @@ discard block |
||
| 521 | 633 | $icao = $value['airport_arrival_icao']; |
| 522 | 634 | if (isset($all[$icao])) { |
| 523 | 635 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 524 | - } else $all[$icao] = $value; |
|
| 636 | + } else { |
|
| 637 | + $all[$icao] = $value; |
|
| 638 | + } |
|
| 525 | 639 | } |
| 526 | 640 | $count = array(); |
| 527 | 641 | foreach ($all as $key => $row) { |
@@ -534,13 +648,21 @@ discard block |
||
| 534 | 648 | } |
| 535 | 649 | public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') { |
| 536 | 650 | global $globalDBdriver, $globalStatsFilters; |
| 537 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 651 | + if ($filter_name == '') { |
|
| 652 | + $filter_name = $this->filter_name; |
|
| 653 | + } |
|
| 538 | 654 | if ($globalDBdriver == 'mysql') { |
| 539 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 540 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 655 | + if ($limit) { |
|
| 656 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 657 | + } else { |
|
| 658 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 659 | + } |
|
| 541 | 660 | } else { |
| 542 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 543 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 661 | + if ($limit) { |
|
| 662 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 663 | + } else { |
|
| 664 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 665 | + } |
|
| 544 | 666 | } |
| 545 | 667 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 546 | 668 | try { |
@@ -564,7 +686,9 @@ discard block |
||
| 564 | 686 | |
| 565 | 687 | public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') { |
| 566 | 688 | global $globalStatsFilters; |
| 567 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 689 | + if ($filter_name == '') { |
|
| 690 | + $filter_name = $this->filter_name; |
|
| 691 | + } |
|
| 568 | 692 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 569 | 693 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 570 | 694 | try { |
@@ -586,7 +710,9 @@ discard block |
||
| 586 | 710 | } |
| 587 | 711 | public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') { |
| 588 | 712 | global $globalDBdriver, $globalStatsFilters; |
| 589 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 713 | + if ($filter_name == '') { |
|
| 714 | + $filter_name = $this->filter_name; |
|
| 715 | + } |
|
| 590 | 716 | if ($globalDBdriver == 'mysql') { |
| 591 | 717 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 592 | 718 | } else { |
@@ -612,7 +738,9 @@ discard block |
||
| 612 | 738 | } |
| 613 | 739 | public function countAllDates($stats_airline = '',$filter_name = '') { |
| 614 | 740 | global $globalStatsFilters; |
| 615 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 741 | + if ($filter_name == '') { |
|
| 742 | + $filter_name = $this->filter_name; |
|
| 743 | + } |
|
| 616 | 744 | $query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 617 | 745 | $query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 618 | 746 | try { |
@@ -634,7 +762,9 @@ discard block |
||
| 634 | 762 | } |
| 635 | 763 | public function countAllDatesByAirlines($filter_name = '') { |
| 636 | 764 | global $globalStatsFilters; |
| 637 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 765 | + if ($filter_name == '') { |
|
| 766 | + $filter_name = $this->filter_name; |
|
| 767 | + } |
|
| 638 | 768 | $query = "SELECT stats_airline as airline_icao, flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'date' AND filter_name = :filter_name"; |
| 639 | 769 | $query_data = array('filter_name' => $filter_name); |
| 640 | 770 | try { |
@@ -656,7 +786,9 @@ discard block |
||
| 656 | 786 | } |
| 657 | 787 | public function countAllMonths($stats_airline = '',$filter_name = '') { |
| 658 | 788 | global $globalStatsFilters; |
| 659 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 789 | + if ($filter_name == '') { |
|
| 790 | + $filter_name = $this->filter_name; |
|
| 791 | + } |
|
| 660 | 792 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 661 | 793 | try { |
| 662 | 794 | $sth = $this->db->prepare($query); |
@@ -679,7 +811,9 @@ discard block |
||
| 679 | 811 | } |
| 680 | 812 | public function countAllMilitaryMonths($filter_name = '') { |
| 681 | 813 | global $globalStatsFilters; |
| 682 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 814 | + if ($filter_name == '') { |
|
| 815 | + $filter_name = $this->filter_name; |
|
| 816 | + } |
|
| 683 | 817 | $query = "SELECT YEAR(stats_date) AS year_name,MONTH(stats_date) AS month_name, cnt as date_count FROM stats WHERE stats_type = 'military_flights_bymonth' AND filter_name = :filter_name"; |
| 684 | 818 | try { |
| 685 | 819 | $sth = $this->db->prepare($query); |
@@ -700,9 +834,14 @@ discard block |
||
| 700 | 834 | } |
| 701 | 835 | public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') { |
| 702 | 836 | global $globalTimezone, $globalDBdriver, $globalStatsFilters; |
| 703 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 704 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 705 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 837 | + if ($filter_name == '') { |
|
| 838 | + $filter_name = $this->filter_name; |
|
| 839 | + } |
|
| 840 | + if ($limit) { |
|
| 841 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 842 | + } else { |
|
| 843 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour' AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
|
| 844 | + } |
|
| 706 | 845 | if ($orderby == 'hour') { |
| 707 | 846 | /* |
| 708 | 847 | if ($globalDBdriver == 'mysql') { |
@@ -711,7 +850,9 @@ discard block |
||
| 711 | 850 | */ |
| 712 | 851 | $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
| 713 | 852 | } |
| 714 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
| 853 | + if ($orderby == 'count') { |
|
| 854 | + $query .= " ORDER BY hour_count DESC"; |
|
| 855 | + } |
|
| 715 | 856 | try { |
| 716 | 857 | $sth = $this->db->prepare($query); |
| 717 | 858 | $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name)); |
@@ -732,8 +873,12 @@ discard block |
||
| 732 | 873 | |
| 733 | 874 | public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') { |
| 734 | 875 | global $globalStatsFilters; |
| 735 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 736 | - if ($year == '') $year = date('Y'); |
|
| 876 | + if ($filter_name == '') { |
|
| 877 | + $filter_name = $this->filter_name; |
|
| 878 | + } |
|
| 879 | + if ($year == '') { |
|
| 880 | + $year = date('Y'); |
|
| 881 | + } |
|
| 737 | 882 | $all = $this->getSumStats('flights_bymonth',$year,$stats_airline,$filter_name,$month); |
| 738 | 883 | if (empty($all)) { |
| 739 | 884 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -748,8 +893,12 @@ discard block |
||
| 748 | 893 | } |
| 749 | 894 | public function countOverallMilitaryFlights($filter_name = '',$year = '', $month = '') { |
| 750 | 895 | global $globalStatsFilters; |
| 751 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 752 | - if ($year == '') $year = date('Y'); |
|
| 896 | + if ($filter_name == '') { |
|
| 897 | + $filter_name = $this->filter_name; |
|
| 898 | + } |
|
| 899 | + if ($year == '') { |
|
| 900 | + $year = date('Y'); |
|
| 901 | + } |
|
| 753 | 902 | $all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month); |
| 754 | 903 | if (empty($all)) { |
| 755 | 904 | $filters = array(); |
@@ -765,8 +914,12 @@ discard block |
||
| 765 | 914 | } |
| 766 | 915 | public function countOverallArrival($stats_airline = '',$filter_name = '', $year = '', $month = '') { |
| 767 | 916 | global $globalStatsFilters; |
| 768 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 769 | - if ($year == '') $year = date('Y'); |
|
| 917 | + if ($filter_name == '') { |
|
| 918 | + $filter_name = $this->filter_name; |
|
| 919 | + } |
|
| 920 | + if ($year == '') { |
|
| 921 | + $year = date('Y'); |
|
| 922 | + } |
|
| 770 | 923 | $all = $this->getSumStats('realarrivals_bymonth',$year,$stats_airline,$filter_name,$month); |
| 771 | 924 | if (empty($all)) { |
| 772 | 925 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
@@ -781,7 +934,9 @@ discard block |
||
| 781 | 934 | } |
| 782 | 935 | public function countOverallAircrafts($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 783 | 936 | global $globalStatsFilters; |
| 784 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 937 | + if ($filter_name == '') { |
|
| 938 | + $filter_name = $this->filter_name; |
|
| 939 | + } |
|
| 785 | 940 | if ($year == '' && $month == '') { |
| 786 | 941 | $query = "SELECT COUNT(*) AS nb FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 787 | 942 | try { |
@@ -792,7 +947,9 @@ discard block |
||
| 792 | 947 | } |
| 793 | 948 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 794 | 949 | $all = $result[0]['nb']; |
| 795 | - } else $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 950 | + } else { |
|
| 951 | + $all = $this->getSumStats('aircrafts_bymonth',$year,$stats_airline,$filter_name,$month); |
|
| 952 | + } |
|
| 796 | 953 | if (empty($all)) { |
| 797 | 954 | $filters = array('airlines' => array($stats_airline),'year' => $year,'month' => $month); |
| 798 | 955 | if ($filter_name != '') { |
@@ -806,7 +963,9 @@ discard block |
||
| 806 | 963 | } |
| 807 | 964 | public function countOverallAirlines($filter_name = '',$year = '',$month = '') { |
| 808 | 965 | global $globalStatsFilters; |
| 809 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 966 | + if ($filter_name == '') { |
|
| 967 | + $filter_name = $this->filter_name; |
|
| 968 | + } |
|
| 810 | 969 | if ($year == '' && $month == '') { |
| 811 | 970 | $query = "SELECT COUNT(*) AS nb_airline FROM stats_airline WHERE filter_name = :filter_name"; |
| 812 | 971 | try { |
@@ -817,7 +976,9 @@ discard block |
||
| 817 | 976 | } |
| 818 | 977 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 819 | 978 | $all = $result[0]['nb_airline']; |
| 820 | - } else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 979 | + } else { |
|
| 980 | + $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month); |
|
| 981 | + } |
|
| 821 | 982 | if (empty($all)) { |
| 822 | 983 | $filters = array(); |
| 823 | 984 | $filters = array('year' => $year,'month' => $month); |
@@ -832,7 +993,9 @@ discard block |
||
| 832 | 993 | } |
| 833 | 994 | public function countOverallOwners($stats_airline = '',$filter_name = '',$year = '', $month = '') { |
| 834 | 995 | global $globalStatsFilters; |
| 835 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 996 | + if ($filter_name == '') { |
|
| 997 | + $filter_name = $this->filter_name; |
|
| 998 | + } |
|
| 836 | 999 | if ($year == '' && $month == '') { |
| 837 | 1000 | $query = "SELECT count(*) as nb FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 838 | 1001 | $query_values = array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
@@ -860,7 +1023,9 @@ discard block |
||
| 860 | 1023 | } |
| 861 | 1024 | public function countOverallPilots($stats_airline = '',$filter_name = '',$year = '',$month = '') { |
| 862 | 1025 | global $globalStatsFilters; |
| 863 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1026 | + if ($filter_name == '') { |
|
| 1027 | + $filter_name = $this->filter_name; |
|
| 1028 | + } |
|
| 864 | 1029 | //if ($year == '') $year = date('Y'); |
| 865 | 1030 | if ($year == '' && $month == '') { |
| 866 | 1031 | $query = "SELECT count(*) as nb FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
@@ -889,7 +1054,9 @@ discard block |
||
| 889 | 1054 | } |
| 890 | 1055 | |
| 891 | 1056 | public function getLast7DaysAirports($airport_icao = '', $stats_airline = '',$filter_name = '') { |
| 892 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1057 | + if ($filter_name == '') { |
|
| 1058 | + $filter_name = $this->filter_name; |
|
| 1059 | + } |
|
| 893 | 1060 | $query = "SELECT * FROM stats_airport WHERE stats_type = 'daily' AND airport_icao = :airport_icao AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY date"; |
| 894 | 1061 | $query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name); |
| 895 | 1062 | try { |
@@ -902,7 +1069,9 @@ discard block |
||
| 902 | 1069 | return $all; |
| 903 | 1070 | } |
| 904 | 1071 | public function getStats($type,$stats_airline = '', $filter_name = '') { |
| 905 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1072 | + if ($filter_name == '') { |
|
| 1073 | + $filter_name = $this->filter_name; |
|
| 1074 | + } |
|
| 906 | 1075 | $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date"; |
| 907 | 1076 | $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name); |
| 908 | 1077 | try { |
@@ -915,7 +1084,9 @@ discard block |
||
| 915 | 1084 | return $all; |
| 916 | 1085 | } |
| 917 | 1086 | public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') { |
| 918 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1087 | + if ($filter_name == '') { |
|
| 1088 | + $filter_name = $this->filter_name; |
|
| 1089 | + } |
|
| 919 | 1090 | global $globalArchiveMonths, $globalDBdriver; |
| 920 | 1091 | if ($globalDBdriver == 'mysql') { |
| 921 | 1092 | if ($month == '') { |
@@ -945,7 +1116,9 @@ discard block |
||
| 945 | 1116 | } |
| 946 | 1117 | public function getStatsTotal($type, $stats_airline = '', $filter_name = '') { |
| 947 | 1118 | global $globalArchiveMonths, $globalDBdriver; |
| 948 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1119 | + if ($filter_name == '') { |
|
| 1120 | + $filter_name = $this->filter_name; |
|
| 1121 | + } |
|
| 949 | 1122 | if ($globalDBdriver == 'mysql') { |
| 950 | 1123 | $query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL ".$globalArchiveMonths." MONTH) AND stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 951 | 1124 | } else { |
@@ -963,7 +1136,9 @@ discard block |
||
| 963 | 1136 | } |
| 964 | 1137 | public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') { |
| 965 | 1138 | global $globalArchiveMonths, $globalDBdriver; |
| 966 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1139 | + if ($filter_name == '') { |
|
| 1140 | + $filter_name = $this->filter_name; |
|
| 1141 | + } |
|
| 967 | 1142 | if ($globalDBdriver == 'mysql') { |
| 968 | 1143 | $query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name"; |
| 969 | 1144 | } else { |
@@ -980,7 +1155,9 @@ discard block |
||
| 980 | 1155 | } |
| 981 | 1156 | public function getStatsAirlineTotal($filter_name = '') { |
| 982 | 1157 | global $globalArchiveMonths, $globalDBdriver; |
| 983 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1158 | + if ($filter_name == '') { |
|
| 1159 | + $filter_name = $this->filter_name; |
|
| 1160 | + } |
|
| 984 | 1161 | if ($globalDBdriver == 'mysql') { |
| 985 | 1162 | $query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name"; |
| 986 | 1163 | } else { |
@@ -997,7 +1174,9 @@ discard block |
||
| 997 | 1174 | } |
| 998 | 1175 | public function getStatsOwnerTotal($filter_name = '') { |
| 999 | 1176 | global $globalArchiveMonths, $globalDBdriver; |
| 1000 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1177 | + if ($filter_name == '') { |
|
| 1178 | + $filter_name = $this->filter_name; |
|
| 1179 | + } |
|
| 1001 | 1180 | if ($globalDBdriver == 'mysql') { |
| 1002 | 1181 | $query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name"; |
| 1003 | 1182 | } else { |
@@ -1014,7 +1193,9 @@ discard block |
||
| 1014 | 1193 | } |
| 1015 | 1194 | public function getStatsOwner($owner_name,$filter_name = '') { |
| 1016 | 1195 | global $globalArchiveMonths, $globalDBdriver; |
| 1017 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1196 | + if ($filter_name == '') { |
|
| 1197 | + $filter_name = $this->filter_name; |
|
| 1198 | + } |
|
| 1018 | 1199 | $query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name"; |
| 1019 | 1200 | try { |
| 1020 | 1201 | $sth = $this->db->prepare($query); |
@@ -1023,12 +1204,17 @@ discard block |
||
| 1023 | 1204 | echo "error : ".$e->getMessage(); |
| 1024 | 1205 | } |
| 1025 | 1206 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1026 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1027 | - else return 0; |
|
| 1207 | + if (isset($all[0]['cnt'])) { |
|
| 1208 | + return $all[0]['cnt']; |
|
| 1209 | + } else { |
|
| 1210 | + return 0; |
|
| 1211 | + } |
|
| 1028 | 1212 | } |
| 1029 | 1213 | public function getStatsPilotTotal($filter_name = '') { |
| 1030 | 1214 | global $globalArchiveMonths, $globalDBdriver; |
| 1031 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1215 | + if ($filter_name == '') { |
|
| 1216 | + $filter_name = $this->filter_name; |
|
| 1217 | + } |
|
| 1032 | 1218 | if ($globalDBdriver == 'mysql') { |
| 1033 | 1219 | $query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name"; |
| 1034 | 1220 | } else { |
@@ -1045,7 +1231,9 @@ discard block |
||
| 1045 | 1231 | } |
| 1046 | 1232 | public function getStatsPilot($pilot,$filter_name = '') { |
| 1047 | 1233 | global $globalArchiveMonths, $globalDBdriver; |
| 1048 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1234 | + if ($filter_name == '') { |
|
| 1235 | + $filter_name = $this->filter_name; |
|
| 1236 | + } |
|
| 1049 | 1237 | $query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)"; |
| 1050 | 1238 | try { |
| 1051 | 1239 | $sth = $this->db->prepare($query); |
@@ -1054,13 +1242,18 @@ discard block |
||
| 1054 | 1242 | echo "error : ".$e->getMessage(); |
| 1055 | 1243 | } |
| 1056 | 1244 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 1057 | - if (isset($all[0]['cnt'])) return $all[0]['cnt']; |
|
| 1058 | - else return 0; |
|
| 1245 | + if (isset($all[0]['cnt'])) { |
|
| 1246 | + return $all[0]['cnt']; |
|
| 1247 | + } else { |
|
| 1248 | + return 0; |
|
| 1249 | + } |
|
| 1059 | 1250 | } |
| 1060 | 1251 | |
| 1061 | 1252 | public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1062 | 1253 | global $globalDBdriver; |
| 1063 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1254 | + if ($filter_name == '') { |
|
| 1255 | + $filter_name = $this->filter_name; |
|
| 1256 | + } |
|
| 1064 | 1257 | if ($globalDBdriver == 'mysql') { |
| 1065 | 1258 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = :cnt"; |
| 1066 | 1259 | } else { |
@@ -1076,7 +1269,9 @@ discard block |
||
| 1076 | 1269 | } |
| 1077 | 1270 | public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') { |
| 1078 | 1271 | global $globalDBdriver; |
| 1079 | - if ($filter_name == '') $filter_name = $this->filter_name; |
|
| 1272 | + if ($filter_name == '') { |
|
| 1273 | + $filter_name = $this->filter_name; |
|
| 1274 | + } |
|
| 1080 | 1275 | if ($globalDBdriver == 'mysql') { |
| 1081 | 1276 | $query = "INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) VALUES (:type,:cnt,:stats_date,:stats_airline,:filter_name) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date"; |
| 1082 | 1277 | } else { |
@@ -1462,10 +1657,14 @@ discard block |
||
| 1462 | 1657 | $Connection = new Connection(); |
| 1463 | 1658 | date_default_timezone_set('UTC'); |
| 1464 | 1659 | $last_update = $this->getLastStatsUpdate('last_update_stats'); |
| 1465 | - if ($globalDebug) echo 'Update stats !'."\n"; |
|
| 1660 | + if ($globalDebug) { |
|
| 1661 | + echo 'Update stats !'."\n"; |
|
| 1662 | + } |
|
| 1466 | 1663 | if (isset($last_update[0]['value'])) { |
| 1467 | 1664 | $last_update_day = $last_update[0]['value']; |
| 1468 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
| 1665 | + } else { |
|
| 1666 | + $last_update_day = '2012-12-12 12:12:12'; |
|
| 1667 | + } |
|
| 1469 | 1668 | $reset = false; |
| 1470 | 1669 | //if ($globalStatsResetYear && date('Y',strtotime($last_update_day)) != date('Y')) { |
| 1471 | 1670 | if ($globalStatsResetYear) { |
@@ -1474,42 +1673,60 @@ discard block |
||
| 1474 | 1673 | } |
| 1475 | 1674 | $Spotter = new Spotter($this->db); |
| 1476 | 1675 | |
| 1477 | - if ($globalDebug) echo 'Count all aircraft types...'."\n"; |
|
| 1676 | + if ($globalDebug) { |
|
| 1677 | + echo 'Count all aircraft types...'."\n"; |
|
| 1678 | + } |
|
| 1478 | 1679 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
| 1479 | 1680 | foreach ($alldata as $number) { |
| 1480 | 1681 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],'','',$reset); |
| 1481 | 1682 | } |
| 1482 | - if ($globalDebug) echo 'Count all airlines...'."\n"; |
|
| 1683 | + if ($globalDebug) { |
|
| 1684 | + echo 'Count all airlines...'."\n"; |
|
| 1685 | + } |
|
| 1483 | 1686 | $alldata = $Spotter->countAllAirlines(false,0,$last_update_day); |
| 1484 | 1687 | foreach ($alldata as $number) { |
| 1485 | 1688 | $this->addStatAirline($number['airline_icao'],$number['airline_count'],$number['airline_name'],'',$reset); |
| 1486 | 1689 | } |
| 1487 | - if ($globalDebug) echo 'Count all registrations...'."\n"; |
|
| 1690 | + if ($globalDebug) { |
|
| 1691 | + echo 'Count all registrations...'."\n"; |
|
| 1692 | + } |
|
| 1488 | 1693 | $alldata = $Spotter->countAllAircraftRegistrations(false,0,$last_update_day); |
| 1489 | 1694 | foreach ($alldata as $number) { |
| 1490 | 1695 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],'','',$reset); |
| 1491 | 1696 | } |
| 1492 | - if ($globalDebug) echo 'Count all callsigns...'."\n"; |
|
| 1697 | + if ($globalDebug) { |
|
| 1698 | + echo 'Count all callsigns...'."\n"; |
|
| 1699 | + } |
|
| 1493 | 1700 | $alldata = $Spotter->countAllCallsigns(false,0,$last_update_day); |
| 1494 | 1701 | foreach ($alldata as $number) { |
| 1495 | 1702 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 1496 | 1703 | } |
| 1497 | - if ($globalDebug) echo 'Count all owners...'."\n"; |
|
| 1704 | + if ($globalDebug) { |
|
| 1705 | + echo 'Count all owners...'."\n"; |
|
| 1706 | + } |
|
| 1498 | 1707 | $alldata = $Spotter->countAllOwners(false,0,$last_update_day); |
| 1499 | 1708 | foreach ($alldata as $number) { |
| 1500 | 1709 | $this->addStatOwner($number['owner_name'],$number['owner_count'],'','',$reset); |
| 1501 | 1710 | } |
| 1502 | - if ($globalDebug) echo 'Count all pilots...'."\n"; |
|
| 1711 | + if ($globalDebug) { |
|
| 1712 | + echo 'Count all pilots...'."\n"; |
|
| 1713 | + } |
|
| 1503 | 1714 | $alldata = $Spotter->countAllPilots(false,0,$last_update_day); |
| 1504 | 1715 | foreach ($alldata as $number) { |
| 1505 | 1716 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'','',$number['format_source'],$reset); |
| 1506 | 1717 | } |
| 1507 | 1718 | |
| 1508 | - if ($globalDebug) echo 'Count all departure airports...'."\n"; |
|
| 1719 | + if ($globalDebug) { |
|
| 1720 | + echo 'Count all departure airports...'."\n"; |
|
| 1721 | + } |
|
| 1509 | 1722 | $pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day); |
| 1510 | - if ($globalDebug) echo 'Count all detected departure airports...'."\n"; |
|
| 1723 | + if ($globalDebug) { |
|
| 1724 | + echo 'Count all detected departure airports...'."\n"; |
|
| 1725 | + } |
|
| 1511 | 1726 | $dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day); |
| 1512 | - if ($globalDebug) echo 'Order departure airports...'."\n"; |
|
| 1727 | + if ($globalDebug) { |
|
| 1728 | + echo 'Order departure airports...'."\n"; |
|
| 1729 | + } |
|
| 1513 | 1730 | $alldata = array(); |
| 1514 | 1731 | |
| 1515 | 1732 | foreach ($pall as $value) { |
@@ -1520,7 +1737,9 @@ discard block |
||
| 1520 | 1737 | $icao = $value['airport_departure_icao']; |
| 1521 | 1738 | if (isset($alldata[$icao])) { |
| 1522 | 1739 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 1523 | - } else $alldata[$icao] = $value; |
|
| 1740 | + } else { |
|
| 1741 | + $alldata[$icao] = $value; |
|
| 1742 | + } |
|
| 1524 | 1743 | } |
| 1525 | 1744 | $count = array(); |
| 1526 | 1745 | foreach ($alldata as $key => $row) { |
@@ -1530,11 +1749,17 @@ discard block |
||
| 1530 | 1749 | foreach ($alldata as $number) { |
| 1531 | 1750 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'','',$reset); |
| 1532 | 1751 | } |
| 1533 | - if ($globalDebug) echo 'Count all arrival airports...'."\n"; |
|
| 1752 | + if ($globalDebug) { |
|
| 1753 | + echo 'Count all arrival airports...'."\n"; |
|
| 1754 | + } |
|
| 1534 | 1755 | $pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day); |
| 1535 | - if ($globalDebug) echo 'Count all detected arrival airports...'."\n"; |
|
| 1756 | + if ($globalDebug) { |
|
| 1757 | + echo 'Count all detected arrival airports...'."\n"; |
|
| 1758 | + } |
|
| 1536 | 1759 | $dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day); |
| 1537 | - if ($globalDebug) echo 'Order arrival airports...'."\n"; |
|
| 1760 | + if ($globalDebug) { |
|
| 1761 | + echo 'Order arrival airports...'."\n"; |
|
| 1762 | + } |
|
| 1538 | 1763 | $alldata = array(); |
| 1539 | 1764 | foreach ($pall as $value) { |
| 1540 | 1765 | $icao = $value['airport_arrival_icao']; |
@@ -1544,7 +1769,9 @@ discard block |
||
| 1544 | 1769 | $icao = $value['airport_arrival_icao']; |
| 1545 | 1770 | if (isset($alldata[$icao])) { |
| 1546 | 1771 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 1547 | - } else $alldata[$icao] = $value; |
|
| 1772 | + } else { |
|
| 1773 | + $alldata[$icao] = $value; |
|
| 1774 | + } |
|
| 1548 | 1775 | } |
| 1549 | 1776 | $count = array(); |
| 1550 | 1777 | foreach ($alldata as $key => $row) { |
@@ -1555,7 +1782,9 @@ discard block |
||
| 1555 | 1782 | echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'','',$reset); |
| 1556 | 1783 | } |
| 1557 | 1784 | if ($Connection->tableExists('countries')) { |
| 1558 | - if ($globalDebug) echo 'Count all flights by countries...'."\n"; |
|
| 1785 | + if ($globalDebug) { |
|
| 1786 | + echo 'Count all flights by countries...'."\n"; |
|
| 1787 | + } |
|
| 1559 | 1788 | $SpotterArchive = new SpotterArchive(); |
| 1560 | 1789 | $alldata = $SpotterArchive->countAllFlightOverCountries(false,0,$last_update_day); |
| 1561 | 1790 | foreach ($alldata as $number) { |
@@ -1567,46 +1796,66 @@ discard block |
||
| 1567 | 1796 | // Add by month using getstat if month finish... |
| 1568 | 1797 | |
| 1569 | 1798 | //if (date('m',strtotime($last_update_day)) != date('m')) { |
| 1570 | - if ($globalDebug) echo 'Count all flights by months...'."\n"; |
|
| 1799 | + if ($globalDebug) { |
|
| 1800 | + echo 'Count all flights by months...'."\n"; |
|
| 1801 | + } |
|
| 1571 | 1802 | $Spotter = new Spotter($this->db); |
| 1572 | 1803 | $alldata = $Spotter->countAllMonths(); |
| 1573 | 1804 | $lastyear = false; |
| 1574 | 1805 | foreach ($alldata as $number) { |
| 1575 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 1806 | + if ($number['year_name'] != date('Y')) { |
|
| 1807 | + $lastyear = true; |
|
| 1808 | + } |
|
| 1576 | 1809 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1577 | 1810 | } |
| 1578 | - if ($globalDebug) echo 'Count all military flights by months...'."\n"; |
|
| 1811 | + if ($globalDebug) { |
|
| 1812 | + echo 'Count all military flights by months...'."\n"; |
|
| 1813 | + } |
|
| 1579 | 1814 | $alldata = $Spotter->countAllMilitaryMonths(); |
| 1580 | 1815 | foreach ($alldata as $number) { |
| 1581 | 1816 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1582 | 1817 | } |
| 1583 | - if ($globalDebug) echo 'Count all owners by months...'."\n"; |
|
| 1818 | + if ($globalDebug) { |
|
| 1819 | + echo 'Count all owners by months...'."\n"; |
|
| 1820 | + } |
|
| 1584 | 1821 | $alldata = $Spotter->countAllMonthsOwners(); |
| 1585 | 1822 | foreach ($alldata as $number) { |
| 1586 | 1823 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1587 | 1824 | } |
| 1588 | - if ($globalDebug) echo 'Count all pilots by months...'."\n"; |
|
| 1825 | + if ($globalDebug) { |
|
| 1826 | + echo 'Count all pilots by months...'."\n"; |
|
| 1827 | + } |
|
| 1589 | 1828 | $alldata = $Spotter->countAllMonthsPilots(); |
| 1590 | 1829 | foreach ($alldata as $number) { |
| 1591 | 1830 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1592 | 1831 | } |
| 1593 | - if ($globalDebug) echo 'Count all airlines by months...'."\n"; |
|
| 1832 | + if ($globalDebug) { |
|
| 1833 | + echo 'Count all airlines by months...'."\n"; |
|
| 1834 | + } |
|
| 1594 | 1835 | $alldata = $Spotter->countAllMonthsAirlines(); |
| 1595 | 1836 | foreach ($alldata as $number) { |
| 1596 | 1837 | $this->addStat('airlines_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1597 | 1838 | } |
| 1598 | - if ($globalDebug) echo 'Count all aircrafts by months...'."\n"; |
|
| 1839 | + if ($globalDebug) { |
|
| 1840 | + echo 'Count all aircrafts by months...'."\n"; |
|
| 1841 | + } |
|
| 1599 | 1842 | $alldata = $Spotter->countAllMonthsAircrafts(); |
| 1600 | 1843 | foreach ($alldata as $number) { |
| 1601 | 1844 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1602 | 1845 | } |
| 1603 | - if ($globalDebug) echo 'Count all real arrivals by months...'."\n"; |
|
| 1846 | + if ($globalDebug) { |
|
| 1847 | + echo 'Count all real arrivals by months...'."\n"; |
|
| 1848 | + } |
|
| 1604 | 1849 | $alldata = $Spotter->countAllMonthsRealArrivals(); |
| 1605 | 1850 | foreach ($alldata as $number) { |
| 1606 | 1851 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
| 1607 | 1852 | } |
| 1608 | - if ($globalDebug) echo 'Airports data...'."\n"; |
|
| 1609 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 1853 | + if ($globalDebug) { |
|
| 1854 | + echo 'Airports data...'."\n"; |
|
| 1855 | + } |
|
| 1856 | + if ($globalDebug) { |
|
| 1857 | + echo '...Departure'."\n"; |
|
| 1858 | + } |
|
| 1610 | 1859 | $this->deleteStatAirport('daily'); |
| 1611 | 1860 | // $pall = $Spotter->getLast7DaysAirportsDeparture(); |
| 1612 | 1861 | // $dall = $Spotter->getLast7DaysDetectedAirportsDeparture(); |
@@ -1727,44 +1976,62 @@ discard block |
||
| 1727 | 1976 | // Count by airlines |
| 1728 | 1977 | echo '--- Stats by airlines ---'."\n"; |
| 1729 | 1978 | if ($Connection->tableExists('countries')) { |
| 1730 | - if ($globalDebug) echo 'Count all flights by countries by airlines...'."\n"; |
|
| 1979 | + if ($globalDebug) { |
|
| 1980 | + echo 'Count all flights by countries by airlines...'."\n"; |
|
| 1981 | + } |
|
| 1731 | 1982 | $SpotterArchive = new SpotterArchive(); |
| 1732 | 1983 | $alldata = $SpotterArchive->countAllFlightOverCountriesByAirlines(false,0,$last_update_day); |
| 1733 | 1984 | foreach ($alldata as $number) { |
| 1734 | 1985 | $this->addStatCountry($number['flight_country_iso2'],$number['flight_country_iso3'],$number['flight_country'],$number['flight_count'],$number['airline_icao'],'',$reset); |
| 1735 | 1986 | } |
| 1736 | 1987 | } |
| 1737 | - if ($globalDebug) echo 'Count all aircraft types by airlines...'."\n"; |
|
| 1988 | + if ($globalDebug) { |
|
| 1989 | + echo 'Count all aircraft types by airlines...'."\n"; |
|
| 1990 | + } |
|
| 1738 | 1991 | $Spotter = new Spotter($this->db); |
| 1739 | 1992 | $alldata = $Spotter->countAllAircraftTypesByAirlines(false,0,$last_update_day); |
| 1740 | 1993 | foreach ($alldata as $number) { |
| 1741 | 1994 | $this->addStatAircraft($number['aircraft_icao'],$number['aircraft_icao_count'],$number['aircraft_name'],$number['aircraft_manufacturer'],$number['airline_icao'],'',$reset); |
| 1742 | 1995 | } |
| 1743 | - if ($globalDebug) echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 1996 | + if ($globalDebug) { |
|
| 1997 | + echo 'Count all aircraft registrations by airlines...'."\n"; |
|
| 1998 | + } |
|
| 1744 | 1999 | $alldata = $Spotter->countAllAircraftRegistrationsByAirlines(false,0,$last_update_day); |
| 1745 | 2000 | foreach ($alldata as $number) { |
| 1746 | 2001 | $this->addStatAircraftRegistration($number['registration'],$number['aircraft_registration_count'],$number['aircraft_icao'],$number['airline_icao'],'',$reset); |
| 1747 | 2002 | } |
| 1748 | - if ($globalDebug) echo 'Count all callsigns by airlines...'."\n"; |
|
| 2003 | + if ($globalDebug) { |
|
| 2004 | + echo 'Count all callsigns by airlines...'."\n"; |
|
| 2005 | + } |
|
| 1749 | 2006 | $alldata = $Spotter->countAllCallsignsByAirlines(false,0,$last_update_day); |
| 1750 | 2007 | foreach ($alldata as $number) { |
| 1751 | 2008 | $this->addStatCallsign($number['callsign_icao'],$number['callsign_icao_count'],$number['airline_icao'],'',$reset); |
| 1752 | 2009 | } |
| 1753 | - if ($globalDebug) echo 'Count all owners by airlines...'."\n"; |
|
| 2010 | + if ($globalDebug) { |
|
| 2011 | + echo 'Count all owners by airlines...'."\n"; |
|
| 2012 | + } |
|
| 1754 | 2013 | $alldata = $Spotter->countAllOwnersByAirlines(false,0,$last_update_day); |
| 1755 | 2014 | foreach ($alldata as $number) { |
| 1756 | 2015 | $this->addStatOwner($number['owner_name'],$number['owner_count'],$number['airline_icao'],'',$reset); |
| 1757 | 2016 | } |
| 1758 | - if ($globalDebug) echo 'Count all pilots by airlines...'."\n"; |
|
| 2017 | + if ($globalDebug) { |
|
| 2018 | + echo 'Count all pilots by airlines...'."\n"; |
|
| 2019 | + } |
|
| 1759 | 2020 | $alldata = $Spotter->countAllPilotsByAirlines(false,0,$last_update_day); |
| 1760 | 2021 | foreach ($alldata as $number) { |
| 1761 | 2022 | $this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],$number['airline_icao'],'',$number['format_source'],$reset); |
| 1762 | 2023 | } |
| 1763 | - if ($globalDebug) echo 'Count all departure airports by airlines...'."\n"; |
|
| 2024 | + if ($globalDebug) { |
|
| 2025 | + echo 'Count all departure airports by airlines...'."\n"; |
|
| 2026 | + } |
|
| 1764 | 2027 | $pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1765 | - if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2028 | + if ($globalDebug) { |
|
| 2029 | + echo 'Count all detected departure airports by airlines...'."\n"; |
|
| 2030 | + } |
|
| 1766 | 2031 | $dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day); |
| 1767 | - if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2032 | + if ($globalDebug) { |
|
| 2033 | + echo 'Order detected departure airports by airlines...'."\n"; |
|
| 2034 | + } |
|
| 1768 | 2035 | //$alldata = array(); |
| 1769 | 2036 | foreach ($dall as $value) { |
| 1770 | 2037 | $icao = $value['airport_departure_icao']; |
@@ -1785,11 +2052,17 @@ discard block |
||
| 1785 | 2052 | foreach ($alldata as $number) { |
| 1786 | 2053 | echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],$number['airline_icao'],'',$reset); |
| 1787 | 2054 | } |
| 1788 | - if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2055 | + if ($globalDebug) { |
|
| 2056 | + echo 'Count all arrival airports by airlines...'."\n"; |
|
| 2057 | + } |
|
| 1789 | 2058 | $pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1790 | - if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2059 | + if ($globalDebug) { |
|
| 2060 | + echo 'Count all detected arrival airports by airlines...'."\n"; |
|
| 2061 | + } |
|
| 1791 | 2062 | $dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day); |
| 1792 | - if ($globalDebug) echo 'Order arrival airports by airlines...'."\n"; |
|
| 2063 | + if ($globalDebug) { |
|
| 2064 | + echo 'Order arrival airports by airlines...'."\n"; |
|
| 2065 | + } |
|
| 1793 | 2066 | //$alldata = array(); |
| 1794 | 2067 | foreach ($dall as $value) { |
| 1795 | 2068 | $icao = $value['airport_arrival_icao']; |
@@ -1808,37 +2081,53 @@ discard block |
||
| 1808 | 2081 | } |
| 1809 | 2082 | $alldata = $pall; |
| 1810 | 2083 | foreach ($alldata as $number) { |
| 1811 | - if ($number['airline_icao'] != '') echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2084 | + if ($number['airline_icao'] != '') { |
|
| 2085 | + echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],$number['airline_icao'],'',$reset); |
|
| 2086 | + } |
|
| 2087 | + } |
|
| 2088 | + if ($globalDebug) { |
|
| 2089 | + echo 'Count all flights by months by airlines...'."\n"; |
|
| 1812 | 2090 | } |
| 1813 | - if ($globalDebug) echo 'Count all flights by months by airlines...'."\n"; |
|
| 1814 | 2091 | $Spotter = new Spotter($this->db); |
| 1815 | 2092 | $alldata = $Spotter->countAllMonthsByAirlines(); |
| 1816 | 2093 | $lastyear = false; |
| 1817 | 2094 | foreach ($alldata as $number) { |
| 1818 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2095 | + if ($number['year_name'] != date('Y')) { |
|
| 2096 | + $lastyear = true; |
|
| 2097 | + } |
|
| 1819 | 2098 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1820 | 2099 | } |
| 1821 | - if ($globalDebug) echo 'Count all owners by months by airlines...'."\n"; |
|
| 2100 | + if ($globalDebug) { |
|
| 2101 | + echo 'Count all owners by months by airlines...'."\n"; |
|
| 2102 | + } |
|
| 1822 | 2103 | $alldata = $Spotter->countAllMonthsOwnersByAirlines(); |
| 1823 | 2104 | foreach ($alldata as $number) { |
| 1824 | 2105 | $this->addStat('owners_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1825 | 2106 | } |
| 1826 | - if ($globalDebug) echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2107 | + if ($globalDebug) { |
|
| 2108 | + echo 'Count all pilots by months by airlines...'."\n"; |
|
| 2109 | + } |
|
| 1827 | 2110 | $alldata = $Spotter->countAllMonthsPilotsByAirlines(); |
| 1828 | 2111 | foreach ($alldata as $number) { |
| 1829 | 2112 | $this->addStat('pilots_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1830 | 2113 | } |
| 1831 | - if ($globalDebug) echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2114 | + if ($globalDebug) { |
|
| 2115 | + echo 'Count all aircrafts by months by airlines...'."\n"; |
|
| 2116 | + } |
|
| 1832 | 2117 | $alldata = $Spotter->countAllMonthsAircraftsByAirlines(); |
| 1833 | 2118 | foreach ($alldata as $number) { |
| 1834 | 2119 | $this->addStat('aircrafts_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1835 | 2120 | } |
| 1836 | - if ($globalDebug) echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2121 | + if ($globalDebug) { |
|
| 2122 | + echo 'Count all real arrivals by months by airlines...'."\n"; |
|
| 2123 | + } |
|
| 1837 | 2124 | $alldata = $Spotter->countAllMonthsRealArrivalsByAirlines(); |
| 1838 | 2125 | foreach ($alldata as $number) { |
| 1839 | 2126 | $this->addStat('realarrivals_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),$number['airline_icao']); |
| 1840 | 2127 | } |
| 1841 | - if ($globalDebug) echo '...Departure'."\n"; |
|
| 2128 | + if ($globalDebug) { |
|
| 2129 | + echo '...Departure'."\n"; |
|
| 2130 | + } |
|
| 1842 | 2131 | $pall = $Spotter->getLast7DaysAirportsDepartureByAirlines(); |
| 1843 | 2132 | $dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines(); |
| 1844 | 2133 | foreach ($dall as $value) { |
@@ -1861,7 +2150,9 @@ discard block |
||
| 1861 | 2150 | foreach ($alldata as $number) { |
| 1862 | 2151 | $this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],$number['airline_icao']); |
| 1863 | 2152 | } |
| 1864 | - if ($globalDebug) echo '...Arrival'."\n"; |
|
| 2153 | + if ($globalDebug) { |
|
| 2154 | + echo '...Arrival'."\n"; |
|
| 2155 | + } |
|
| 1865 | 2156 | $pall = $Spotter->getLast7DaysAirportsArrivalByAirlines(); |
| 1866 | 2157 | $dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines(); |
| 1867 | 2158 | foreach ($dall as $value) { |
@@ -1885,13 +2176,19 @@ discard block |
||
| 1885 | 2176 | $this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],$number['airline_icao']); |
| 1886 | 2177 | } |
| 1887 | 2178 | |
| 1888 | - if ($globalDebug) echo 'Flights data...'."\n"; |
|
| 1889 | - if ($globalDebug) echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2179 | + if ($globalDebug) { |
|
| 2180 | + echo 'Flights data...'."\n"; |
|
| 2181 | + } |
|
| 2182 | + if ($globalDebug) { |
|
| 2183 | + echo '-> countAllDatesLastMonth...'."\n"; |
|
| 2184 | + } |
|
| 1890 | 2185 | $alldata = $Spotter->countAllDatesLastMonthByAirlines(); |
| 1891 | 2186 | foreach ($alldata as $number) { |
| 1892 | 2187 | $this->addStatFlight('month',$number['date_name'],$number['date_count'], $number['airline_icao']); |
| 1893 | 2188 | } |
| 1894 | - if ($globalDebug) echo '-> countAllDates...'."\n"; |
|
| 2189 | + if ($globalDebug) { |
|
| 2190 | + echo '-> countAllDates...'."\n"; |
|
| 2191 | + } |
|
| 1895 | 2192 | //$previousdata = $this->countAllDatesByAirlines(); |
| 1896 | 2193 | $alldata = $Common->array_merge_noappend($previousdatabyairlines,$Spotter->countAllDatesByAirlines()); |
| 1897 | 2194 | $values = array(); |
@@ -1904,7 +2201,9 @@ discard block |
||
| 1904 | 2201 | $this->addStatFlight('date',$number['date_name'],$number['date_count'],$number['airline_icao']); |
| 1905 | 2202 | } |
| 1906 | 2203 | |
| 1907 | - if ($globalDebug) echo '-> countAllHours...'."\n"; |
|
| 2204 | + if ($globalDebug) { |
|
| 2205 | + echo '-> countAllHours...'."\n"; |
|
| 2206 | + } |
|
| 1908 | 2207 | $alldata = $Spotter->countAllHoursByAirlines('hour'); |
| 1909 | 2208 | foreach ($alldata as $number) { |
| 1910 | 2209 | $this->addStatFlight('hour',$number['hour_name'],$number['hour_count'],$number['airline_icao']); |
@@ -1912,14 +2211,18 @@ discard block |
||
| 1912 | 2211 | |
| 1913 | 2212 | |
| 1914 | 2213 | // Stats by filters |
| 1915 | - if (!isset($globalStatsFilters) || $globalStatsFilters == '') $globalStatsFilters = array(); |
|
| 2214 | + if (!isset($globalStatsFilters) || $globalStatsFilters == '') { |
|
| 2215 | + $globalStatsFilters = array(); |
|
| 2216 | + } |
|
| 1916 | 2217 | foreach ($globalStatsFilters as $name => $filter) { |
| 1917 | 2218 | //$filter_name = $filter['name']; |
| 1918 | 2219 | $filter_name = $name; |
| 1919 | 2220 | $reset = false; |
| 1920 | 2221 | $last_update = $this->getLastStatsUpdate('last_update_stats_'.$filter_name); |
| 1921 | 2222 | if (isset($filter['resetall']) && isset($last_update[0]['value']) && strtotime($filter['resetall']) > strtotime($last_update[0]['value'])) { |
| 1922 | - if ($globalDebug) echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 2223 | + if ($globalDebug) { |
|
| 2224 | + echo '!!! Delete stats for filter '.$filter_name.' !!!'."\n"; |
|
| 2225 | + } |
|
| 1923 | 2226 | $this->deleteOldStats($filter_name); |
| 1924 | 2227 | unset($last_update); |
| 1925 | 2228 | } |
@@ -1938,7 +2241,9 @@ discard block |
||
| 1938 | 2241 | |
| 1939 | 2242 | |
| 1940 | 2243 | // Count by filter |
| 1941 | - if ($globalDebug) echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2244 | + if ($globalDebug) { |
|
| 2245 | + echo '--- Stats for filter '.$filter_name.' ---'."\n"; |
|
| 2246 | + } |
|
| 1942 | 2247 | $Spotter = new Spotter($this->db); |
| 1943 | 2248 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day,$filter); |
| 1944 | 2249 | foreach ($alldata as $number) { |
@@ -1975,7 +2280,9 @@ discard block |
||
| 1975 | 2280 | $icao = $value['airport_departure_icao']; |
| 1976 | 2281 | if (isset($alldata[$icao])) { |
| 1977 | 2282 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
| 1978 | - } else $alldata[$icao] = $value; |
|
| 2283 | + } else { |
|
| 2284 | + $alldata[$icao] = $value; |
|
| 2285 | + } |
|
| 1979 | 2286 | } |
| 1980 | 2287 | $count = array(); |
| 1981 | 2288 | foreach ($alldata as $key => $row) { |
@@ -1996,7 +2303,9 @@ discard block |
||
| 1996 | 2303 | $icao = $value['airport_arrival_icao']; |
| 1997 | 2304 | if (isset($alldata[$icao])) { |
| 1998 | 2305 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
| 1999 | - } else $alldata[$icao] = $value; |
|
| 2306 | + } else { |
|
| 2307 | + $alldata[$icao] = $value; |
|
| 2308 | + } |
|
| 2000 | 2309 | } |
| 2001 | 2310 | $count = array(); |
| 2002 | 2311 | foreach ($alldata as $key => $row) { |
@@ -2010,7 +2319,9 @@ discard block |
||
| 2010 | 2319 | $alldata = $Spotter->countAllMonths($filter); |
| 2011 | 2320 | $lastyear = false; |
| 2012 | 2321 | foreach ($alldata as $number) { |
| 2013 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
| 2322 | + if ($number['year_name'] != date('Y')) { |
|
| 2323 | + $lastyear = true; |
|
| 2324 | + } |
|
| 2014 | 2325 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name'])),'',$filter_name); |
| 2015 | 2326 | } |
| 2016 | 2327 | $alldata = $Spotter->countAllMonthsOwners($filter); |