Completed
Push — master ( 39e860...0f5d36 )
by Yannick
05:38
created
statistics-date.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 
14 14
 require_once('header.php');
Please login to merge, or discard this patch.
statistics-callsign.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT);
14 14
 $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT);
Please login to merge, or discard this patch.
statistics-year.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 
14 14
 require_once('header.php');
Please login to merge, or discard this patch.
statistics-country.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 if (!isset($filter_name)) $filter_name = '';
9 9
 $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
10 10
 if ($airline_icao == '' && isset($globalFilter)) {
11
-    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
11
+	if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
12 12
 }
13 13
 
14 14
 require_once('header.php');
Please login to merge, or discard this patch.
require/class.METAR.php 1 patch
Indentation   +263 added lines, -263 removed lines patch added patch discarded remove patch
@@ -7,109 +7,109 @@  discard block
 block discarded – undo
7 7
 	public $db;
8 8
 	
9 9
 	protected $texts = Array(
10
-	    'MI' => 'Shallow',
11
-	    'PR' => 'Partial',
12
-	    'BC' => 'Low drifting',
13
-	    'BL' => 'Blowing',
14
-	    'SH' => 'Showers',
15
-	    'TS' => 'Thunderstorm',
16
-	    'FZ' => 'Freezing',
17
-	    'DZ' => 'Drizzle',
18
-	    'RA' => 'Rain',
19
-	    'SN' => 'Snow',
20
-	    'SG' => 'Snow Grains',
21
-	    'IC' => 'Ice crystals',
22
-	    'PL' => 'Ice pellets',
23
-	    'GR' => 'Hail',
24
-	    'GS' => 'Small hail',
25
-	    'UP' => 'Unknown',
26
-	    'BR' => 'Mist',
27
-	    'FG' => 'Fog',
28
-	    'FU' => 'Smoke',
29
-	    'VA' => 'Volcanic ash',
30
-	    'DU' => 'Widespread dust',
31
-	    'SA' => 'Sand',
32
-	    'HZ' => 'Haze',
33
-	    'PY' => 'Spray',
34
-	    'PO' => 'Well developed dust / sand whirls',
35
-	    'SQ' => 'Squalls',
36
-	    'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
-	    'SS' => 'Sandstorm',
38
-	    'DS' => 'Duststorm'
10
+		'MI' => 'Shallow',
11
+		'PR' => 'Partial',
12
+		'BC' => 'Low drifting',
13
+		'BL' => 'Blowing',
14
+		'SH' => 'Showers',
15
+		'TS' => 'Thunderstorm',
16
+		'FZ' => 'Freezing',
17
+		'DZ' => 'Drizzle',
18
+		'RA' => 'Rain',
19
+		'SN' => 'Snow',
20
+		'SG' => 'Snow Grains',
21
+		'IC' => 'Ice crystals',
22
+		'PL' => 'Ice pellets',
23
+		'GR' => 'Hail',
24
+		'GS' => 'Small hail',
25
+		'UP' => 'Unknown',
26
+		'BR' => 'Mist',
27
+		'FG' => 'Fog',
28
+		'FU' => 'Smoke',
29
+		'VA' => 'Volcanic ash',
30
+		'DU' => 'Widespread dust',
31
+		'SA' => 'Sand',
32
+		'HZ' => 'Haze',
33
+		'PY' => 'Spray',
34
+		'PO' => 'Well developed dust / sand whirls',
35
+		'SQ' => 'Squalls',
36
+		'FC' => 'Funnel clouds inc tornadoes or waterspouts',
37
+		'SS' => 'Sandstorm',
38
+		'DS' => 'Duststorm'
39 39
 	);
40 40
 	
41 41
 	public function __construct($dbc = null) {
42
-                $Connection = new Connection($dbc);
43
-                $this->db = $Connection->db;
44
-        }
42
+				$Connection = new Connection($dbc);
43
+				$this->db = $Connection->db;
44
+		}
45 45
 
46
-       public static function check_last_update() {
47
-    		global $globalDBdriver;
48
-    		if ($globalDBdriver == 'mysql') {
46
+	   public static function check_last_update() {
47
+			global $globalDBdriver;
48
+			if ($globalDBdriver == 'mysql') {
49 49
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value > DATE_SUB(NOW(), INTERVAL 20 MINUTE)";
50 50
 		} else {
51 51
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_metar' AND value::timestamp > CURRENT_TIMESTAMP - INTERVAL '20 MINUTES'";
52 52
 		}
53
-                try {
54
-                        $Connection = new Connection();
55
-                        $sth = $Connection->db->prepare($query);
56
-                        $sth->execute();
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-                $row = $sth->fetch(PDO::FETCH_ASSOC);
61
-                $sth->closeCursor();
62
-                if ($row['nb'] > 0) return false;
63
-                else return true;
64
-        }
53
+				try {
54
+						$Connection = new Connection();
55
+						$sth = $Connection->db->prepare($query);
56
+						$sth->execute();
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+				$row = $sth->fetch(PDO::FETCH_ASSOC);
61
+				$sth->closeCursor();
62
+				if ($row['nb'] > 0) return false;
63
+				else return true;
64
+		}
65 65
 
66
-        public static function insert_last_update() {
67
-                $query = "DELETE FROM config WHERE name = 'last_update_metar';
66
+		public static function insert_last_update() {
67
+				$query = "DELETE FROM config WHERE name = 'last_update_metar';
68 68
                         INSERT INTO config (name,value) VALUES ('last_update_metar',NOW());";
69
-                try {
70
-                        $Connection = new Connection();
71
-                        $sth = $Connection->db->prepare($query);
72
-                        $sth->execute();
73
-                } catch(PDOException $e) {
74
-                        return "error : ".$e->getMessage();
75
-                }
76
-        }
69
+				try {
70
+						$Connection = new Connection();
71
+						$sth = $Connection->db->prepare($query);
72
+						$sth->execute();
73
+				} catch(PDOException $e) {
74
+						return "error : ".$e->getMessage();
75
+				}
76
+		}
77 77
 
78 78
 
79 79
         
80
-        public function parse($data) {
81
-    		//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
-    		$codes = implode('|', array_keys($this->texts));
83
-    		$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
-    		//$pieces = explode(' ',$data);
85
-    		$pieces = preg_split('/\s/',$data);
86
-    		$pos = 0;
87
-    		if ($pieces[0] == 'METAR') $pos++;
88
-    		elseif ($pieces[0] == 'SPECI') $pos++;
89
-    		if (strlen($pieces[$pos]) != 4) $pos++;
90
-    		$result = array();
91
-    		$result['location'] = $pieces[$pos];
92
-    		$pos++;
93
-    		$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
-    		$result['time'] = substr($pieces[$pos],2,4);
95
-    		$c = count($pieces);
96
-    		for($pos++; $pos < $c; $pos++) {
97
-    			$piece = $pieces[$pos];
98
-    			if ($piece == 'RMK') break;
99
-    			if ($piece == 'AUTO') $result['auto'] = true;
100
-    			if ($piece == 'COR') $result['correction'] = true;
101
-    			// Wind Speed
102
-    			if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
-    				$result['wind']['direction'] = (float)$matches[1];
80
+		public function parse($data) {
81
+			//$data = str_replace(array('\n','\r','\r','\n'),'',$data);
82
+			$codes = implode('|', array_keys($this->texts));
83
+			$regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#';
84
+			//$pieces = explode(' ',$data);
85
+			$pieces = preg_split('/\s/',$data);
86
+			$pos = 0;
87
+			if ($pieces[0] == 'METAR') $pos++;
88
+			elseif ($pieces[0] == 'SPECI') $pos++;
89
+			if (strlen($pieces[$pos]) != 4) $pos++;
90
+			$result = array();
91
+			$result['location'] = $pieces[$pos];
92
+			$pos++;
93
+			$result['dayofmonth'] = substr($pieces[$pos],0,2);
94
+			$result['time'] = substr($pieces[$pos],2,4);
95
+			$c = count($pieces);
96
+			for($pos++; $pos < $c; $pos++) {
97
+				$piece = $pieces[$pos];
98
+				if ($piece == 'RMK') break;
99
+				if ($piece == 'AUTO') $result['auto'] = true;
100
+				if ($piece == 'COR') $result['correction'] = true;
101
+				// Wind Speed
102
+				if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) {
103
+					$result['wind']['direction'] = (float)$matches[1];
104 104
 				$result['wind']['unit'] = $matches[4];
105
-    				if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
-    				elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
-    				elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
105
+					if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2);
106
+					elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2);
107
+					elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2);
108 108
 				$result['wind']['gust'] = (float)$matches[3];
109 109
 				$result['wind']['unit'] = $matches[4];
110 110
 				$result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0;
111 111
 				$result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0;
112
-    			}
112
+				}
113 113
 
114 114
 /*    			if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) {
115 115
     				$result['wind_direction'] = (float)$matches[1];
@@ -126,35 +126,35 @@  discard block
 block discarded – undo
126 126
     				}
127 127
     			}
128 128
     			*/
129
-    			// Temperature
130
-    			if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
-    				$temp = (float)$matches[1];
129
+				// Temperature
130
+				if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) {
131
+					$temp = (float)$matches[1];
132 132
 				if ($matches[1]{0} == 'M') {
133 133
 					$temp = ((float)substr($matches[1], 1)) * -1;
134 134
 				}
135
-    				$result['temperature'] = $temp;
136
-    				$dew = (float)$matches[2];
135
+					$result['temperature'] = $temp;
136
+					$dew = (float)$matches[2];
137 137
 				if ($matches[2]{0} == 'M') {
138 138
 					$dew = ((float)substr($matches[2], 1)) * -1;
139 139
 				}
140 140
 				$result['dew'] = $dew;
141
-    			}
142
-    			// QNH
143
-    			if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
-    			// #^(Q|A)(////|[0-9]{4})( )#
145
-    				if ($matches[1] == 'Q') {
146
-    					// hPa
147
-    					$result['QNH'] = $matches[2];
148
-    				} else {
149
-    					// inHg
150
-    					$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151 141
 				}
152
-    				/*
142
+				// QNH
143
+				if (preg_match('#^(A|Q)([0-9]{4})$#', $piece, $matches)) {
144
+				// #^(Q|A)(////|[0-9]{4})( )#
145
+					if ($matches[1] == 'Q') {
146
+						// hPa
147
+						$result['QNH'] = $matches[2];
148
+					} else {
149
+						// inHg
150
+						$result['QNH'] = round(($matches[2] / 100)*33.86389,2);
151
+				}
152
+					/*
153 153
     				$result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100);
154 154
     				$result['QNH_format'] = $matches[1] == 'Q' ? 'hPa' : 'inHg';
155 155
     				*/
156
-    			}
157
-                     /*
156
+				}
157
+					 /*
158 158
     			// Wind Direction
159 159
     			if (preg_match('#^([0-9]{3})V([0-9]{3})$#', $piece, $matches)) {
160 160
     				$result['wind_direction'] = $matches[1];
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
     				$result['speed_variable'] = $matches[1];
166 166
     			}
167 167
     			*/
168
-    			// Visibility
169
-    			if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
-    				if (isset($matches[3]) && strlen($matches[3]) > 0) {
168
+				// Visibility
169
+				if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) {
170
+					if (isset($matches[3]) && strlen($matches[3]) > 0) {
171 171
 					$result['visibility'] = (float)$matches[3] * 1609.34;
172 172
 				} else {
173 173
 					if ($matches[1] == '9999') {
@@ -180,28 +180,28 @@  discard block
 block discarded – undo
180 180
 					$result['visibility'] = '> 10000';
181 181
 					$result['weather'] = "CAVOK";
182 182
 				}
183
-    			}
184
-    			// Cloud Coverage
185
-    			if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
-    				//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
-    				$type = $matches[1];
188
-    				$cloud = array();
189
-    				if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
-    				elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
-    				elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
-    				elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
-    				elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
-    				elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
-    				elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
-    				elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
-    				$cloud['type_code'] = $type;
198
-    				$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
-    				$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
-    				$result['cloud'][] = $cloud;
201
-    			}
202
-    			// RVR
203
-    			 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
-    				$rvr = array();
183
+				}
184
+				// Cloud Coverage
185
+				if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) {
186
+					//$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : '');
187
+					$type = $matches[1];
188
+					$cloud = array();
189
+					if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear';
190
+					elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)';
191
+					elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud';
192
+					elseif ($type == 'FEW') $cloud['type'] = 'Few';
193
+					elseif ($type == 'SCT') $cloud['type'] = 'Scattered';
194
+					elseif ($type == 'BKN') $cloud['type'] = 'Broken';
195
+					elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage';
196
+					elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility';
197
+					$cloud['type_code'] = $type;
198
+					$cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048);
199
+					$cloud['significant'] = isset($matches[3]) ? $matches[3] : '';
200
+					$result['cloud'][] = $cloud;
201
+				}
202
+				// RVR
203
+				 if (preg_match('#^(R.+)/([M|P])?(\d{4})(?:V(\d+)|[UDN])?(FT)?$#', $piece, $matches)) {
204
+					$rvr = array();
205 205
 				$rvr['runway'] = $matches[1];
206 206
 				$rvr['assessment'] = $matches[2];
207 207
 				$rvr['rvr'] = $matches[3];
@@ -210,33 +210,33 @@  discard block
 block discarded – undo
210 210
 				$result['RVR'] = $rvr;
211 211
 			}
212 212
     			
213
-    			//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
-    			if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
-    				//print_r($matches);
216
-    				// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
-    				$result['RVR']['runway'] = $matches[1];
218
-        			$result['RVR']['deposits'] = $matches[2];
219
-        			$result['RVR']['extent'] = $matches[3];
220
-        			$result['RVR']['depth'] = $matches[4];
221
-        			$result['RVR']['friction'] = $matches[5];
222
-    			}
223
-    			if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
-    				//echo $piece;
225
-    				//print_r($matches);
226
-    				if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
-    				else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
213
+				//if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
214
+				if (preg_match('#^R(\d{2}[LRC]?)/([\d/])([\d/])([\d/]{2})([\d/]{2})$#', $piece, $matches)) {
215
+					//print_r($matches);
216
+					// https://github.com/davidmegginson/metar-taf/blob/master/Metar.php
217
+					$result['RVR']['runway'] = $matches[1];
218
+					$result['RVR']['deposits'] = $matches[2];
219
+					$result['RVR']['extent'] = $matches[3];
220
+					$result['RVR']['depth'] = $matches[4];
221
+					$result['RVR']['friction'] = $matches[5];
222
+				}
223
+				if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) {
224
+					//echo $piece;
225
+					//print_r($matches);
226
+					if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M');
227
+					else $range = array('exact' => (float)$matches[2], 'unit' => 'M');
228 228
 				if (isset($matches[3])) {
229 229
 					$range = Array(
230
-					    'from' => (float)$matches[2],
231
-					    'to'   => (float)$matches[4],
232
-					    'unit' => $matches[5] ? 'FT' : 'M'
230
+						'from' => (float)$matches[2],
231
+						'to'   => (float)$matches[4],
232
+						'unit' => $matches[5] ? 'FT' : 'M'
233 233
 					);
234 234
 				}
235 235
 				$result['RVR'] = $matches[1];
236 236
 				$result['RVR_range'] = $range;
237
-    			}
238
-    			// Weather
239
-    			if (preg_match($regWeather, $piece, $matches)) {
237
+				}
238
+				// Weather
239
+				if (preg_match($regWeather, $piece, $matches)) {
240 240
 				$text = Array();
241 241
 				switch ($matches[1]) {
242 242
 					case '+':
@@ -259,35 +259,35 @@  discard block
 block discarded – undo
259 259
 				}
260 260
 				if (!isset($result['weather'])) $result['weather'] = implode(' ', $text);
261 261
 				else $result['weather'] = $result['weather'].' / '.implode(' ', $text);
262
-    			}
263
-    		}
264
-    		return $result;
262
+				}
263
+			}
264
+			return $result;
265 265
         
266
-        }
266
+		}
267 267
         
268 268
 	public function getMETAR($icao) {
269
-    		global $globalMETARcycle, $globalDBdriver;
270
-    		if (isset($globalMETARcycle) && $globalMETARcycle) {
271
-            		$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
-                } else {
273
-            		if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
-            		else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
-                }
276
-                $query_values = array(':icao' => $icao);
277
-                 try {
278
-                        $sth = $this->db->prepare($query);
279
-                        $sth->execute($query_values);
280
-                } catch(PDOException $e) {
281
-                        return "error : ".$e->getMessage();
282
-                }
283
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
-                if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
-            		$all = $this->downloadMETAR($icao);
286
-                }
287
-                return $all;
288
-        }
269
+			global $globalMETARcycle, $globalDBdriver;
270
+			if (isset($globalMETARcycle) && $globalMETARcycle) {
271
+					$query = "SELECT * FROM metar WHERE metar_location = :icao";
272
+				} else {
273
+					if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1";
274
+					else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1";
275
+				}
276
+				$query_values = array(':icao' => $icao);
277
+				 try {
278
+						$sth = $this->db->prepare($query);
279
+						$sth->execute($query_values);
280
+				} catch(PDOException $e) {
281
+						return "error : ".$e->getMessage();
282
+				}
283
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
284
+				if ((!isset($globalMETARcycle) || $globalMETARcycle === false) && count($all) == 0) {
285
+					$all = $this->downloadMETAR($icao);
286
+				}
287
+				return $all;
288
+		}
289 289
 
290
-       public function addMETAR($location,$metar,$date) {
290
+	   public function addMETAR($location,$metar,$date) {
291 291
 		global $globalDBdriver;
292 292
 		$date = date('Y-m-d H:i:s',strtotime($date));
293 293
 		if ($globalDBdriver == 'mysql') {
@@ -295,106 +295,106 @@  discard block
 block discarded – undo
295 295
 		} else {
296 296
 			$query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);";
297 297
 		}
298
-                $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
-                 try {
300
-                        $sth = $this->db->prepare($query);
301
-                        $sth->execute($query_values);
302
-                } catch(PDOException $e) {
303
-                        return "error : ".$e->getMessage();
304
-                }
305
-        }
298
+				$query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar));
299
+				 try {
300
+						$sth = $this->db->prepare($query);
301
+						$sth->execute($query_values);
302
+				} catch(PDOException $e) {
303
+						return "error : ".$e->getMessage();
304
+				}
305
+		}
306 306
 
307
-       public function deleteMETAR($id) {
308
-                $query = "DELETE FROM metar WHERE id = :id";
309
-                $query_values = array(':id' => $id);
310
-                 try {
311
-                        $sth = $this->db->prepare($query);
312
-                        $sth->execute($query_values);
313
-                } catch(PDOException $e) {
314
-                        return "error : ".$e->getMessage();
315
-                }
316
-        }
317
-       public function deleteAllMETARLocation() {
318
-                $query = "DELETE FROM metar";
319
-                 try {
320
-                        $sth = $this->db->prepare($query);
321
-                        $sth->execute();
322
-                } catch(PDOException $e) {
323
-                        return "error : ".$e->getMessage();
324
-                }
325
-        }
307
+	   public function deleteMETAR($id) {
308
+				$query = "DELETE FROM metar WHERE id = :id";
309
+				$query_values = array(':id' => $id);
310
+				 try {
311
+						$sth = $this->db->prepare($query);
312
+						$sth->execute($query_values);
313
+				} catch(PDOException $e) {
314
+						return "error : ".$e->getMessage();
315
+				}
316
+		}
317
+	   public function deleteAllMETARLocation() {
318
+				$query = "DELETE FROM metar";
319
+				 try {
320
+						$sth = $this->db->prepare($query);
321
+						$sth->execute();
322
+				} catch(PDOException $e) {
323
+						return "error : ".$e->getMessage();
324
+				}
325
+		}
326 326
         
327
-        public function addMETARCycle() {
328
-    		global $globalDebug, $globalIVAO, $globalTransaction;
329
-    		if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
-    		date_default_timezone_set("UTC");
331
-    		$Common = new Common();
332
-    		if (isset($globalIVAO) && $globalIVAO) {
333
-        		//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
327
+		public function addMETARCycle() {
328
+			global $globalDebug, $globalIVAO, $globalTransaction;
329
+			if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle...";
330
+			date_default_timezone_set("UTC");
331
+			$Common = new Common();
332
+			if (isset($globalIVAO) && $globalIVAO) {
333
+				//$cycle = $Common->getData('http://wx.ivao.aero/metar.php');
334 334
 			$Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt');
335
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
-    		} else {
335
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r");
336
+			} else {
337 337
 			//$cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT');
338 338
 			$Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT');
339
-    			$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
-    		}
341
-    		if ($handle) {
339
+				$handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r");
340
+			}
341
+			if ($handle) {
342 342
 			if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB...";
343 343
 			$date = '';
344
-    			//foreach(explode("\n",$cycle) as $line) {
345
-    			if ($globalTransaction) $this->db->beginTransaction();
346
-	    		while(($line = fgets($handle,4096)) !== false) {
344
+				//foreach(explode("\n",$cycle) as $line) {
345
+				if ($globalTransaction) $this->db->beginTransaction();
346
+				while(($line = fgets($handle,4096)) !== false) {
347 347
 				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
348 348
 					$date = $line;
349
-    				} elseif ($line != '') {
350
-    				    //$this->parse($line);
351
-    				    if ($date == '') $date = date('Y/m/d H:m');
352
-        			    $pos = 0;
353
-        			    $pieces = preg_split('/\s/',$line);
354
-        			    if ($pieces[0] == 'METAR') $pos++;
355
-        			    if (strlen($pieces[$pos]) != 4) $pos++;
356
-		        	    $location = $pieces[$pos];
357
-        	        	    echo $this->addMETAR($location,$line,$date);
358
-    				}
359
-    			}
360
-    			fclose($handle);
361
-    			if ($globalTransaction) $this->db->commit();
362
-    		}
363
-    		if (isset($globalDebug) && $globalDebug) echo "Done\n";
349
+					} elseif ($line != '') {
350
+						//$this->parse($line);
351
+						if ($date == '') $date = date('Y/m/d H:m');
352
+						$pos = 0;
353
+						$pieces = preg_split('/\s/',$line);
354
+						if ($pieces[0] == 'METAR') $pos++;
355
+						if (strlen($pieces[$pos]) != 4) $pos++;
356
+						$location = $pieces[$pos];
357
+							echo $this->addMETAR($location,$line,$date);
358
+					}
359
+				}
360
+				fclose($handle);
361
+				if ($globalTransaction) $this->db->commit();
362
+			}
363
+			if (isset($globalDebug) && $globalDebug) echo "Done\n";
364 364
         
365
-        }
366
-        public function downloadMETAR($icao) {
367
-    		global $globalMETARurl;
368
-    		if ($globalMETARurl == '') return array();
369
-    		date_default_timezone_set("UTC");
370
-    		$Common = new Common();
371
-    		$url = str_replace('{icao}',$icao,$globalMETARurl);
372
-    		$cycle = $Common->getData($url);
373
-    		$date = '';
374
-    		foreach(explode("\n",$cycle) as $line) {
375
-    			if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
376
-    				//echo "date : ".$line."\n";
377
-    				$date = $line;
378
-    			} 
379
-    			if ($line != '') {
380
-    			    //$this->parse($line);
381
-    			    //echo $line;
382
-    			    if ($date == '') $date = date('Y/m/d H:m');
383
-    			    $pos = 0;
384
-    			    $pieces = preg_split('/\s/',$line);
385
-    			    if ($pieces[0] == 'METAR') $pos++;
386
-    			    if (strlen($pieces[$pos]) != 4) $pos++;
387
-	        	    $location = $pieces[$pos];
388
-	        	    if (strlen($location == 4)) {
389
-	        		$this->addMETAR($location,$line,$date);
390
-	        		return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
-	        	    } else return array();
392
-    			}
393
-    			//echo $line."\n";
394
-    		}
395
-    		return array();
365
+		}
366
+		public function downloadMETAR($icao) {
367
+			global $globalMETARurl;
368
+			if ($globalMETARurl == '') return array();
369
+			date_default_timezone_set("UTC");
370
+			$Common = new Common();
371
+			$url = str_replace('{icao}',$icao,$globalMETARurl);
372
+			$cycle = $Common->getData($url);
373
+			$date = '';
374
+			foreach(explode("\n",$cycle) as $line) {
375
+				if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) {
376
+					//echo "date : ".$line."\n";
377
+					$date = $line;
378
+				} 
379
+				if ($line != '') {
380
+					//$this->parse($line);
381
+					//echo $line;
382
+					if ($date == '') $date = date('Y/m/d H:m');
383
+					$pos = 0;
384
+					$pieces = preg_split('/\s/',$line);
385
+					if ($pieces[0] == 'METAR') $pos++;
386
+					if (strlen($pieces[$pos]) != 4) $pos++;
387
+					$location = $pieces[$pos];
388
+					if (strlen($location == 4)) {
389
+					$this->addMETAR($location,$line,$date);
390
+					return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line));
391
+					} else return array();
392
+				}
393
+				//echo $line."\n";
394
+			}
395
+			return array();
396 396
         
397
-        }
397
+		}
398 398
 }
399 399
 /*
400 400
 $METAR = new METAR();
Please login to merge, or discard this patch.
require/class.SpotterArchive.php 1 patch
Indentation   +633 added lines, -633 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
 		$this->db = $Connection->db;
9 9
 	}
10 10
 
11
-    /**
12
-    * Get SQL query part for filter used
13
-    * @param Array $filter the filter
14
-    * @return Array the SQL part
15
-    */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
11
+	/**
12
+	 * Get SQL query part for filter used
13
+	 * @param Array $filter the filter
14
+	 * @return Array the SQL part
15
+	 */
16
+	public function getFilter($filter = array(),$where = false,$and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
@@ -27,58 +27,58 @@  discard block
 block discarded – undo
27 27
 	$filter_query_join = '';
28 28
 	$filter_query_where = '';
29 29
 	foreach($filters as $flt) {
30
-	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
30
+		if (isset($flt['airlines']) && !empty($flt['airlines'])) {
31 31
 		if ($flt['airlines'][0] != '') {
32
-		    if (isset($flt['source'])) {
32
+			if (isset($flt['source'])) {
33 33
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
34
-		    } else {
34
+			} else {
35 35
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
36
-		    }
36
+			}
37
+		}
37 38
 		}
38
-	    }
39
-	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
39
+		if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
40 40
 		if (isset($flt['source'])) {
41
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
41
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
42 42
 		} else {
43
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
43
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
44 44
 		}
45
-	    }
46
-	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
45
+		}
46
+		if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']))) {
47 47
 		if (isset($flt['source'])) {
48
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
48
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
49
+		}
49 50
 		}
50
-	    }
51 51
 	}
52 52
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
53
-	    if ($filter['airlines'][0] != '') {
53
+		if ($filter['airlines'][0] != '') {
54 54
 		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
55
-	    }
55
+		}
56 56
 	}
57 57
 	
58 58
 	if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
59
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
59
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
60 60
 	}
61 61
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
62
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
62
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) so ON so.flightaware_id = spotter_archive_output.flightaware_id";
63 63
 	}
64 64
 	if (isset($filter['source']) && !empty($filter['source'])) {
65
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
65
+		$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
66 66
 	}
67 67
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
68
-	    $filter_query_where = " WHERE ident = '".$filter['ident']."'";
68
+		$filter_query_where = " WHERE ident = '".$filter['ident']."'";
69 69
 	}
70 70
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
71
-	    if ($filter_query_where == '') {
71
+		if ($filter_query_where == '') {
72 72
 		$filter_query_where = " WHERE format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
73
-	    } else {
73
+		} else {
74 74
 		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
75
-	    }
75
+		}
76 76
 	}
77 77
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
78 78
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
79 79
 	$filter_query = $filter_query_join.$filter_query_where;
80 80
 	return $filter_query;
81
-    }
81
+	}
82 82
 
83 83
 	// Spotter_archive
84 84
 	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
@@ -109,44 +109,44 @@  discard block
 block discarded – undo
109 109
 	}
110 110
 
111 111
 
112
-        /**
113
-        * Gets all the spotter information based on a particular callsign
114
-        *
115
-        * @return Array the spotter information
116
-        *
117
-        */
118
-        public function getLastArchiveSpotterDataByIdent($ident)
119
-        {
112
+		/**
113
+		 * Gets all the spotter information based on a particular callsign
114
+		 *
115
+		 * @return Array the spotter information
116
+		 *
117
+		 */
118
+		public function getLastArchiveSpotterDataByIdent($ident)
119
+		{
120 120
 		$Spotter = new Spotter($this->db);
121
-                date_default_timezone_set('UTC');
121
+				date_default_timezone_set('UTC');
122 122
 
123
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
124
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
125
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
123
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
124
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
125
+				$query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
126 126
 
127
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
127
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
128 128
 
129
-                return $spotter_array;
130
-        }
129
+				return $spotter_array;
130
+		}
131 131
 
132 132
 
133
-        /**
134
-        * Gets last the spotter information based on a particular id
135
-        *
136
-        * @return Array the spotter information
137
-        *
138
-        */
139
-        public function getLastArchiveSpotterDataById($id)
140
-        {
141
-    		$Spotter = new Spotter($this->db);
142
-                date_default_timezone_set('UTC');
143
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
144
-                //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
145
-                //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
146
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
133
+		/**
134
+		 * Gets last the spotter information based on a particular id
135
+		 *
136
+		 * @return Array the spotter information
137
+		 *
138
+		 */
139
+		public function getLastArchiveSpotterDataById($id)
140
+		{
141
+			$Spotter = new Spotter($this->db);
142
+				date_default_timezone_set('UTC');
143
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
144
+				//$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
145
+				//$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
146
+				$query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
147 147
 
148 148
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
149
-                  /*
149
+				  /*
150 150
                 try {
151 151
                         $Connection = new Connection();
152 152
                         $sth = Connection->$db->prepare($query);
@@ -156,232 +156,232 @@  discard block
 block discarded – undo
156 156
                 }
157 157
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
158 158
                 */
159
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
160
-
161
-                return $spotter_array;
162
-        }
163
-
164
-        /**
165
-        * Gets all the spotter information based on a particular id
166
-        *
167
-        * @return Array the spotter information
168
-        *
169
-        */
170
-        public function getAllArchiveSpotterDataById($id)
171
-        {
172
-                date_default_timezone_set('UTC');
173
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
174
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
159
+				$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
160
+
161
+				return $spotter_array;
162
+		}
163
+
164
+		/**
165
+		 * Gets all the spotter information based on a particular id
166
+		 *
167
+		 * @return Array the spotter information
168
+		 *
169
+		 */
170
+		public function getAllArchiveSpotterDataById($id)
171
+		{
172
+				date_default_timezone_set('UTC');
173
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
174
+				$query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id";
175 175
 
176 176
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
177 177
 
178
-                try {
179
-                        $sth = $this->db->prepare($query);
180
-                        $sth->execute(array(':id' => $id));
181
-                } catch(PDOException $e) {
182
-                        echo $e->getMessage();
183
-                        die;
184
-                }
185
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
186
-
187
-                return $spotter_array;
188
-        }
189
-
190
-        /**
191
-        * Gets coordinate & time spotter information based on a particular id
192
-        *
193
-        * @return Array the spotter information
194
-        *
195
-        */
196
-        public function getCoordArchiveSpotterDataById($id)
197
-        {
198
-                date_default_timezone_set('UTC');
199
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
200
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
178
+				try {
179
+						$sth = $this->db->prepare($query);
180
+						$sth->execute(array(':id' => $id));
181
+				} catch(PDOException $e) {
182
+						echo $e->getMessage();
183
+						die;
184
+				}
185
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
186
+
187
+				return $spotter_array;
188
+		}
189
+
190
+		/**
191
+		 * Gets coordinate & time spotter information based on a particular id
192
+		 *
193
+		 * @return Array the spotter information
194
+		 *
195
+		 */
196
+		public function getCoordArchiveSpotterDataById($id)
197
+		{
198
+				date_default_timezone_set('UTC');
199
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
200
+				$query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
201 201
 
202 202
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
203 203
 
204
-                try {
205
-                        $sth = $this->db->prepare($query);
206
-                        $sth->execute(array(':id' => $id));
207
-                } catch(PDOException $e) {
208
-                        echo $e->getMessage();
209
-                        die;
210
-                }
211
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
204
+				try {
205
+						$sth = $this->db->prepare($query);
206
+						$sth->execute(array(':id' => $id));
207
+				} catch(PDOException $e) {
208
+						echo $e->getMessage();
209
+						die;
210
+				}
211
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
212 212
 
213
-                return $spotter_array;
214
-        }
213
+				return $spotter_array;
214
+		}
215 215
 
216 216
 
217
-        /**
218
-        * Gets altitude information based on a particular callsign
219
-        *
220
-        * @return Array the spotter information
221
-        *
222
-        */
223
-        public function getAltitudeArchiveSpotterDataByIdent($ident)
224
-        {
217
+		/**
218
+		 * Gets altitude information based on a particular callsign
219
+		 *
220
+		 * @return Array the spotter information
221
+		 *
222
+		 */
223
+		public function getAltitudeArchiveSpotterDataByIdent($ident)
224
+		{
225 225
 
226
-                date_default_timezone_set('UTC');
226
+				date_default_timezone_set('UTC');
227 227
 
228
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
229
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
228
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
229
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
230 230
 
231
-                try {
232
-                        $sth = $this->db->prepare($query);
233
-                        $sth->execute(array(':ident' => $ident));
234
-                } catch(PDOException $e) {
235
-                        echo $e->getMessage();
236
-                        die;
237
-                }
238
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
231
+				try {
232
+						$sth = $this->db->prepare($query);
233
+						$sth->execute(array(':ident' => $ident));
234
+				} catch(PDOException $e) {
235
+						echo $e->getMessage();
236
+						die;
237
+				}
238
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
239 239
 
240
-                return $spotter_array;
241
-        }
240
+				return $spotter_array;
241
+		}
242 242
 
243
-        /**
244
-        * Gets altitude information based on a particular id
245
-        *
246
-        * @return Array the spotter information
247
-        *
248
-        */
249
-        public function getAltitudeArchiveSpotterDataById($id)
250
-        {
243
+		/**
244
+		 * Gets altitude information based on a particular id
245
+		 *
246
+		 * @return Array the spotter information
247
+		 *
248
+		 */
249
+		public function getAltitudeArchiveSpotterDataById($id)
250
+		{
251 251
 
252
-                date_default_timezone_set('UTC');
252
+				date_default_timezone_set('UTC');
253 253
 
254
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
255
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
254
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
255
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
256 256
 
257
-                try {
258
-                        $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':id' => $id));
260
-                } catch(PDOException $e) {
261
-                        echo $e->getMessage();
262
-                        die;
263
-                }
264
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
257
+				try {
258
+						$sth = $this->db->prepare($query);
259
+						$sth->execute(array(':id' => $id));
260
+				} catch(PDOException $e) {
261
+						echo $e->getMessage();
262
+						die;
263
+				}
264
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
265 265
 
266
-                return $spotter_array;
267
-        }
266
+				return $spotter_array;
267
+		}
268 268
 
269
-        /**
270
-        * Gets altitude & speed information based on a particular id
271
-        *
272
-        * @return Array the spotter information
273
-        *
274
-        */
275
-        public function getAltitudeSpeedArchiveSpotterDataById($id)
276
-        {
269
+		/**
270
+		 * Gets altitude & speed information based on a particular id
271
+		 *
272
+		 * @return Array the spotter information
273
+		 *
274
+		 */
275
+		public function getAltitudeSpeedArchiveSpotterDataById($id)
276
+		{
277 277
 
278
-                date_default_timezone_set('UTC');
278
+				date_default_timezone_set('UTC');
279 279
 
280
-                $id = filter_var($id, FILTER_SANITIZE_STRING);
281
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
280
+				$id = filter_var($id, FILTER_SANITIZE_STRING);
281
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
282 282
 
283
-                try {
284
-                        $sth = $this->db->prepare($query);
285
-                        $sth->execute(array(':id' => $id));
286
-                } catch(PDOException $e) {
287
-                        echo $e->getMessage();
288
-                        die;
289
-                }
290
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
283
+				try {
284
+						$sth = $this->db->prepare($query);
285
+						$sth->execute(array(':id' => $id));
286
+				} catch(PDOException $e) {
287
+						echo $e->getMessage();
288
+						die;
289
+				}
290
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
291 291
 
292
-                return $spotter_array;
293
-        }
292
+				return $spotter_array;
293
+		}
294 294
 
295 295
 
296
-        /**
297
-        * Gets altitude information based on a particular callsign
298
-        *
299
-        * @return Array the spotter information
300
-        *
301
-        */
302
-        public function getLastAltitudeArchiveSpotterDataByIdent($ident)
303
-        {
296
+		/**
297
+		 * Gets altitude information based on a particular callsign
298
+		 *
299
+		 * @return Array the spotter information
300
+		 *
301
+		 */
302
+		public function getLastAltitudeArchiveSpotterDataByIdent($ident)
303
+		{
304 304
 
305
-                date_default_timezone_set('UTC');
305
+				date_default_timezone_set('UTC');
306 306
 
307
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
308
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
307
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
308
+				$query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
309 309
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
310 310
 
311
-                try {
312
-                        $sth = $this->db->prepare($query);
313
-                        $sth->execute(array(':ident' => $ident));
314
-                } catch(PDOException $e) {
315
-                        echo $e->getMessage();
316
-                        die;
317
-                }
318
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
311
+				try {
312
+						$sth = $this->db->prepare($query);
313
+						$sth->execute(array(':ident' => $ident));
314
+				} catch(PDOException $e) {
315
+						echo $e->getMessage();
316
+						die;
317
+				}
318
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
319 319
 
320
-                return $spotter_array;
321
-        }
320
+				return $spotter_array;
321
+		}
322 322
 
323 323
 
324 324
 
325
-       /**
326
-        * Gets all the archive spotter information
327
-        *
328
-        * @return Array the spotter information
329
-        *
330
-        */
331
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
332
-        {
333
-    		$Spotter = new Spotter($this->db);
334
-                $ident = filter_var($ident, FILTER_SANITIZE_STRING);
335
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
325
+	   /**
326
+	    * Gets all the archive spotter information
327
+	    *
328
+	    * @return Array the spotter information
329
+	    *
330
+	    */
331
+		public function getSpotterArchiveData($ident,$flightaware_id,$date)
332
+		{
333
+			$Spotter = new Spotter($this->db);
334
+				$ident = filter_var($ident, FILTER_SANITIZE_STRING);
335
+				$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
336 336
 
337
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
337
+				$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
338 338
 
339
-                return $spotter_array;
340
-        }
339
+				return $spotter_array;
340
+		}
341 341
         
342
-        public function deleteSpotterArchiveTrackData()
343
-        {
342
+		public function deleteSpotterArchiveTrackData()
343
+		{
344 344
 		global $globalArchiveKeepTrackMonths;
345
-                date_default_timezone_set('UTC');
345
+				date_default_timezone_set('UTC');
346 346
 		$query = 'DELETE FROM spotter_archive WHERE spotter_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
347
-                try {
348
-                        $sth = $this->db->prepare($query);
349
-                        $sth->execute();
350
-                } catch(PDOException $e) {
351
-                        echo $e->getMessage();
352
-                        die;
353
-                }
347
+				try {
348
+						$sth = $this->db->prepare($query);
349
+						$sth->execute();
350
+				} catch(PDOException $e) {
351
+						echo $e->getMessage();
352
+						die;
353
+				}
354 354
 	}
355 355
 
356 356
 	/**
357
-        * Gets Minimal Live Spotter data
358
-        *
359
-        * @return Array the spotter information
360
-        *
361
-        */
362
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
363
-        {
364
-                global $globalDBdriver, $globalLiveInterval;
365
-                date_default_timezone_set('UTC');
366
-
367
-                $filter_query = '';
368
-                if (isset($filter['source']) && !empty($filter['source'])) {
369
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
370
-                }
371
-                // Use spotter_output also ?
372
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
373
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
374
-                }
375
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
376
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
377
-                }
378
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
379
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
380
-                }
381
-
382
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
383
-                if ($globalDBdriver == 'mysql') {
384
-                        /*
357
+	 * Gets Minimal Live Spotter data
358
+	 *
359
+	 * @return Array the spotter information
360
+	 *
361
+	 */
362
+		public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
363
+		{
364
+				global $globalDBdriver, $globalLiveInterval;
365
+				date_default_timezone_set('UTC');
366
+
367
+				$filter_query = '';
368
+				if (isset($filter['source']) && !empty($filter['source'])) {
369
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
370
+				}
371
+				// Use spotter_output also ?
372
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
373
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
374
+				}
375
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
376
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
377
+				}
378
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
379
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
380
+				}
381
+
382
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
383
+				if ($globalDBdriver == 'mysql') {
384
+						/*
385 385
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
386 386
                     		    FROM spotter_archive 
387 387
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -400,56 +400,56 @@  discard block
 block discarded – undo
400 400
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
401 401
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
402 402
                         	    '.$filter_query.' ORDER BY flightaware_id';
403
-                } else {
404
-                        //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
405
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
403
+				} else {
404
+						//$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
405
+						$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
406 406
                         	    FROM spotter_archive 
407 407
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
408 408
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
409 409
                         	    '.$filter_query.' ORDER BY flightaware_id';
410
-                }
411
-                //echo $query;
412
-                try {
413
-                        $sth = $this->db->prepare($query);
414
-                        $sth->execute();
415
-                } catch(PDOException $e) {
416
-                        echo $e->getMessage();
417
-                        die;
418
-                }
419
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
420
-
421
-                return $spotter_array;
422
-        }
410
+				}
411
+				//echo $query;
412
+				try {
413
+						$sth = $this->db->prepare($query);
414
+						$sth->execute();
415
+				} catch(PDOException $e) {
416
+						echo $e->getMessage();
417
+						die;
418
+				}
419
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
420
+
421
+				return $spotter_array;
422
+		}
423 423
 
424 424
 	/**
425
-        * Gets Minimal Live Spotter data
426
-        *
427
-        * @return Array the spotter information
428
-        *
429
-        */
430
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
431
-        {
432
-                global $globalDBdriver, $globalLiveInterval;
433
-                date_default_timezone_set('UTC');
434
-
435
-                $filter_query = '';
436
-                if (isset($filter['source']) && !empty($filter['source'])) {
437
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
438
-                }
439
-                // Should use spotter_output also ?
440
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
441
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
442
-                }
443
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
444
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
445
-                }
446
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
447
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
448
-                }
449
-
450
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
451
-                if ($globalDBdriver == 'mysql') {
452
-                        /*
425
+	 * Gets Minimal Live Spotter data
426
+	 *
427
+	 * @return Array the spotter information
428
+	 *
429
+	 */
430
+		public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
431
+		{
432
+				global $globalDBdriver, $globalLiveInterval;
433
+				date_default_timezone_set('UTC');
434
+
435
+				$filter_query = '';
436
+				if (isset($filter['source']) && !empty($filter['source'])) {
437
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
438
+				}
439
+				// Should use spotter_output also ?
440
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
441
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
442
+				}
443
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
444
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
445
+				}
446
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
447
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
448
+				}
449
+
450
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
451
+				if ($globalDBdriver == 'mysql') {
452
+						/*
453 453
                         $query  = 'SELECT a.aircraft_shadow, spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk 
454 454
                     		    FROM spotter_archive 
455 455
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
@@ -460,95 +460,95 @@  discard block
 block discarded – undo
460 460
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
461 461
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
462 462
 
463
-                } else {
464
-                        //$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
465
-                       /*
463
+				} else {
464
+						//$query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow FROM spotter_archive_output INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive_output.flightaware_id = s.flightaware_id AND spotter_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao';
465
+					   /*
466 466
                         $query  = 'SELECT spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
467 467
                         	    FROM spotter_archive_output 
468 468
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
469 469
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
470 470
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
471 471
                         */
472
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
472
+						$query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
473 473
                         	    FROM spotter_archive_output 
474 474
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
475 475
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
476 476
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
477 477
 //                        	    .' GROUP BY spotter_output.flightaware_id, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
478 478
                         	    
479
-                }
480
-                //echo $query;
481
-                try {
482
-                        $sth = $this->db->prepare($query);
483
-                        $sth->execute();
484
-                } catch(PDOException $e) {
485
-                        echo $e->getMessage();
486
-                        die;
487
-                }
488
-                $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
489
-
490
-                return $spotter_array;
491
-        }
479
+				}
480
+				//echo $query;
481
+				try {
482
+						$sth = $this->db->prepare($query);
483
+						$sth->execute();
484
+				} catch(PDOException $e) {
485
+						echo $e->getMessage();
486
+						die;
487
+				}
488
+				$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
489
+
490
+				return $spotter_array;
491
+		}
492 492
 
493 493
 	 /**
494
-        * Gets count Live Spotter data
495
-        *
496
-        * @return Array the spotter information
497
-        *
498
-        */
499
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
500
-        {
501
-                global $globalDBdriver, $globalLiveInterval;
502
-                date_default_timezone_set('UTC');
503
-
504
-                $filter_query = '';
505
-                if (isset($filter['source']) && !empty($filter['source'])) {
506
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
507
-                }
508
-                if (isset($filter['airlines']) && !empty($filter['airlines'])) {
509
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
510
-                }
511
-                if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
512
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
513
-                }
514
-                if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
515
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
516
-                }
517
-
518
-                //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
519
-                if ($globalDBdriver == 'mysql') {
494
+	  * Gets count Live Spotter data
495
+	  *
496
+	  * @return Array the spotter information
497
+	  *
498
+	  */
499
+		public function getLiveSpotterCount($begindate,$enddate,$filter = array())
500
+		{
501
+				global $globalDBdriver, $globalLiveInterval;
502
+				date_default_timezone_set('UTC');
503
+
504
+				$filter_query = '';
505
+				if (isset($filter['source']) && !empty($filter['source'])) {
506
+						$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
507
+				}
508
+				if (isset($filter['airlines']) && !empty($filter['airlines'])) {
509
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
510
+				}
511
+				if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
512
+						$filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
513
+				}
514
+				if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
515
+						$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
516
+				}
517
+
518
+				//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
519
+				if ($globalDBdriver == 'mysql') {
520 520
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb 
521 521
 			FROM spotter_archive l 
522 522
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
523
-                } else {
523
+				} else {
524 524
 			$query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
525
-                }
526
-                //echo $query;
527
-                try {
528
-                        $sth = $this->db->prepare($query);
529
-                        $sth->execute();
530
-                } catch(PDOException $e) {
531
-                        echo $e->getMessage();
532
-                        die;
533
-                }
525
+				}
526
+				//echo $query;
527
+				try {
528
+						$sth = $this->db->prepare($query);
529
+						$sth->execute();
530
+				} catch(PDOException $e) {
531
+						echo $e->getMessage();
532
+						die;
533
+				}
534 534
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
535 535
 		$sth->closeCursor();
536
-                return $result['nb'];
536
+				return $result['nb'];
537 537
 
538
-        }
538
+		}
539 539
 
540 540
 
541 541
 
542 542
 	// Spotter_Archive_output
543 543
 	
544
-    /**
545
-    * Gets all the spotter information
546
-    *
547
-    * @return Array the spotter information
548
-    *
549
-    */
550
-    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())
551
-    {
544
+	/**
545
+	 * Gets all the spotter information
546
+	 *
547
+	 * @return Array the spotter information
548
+	 *
549
+	 */
550
+	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())
551
+	{
552 552
 	global $globalTimezone, $globalDBdriver;
553 553
 	require_once(dirname(__FILE__).'/class.Translation.php');
554 554
 	$Translation = new Translation();
@@ -562,159 +562,159 @@  discard block
 block discarded – undo
562 562
 	$filter_query = $this->getFilter($filters);
563 563
 	if ($q != "")
564 564
 	{
565
-	    if (!is_string($q))
566
-	    {
565
+		if (!is_string($q))
566
+		{
567 567
 		return false;
568
-	    } else {
568
+		} else {
569 569
 	        
570 570
 		$q_array = explode(" ", $q);
571 571
 		
572 572
 		foreach ($q_array as $q_item){
573
-		    $additional_query .= " AND (";
574
-		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
575
-		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
576
-		    $additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
577
-		    $additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
578
-		    $additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
579
-		    $additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
580
-		    $additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
581
-		    $additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
582
-		    $additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
583
-		    $additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
584
-		    $additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
585
-		    $additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
586
-		    $additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
587
-		    $additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
588
-		    $additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
589
-		    $additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
590
-		    $additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
591
-		    $additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
592
-		    $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
593
-		    $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
594
-		    $translate = $Translation->ident2icao($q_item);
595
-		    if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
596
-		    $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
597
-		    $additional_query .= ")";
573
+			$additional_query .= " AND (";
574
+			$additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
575
+			$additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
576
+			$additional_query .= "(spotter_archive_output.aircraft_name like '%".$q_item."%') OR ";
577
+			$additional_query .= "(spotter_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
578
+			$additional_query .= "(spotter_archive_output.airline_icao like '%".$q_item."%') OR ";
579
+			$additional_query .= "(spotter_archive_output.airline_name like '%".$q_item."%') OR ";
580
+			$additional_query .= "(spotter_archive_output.airline_country like '%".$q_item."%') OR ";
581
+			$additional_query .= "(spotter_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
582
+			$additional_query .= "(spotter_archive_output.departure_airport_name like '%".$q_item."%') OR ";
583
+			$additional_query .= "(spotter_archive_output.departure_airport_city like '%".$q_item."%') OR ";
584
+			$additional_query .= "(spotter_archive_output.departure_airport_country like '%".$q_item."%') OR ";
585
+			$additional_query .= "(spotter_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
586
+			$additional_query .= "(spotter_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
587
+			$additional_query .= "(spotter_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
588
+			$additional_query .= "(spotter_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
589
+			$additional_query .= "(spotter_archive_output.registration like '%".$q_item."%') OR ";
590
+			$additional_query .= "(spotter_archive_output.owner_name like '%".$q_item."%') OR ";
591
+			$additional_query .= "(spotter_archive_output.pilot_id like '%".$q_item."%') OR ";
592
+			$additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR ";
593
+			$additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR ";
594
+			$translate = $Translation->ident2icao($q_item);
595
+			if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR ";
596
+			$additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')";
597
+			$additional_query .= ")";
598
+		}
598 599
 		}
599
-	    }
600 600
 	}
601 601
 	
602 602
 	if ($registration != "")
603 603
 	{
604
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
605
-	    if (!is_string($registration))
606
-	    {
604
+		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
605
+		if (!is_string($registration))
606
+		{
607 607
 		return false;
608
-	    } else {
608
+		} else {
609 609
 		$additional_query .= " AND (spotter_archive_output.registration = '".$registration."')";
610
-	    }
610
+		}
611 611
 	}
612 612
 	
613 613
 	if ($aircraft_icao != "")
614 614
 	{
615
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
616
-	    if (!is_string($aircraft_icao))
617
-	    {
615
+		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
616
+		if (!is_string($aircraft_icao))
617
+		{
618 618
 		return false;
619
-	    } else {
619
+		} else {
620 620
 		$additional_query .= " AND (spotter_archive_output.aircraft_icao = '".$aircraft_icao."')";
621
-	    }
621
+		}
622 622
 	}
623 623
 	
624 624
 	if ($aircraft_manufacturer != "")
625 625
 	{
626
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
627
-	    if (!is_string($aircraft_manufacturer))
628
-	    {
626
+		$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
627
+		if (!is_string($aircraft_manufacturer))
628
+		{
629 629
 		return false;
630
-	    } else {
630
+		} else {
631 631
 		$additional_query .= " AND (spotter_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
632
-	    }
632
+		}
633 633
 	}
634 634
 	
635 635
 	if ($highlights == "true")
636 636
 	{
637
-	    if (!is_string($highlights))
638
-	    {
637
+		if (!is_string($highlights))
638
+		{
639 639
 		return false;
640
-	    } else {
640
+		} else {
641 641
 		$additional_query .= " AND (spotter_archive_output.highlight <> '')";
642
-	    }
642
+		}
643 643
 	}
644 644
 	
645 645
 	if ($airline_icao != "")
646 646
 	{
647
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
648
-	    if (!is_string($airline_icao))
649
-	    {
647
+		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
648
+		if (!is_string($airline_icao))
649
+		{
650 650
 		return false;
651
-	    } else {
651
+		} else {
652 652
 		$additional_query .= " AND (spotter_archive_output.airline_icao = '".$airline_icao."')";
653
-	    }
653
+		}
654 654
 	}
655 655
 	
656 656
 	if ($airline_country != "")
657 657
 	{
658
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
-	    if (!is_string($airline_country))
660
-	    {
658
+		$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
659
+		if (!is_string($airline_country))
660
+		{
661 661
 		return false;
662
-	    } else {
662
+		} else {
663 663
 		$additional_query .= " AND (spotter_archive_output.airline_country = '".$airline_country."')";
664
-	    }
664
+		}
665 665
 	}
666 666
 	
667 667
 	if ($airline_type != "")
668 668
 	{
669
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
670
-	    if (!is_string($airline_type))
671
-	    {
669
+		$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
670
+		if (!is_string($airline_type))
671
+		{
672 672
 		return false;
673
-	    } else {
673
+		} else {
674 674
 		if ($airline_type == "passenger")
675 675
 		{
676
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
676
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'passenger')";
677 677
 		}
678 678
 		if ($airline_type == "cargo")
679 679
 		{
680
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
680
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'cargo')";
681 681
 		}
682 682
 		if ($airline_type == "military")
683 683
 		{
684
-		    $additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
684
+			$additional_query .= " AND (spotter_archive_output.airline_type = 'military')";
685
+		}
685 686
 		}
686
-	    }
687 687
 	}
688 688
 	
689 689
 	if ($airport != "")
690 690
 	{
691
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
-	    if (!is_string($airport))
693
-	    {
691
+		$airport = filter_var($airport,FILTER_SANITIZE_STRING);
692
+		if (!is_string($airport))
693
+		{
694 694
 		return false;
695
-	    } else {
695
+		} else {
696 696
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = '".$airport."') OR (spotter_archive_output.arrival_airport_icao = '".$airport."'))";
697
-	    }
697
+		}
698 698
 	}
699 699
 	
700 700
 	if ($airport_country != "")
701 701
 	{
702
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
703
-	    if (!is_string($airport_country))
704
-	    {
702
+		$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
703
+		if (!is_string($airport_country))
704
+		{
705 705
 		return false;
706
-	    } else {
706
+		} else {
707 707
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_country = '".$airport_country."') OR (spotter_archive_output.arrival_airport_country = '".$airport_country."'))";
708
-	    }
708
+		}
709 709
 	}
710 710
     
711 711
 	if ($callsign != "")
712 712
 	{
713
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
714
-	    if (!is_string($callsign))
715
-	    {
713
+		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
714
+		if (!is_string($callsign))
715
+		{
716 716
 		return false;
717
-	    } else {
717
+		} else {
718 718
 		$translate = $Translation->ident2icao($callsign);
719 719
 		if ($translate != $callsign) {
720 720
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
@@ -722,99 +722,99 @@  discard block
 block discarded – undo
722 722
 		} else {
723 723
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
724 724
 		}
725
-	    }
725
+		}
726 726
 	}
727 727
 
728 728
 	if ($owner != "")
729 729
 	{
730
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
731
-	    if (!is_string($owner))
732
-	    {
730
+		$owner = filter_var($owner,FILTER_SANITIZE_STRING);
731
+		if (!is_string($owner))
732
+		{
733 733
 		return false;
734
-	    } else {
734
+		} else {
735 735
 		$additional_query .= " AND (spotter_archive_output.owner_name = '".$owner."')";
736
-	    }
736
+		}
737 737
 	}
738 738
 
739 739
 	if ($pilot_name != "")
740 740
 	{
741
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
742
-	    if (!is_string($pilot_name))
743
-	    {
741
+		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
742
+		if (!is_string($pilot_name))
743
+		{
744 744
 		return false;
745
-	    } else {
745
+		} else {
746 746
 		$additional_query .= " AND (spotter_archive_output.pilot_name = '".$pilot_name."')";
747
-	    }
747
+		}
748 748
 	}
749 749
 	
750 750
 	if ($pilot_id != "")
751 751
 	{
752
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
753
-	    if (!is_string($pilot_id))
754
-	    {
752
+		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
753
+		if (!is_string($pilot_id))
754
+		{
755 755
 		return false;
756
-	    } else {
756
+		} else {
757 757
 		$additional_query .= " AND (spotter_archive_output.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);
764
-	    if (!is_string($departure_airport_route))
765
-	    {
763
+		$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
764
+		if (!is_string($departure_airport_route))
765
+		{
766 766
 		return false;
767
-	    } else {
767
+		} else {
768 768
 		$additional_query .= " AND (spotter_archive_output.departure_airport_icao = '".$departure_airport_route."')";
769
-	    }
769
+		}
770 770
 	}
771 771
 	
772 772
 	if ($arrival_airport_route != "")
773 773
 	{
774
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
775
-	    if (!is_string($arrival_airport_route))
776
-	    {
774
+		$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
775
+		if (!is_string($arrival_airport_route))
776
+		{
777 777
 		return false;
778
-	    } else {
778
+		} else {
779 779
 		$additional_query .= " AND (spotter_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
780
-	    }
780
+		}
781 781
 	}
782 782
 	
783 783
 	if ($altitude != "")
784 784
 	{
785
-	    $altitude_array = explode(",", $altitude);
785
+		$altitude_array = explode(",", $altitude);
786 786
 	    
787
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
787
+		$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
788
+		$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
789 789
 	    
790 790
 
791
-	    if ($altitude_array[1] != "")
792
-	    {                
791
+		if ($altitude_array[1] != "")
792
+		{                
793 793
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
794 794
 		$altitude_array[1] = substr($altitude_array[1], 0, -2);
795 795
 		$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
796
-	    } else {
796
+		} else {
797 797
 		$altitude_array[0] = substr($altitude_array[0], 0, -2);
798 798
 		$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
799
-	    }
799
+		}
800 800
 	}
801 801
 	
802 802
 	if ($date_posted != "")
803 803
 	{
804
-	    $date_array = explode(",", $date_posted);
804
+		$date_array = explode(",", $date_posted);
805 805
 	    
806
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
807
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
806
+		$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
807
+		$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
808 808
 	    
809
-	    if ($globalTimezone != '') {
809
+		if ($globalTimezone != '') {
810 810
 		date_default_timezone_set($globalTimezone);
811 811
 		$datetime = new DateTime();
812 812
 		$offset = $datetime->format('P');
813
-	    } else $offset = '+00:00';
813
+		} else $offset = '+00:00';
814 814
 
815 815
 
816
-	    if ($date_array[1] != "")
817
-	    {                
816
+		if ($date_array[1] != "")
817
+		{                
818 818
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
819 819
 		$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
820 820
 		if ($globalDBdriver == 'mysql') {
@@ -822,28 +822,28 @@  discard block
 block discarded – undo
822 822
 		} else {
823 823
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
824 824
 		}
825
-	    } else {
825
+		} else {
826 826
 		$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
827
-                if ($globalDBdriver == 'mysql') {
827
+				if ($globalDBdriver == 'mysql') {
828 828
 			$additional_query .= " AND TIMESTAMP(CONVERT_TZ(spotter_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
829 829
 		} else {
830 830
 			$additional_query .= " AND spotter_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
831 831
 		}
832
-	    }
832
+		}
833 833
 	}
834 834
 	
835 835
 	if ($limit != "")
836 836
 	{
837
-	    $limit_array = explode(",", $limit);
837
+		$limit_array = explode(",", $limit);
838 838
 	    
839
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
840
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
839
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
840
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
841 841
 	    
842
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
843
-	    {
842
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
843
+		{
844 844
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
845 845
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
846
-	    }
846
+		}
847 847
 	}
848 848
 	
849 849
 
@@ -874,33 +874,33 @@  discard block
 block discarded – undo
874 874
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
875 875
 
876 876
 	return $spotter_array;
877
-    }
877
+	}
878 878
 
879
-    public function deleteSpotterArchiveData()
880
-    {
879
+	public function deleteSpotterArchiveData()
880
+	{
881 881
 		global $globalArchiveKeepMonths, $globalDBdriver;
882
-                date_default_timezone_set('UTC');
883
-                if ($globalDBdriver == 'mysql') {
882
+				date_default_timezone_set('UTC');
883
+				if ($globalDBdriver == 'mysql') {
884 884
 			$query = 'DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
885 885
 		} else {
886 886
 			$query = "DELETE FROM spotter_archive_output WHERE spotter_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
887 887
 		}
888
-                try {
889
-                        $sth = $this->db->prepare($query);
890
-                        $sth->execute();
891
-                } catch(PDOException $e) {
892
-                        return "error";
893
-                }
888
+				try {
889
+						$sth = $this->db->prepare($query);
890
+						$sth->execute();
891
+				} catch(PDOException $e) {
892
+						return "error";
893
+				}
894 894
 	}
895 895
 
896
-    /**
897
-    * Gets all the spotter information based on the callsign
898
-    *
899
-    * @return Array the spotter information
900
-    *
901
-    */
902
-    public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
903
-    {
896
+	/**
897
+	 * Gets all the spotter information based on the callsign
898
+	 *
899
+	 * @return Array the spotter information
900
+	 *
901
+	 */
902
+	public function getSpotterDataByIdent($ident = '', $limit = '', $sort = '')
903
+	{
904 904
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
905 905
 	
906 906
 	date_default_timezone_set('UTC');
@@ -912,35 +912,35 @@  discard block
 block discarded – undo
912 912
 	
913 913
 	if ($ident != "")
914 914
 	{
915
-	    if (!is_string($ident))
916
-	    {
915
+		if (!is_string($ident))
916
+		{
917 917
 		return false;
918
-	    } else {
918
+		} else {
919 919
 		$additional_query = " AND (spotter_archive_output.ident = :ident)";
920 920
 		$query_values = array(':ident' => $ident);
921
-	    }
921
+		}
922 922
 	}
923 923
 	
924 924
 	if ($limit != "")
925 925
 	{
926
-	    $limit_array = explode(",", $limit);
926
+		$limit_array = explode(",", $limit);
927 927
 	    
928
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
929
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
928
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
929
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
930 930
 	    
931
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
932
-	    {
931
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
932
+		{
933 933
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
934 934
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
935
-	    }
935
+		}
936 936
 	}
937 937
 
938 938
 	if ($sort != "")
939 939
 	{
940
-	    $search_orderby_array = $Spotter->getOrderBy();
941
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
940
+		$search_orderby_array = $Spotter->getOrderBy();
941
+		$orderby_query = $search_orderby_array[$sort]['sql'];
942 942
 	} else {
943
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
943
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
944 944
 	}
945 945
 
946 946
 	$query = $global_query." WHERE spotter_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
@@ -948,17 +948,17 @@  discard block
 block discarded – undo
948 948
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
949 949
 
950 950
 	return $spotter_array;
951
-    }
951
+	}
952 952
 
953 953
 
954
-    /**
955
-    * Gets all the spotter information based on the owner
956
-    *
957
-    * @return Array the spotter information
958
-    *
959
-    */
960
-    public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '')
961
-    {
954
+	/**
955
+	 * Gets all the spotter information based on the owner
956
+	 *
957
+	 * @return Array the spotter information
958
+	 *
959
+	 */
960
+	public function getSpotterDataByOwner($owner = '', $limit = '', $sort = '')
961
+	{
962 962
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
963 963
 	
964 964
 	date_default_timezone_set('UTC');
@@ -970,35 +970,35 @@  discard block
 block discarded – undo
970 970
 	
971 971
 	if ($owner != "")
972 972
 	{
973
-	    if (!is_string($owner))
974
-	    {
973
+		if (!is_string($owner))
974
+		{
975 975
 		return false;
976
-	    } else {
976
+		} else {
977 977
 		$additional_query = " AND (spotter_archive_output.owner_name = :owner)";
978 978
 		$query_values = array(':owner' => $owner);
979
-	    }
979
+		}
980 980
 	}
981 981
 	
982 982
 	if ($limit != "")
983 983
 	{
984
-	    $limit_array = explode(",", $limit);
984
+		$limit_array = explode(",", $limit);
985 985
 	    
986
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
987
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
986
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
987
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988 988
 	    
989
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
990
-	    {
989
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
990
+		{
991 991
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
992 992
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
993
-	    }
993
+		}
994 994
 	}
995 995
 
996 996
 	if ($sort != "")
997 997
 	{
998
-	    $search_orderby_array = $Spotter->getOrderBy();
999
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
998
+		$search_orderby_array = $Spotter->getOrderBy();
999
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1000 1000
 	} else {
1001
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1001
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1002 1002
 	}
1003 1003
 
1004 1004
 	$query = $global_query." WHERE spotter_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
@@ -1006,16 +1006,16 @@  discard block
 block discarded – undo
1006 1006
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1007 1007
 
1008 1008
 	return $spotter_array;
1009
-    }
1010
-
1011
-    /**
1012
-    * Gets all the spotter information based on the pilot
1013
-    *
1014
-    * @return Array the spotter information
1015
-    *
1016
-    */
1017
-    public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '')
1018
-    {
1009
+	}
1010
+
1011
+	/**
1012
+	 * Gets all the spotter information based on the pilot
1013
+	 *
1014
+	 * @return Array the spotter information
1015
+	 *
1016
+	 */
1017
+	public function getSpotterDataByPilot($pilot = '', $limit = '', $sort = '')
1018
+	{
1019 1019
 	$global_query = "SELECT spotter_archive_output.* FROM spotter_archive_output";
1020 1020
 	
1021 1021
 	date_default_timezone_set('UTC');
@@ -1033,24 +1033,24 @@  discard block
 block discarded – undo
1033 1033
 	
1034 1034
 	if ($limit != "")
1035 1035
 	{
1036
-	    $limit_array = explode(",", $limit);
1036
+		$limit_array = explode(",", $limit);
1037 1037
 	    
1038
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1039
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1038
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1039
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1040 1040
 	    
1041
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1042
-	    {
1041
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1042
+		{
1043 1043
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1044 1044
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1045
-	    }
1045
+		}
1046 1046
 	}
1047 1047
 
1048 1048
 	if ($sort != "")
1049 1049
 	{
1050
-	    $search_orderby_array = $Spotter->getOrderBy();
1051
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1050
+		$search_orderby_array = $Spotter->getOrderBy();
1051
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1052 1052
 	} else {
1053
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1053
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1054 1054
 	}
1055 1055
 
1056 1056
 	$query = $global_query." WHERE spotter_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
@@ -1058,16 +1058,16 @@  discard block
 block discarded – undo
1058 1058
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1059 1059
 
1060 1060
 	return $spotter_array;
1061
-    }
1062
-
1063
-    /**
1064
-    * Gets all number of flight over countries
1065
-    *
1066
-    * @return Array the airline country list
1067
-    *
1068
-    */
1069
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1070
-    {
1061
+	}
1062
+
1063
+	/**
1064
+	 * Gets all number of flight over countries
1065
+	 *
1066
+	 * @return Array the airline country list
1067
+	 *
1068
+	 */
1069
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1070
+	{
1071 1071
 	global $globalDBdriver;
1072 1072
 	/*
1073 1073
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1077,14 +1077,14 @@  discard block
 block discarded – undo
1077 1077
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1078 1078
 		    FROM countries c, spotter_archive s
1079 1079
 		    WHERE c.iso2 = s.over_country ";
1080
-                if ($olderthanmonths > 0) {
1081
-            		if ($globalDBdriver == 'mysql') {
1080
+				if ($olderthanmonths > 0) {
1081
+					if ($globalDBdriver == 'mysql') {
1082 1082
 				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1083 1083
 			} else {
1084 1084
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1085 1085
 			}
1086 1086
 		}
1087
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1087
+				if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1088 1088
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1089 1089
 	if ($limit) $query .= " LIMIT 0,10";
1090 1090
       
@@ -1097,23 +1097,23 @@  discard block
 block discarded – undo
1097 1097
         
1098 1098
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1099 1099
 	{
1100
-	    $temp_array['flight_count'] = $row['nb'];
1101
-	    $temp_array['flight_country'] = $row['name'];
1102
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1103
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1104
-	    $flight_array[] = $temp_array;
1100
+		$temp_array['flight_count'] = $row['nb'];
1101
+		$temp_array['flight_country'] = $row['name'];
1102
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1103
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1104
+		$flight_array[] = $temp_array;
1105 1105
 	}
1106 1106
 	return $flight_array;
1107
-    }
1108
-
1109
-    /**
1110
-    * Gets all number of flight over countries
1111
-    *
1112
-    * @return Array the airline country list
1113
-    *
1114
-    */
1115
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1116
-    {
1107
+	}
1108
+
1109
+	/**
1110
+	 * Gets all number of flight over countries
1111
+	 *
1112
+	 * @return Array the airline country list
1113
+	 *
1114
+	 */
1115
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1116
+	{
1117 1117
 	global $globalDBdriver;
1118 1118
 	/*
1119 1119
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
@@ -1123,14 +1123,14 @@  discard block
 block discarded – undo
1123 1123
 	$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1124 1124
 		    FROM countries c, spotter_archive s, spotter_output o
1125 1125
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.flightaware_id = s.flightaware_id ";
1126
-                if ($olderthanmonths > 0) {
1127
-            		if ($globalDBdriver == 'mysql') {
1126
+				if ($olderthanmonths > 0) {
1127
+					if ($globalDBdriver == 'mysql') {
1128 1128
 				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1129 1129
 			} else {
1130 1130
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1131 1131
 			}
1132 1132
 		}
1133
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1133
+				if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1134 1134
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1135 1135
 	if ($limit) $query .= " LIMIT 0,10";
1136 1136
       
@@ -1143,24 +1143,24 @@  discard block
 block discarded – undo
1143 1143
         
1144 1144
 	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1145 1145
 	{
1146
-	    $temp_array['airline_icao'] = $row['airline_icao'];
1147
-	    $temp_array['flight_count'] = $row['nb'];
1148
-	    $temp_array['flight_country'] = $row['name'];
1149
-	    $temp_array['flight_country_iso3'] = $row['iso3'];
1150
-	    $temp_array['flight_country_iso2'] = $row['iso2'];
1151
-	    $flight_array[] = $temp_array;
1146
+		$temp_array['airline_icao'] = $row['airline_icao'];
1147
+		$temp_array['flight_count'] = $row['nb'];
1148
+		$temp_array['flight_country'] = $row['name'];
1149
+		$temp_array['flight_country_iso3'] = $row['iso3'];
1150
+		$temp_array['flight_country_iso2'] = $row['iso2'];
1151
+		$flight_array[] = $temp_array;
1152 1152
 	}
1153 1153
 	return $flight_array;
1154
-    }
1155
-
1156
-    /**
1157
-    * Gets last spotter information based on a particular callsign
1158
-    *
1159
-    * @return Array the spotter information
1160
-    *
1161
-    */
1162
-    public function getDateArchiveSpotterDataById($id,$date)
1163
-    {
1154
+	}
1155
+
1156
+	/**
1157
+	 * Gets last spotter information based on a particular callsign
1158
+	 *
1159
+	 * @return Array the spotter information
1160
+	 *
1161
+	 */
1162
+	public function getDateArchiveSpotterDataById($id,$date)
1163
+	{
1164 1164
 	$Spotter = new Spotter($this->db);
1165 1165
 	date_default_timezone_set('UTC');
1166 1166
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
@@ -1168,16 +1168,16 @@  discard block
 block discarded – undo
1168 1168
 	$date = date('c',$date);
1169 1169
 	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1170 1170
 	return $spotter_array;
1171
-    }
1172
-
1173
-    /**
1174
-    * Gets all the spotter information based on a particular callsign
1175
-    *
1176
-    * @return Array the spotter information
1177
-    *
1178
-    */
1179
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1180
-    {
1171
+	}
1172
+
1173
+	/**
1174
+	 * Gets all the spotter information based on a particular callsign
1175
+	 *
1176
+	 * @return Array the spotter information
1177
+	 *
1178
+	 */
1179
+	public function getDateArchiveSpotterDataByIdent($ident,$date)
1180
+	{
1181 1181
 	$Spotter = new Spotter($this->db);
1182 1182
 	date_default_timezone_set('UTC');
1183 1183
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
@@ -1185,16 +1185,16 @@  discard block
 block discarded – undo
1185 1185
 	$date = date('c',$date);
1186 1186
 	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1187 1187
 	return $spotter_array;
1188
-    }
1189
-
1190
-    /**
1191
-    * Gets all the spotter information based on the airport
1192
-    *
1193
-    * @return Array the spotter information
1194
-    *
1195
-    */
1196
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1197
-    {
1188
+	}
1189
+
1190
+	/**
1191
+	 * Gets all the spotter information based on the airport
1192
+	 *
1193
+	 * @return Array the spotter information
1194
+	 *
1195
+	 */
1196
+	public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1197
+	{
1198 1198
 	global $global_query;
1199 1199
 	$Spotter = new Spotter();
1200 1200
 	date_default_timezone_set('UTC');
@@ -1205,35 +1205,35 @@  discard block
 block discarded – undo
1205 1205
 	
1206 1206
 	if ($airport != "")
1207 1207
 	{
1208
-	    if (!is_string($airport))
1209
-	    {
1208
+		if (!is_string($airport))
1209
+		{
1210 1210
 		return false;
1211
-	    } else {
1211
+		} else {
1212 1212
 		$additional_query .= " AND ((spotter_archive_output.departure_airport_icao = :airport) OR (spotter_archive_output.arrival_airport_icao = :airport))";
1213 1213
 		$query_values = array(':airport' => $airport);
1214
-	    }
1214
+		}
1215 1215
 	}
1216 1216
 	
1217 1217
 	if ($limit != "")
1218 1218
 	{
1219
-	    $limit_array = explode(",", $limit);
1219
+		$limit_array = explode(",", $limit);
1220 1220
 	    
1221
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1222
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1221
+		$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1222
+		$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1223 1223
 	    
1224
-	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1225
-	    {
1224
+		if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1225
+		{
1226 1226
 		//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1227 1227
 		$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1228
-	    }
1228
+		}
1229 1229
 	}
1230 1230
 	
1231 1231
 	if ($sort != "")
1232 1232
 	{
1233
-	    $search_orderby_array = $Spotter->getOrderBy();
1234
-	    $orderby_query = $search_orderby_array[$sort]['sql'];
1233
+		$search_orderby_array = $Spotter->getOrderBy();
1234
+		$orderby_query = $search_orderby_array[$sort]['sql'];
1235 1235
 	} else {
1236
-	    $orderby_query = " ORDER BY spotter_archive_output.date DESC";
1236
+		$orderby_query = " ORDER BY spotter_archive_output.date DESC";
1237 1237
 	}
1238 1238
 
1239 1239
 	$query = $global_query.$filter_query." spotter_archive_output.ident <> '' ".$additional_query." AND ((spotter_archive_output.departure_airport_icao <> 'NA') AND (spotter_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
@@ -1241,6 +1241,6 @@  discard block
 block discarded – undo
1241 1241
 	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
1242 1242
 
1243 1243
 	return $spotter_array;
1244
-    }
1244
+	}
1245 1245
 }
1246 1246
 ?>
1247 1247
\ No newline at end of file
Please login to merge, or discard this patch.
statistics.php 1 patch
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 		if (isset($globalTimezone) && $globalTimezone != '') date_default_timezone_set($globalTimezone);
47 47
 		print '<i>Last update: '.date('Y-m-d G:i:s',$lastupdate).'</i>';
48 48
 	}
49
-    ?>
49
+	?>
50 50
     </div>
51 51
     <?php include('statistics-sub-menu.php'); ?>
52 52
     <p class="global-stats">
@@ -55,23 +55,23 @@  discard block
 block discarded – undo
55 55
         <span><span class="badge"><?php print number_format($Stats->countOverallArrival($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Arrivals seen"); ?></span>
56 56
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
57 57
 	<?php
58
-	    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
58
+		if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
59 59
 	?>
60 60
     	    <span><span class="badge"><?php print number_format($Stats->countOverallPilots($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Pilots"); ?></span>
61 61
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
62 62
         <?php
63
-    	    } else {
64
-    	?>
63
+			} else {
64
+		?>
65 65
     	    <span><span class="badge"><?php print number_format($Stats->countOverallOwners($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Owners"); ?></span>
66 66
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
67 67
     	<?php
68
-    	    }
69
-    	?>
68
+			}
69
+		?>
70 70
         <span><span class="badge"><?php print number_format($Stats->countOverallAircrafts($airline_icao,$filter_name,$year,$month)); ?></span> <?php echo _("Aircrafts types"); ?></span>
71 71
         <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
72 72
         <?php
73
-    		if ($airline_icao == '') {
74
-    	?>
73
+			if ($airline_icao == '') {
74
+		?>
75 75
         <span><span class="badge"><?php print number_format($Stats->countOverallAirlines($filter_name,$year,$month)); ?></span> <?php echo _("Airlines"); ?></span>
76 76
 	<!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
77 77
 	<?php
@@ -94,25 +94,25 @@  discard block
 block discarded – undo
94 94
             <div class="col-md-6">
95 95
                 <h2><?php echo _("Top 10 Most Common Aircraft Type"); ?></h2>
96 96
                  <?php
97
-                  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
-		    if (count($aircraft_array) == 0) print _("No data available");
99
-		    else {
97
+				  $aircraft_array = $Stats->countAllAircraftTypes(true,$airline_icao,$filter_name,$year,$month);
98
+			if (count($aircraft_array) == 0) print _("No data available");
99
+			else {
100 100
 
101
-                    print '<div id="chart1" class="chart" width="100%"></div>
101
+					print '<div id="chart1" class="chart" width="100%"></div>
102 102
                     <script> 
103 103
                         google.load("visualization", "1", {packages:["corechart"]});
104 104
                       google.setOnLoadCallback(drawChart1);
105 105
                       function drawChart1() {
106 106
                         var data = google.visualization.arrayToDataTable([
107 107
                             ["'._("Aircraft").'", "'._("# of times").'"], ';
108
-                            $aircraft_data = '';
109
-                          foreach($aircraft_array as $aircraft_item)
110
-                                    {
111
-                                            $aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112
-                                    }
113
-                                    $aircraft_data = substr($aircraft_data, 0, -1);
114
-                                    print $aircraft_data;
115
-                        print ']);
108
+							$aircraft_data = '';
109
+						  foreach($aircraft_array as $aircraft_item)
110
+									{
111
+											$aircraft_data .= '[ "'.$aircraft_item['aircraft_manufacturer'].' '.$aircraft_item['aircraft_name'].' ('.$aircraft_item['aircraft_icao'].')",'.$aircraft_item['aircraft_icao_count'].'],';
112
+									}
113
+									$aircraft_data = substr($aircraft_data, 0, -1);
114
+									print $aircraft_data;
115
+						print ']);
116 116
 
117 117
                         var options = {
118 118
                             chartArea: {"width": "80%", "height": "60%"},
@@ -127,45 +127,45 @@  discard block
 block discarded – undo
127 127
                               drawChart1();
128 128
                             });
129 129
                   </script>';
130
-                  }
131
-                  ?>
130
+				  }
131
+				  ?>
132 132
                 <div class="more">
133 133
             	    <?php
134
-            		if ($year != '' && $month != '') {
135
-            	    ?>
134
+					if ($year != '' && $month != '') {
135
+					?>
136 136
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
137 137
             	    <?php
138
-            		} else {
139
-            	    ?>
138
+					} else {
139
+					?>
140 140
             	    <a href="<?php print $globalURL; ?>/statistics/aircraft<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
141 141
             	    <?php
142
-            		}
143
-            	    ?>
142
+					}
143
+					?>
144 144
                 </div>
145 145
             </div>
146 146
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
147 147
 <?php
148 148
 //    echo $airline_icao;
149
-    if ($airline_icao == '' || $airline_icao == 'all') {
149
+	if ($airline_icao == '' || $airline_icao == 'all') {
150 150
 	$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month);
151 151
 	if (count($airline_array) > 0) {
152
-            print '<div class="col-md-6">';
153
-	    print '<h2>'._("Top 10 Most Common Airline").'</h2>';
154
-	    print '<div id="chart2" class="chart" width="100%"></div>
152
+			print '<div class="col-md-6">';
153
+		print '<h2>'._("Top 10 Most Common Airline").'</h2>';
154
+		print '<div id="chart2" class="chart" width="100%"></div>
155 155
                     <script> 
156 156
                         google.load("visualization", "1", {packages:["corechart"]});
157 157
                       google.setOnLoadCallback(drawChart2);
158 158
                       function drawChart2() {
159 159
                         var data = google.visualization.arrayToDataTable([
160 160
                             ["'._("Airline").'", "'._("# of times").'"], ';
161
-	    $airline_data = '';
162
-	    foreach($airline_array as $airline_item)
163
-	    {
161
+		$airline_data = '';
162
+		foreach($airline_array as $airline_item)
163
+		{
164 164
 		$airline_data .= '[ "'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],';
165
-	    }
166
-	    $airline_data = substr($airline_data, 0, -1);
167
-	    print $airline_data;
168
-	    print ']);
165
+		}
166
+		$airline_data = substr($airline_data, 0, -1);
167
+		print $airline_data;
168
+		print ']);
169 169
 
170 170
                         var options = {
171 171
                             chartArea: {"width": "80%", "height": "60%"},
@@ -180,31 +180,31 @@  discard block
 block discarded – undo
180 180
                               drawChart2();
181 181
                             });
182 182
                   </script>';
183
-	    if ($year != '' && $month != '') {
183
+		if ($year != '' && $month != '') {
184 184
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
185 185
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
186 186
 		print '/'.$year.'/'.$month.'/" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
187
-	    } else {
187
+		} else {
188 188
 		print '<div class="more"><a href="'.$globalURL.'/statistics/airline';
189 189
 		if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
190 190
 		print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
191
-	    }
192
-    	    print '</div>';
191
+		}
192
+			print '</div>';
193 193
 	}
194 194
 ?>
195 195
         </div>
196 196
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
197 197
 <?php
198
-    }
198
+	}
199 199
 ?>
200 200
         <div class="row column">
201 201
 <?php
202
-    $flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
203
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
202
+	$flightover_array = $Stats->countAllFlightOverCountries(false,$airline_icao,$filter_name,$year,$month);
203
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
204 204
 	if (empty($flightover_array)) {
205
-	    print '<div class="col-md-12">';
205
+		print '<div class="col-md-12">';
206 206
 	} else {
207
-            print '<div class="col-md-6">';
207
+			print '<div class="col-md-6">';
208 208
 	}
209 209
 ?>
210 210
                 <h2><?php echo _("Top 10 Most Common Pilots"); ?></h2>
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
 	$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month);
213 213
 	if (count($pilot_array) == 0) print _("No data available");
214 214
 	else {
215
-	    print '<div id="chart7" class="chart" width="100%"></div>
215
+		print '<div id="chart7" class="chart" width="100%"></div>
216 216
                     <script> 
217 217
                         google.load("visualization", "1", {packages:["corechart"]});
218 218
                       google.setOnLoadCallback(drawChart7);
219 219
                       function drawChart7() {
220 220
                         var data = google.visualization.arrayToDataTable([
221 221
                             ["'._("Pilots").'", "'._("# of times").'"], ';
222
-	    $pilot_data = '';
223
-	    foreach($pilot_array as $pilot_item)
224
-	    {
222
+		$pilot_data = '';
223
+		foreach($pilot_array as $pilot_item)
224
+		{
225 225
 		$pilot_data .= '[ "'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],';
226
-	    }
227
-	    $pilot_data = substr($pilot_data, 0, -1);
228
-	    print $pilot_data;
229
-	    print ']);
226
+		}
227
+		$pilot_data = substr($pilot_data, 0, -1);
228
+		print $pilot_data;
229
+		print ']);
230 230
 
231 231
                         var options = {
232 232
                             chartArea: {"width": "80%", "height": "60%"},
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
                               drawChart7();
242 242
                             });
243 243
                   </script>';
244
-        }
245
-        print '<div class="more">';
244
+		}
245
+		print '<div class="more">';
246 246
 	print '<a href="'.$globalURL.'/statistics/pilot'; 
247 247
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
248 248
 	print'" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a>';
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         
253 253
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
254 254
 <?php
255
-    } else {
255
+	} else {
256 256
 ?>
257 257
             <div class="col-md-6">
258 258
                 <h2><?php echo _("Top 10 Most Common Owners"); ?></h2>
@@ -260,21 +260,21 @@  discard block
 block discarded – undo
260 260
 	$owner_array = $Stats->countAllOwners(true,$airline_icao,$filter_name,$year,$month);
261 261
 	if (count($owner_array) == 0) print _("No data available");
262 262
 	else {
263
-	    print '<div id="chart7" class="chart" width="100%"></div>
263
+		print '<div id="chart7" class="chart" width="100%"></div>
264 264
                     <script> 
265 265
                         google.load("visualization", "1", {packages:["corechart"]});
266 266
                       google.setOnLoadCallback(drawChart7);
267 267
                       function drawChart7() {
268 268
                         var data = google.visualization.arrayToDataTable([
269 269
                             ["'._("Owner").'", "'._("# of times").'"], ';
270
-                            $owner_data = '';
271
-	    foreach($owner_array as $owner_item)
272
-	    {
270
+							$owner_data = '';
271
+		foreach($owner_array as $owner_item)
272
+		{
273 273
 		$owner_data .= '[ "'.$owner_item['owner_name'].'",'.$owner_item['owner_count'].'],';
274
-	    }
275
-	    $owner_data = substr($owner_data, 0, -1);
276
-	    print $owner_data;
277
-	    print ']);
274
+		}
275
+		$owner_data = substr($owner_data, 0, -1);
276
+		print $owner_data;
277
+		print ']);
278 278
 
279 279
                         var options = {
280 280
                             chartArea: {"width": "80%", "height": "60%"},
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
         
299 299
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
300 300
 <?php
301
-    }
302
-    if (!empty($flightover_array)) {
301
+	}
302
+	if (!empty($flightover_array)) {
303 303
 ?>
304 304
             <div class="col-md-6">
305 305
                 <h2><?php echo _("Top 20 Most Common Country a Flight was Over"); ?></h2>
@@ -307,21 +307,21 @@  discard block
 block discarded – undo
307 307
 	 //$flightover_array = $Stats->countAllFlightOverCountries();
308 308
 	if (count($flightover_array) == 0) print _("No data available");
309 309
 	else {
310
-	    print '<div id="chart10" class="chart" width="100%"></div>
310
+		print '<div id="chart10" class="chart" width="100%"></div>
311 311
                     <script> 
312 312
                         google.load("visualization", "1", {packages:["corechart"]});
313 313
                       google.setOnLoadCallback(drawChart10);
314 314
                       function drawChart10() {
315 315
                         var data = google.visualization.arrayToDataTable([
316 316
                             ["'._("Country").'", "'._("# of times").'"], ';
317
-                            $flightover_data = '';
318
-	    foreach($flightover_array as $flightover_item)
319
-	    {
317
+							$flightover_data = '';
318
+		foreach($flightover_array as $flightover_item)
319
+		{
320 320
 		$flightover_data .= '[ "'.$flightover_item['flight_country'].' ('.$flightover_item['flight_country_iso2'].')",'.$flightover_item['flight_count'].'],';
321
-	    }
322
-	    $flightover_data = substr($flightover_data, 0, -1);
323
-	    print $flightover_data;
324
-	    print ']);
321
+		}
322
+		$flightover_data = substr($flightover_data, 0, -1);
323
+		print $flightover_data;
324
+		print ']);
325 325
 
326 326
                         var options = {
327 327
                             chartArea: {"width": "80%", "height": "60%"},
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
                 </div>
346 346
             </div>
347 347
 <?php
348
-    }
348
+	}
349 349
 ?>
350 350
         </div>
351 351
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
         <div class="row column">
356 356
             <div class="col-md-6">
357 357
 <?php
358
-    $airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
359
-    if (count($airport_airport_array) > 0) {
358
+	$airport_airport_array = $Stats->countAllDepartureAirports(true,$airline_icao,$filter_name,$year,$month);
359
+	if (count($airport_airport_array) > 0) {
360 360
 	print '<h2>'._("Top 10 Most Common Departure Airports").'</h2>';
361 361
 	print '<div id="chart3" class="chart" width="100%"></div>
362 362
                 <script>
@@ -369,13 +369,13 @@  discard block
 block discarded – undo
369 369
 
370 370
                 var data = google.visualization.arrayToDataTable([ 
371 371
                     ["'._("Airport").'", "'._("# of times").'"],';
372
-                    $airport_data = '';
372
+					$airport_data = '';
373 373
 	foreach($airport_airport_array as $airport_item)
374 374
 	{
375
-	    $name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376
-	    $name = str_replace("'", "", $name);
377
-	    $name = str_replace('"', "", $name);
378
-	    $airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
375
+		$name = $airport_item['airport_departure_city'].', '.$airport_item['airport_departure_country'].' ('.$airport_item['airport_departure_icao'].')';
376
+		$name = str_replace("'", "", $name);
377
+		$name = str_replace('"', "", $name);
378
+		$airport_data .= '[ "'.$name.'",'.$airport_item['airport_departure_icao_count'].'],';
379 379
 	}
380 380
 	$airport_data = substr($airport_data, 0, -1);
381 381
 	print $airport_data;
@@ -396,15 +396,15 @@  discard block
 block discarded – undo
396 396
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-departure'; 
397 397
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
398 398
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
399
-    }
399
+	}
400 400
 ?>
401 401
             </div>
402 402
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
403 403
 
404 404
             <div class="col-md-6">
405 405
 <?php
406
-    $airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
407
-    if (count($airport_airport_array2) > 0) {
406
+	$airport_airport_array2 = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month);
407
+	if (count($airport_airport_array2) > 0) {
408 408
 	print '<h2>'._("Top 10 Most Common Arrival Airports").'</h2>';
409 409
 	print '<div id="chart4" class="chart" width="100%"></div>
410 410
                 <script>
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 	$airport_data2 = '';
421 421
 	foreach($airport_airport_array2 as $airport_item2)
422 422
 	{
423
-	    $name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
-	    $name2 = str_replace(array("'",'"'), '', $name2);
425
-	    $airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
423
+		$name2 = $airport_item2['airport_arrival_city'].', '.$airport_item2['airport_arrival_country'].' ('.$airport_item2['airport_arrival_icao'].')';
424
+		$name2 = str_replace(array("'",'"'), '', $name2);
425
+		$airport_data2 .= '[ "'.$name2.'",'.$airport_item2['airport_arrival_icao_count'].'],';
426 426
 	}
427 427
 	$airport_data2 = substr($airport_data2, 0, -1);
428 428
 	print $airport_data2;
@@ -443,36 +443,36 @@  discard block
 block discarded – undo
443 443
 	print '<div class="more"><a href="'.$globalURL.'/statistics/airport-arrival';
444 444
 	if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao;
445 445
 	print '" class="btn btn-default btn" role="button">'._("See full statistic").'&raquo;</a></div>';
446
-    }
446
+	}
447 447
 ?>
448 448
             </div>
449 449
         </div>
450 450
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
451 451
 <?php
452
-    if ($year == '' && $month == '') {
452
+	if ($year == '' && $month == '') {
453 453
 ?>
454 454
         <div class="row column">
455 455
             <div class="col-md-6">
456 456
                 <h2><?php echo _("Busiest Months of the last 12 Months"); ?></h2>
457 457
                 <?php
458
-                  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
-		    if (count($year_array) == 0) print _("No data available");
460
-		    else {
461
-                  print '<div id="chart8" class="chart" width="100%"></div>
458
+				  $year_array = $Stats->countAllMonthsLastYear(true,$airline_icao,$filter_name);
459
+			if (count($year_array) == 0) print _("No data available");
460
+			else {
461
+				  print '<div id="chart8" class="chart" width="100%"></div>
462 462
                     <script> 
463 463
                         google.load("visualization", "1", {packages:["corechart"]});
464 464
                       google.setOnLoadCallback(drawChart8);
465 465
                       function drawChart8() {
466 466
                         var data = google.visualization.arrayToDataTable([
467 467
                             ["'._("Month").'", "'._("# of Flights").'"], ';
468
-                            $year_data = '';
469
-                          foreach($year_array as $year_item)
470
-                                    {
471
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472
-                                    }
473
-                                    $year_data = substr($year_data, 0, -1);
474
-                                    print $year_data;
475
-                        print ']);
468
+							$year_data = '';
469
+						  foreach($year_array as $year_item)
470
+									{
471
+										$year_data .= '[ "'.date('F, Y',strtotime($year_item['year_name'].'-'.$year_item['month_name'].'-01')).'",'.$year_item['date_count'].'],';
472
+									}
473
+									$year_data = substr($year_data, 0, -1);
474
+									print $year_data;
475
+						print ']);
476 476
 
477 477
                         var options = {
478 478
                             legend: {position: "none"},
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
                               drawChart8();
491 491
                             });
492 492
                   </script>';
493
-                  }
494
-                  ?>
493
+				  }
494
+				  ?>
495 495
                 <div class="more">
496 496
                     <a href="<?php print $globalURL; ?>/statistics/year<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
497 497
                 </div>
@@ -500,24 +500,24 @@  discard block
 block discarded – undo
500 500
             <div class="col-md-6">
501 501
                 <h2><?php echo _("Busiest Day in the last Month"); ?></h2>
502 502
                 <?php
503
-                  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
-		    if (count($month_array) == 0) print _("No data available");
505
-		    else {
506
-                  print '<div id="chart9" class="chart" width="100%"></div>
503
+				  $month_array = $Stats->countAllDatesLastMonth($airline_icao,$filter_name);
504
+			if (count($month_array) == 0) print _("No data available");
505
+			else {
506
+				  print '<div id="chart9" class="chart" width="100%"></div>
507 507
                     <script> 
508 508
                         google.load("visualization", "1", {packages:["corechart"]});
509 509
                       google.setOnLoadCallback(drawChart9);
510 510
                       function drawChart9() {
511 511
                         var data = google.visualization.arrayToDataTable([
512 512
                             ["'._("Day").'", "'._("# of Flights").'"], ';
513
-                            $month_data = '';
514
-                          foreach($month_array as $month_item)
515
-                                    {
516
-                                        $month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517
-                                    }
518
-                                    $month_data = substr($month_data, 0, -1);
519
-                                    print $month_data;
520
-                        print ']);
513
+							$month_data = '';
514
+						  foreach($month_array as $month_item)
515
+									{
516
+										$month_data .= '[ "'.date('F j, Y',strtotime($month_item['date_name'])).'",'.$month_item['date_count'].'],';
517
+									}
518
+									$month_data = substr($month_data, 0, -1);
519
+									print $month_data;
520
+						print ']);
521 521
 
522 522
                         var options = {
523 523
                             legend: {position: "none"},
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
                               drawChart9();
536 536
                             });
537 537
                   </script>';
538
-                  }
539
-                  ?>
538
+				  }
539
+				  ?>
540 540
                 <div class="more">
541 541
                     <a href="<?php print $globalURL; ?>/statistics/month<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
542 542
                 </div>
@@ -546,25 +546,25 @@  discard block
 block discarded – undo
546 546
             <div class="col-md-6">
547 547
                 <h2><?php echo _("Busiest Day in the last 7 Days"); ?></h2>
548 548
                 <?php
549
-                    $date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
-		    if (empty($date_array)) print _("No data available");
551
-		    else {
552
-                  print '<div id="chart5" class="chart" width="100%"></div>
549
+					$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name);
550
+			if (empty($date_array)) print _("No data available");
551
+			else {
552
+				  print '<div id="chart5" class="chart" width="100%"></div>
553 553
                     <script> 
554 554
                         google.load("visualization", "1", {packages:["corechart"]});
555 555
                       google.setOnLoadCallback(drawChart5);
556 556
                       function drawChart5() {
557 557
                         var data = google.visualization.arrayToDataTable([
558 558
                             ["'._("Date").'", "'._("# of Flights").'"], ';
559
-                            $date_data = '';
559
+							$date_data = '';
560 560
                         
561
-                          foreach($date_array as $date_item)
562
-                                    {
563
-                                        $date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564
-                                    }
565
-                                    $date_data = substr($date_data, 0, -1);
566
-                                    print $date_data;
567
-                        print ']);
561
+						  foreach($date_array as $date_item)
562
+									{
563
+										$date_data .= '[ "'.date("F j, Y", strtotime($date_item['date_name'])).'",'.$date_item['date_count'].'],';
564
+									}
565
+									$date_data = substr($date_data, 0, -1);
566
+									print $date_data;
567
+						print ']);
568 568
 
569 569
                         var options = {
570 570
                             legend: {position: "none"},
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
                               drawChart5();
583 583
                             });
584 584
                   </script>';
585
-                  }
586
-                  ?>
585
+				  }
586
+				  ?>
587 587
                 <div class="more">
588 588
                     <a href="<?php print $globalURL; ?>/statistics/date<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
589 589
                 </div>
@@ -592,25 +592,25 @@  discard block
 block discarded – undo
592 592
             <div class="col-md-6">
593 593
                 <h2><?php echo _("Busiest Time of the Day"); ?></h2>
594 594
                 <?php
595
-                  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
-		    if (empty($hour_array)) print _("No data available");
597
-		    else {
595
+				  $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
596
+			if (empty($hour_array)) print _("No data available");
597
+			else {
598 598
 
599
-                  print '<div id="chart6" class="chart" width="100%"></div>
599
+				  print '<div id="chart6" class="chart" width="100%"></div>
600 600
                     <script> 
601 601
                         google.load("visualization", "1", {packages:["corechart"]});
602 602
                       google.setOnLoadCallback(drawChart6);
603 603
                       function drawChart6() {
604 604
                         var data = google.visualization.arrayToDataTable([
605 605
                             ["'._("Hour").'", "'._("# of Flights").'"], ';
606
-                            $hour_data = '';
607
-                          foreach($hour_array as $hour_item)
608
-                                    {
609
-                                        $hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610
-                                    }
611
-                                    $hour_data = substr($hour_data, 0, -1);
612
-                                    print $hour_data;
613
-                        print ']);
606
+							$hour_data = '';
607
+						  foreach($hour_array as $hour_item)
608
+									{
609
+										$hour_data .= '[ "'.$hour_item['hour_name'].':00",'.$hour_item['hour_count'].'],';
610
+									}
611
+									$hour_data = substr($hour_data, 0, -1);
612
+									print $hour_data;
613
+						print ']);
614 614
 
615 615
                         var options = {
616 616
                             legend: {position: "none"},
@@ -628,8 +628,8 @@  discard block
 block discarded – undo
628 628
                               drawChart6();
629 629
                             });
630 630
                   </script>';
631
-                  }
632
-                ?>
631
+				  }
632
+				?>
633 633
                 <div class="more">
634 634
                     <a href="<?php print $globalURL; ?>/statistics/time<?php if (isset($airline_icao) && $airline_icao != '' && $airline_icao != 'all') echo '/'.$airline_icao; ?>" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
635 635
                 </div>
@@ -637,36 +637,36 @@  discard block
 block discarded – undo
637 637
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
638 638
         </div>
639 639
 <?php
640
-    }
640
+	}
641 641
 ?>
642 642
 
643 643
 <?php
644
-    if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
644
+	if (($airline_icao == '' || $airline_icao == 'all') && $year == '' && $month == '' && isset($globalAccidents) && $globalAccidents) {
645 645
 ?>
646 646
         <div class="row column">
647 647
             <div class="col-md-6">
648 648
                 <h2><?php echo _("Fatalities by Years"); ?></h2>
649 649
                 <?php
650
-		    require_once('require/class.Accident.php');
651
-            	    $Accident = new Accident();
652
-                  $year_array = $Accident->countFatalitiesByYear($filter_name);
653
-		    if (count($year_array) == 0) print _("No data available");
654
-		    else {
655
-                  print '<div id="chart32" class="chart" width="100%"></div>
650
+			require_once('require/class.Accident.php');
651
+					$Accident = new Accident();
652
+				  $year_array = $Accident->countFatalitiesByYear($filter_name);
653
+			if (count($year_array) == 0) print _("No data available");
654
+			else {
655
+				  print '<div id="chart32" class="chart" width="100%"></div>
656 656
                     <script> 
657 657
                         google.load("visualization", "1", {packages:["corechart"]});
658 658
                       google.setOnLoadCallback(drawChart32);
659 659
                       function drawChart32() {
660 660
                         var data = google.visualization.arrayToDataTable([
661 661
                             ["'._("Year").'", "'._("# of Fatalities").'"], ';
662
-                            $year_data = '';
663
-                          foreach($year_array as $year_item)
664
-                                    {
665
-                                        $year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
666
-                                    }
667
-                                    $year_data = substr($year_data, 0, -1);
668
-                                    print $year_data;
669
-                        print ']);
662
+							$year_data = '';
663
+						  foreach($year_array as $year_item)
664
+									{
665
+										$year_data .= '[ "'.$year_item['year'].'",'.$year_item['count'].'],';
666
+									}
667
+									$year_data = substr($year_data, 0, -1);
668
+									print $year_data;
669
+						print ']);
670 670
 
671 671
                         var options = {
672 672
                             legend: {position: "none"},
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
                               drawChart32();
685 685
                             });
686 686
                   </script>';
687
-                  }
688
-                  ?>
687
+				  }
688
+				  ?>
689 689
                 <div class="more">
690 690
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/year" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
691 691
                 </div>
@@ -696,26 +696,26 @@  discard block
 block discarded – undo
696 696
             <div class="col-md-6">
697 697
                 <h2><?php echo _("Fatalities last 12 Months"); ?></h2>
698 698
                 <?php
699
-		    require_once('require/class.Accident.php');
700
-            	    $Accident = new Accident();
701
-                  $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
-		    if (count($year_array) == 0) print _("No data available");
703
-		    else {
704
-                  print '<div id="chart33" class="chart" width="100%"></div>
699
+			require_once('require/class.Accident.php');
700
+					$Accident = new Accident();
701
+				  $year_array = $Accident->countFatalitiesLast12Months($filter_name);
702
+			if (count($year_array) == 0) print _("No data available");
703
+			else {
704
+				  print '<div id="chart33" class="chart" width="100%"></div>
705 705
                     <script> 
706 706
                         google.load("visualization", "1", {packages:["corechart"]});
707 707
                       google.setOnLoadCallback(drawChart33);
708 708
                       function drawChart33() {
709 709
                         var data = google.visualization.arrayToDataTable([
710 710
                             ["'._("Month").'", "'._("# of Fatalities").'"], ';
711
-                            $year_data = '';
712
-                          foreach($year_array as $year_item)
713
-                                    {
714
-                                        $year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
715
-                                    }
716
-                                    $year_data = substr($year_data, 0, -1);
717
-                                    print $year_data;
718
-                        print ']);
711
+							$year_data = '';
712
+						  foreach($year_array as $year_item)
713
+									{
714
+										$year_data .= '[ "'.date('F, Y',strtotime($year_item['year'].'-'.$year_item['month'].'-01')).'",'.$year_item['count'].'],';
715
+									}
716
+									$year_data = substr($year_data, 0, -1);
717
+									print $year_data;
718
+						print ']);
719 719
 
720 720
                         var options = {
721 721
                             legend: {position: "none"},
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
                               drawChart33();
734 734
                             });
735 735
                   </script>';
736
-                  }
737
-                  ?>
736
+				  }
737
+				  ?>
738 738
                 <div class="more">
739 739
                     <a href="<?php print $globalURL; ?>/statistics/fatalities/month" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
740 740
                 </div>
@@ -742,30 +742,30 @@  discard block
 block discarded – undo
742 742
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
743 743
 <br/>
744 744
 <?php
745
-    }
745
+	}
746 746
 ?>
747 747
 
748 748
 <?php
749
-    if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
749
+	if (($airline_icao == '' || $airline_icao == 'all') && $filter_name == '' && $year == '' && $month == '') {
750 750
 ?>
751 751
         <div class="row column">
752 752
         	<?php
753
-        	    //$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
754
-        	    if ($year == '' && $month == '') {
755
-		        $polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
756
-		    } else {
757
-        		$polar = $Stats->getStatsSource('polar',$year,$month);
758
-        	    }
759
-        	    if (!empty($polar)) {
760
-            		print '<h2>'._("Coverage pattern").'</h2>';
761
-        		foreach ($polar as $eachpolar) {
762
-        		    unset($polar_data);
763
-	        	    $Spotter = new Spotter();
764
-        		    $data = json_decode($eachpolar['source_data']);
765
-        		    foreach($data as $value => $key) {
766
-        			$direction = $Spotter->parseDirection(($value*22.5));
767
-        			$distance = $key;
768
-        			$unit = 'km';
753
+				//$polar = $Stats->getStatsSource(date('Y-m-d'),'polar');
754
+				if ($year == '' && $month == '') {
755
+				$polar = $Stats->getStatsSource('polar',date('Y'),date('m'),date('d'));
756
+			} else {
757
+				$polar = $Stats->getStatsSource('polar',$year,$month);
758
+				}
759
+				if (!empty($polar)) {
760
+					print '<h2>'._("Coverage pattern").'</h2>';
761
+				foreach ($polar as $eachpolar) {
762
+					unset($polar_data);
763
+					$Spotter = new Spotter();
764
+					$data = json_decode($eachpolar['source_data']);
765
+					foreach($data as $value => $key) {
766
+					$direction = $Spotter->parseDirection(($value*22.5));
767
+					$distance = $key;
768
+					$unit = 'km';
769 769
 				if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
770 770
 					$distance = round($distance*0.539957);
771 771
 					$unit = 'nm';
@@ -776,10 +776,10 @@  discard block
 block discarded – undo
776 776
 					$distance = $distance;
777 777
 					$unit = 'km';
778 778
 				}
779
-        			if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
-        	    		else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
781
-        		    }
782
-        	?>
779
+					if (!isset($polar_data)) $polar_data = '{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
780
+						else $polar_data = $polar_data.',{axis:"'.$direction[0]['direction_shortname'].'",value:'.$key.'}';
781
+					}
782
+			?>
783 783
             <div class="col-md-6">
784 784
                 <h4><?php print $eachpolar['source_name']; ?></h4>
785 785
         	<div id="polar-<?php print str_replace(' ','_',strtolower($eachpolar['source_name'])); ?>" class="chart" width="100%"></div>
@@ -811,27 +811,27 @@  discard block
 block discarded – undo
811 811
 		</script>
812 812
             </div>
813 813
             <?php
814
-        	    }
815
-        	}
816
-            ?>
814
+				}
815
+			}
816
+			?>
817 817
         </div>
818 818
         <div class="row column">
819 819
             <div class="col-md-6">
820 820
         	<?php
821
-        	    //$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
822
-        	    if ($year == '' && $month == '') {
823
-        		$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
824
-        	    } else {
825
-        		$msg = $Stats->getStatsSource('msg',$year,$month);
826
-        	    }
827
-        	    if (!empty($msg)) {
828
-            		print '<h2>'._("Messages received").'</h2>';
829
-        		foreach ($msg as $eachmsg) {
830
-        		    //$eachmsg = $msg[0];
831
-        		    $data = $eachmsg['source_data'];
832
-        		    if ($data > 500) $max = (round(($data+100)/100))*100;
833
-        		    else $max = 500;
834
-        	?>
821
+				//$msg = $Stats->getStatsSource(date('Y-m-d'),'msg');
822
+				if ($year == '' && $month == '') {
823
+				$msg = $Stats->getStatsSource('msg',date('Y'),date('m'),date('d'));
824
+				} else {
825
+				$msg = $Stats->getStatsSource('msg',$year,$month);
826
+				}
827
+				if (!empty($msg)) {
828
+					print '<h2>'._("Messages received").'</h2>';
829
+				foreach ($msg as $eachmsg) {
830
+					//$eachmsg = $msg[0];
831
+					$data = $eachmsg['source_data'];
832
+					if ($data > 500) $max = (round(($data+100)/100))*100;
833
+					else $max = 500;
834
+			?>
835 835
         	<div id="msg-<?php print str_replace(' ','_',strtolower($eachmsg['source_name'])); ?>" class="col-md-4"></div>
836 836
         	<script>
837 837
 		      var g = new JustGage({
@@ -847,9 +847,9 @@  discard block
 block discarded – undo
847 847
 			  });
848 848
 		</script>
849 849
             <?php
850
-        	   }
851
-        	}
852
-            ?>
850
+			   }
851
+			}
852
+			?>
853 853
             </div>
854 854
         </div>
855 855
         <div class="row column">
@@ -881,19 +881,19 @@  discard block
 block discarded – undo
881 881
 				$hist_data .= '[ "'.$distance.'",'.$nb.'],';
882 882
 			}
883 883
 			$hist_data = substr($hist_data, 0, -1);
884
-            ?>
884
+			?>
885 885
             <div class="col-md-6">
886 886
                 <h2><?php echo sprintf(_("Flights Distance for %s"),$source); ?></h2>
887 887
                 <?php
888
-                  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
888
+				  print '<div id="charthist-'.str_replace(' ','_',strtolower($source)).'" class="chart" width="100%"></div>
889 889
                     <script> 
890 890
                         google.load("visualization", "1", {packages:["corechart"]});
891 891
                       google.setOnLoadCallback(drawCharthist_'.str_replace(' ','_',strtolower($source)).');
892 892
                       function drawCharthist_'.str_replace(' ','_',strtolower($source)).'() {
893 893
                         var data = google.visualization.arrayToDataTable([
894 894
                             ["'._("Distance").'", "'._("# of Flights").'"], ';
895
-                            print $hist_data;
896
-                        print ']);
895
+							print $hist_data;
896
+						print ']);
897 897
 
898 898
                         var options = {
899 899
                             legend: {position: "none"},
@@ -911,15 +911,15 @@  discard block
 block discarded – undo
911 911
                               drawCharthist_'.str_replace(' ','_',strtolower($source)).'();
912 912
                             });
913 913
                   </script>';
914
-        	?>
914
+			?>
915 915
     	    </div>
916 916
 	    <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
917 917
         	<?php
918
-                  }
919
-                ?>
918
+				  }
919
+				?>
920 920
         </div>
921 921
 <?php
922
-    }
922
+	}
923 923
 ?>
924 924
     </div>
925 925
 </div>  
Please login to merge, or discard this patch.
require/class.Stats.php 1 patch
Indentation   +779 added lines, -779 removed lines patch added patch discarded remove patch
@@ -15,33 +15,33 @@  discard block
 block discarded – undo
15 15
 		if (isset($globalFilterName)) $this->filter_name = $globalFilterName;
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-        }
18
+		}
19 19
               
20 20
 	public function addLastStatsUpdate($type,$stats_date) {
21
-                $query = "DELETE FROM config WHERE name = :type;
21
+				$query = "DELETE FROM config WHERE name = :type;
22 22
             		INSERT INTO config (name,value) VALUES (:type,:stats_date);";
23
-                $query_values = array('type' => $type,':stats_date' => $stats_date);
24
-                 try {
25
-                        $sth = $this->db->prepare($query);
26
-                        $sth->execute($query_values);
27
-                } catch(PDOException $e) {
28
-                        return "error : ".$e->getMessage();
29
-                }
30
-        }
23
+				$query_values = array('type' => $type,':stats_date' => $stats_date);
24
+				 try {
25
+						$sth = $this->db->prepare($query);
26
+						$sth->execute($query_values);
27
+				} catch(PDOException $e) {
28
+						return "error : ".$e->getMessage();
29
+				}
30
+		}
31 31
 
32 32
 	public function getLastStatsUpdate($type = 'last_update_stats') {
33
-                $query = "SELECT value FROM config WHERE name = :type";
34
-                 try {
35
-                        $sth = $this->db->prepare($query);
36
-                        $sth->execute(array(':type' => $type));
37
-                } catch(PDOException $e) {
38
-                        echo "error : ".$e->getMessage();
39
-                }
40
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
-                return $all;
42
-        }
43
-        public function deleteStats($filter_name = '') {
44
-        	/*
33
+				$query = "SELECT value FROM config WHERE name = :type";
34
+				 try {
35
+						$sth = $this->db->prepare($query);
36
+						$sth->execute(array(':type' => $type));
37
+				} catch(PDOException $e) {
38
+						echo "error : ".$e->getMessage();
39
+				}
40
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
41
+				return $all;
42
+		}
43
+		public function deleteStats($filter_name = '') {
44
+			/*
45 45
         	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
46 46
                  try {
47 47
                         $sth = $this->db->prepare($query);
@@ -50,106 +50,106 @@  discard block
 block discarded – undo
50 50
                         return "error : ".$e->getMessage();
51 51
                 }
52 52
                 */
53
-        	$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
-                 try {
55
-                        $sth = $this->db->prepare($query);
56
-                        $sth->execute(array(':filter_name' => $filter_name));
57
-                } catch(PDOException $e) {
58
-                        return "error : ".$e->getMessage();
59
-                }
60
-        }
61
-        public function deleteOldStats($filter_name = '') {
53
+			$query = "DELETE FROM stats WHERE filter_name = :filter_name;DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_airport WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_flight WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
54
+				 try {
55
+						$sth = $this->db->prepare($query);
56
+						$sth->execute(array(':filter_name' => $filter_name));
57
+				} catch(PDOException $e) {
58
+						return "error : ".$e->getMessage();
59
+				}
60
+		}
61
+		public function deleteOldStats($filter_name = '') {
62 62
         	
63
-        	$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
-                 try {
65
-                        $sth = $this->db->prepare($query);
66
-                        $sth->execute();
67
-                } catch(PDOException $e) {
68
-                        return "error : ".$e->getMessage();
69
-                }
63
+			$query = "DELETE FROM config WHERE name = 'last_update_stats'";
64
+				 try {
65
+						$sth = $this->db->prepare($query);
66
+						$sth->execute();
67
+				} catch(PDOException $e) {
68
+						return "error : ".$e->getMessage();
69
+				}
70 70
                 
71
-        	$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
-                 try {
73
-                        $sth = $this->db->prepare($query);
74
-                        $sth->execute(array(':filter_name' => $filter_name));
75
-                } catch(PDOException $e) {
76
-                        return "error : ".$e->getMessage();
77
-                }
78
-        }
71
+			$query = "DELETE FROM stats_aircraft WHERE filter_name = :filter_name;DELETE FROM stats_airline WHERE filter_name = :filter_name;DELETE FROM stats_callsign WHERE filter_name = :filter_name;DELETE FROM stats_country WHERE filter_name = :filter_name;DELETE FROM stats_owner WHERE filter_name = :filter_name;DELETE FROM stats_pilot WHERE filter_name = :filter_name;DELETE FROM stats_registration WHERE filter_name = :filter_name;";
72
+				 try {
73
+						$sth = $this->db->prepare($query);
74
+						$sth->execute(array(':filter_name' => $filter_name));
75
+				} catch(PDOException $e) {
76
+						return "error : ".$e->getMessage();
77
+				}
78
+		}
79 79
 	public function getAllAirlineNames($filter_name = '') {
80 80
 		if ($filter_name == '') $filter_name = $this->filter_name;
81
-                $query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
-                 try {
83
-                        $sth = $this->db->prepare($query);
84
-                        $sth->execute(array(':filter_name' => $filter_name));
85
-                } catch(PDOException $e) {
86
-                        echo "error : ".$e->getMessage();
87
-                }
88
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
-                return $all;
90
-        }
81
+				$query = "SELECT * FROM stats_airline WHERE filter_name = :filter_name ORDER BY airline_name ASC";
82
+				 try {
83
+						$sth = $this->db->prepare($query);
84
+						$sth->execute(array(':filter_name' => $filter_name));
85
+				} catch(PDOException $e) {
86
+						echo "error : ".$e->getMessage();
87
+				}
88
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
89
+				return $all;
90
+		}
91 91
 	public function getAllAircraftTypes($stats_airline = '',$filter_name = '') {
92 92
 		if ($filter_name == '') $filter_name = $this->filter_name;
93
-                $query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
-                 try {
95
-                        $sth = $this->db->prepare($query);
96
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
-                } catch(PDOException $e) {
98
-                        echo "error : ".$e->getMessage();
99
-                }
100
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
-                return $all;
102
-        }
93
+				$query = "SELECT * FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY aircraft_manufacturer ASC";
94
+				 try {
95
+						$sth = $this->db->prepare($query);
96
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
97
+				} catch(PDOException $e) {
98
+						echo "error : ".$e->getMessage();
99
+				}
100
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
101
+				return $all;
102
+		}
103 103
 	public function getAllManufacturers($stats_airline = '',$filter_name = '') {
104 104
 		if ($filter_name == '') $filter_name = $this->filter_name;
105
-                $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";
106
-                 try {
107
-                        $sth = $this->db->prepare($query);
108
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
-                } catch(PDOException $e) {
110
-                        echo "error : ".$e->getMessage();
111
-                }
112
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
-                return $all;
114
-        }
105
+				$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";
106
+				 try {
107
+						$sth = $this->db->prepare($query);
108
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
109
+				} catch(PDOException $e) {
110
+						echo "error : ".$e->getMessage();
111
+				}
112
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
113
+				return $all;
114
+		}
115 115
 	public function getAllAirportNames($stats_airline = '',$filter_name = '') {
116 116
 		if ($filter_name == '') $filter_name = $this->filter_name;
117
-                $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";
118
-                 try {
119
-                        $sth = $this->db->prepare($query);
120
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
-                } catch(PDOException $e) {
122
-                        echo "error : ".$e->getMessage();
123
-                }
124
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
-                return $all;
126
-        }
117
+				$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";
118
+				 try {
119
+						$sth = $this->db->prepare($query);
120
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
121
+				} catch(PDOException $e) {
122
+						echo "error : ".$e->getMessage();
123
+				}
124
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
125
+				return $all;
126
+		}
127 127
 
128 128
 	public function getAllOwnerNames($stats_airline = '',$filter_name = '') {
129 129
 		if ($filter_name == '') $filter_name = $this->filter_name;
130
-                $query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
-                 try {
132
-                        $sth = $this->db->prepare($query);
133
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
-                } catch(PDOException $e) {
135
-                        echo "error : ".$e->getMessage();
136
-                }
137
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
-                return $all;
139
-        }
130
+				$query = "SELECT owner_name FROM stats_owner WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY owner_name ASC";
131
+				 try {
132
+						$sth = $this->db->prepare($query);
133
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
134
+				} catch(PDOException $e) {
135
+						echo "error : ".$e->getMessage();
136
+				}
137
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
138
+				return $all;
139
+		}
140 140
 
141 141
 	public function getAllPilotNames($stats_airline = '',$filter_name = '') {
142 142
 		if ($filter_name == '') $filter_name = $this->filter_name;
143
-                $query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
-                 try {
145
-                        $sth = $this->db->prepare($query);
146
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
-                } catch(PDOException $e) {
148
-                        echo "error : ".$e->getMessage();
149
-                }
150
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
-                return $all;
152
-        }
143
+				$query = "SELECT pilot_id,pilot_name FROM stats_pilot WHERE stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY pilot_name ASC";
144
+				 try {
145
+						$sth = $this->db->prepare($query);
146
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
147
+				} catch(PDOException $e) {
148
+						echo "error : ".$e->getMessage();
149
+				}
150
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
151
+				return $all;
152
+		}
153 153
 
154 154
 
155 155
 	public function countAllAircraftTypes($limit = true, $stats_airline = '', $filter_name = '',$year = '', $month = '') {
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 			}
167 167
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
168 168
 		} else $all = array();
169
-                if (empty($all)) {
170
-            	    $filters = array('airlines' => array($stats_airline));
171
-            	    if ($filter_name != '') {
172
-            		    $filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
-            	    }
174
-            	    $Spotter = new Spotter($this->db);
175
-            	    $all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
-                }
177
-                return $all;
169
+				if (empty($all)) {
170
+					$filters = array('airlines' => array($stats_airline));
171
+					if ($filter_name != '') {
172
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
173
+					}
174
+					$Spotter = new Spotter($this->db);
175
+					$all = $Spotter->countAllAircraftTypes($limit,0,'',$filters,$year,$month);
176
+				}
177
+				return $all;
178 178
 	}
179 179
 	public function countAllAirlineCountries($limit = true,$filter_name = '',$year = '',$month = '') {
180 180
 		global $globalStatsFilters;
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
 			}
191 191
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
192 192
 		} else $all = array();
193
-                if (empty($all)) {
194
-            		$Spotter = new Spotter($this->db);
195
-            		$filters = array();
196
-            		if ($filter_name != '') {
197
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
193
+				if (empty($all)) {
194
+					$Spotter = new Spotter($this->db);
195
+					$filters = array();
196
+					if ($filter_name != '') {
197
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
198 198
 			}
199
-            		$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
-                }
201
-                return $all;
199
+					$all = $Spotter->countAllAirlineCountries($limit,$filters,$year,$month);
200
+				}
201
+				return $all;
202 202
 	}
203 203
 	public function countAllAircraftManufacturers($limit = true,$stats_airline = '', $filter_name = '',$year = '', $month = '') {
204 204
 		global $globalStatsFilters;
@@ -239,37 +239,37 @@  discard block
 block discarded – undo
239 239
 			}
240 240
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
241 241
 		} else $all = array();
242
-                if (empty($all)) {
242
+				if (empty($all)) {
243 243
 			$filters = array('airlines' => array($stats_airline));
244 244
 			if ($filter_name != '') {
245
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
245
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
246 246
 			}
247 247
 			$Spotter = new Spotter($this->db);
248 248
 			$all = $Spotter->countAllArrivalCountries($limit,$filters,$year,$month);
249
-                }
250
-                return $all;
249
+				}
250
+				return $all;
251 251
 	}
252 252
 	public function countAllDepartureCountries($limit = true, $stats_airline = '', $filter_name = '', $year = '', $month = '') {
253 253
 		global $globalStatsFilters;
254 254
 		if ($filter_name == '') $filter_name = $this->filter_name;
255 255
 		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";
256 256
 		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";
257
-                 try {
258
-                        $sth = $this->db->prepare($query);
259
-                        $sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
-                } catch(PDOException $e) {
261
-                        echo "error : ".$e->getMessage();
262
-                }
263
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
-                if (empty($all)) {
257
+				 try {
258
+						$sth = $this->db->prepare($query);
259
+						$sth->execute(array(':stats_airline' => $stats_airline,':filter_name' => $filter_name));
260
+				} catch(PDOException $e) {
261
+						echo "error : ".$e->getMessage();
262
+				}
263
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
264
+				if (empty($all)) {
265 265
 			$filters = array('airlines' => array($stats_airline));
266 266
 			if ($filter_name != '') {
267
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
267
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
268 268
 			}
269 269
 			$Spotter = new Spotter($this->db);
270 270
 			$all = $Spotter->countAllDepartureCountries($filters,$year,$month);
271
-                }
272
-                return $all;
271
+				}
272
+				return $all;
273 273
 	}
274 274
 
275 275
 	public function countAllAirlines($limit = true,$filter_name = '',$year = '',$month = '') {
@@ -286,16 +286,16 @@  discard block
 block discarded – undo
286 286
 			}
287 287
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
288 288
 		} else $all = array();
289
-                if (empty($all)) {
290
-	                $Spotter = new Spotter($this->db);
291
-            		$filters = array();
292
-            		if ($filter_name != '') {
293
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
289
+				if (empty($all)) {
290
+					$Spotter = new Spotter($this->db);
291
+					$filters = array();
292
+					if ($filter_name != '') {
293
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
294 294
 			}
295 295
 
296
-    		        $all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
-                }
298
-                return $all;
296
+					$all = $Spotter->countAllAirlines($limit,0,'',$filters,$year,$month);
297
+				}
298
+				return $all;
299 299
 	}
300 300
 	public function countAllAircraftRegistrations($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
301 301
 		global $globalStatsFilters;
@@ -311,15 +311,15 @@  discard block
 block discarded – undo
311 311
 			}
312 312
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
313 313
 		} else $all = array();
314
-                if (empty($all)) {
314
+				if (empty($all)) {
315 315
 			$filters = array('airlines' => array($stats_airline));
316 316
 			if ($filter_name != '') {
317 317
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
318 318
 			}
319
-	                $Spotter = new Spotter($this->db);
320
-    		        $all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
-                }
322
-                return $all;
319
+					$Spotter = new Spotter($this->db);
320
+					$all = $Spotter->countAllAircraftRegistrations($limit,0,'',$filters,$year,$month);
321
+				}
322
+				return $all;
323 323
 	}
324 324
 	public function countAllCallsigns($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
325 325
 		global $globalStatsFilters;
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 					echo "error : ".$e->getMessage();
360 360
 				}
361 361
 				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
362
-                /*
362
+				/*
363 363
                 if (empty($all)) {
364 364
 	                $Spotter = new Spotter($this->db);
365 365
     		        $all = $Spotter->countAllFlightOverCountries($limit);
@@ -410,15 +410,15 @@  discard block
 block discarded – undo
410 410
 			}
411 411
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
412 412
 		} else $all = array();
413
-                if (empty($all)) {
413
+				if (empty($all)) {
414 414
 			$filters = array('airlines' => array($stats_airline));
415 415
 			if ($filter_name != '') {
416 416
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
417 417
 			}
418
-            		$Spotter = new Spotter($this->db);
419
-            		$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
-                }
421
-                return $all;
418
+					$Spotter = new Spotter($this->db);
419
+					$all = $Spotter->countAllOwners($limit,0,'',$filters,$year,$month);
420
+				}
421
+				return $all;
422 422
 	}
423 423
 	public function countAllDepartureAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
424 424
 		global $globalStatsFilters;
@@ -434,33 +434,33 @@  discard block
 block discarded – undo
434 434
 			}
435 435
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
436 436
 		} else $all = array();
437
-                if (empty($all)) {
437
+				if (empty($all)) {
438 438
 			$filters = array('airlines' => array($stats_airline));
439
-            		if ($filter_name != '') {
440
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
-			}
442
-            		$Spotter = new Spotter($this->db);
443
-            		$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
-        		$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
-        		$all = array();
446
-        		foreach ($pall as $value) {
447
-        			$icao = $value['airport_departure_icao'];
448
-        			$all[$icao] = $value;
449
-        		}
439
+					if ($filter_name != '') {
440
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
441
+			}
442
+					$Spotter = new Spotter($this->db);
443
+					$pall = $Spotter->countAllDepartureAirports($limit,0,'',$filters,$year,$month);
444
+				$dall = $Spotter->countAllDetectedDepartureAirports($limit,0,'',$filters,$year,$month);
445
+				$all = array();
446
+				foreach ($pall as $value) {
447
+					$icao = $value['airport_departure_icao'];
448
+					$all[$icao] = $value;
449
+				}
450 450
         		
451
-        		foreach ($dall as $value) {
452
-        			$icao = $value['airport_departure_icao'];
453
-        			if (isset($all[$icao])) {
454
-        				$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
-        			} else $all[$icao] = $value;
456
-        		}
457
-        		$count = array();
458
-        		foreach ($all as $key => $row) {
459
-        			$count[$key] = $row['airport_departure_icao_count'];
460
-        		}
461
-        		array_multisort($count,SORT_DESC,$all);
462
-                }
463
-                return $all;
451
+				foreach ($dall as $value) {
452
+					$icao = $value['airport_departure_icao'];
453
+					if (isset($all[$icao])) {
454
+						$all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
455
+					} else $all[$icao] = $value;
456
+				}
457
+				$count = array();
458
+				foreach ($all as $key => $row) {
459
+					$count[$key] = $row['airport_departure_icao_count'];
460
+				}
461
+				array_multisort($count,SORT_DESC,$all);
462
+				}
463
+				return $all;
464 464
 	}
465 465
 	public function countAllArrivalAirports($limit = true,$stats_airline = '',$filter_name = '',$year = '',$month = '') {
466 466
 		global $globalStatsFilters;
@@ -484,26 +484,26 @@  discard block
 block discarded – undo
484 484
 			$Spotter = new Spotter($this->db);
485 485
 			$pall = $Spotter->countAllArrivalAirports($limit,0,'',false,$filters,$year,$month);
486 486
 			$dall = $Spotter->countAllDetectedArrivalAirports($limit,0,'',false,$filters,$year,$month);
487
-        		$all = array();
488
-        		foreach ($pall as $value) {
489
-        			$icao = $value['airport_arrival_icao'];
490
-        			$all[$icao] = $value;
491
-        		}
487
+				$all = array();
488
+				foreach ($pall as $value) {
489
+					$icao = $value['airport_arrival_icao'];
490
+					$all[$icao] = $value;
491
+				}
492 492
         		
493
-        		foreach ($dall as $value) {
494
-        			$icao = $value['airport_arrival_icao'];
495
-        			if (isset($all[$icao])) {
496
-        				$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
-        			} else $all[$icao] = $value;
498
-        		}
499
-        		$count = array();
500
-        		foreach ($all as $key => $row) {
501
-        			$count[$key] = $row['airport_arrival_icao_count'];
502
-        		}
503
-        		array_multisort($count,SORT_DESC,$all);
504
-                }
493
+				foreach ($dall as $value) {
494
+					$icao = $value['airport_arrival_icao'];
495
+					if (isset($all[$icao])) {
496
+						$all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
497
+					} else $all[$icao] = $value;
498
+				}
499
+				$count = array();
500
+				foreach ($all as $key => $row) {
501
+					$count[$key] = $row['airport_arrival_icao_count'];
502
+				}
503
+				array_multisort($count,SORT_DESC,$all);
504
+				}
505 505
  
506
-                return $all;
506
+				return $all;
507 507
 	}
508 508
 	public function countAllMonthsLastYear($limit = true,$stats_airline = '',$filter_name = '') {
509 509
 		global $globalDBdriver, $globalStatsFilters;
@@ -516,23 +516,23 @@  discard block
 block discarded – undo
516 516
 			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";
517 517
 		}
518 518
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
519
-                 try {
520
-                        $sth = $this->db->prepare($query);
521
-                        $sth->execute($query_data);
522
-                } catch(PDOException $e) {
523
-                        echo "error : ".$e->getMessage();
524
-                }
525
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
-                if (empty($all)) {
519
+				 try {
520
+						$sth = $this->db->prepare($query);
521
+						$sth->execute($query_data);
522
+				} catch(PDOException $e) {
523
+						echo "error : ".$e->getMessage();
524
+				}
525
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
526
+				if (empty($all)) {
527 527
 			$filters = array('airlines' => array($stats_airline));
528 528
 			if ($filter_name != '') {
529 529
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
530 530
 			}
531
-            		$Spotter = new Spotter($this->db);
532
-            		$all = $Spotter->countAllMonthsLastYear($filters);
533
-                }
531
+					$Spotter = new Spotter($this->db);
532
+					$all = $Spotter->countAllMonthsLastYear($filters);
533
+				}
534 534
                 
535
-                return $all;
535
+				return $all;
536 536
 	}
537 537
 	
538 538
 	public function countAllDatesLastMonth($stats_airline = '',$filter_name = '') {
@@ -540,22 +540,22 @@  discard block
 block discarded – undo
540 540
 		if ($filter_name == '') $filter_name = $this->filter_name;
541 541
 		$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";
542 542
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
543
-                 try {
544
-                        $sth = $this->db->prepare($query);
545
-                        $sth->execute($query_data);
546
-                } catch(PDOException $e) {
547
-                        echo "error : ".$e->getMessage();
548
-                }
549
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
-                if (empty($all)) {
543
+				 try {
544
+						$sth = $this->db->prepare($query);
545
+						$sth->execute($query_data);
546
+				} catch(PDOException $e) {
547
+						echo "error : ".$e->getMessage();
548
+				}
549
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
550
+				if (empty($all)) {
551 551
 			$filters = array('airlines' => array($stats_airline));
552 552
 			if ($filter_name != '') {
553 553
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
554 554
 			}
555
-            		$Spotter = new Spotter($this->db);
556
-            		$all = $Spotter->countAllDatesLastMonth($filters);
557
-                }
558
-                return $all;
555
+					$Spotter = new Spotter($this->db);
556
+					$all = $Spotter->countAllDatesLastMonth($filters);
557
+				}
558
+				return $all;
559 559
 	}
560 560
 	public function countAllDatesLast7Days($stats_airline = '',$filter_name = '') {
561 561
 		global $globalDBdriver, $globalStatsFilters;
@@ -566,110 +566,110 @@  discard block
 block discarded – undo
566 566
 			$query = "SELECT flight_date as date_name, cnt as date_count FROM stats_flight WHERE stats_type = 'month' AND flight_date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '7 DAYS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
567 567
 		}
568 568
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
569
-                 try {
570
-                        $sth = $this->db->prepare($query);
571
-                        $sth->execute($query_data);
572
-                } catch(PDOException $e) {
573
-                        echo "error : ".$e->getMessage();
574
-                }
575
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
-                if (empty($all)) {
569
+				 try {
570
+						$sth = $this->db->prepare($query);
571
+						$sth->execute($query_data);
572
+				} catch(PDOException $e) {
573
+						echo "error : ".$e->getMessage();
574
+				}
575
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
576
+				if (empty($all)) {
577 577
 			$filters = array('airlines' => array($stats_airline));
578 578
 			if ($filter_name != '') {
579 579
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
580 580
 			}
581
-            		$Spotter = new Spotter($this->db);
582
-            		$all = $Spotter->countAllDatesLast7Days($filters);
583
-                }
584
-                return $all;
581
+					$Spotter = new Spotter($this->db);
582
+					$all = $Spotter->countAllDatesLast7Days($filters);
583
+				}
584
+				return $all;
585 585
 	}
586 586
 	public function countAllDates($stats_airline = '',$filter_name = '') {
587 587
 		global $globalStatsFilters;
588 588
 		if ($filter_name == '') $filter_name = $this->filter_name;
589 589
 		$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";
590 590
 		$query_data = array(':stats_airline' => $stats_airline,':filter_name' => $filter_name);
591
-                 try {
592
-                        $sth = $this->db->prepare($query);
593
-                        $sth->execute($query_data);
594
-                } catch(PDOException $e) {
595
-                        echo "error : ".$e->getMessage();
596
-                }
597
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
-                if (empty($all)) {
591
+				 try {
592
+						$sth = $this->db->prepare($query);
593
+						$sth->execute($query_data);
594
+				} catch(PDOException $e) {
595
+						echo "error : ".$e->getMessage();
596
+				}
597
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
598
+				if (empty($all)) {
599 599
 			$filters = array('airlines' => array($stats_airline));
600 600
 			if ($filter_name != '') {
601
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
601
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
602 602
 			}
603
-            		$Spotter = new Spotter($this->db);
604
-            		$all = $Spotter->countAllDates($filters);
605
-                }
606
-                return $all;
603
+					$Spotter = new Spotter($this->db);
604
+					$all = $Spotter->countAllDates($filters);
605
+				}
606
+				return $all;
607 607
 	}
608 608
 	public function countAllDatesByAirlines($filter_name = '') {
609 609
 		global $globalStatsFilters;
610 610
 		if ($filter_name == '') $filter_name = $this->filter_name;
611 611
 		$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";
612 612
 		$query_data = array('filter_name' => $filter_name);
613
-                 try {
614
-                        $sth = $this->db->prepare($query);
615
-                        $sth->execute($query_data);
616
-                } catch(PDOException $e) {
617
-                        echo "error : ".$e->getMessage();
618
-                }
619
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
-                if (empty($all)) {
621
-            		$filters = array();
622
-            		if ($filter_name != '') {
623
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
613
+				 try {
614
+						$sth = $this->db->prepare($query);
615
+						$sth->execute($query_data);
616
+				} catch(PDOException $e) {
617
+						echo "error : ".$e->getMessage();
618
+				}
619
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
620
+				if (empty($all)) {
621
+					$filters = array();
622
+					if ($filter_name != '') {
623
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
624 624
 			}
625
-            		$Spotter = new Spotter($this->db);
626
-            		$all = $Spotter->countAllDatesByAirlines($filters);
627
-                }
628
-                return $all;
625
+					$Spotter = new Spotter($this->db);
626
+					$all = $Spotter->countAllDatesByAirlines($filters);
627
+				}
628
+				return $all;
629 629
 	}
630 630
 	public function countAllMonths($stats_airline = '',$filter_name = '') {
631 631
 		global $globalStatsFilters;
632 632
 		if ($filter_name == '') $filter_name = $this->filter_name;
633
-	    	$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";
634
-                 try {
635
-                        $sth = $this->db->prepare($query);
636
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
-                } catch(PDOException $e) {
638
-                        echo "error : ".$e->getMessage();
639
-                }
640
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
633
+			$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";
634
+				 try {
635
+						$sth = $this->db->prepare($query);
636
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
637
+				} catch(PDOException $e) {
638
+						echo "error : ".$e->getMessage();
639
+				}
640
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
641 641
                 
642
-                if (empty($all)) {
642
+				if (empty($all)) {
643 643
 			$filters = array('airlines' => array($stats_airline));
644 644
 			if ($filter_name != '') {
645 645
 				$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
646 646
 			}
647
-            		$Spotter = new Spotter($this->db);
648
-            		$all = $Spotter->countAllMonths($filters);
649
-                }
647
+					$Spotter = new Spotter($this->db);
648
+					$all = $Spotter->countAllMonths($filters);
649
+				}
650 650
                 
651
-                return $all;
651
+				return $all;
652 652
 	}
653 653
 	public function countAllMilitaryMonths($filter_name = '') {
654 654
 		global $globalStatsFilters;
655 655
 		if ($filter_name == '') $filter_name = $this->filter_name;
656
-	    	$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";
657
-                 try {
658
-                        $sth = $this->db->prepare($query);
659
-                        $sth->execute(array(':filter_name' => $filter_name));
660
-                } catch(PDOException $e) {
661
-                        echo "error : ".$e->getMessage();
662
-                }
663
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
-                if (empty($all)) {
665
-            		$filters = array();
666
-            		if ($filter_name != '') {
667
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
656
+			$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";
657
+				 try {
658
+						$sth = $this->db->prepare($query);
659
+						$sth->execute(array(':filter_name' => $filter_name));
660
+				} catch(PDOException $e) {
661
+						echo "error : ".$e->getMessage();
662
+				}
663
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
664
+				if (empty($all)) {
665
+					$filters = array();
666
+					if ($filter_name != '') {
667
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
668 668
 			}
669
-            		$Spotter = new Spotter($this->db);
670
-            		$all = $Spotter->countAllMilitaryMonths($filters);
671
-                }
672
-                return $all;
669
+					$Spotter = new Spotter($this->db);
670
+					$all = $Spotter->countAllMilitaryMonths($filters);
671
+				}
672
+				return $all;
673 673
 	}
674 674
 	public function countAllHours($orderby = 'hour',$limit = true,$stats_airline = '',$filter_name = '') {
675 675
 		global $globalTimezone, $globalDBdriver, $globalStatsFilters;
@@ -685,22 +685,22 @@  discard block
 block discarded – undo
685 685
 			$query .= " ORDER BY CAST(flight_date AS integer) ASC";
686 686
 		}
687 687
 		if ($orderby == 'count') $query .= " ORDER BY hour_count DESC";
688
-                 try {
689
-                        $sth = $this->db->prepare($query);
690
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
-                } catch(PDOException $e) {
692
-                        echo "error : ".$e->getMessage();
693
-                }
694
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
-                if (empty($all)) {
688
+				 try {
689
+						$sth = $this->db->prepare($query);
690
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
691
+				} catch(PDOException $e) {
692
+						echo "error : ".$e->getMessage();
693
+				}
694
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
695
+				if (empty($all)) {
696 696
 			$filters = array('airlines' => array($stats_airline));
697 697
 			if ($filter_name != '') {
698
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
698
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
699 699
 			}
700
-            		$Spotter = new Spotter($this->db);
701
-            		$all = $Spotter->countAllHours($orderby,$filters);
702
-                }
703
-                return $all;
700
+					$Spotter = new Spotter($this->db);
701
+					$all = $Spotter->countAllHours($orderby,$filters);
702
+				}
703
+				return $all;
704 704
 	}
705 705
 	
706 706
 	public function countOverallFlights($stats_airline = '', $filter_name = '',$year = '',$month = '') {
@@ -724,9 +724,9 @@  discard block
 block discarded – undo
724 724
 		if ($year == '') $year = date('Y');
725 725
 		$all = $this->getSumStats('military_flights_bymonth',$year,'',$filter_name,$month);
726 726
 		if (empty($all)) {
727
-		        $filters = array();
728
-            		if ($filter_name != '') {
729
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
727
+				$filters = array();
728
+					if ($filter_name != '') {
729
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
730 730
 			}
731 731
 			$Spotter = new Spotter($this->db);
732 732
 			$all = $Spotter->countOverallMilitaryFlights($filters,$year,$month);
@@ -787,9 +787,9 @@  discard block
 block discarded – undo
787 787
 			$all = $result[0]['nb_airline'];
788 788
 		} else $all = $this->getSumStats('airlines_bymonth',$year,'',$filter_name,$month);
789 789
 		if (empty($all)) {
790
-            		$filters = array();
791
-            		if ($filter_name != '') {
792
-            			$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
790
+					$filters = array();
791
+					if ($filter_name != '') {
792
+						$filters = array_merge($filters,$globalStatsFilters[$filter_name]);
793 793
 			}
794 794
 			$Spotter = new Spotter($this->db);
795 795
 			$all = $Spotter->countOverallAirlines($filters,$year,$month);
@@ -856,33 +856,33 @@  discard block
 block discarded – undo
856 856
 		if ($filter_name == '') $filter_name = $this->filter_name;
857 857
 		$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";
858 858
 		$query_values = array(':airport_icao' => $airport_icao,':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
859
-                 try {
860
-                        $sth = $this->db->prepare($query);
861
-                        $sth->execute($query_values);
862
-                } catch(PDOException $e) {
863
-                        echo "error : ".$e->getMessage();
864
-                }
865
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
-                return $all;
859
+				 try {
860
+						$sth = $this->db->prepare($query);
861
+						$sth->execute($query_values);
862
+				} catch(PDOException $e) {
863
+						echo "error : ".$e->getMessage();
864
+				}
865
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
866
+				return $all;
867 867
 	}
868 868
 	public function getStats($type,$stats_airline = '', $filter_name = '') {
869 869
 		if ($filter_name == '') $filter_name = $this->filter_name;
870
-                $query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871
-                $query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872
-                 try {
873
-                        $sth = $this->db->prepare($query);
874
-                        $sth->execute($query_values);
875
-                } catch(PDOException $e) {
876
-                        echo "error : ".$e->getMessage();
877
-                }
878
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
879
-                return $all;
880
-        }
870
+				$query = "SELECT * FROM stats WHERE stats_type = :type AND stats_airline = :stats_airline AND filter_name = :filter_name ORDER BY stats_date";
871
+				$query_values = array(':type' => $type,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
872
+				 try {
873
+						$sth = $this->db->prepare($query);
874
+						$sth->execute($query_values);
875
+				} catch(PDOException $e) {
876
+						echo "error : ".$e->getMessage();
877
+				}
878
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
879
+				return $all;
880
+		}
881 881
 	public function getSumStats($type,$year,$stats_airline = '',$filter_name = '',$month = '') {
882 882
 		if ($filter_name == '') $filter_name = $this->filter_name;
883
-    		global $globalArchiveMonths, $globalDBdriver;
884
-    		if ($globalDBdriver == 'mysql') {
885
-    			if ($month == '') {
883
+			global $globalArchiveMonths, $globalDBdriver;
884
+			if ($globalDBdriver == 'mysql') {
885
+				if ($month == '') {
886 886
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND YEAR(stats_date) = :year AND stats_airline = :stats_airline AND filter_name = :filter_name";
887 887
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
888 888
 			} else {
@@ -897,165 +897,165 @@  discard block
 block discarded – undo
897 897
 				$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND EXTRACT(YEAR FROM stats_date) = :year AND EXTRACT(MONTH FROM stats_date) = :month AND stats_airline = :stats_airline AND filter_name = :filter_name";
898 898
 				$query_values = array(':type' => $type, ':year' => $year, ':stats_airline' => $stats_airline,':filter_name' => $filter_name,':month' => $month);
899 899
 			}
900
-                }
901
-                 try {
902
-                        $sth = $this->db->prepare($query);
903
-                        $sth->execute($query_values);
904
-                } catch(PDOException $e) {
905
-                        echo "error : ".$e->getMessage();
906
-                }
907
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
908
-                return $all[0]['total'];
909
-        }
900
+				}
901
+				 try {
902
+						$sth = $this->db->prepare($query);
903
+						$sth->execute($query_values);
904
+				} catch(PDOException $e) {
905
+						echo "error : ".$e->getMessage();
906
+				}
907
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
908
+				return $all[0]['total'];
909
+		}
910 910
 	public function getStatsTotal($type, $stats_airline = '', $filter_name = '') {
911
-    		global $globalArchiveMonths, $globalDBdriver;
911
+			global $globalArchiveMonths, $globalDBdriver;
912 912
 		if ($filter_name == '') $filter_name = $this->filter_name;
913
-    		if ($globalDBdriver == 'mysql') {
913
+			if ($globalDBdriver == 'mysql') {
914 914
 			$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";
915 915
 		} else {
916 916
 			$query = "SELECT SUM(cnt) as total FROM stats WHERE stats_type = :type AND stats_date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveMonths." MONTHS' AND stats_airline = :stats_airline AND filter_name = :filter_name";
917
-                }
918
-                $query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
919
-                 try {
920
-                        $sth = $this->db->prepare($query);
921
-                        $sth->execute($query_values);
922
-                } catch(PDOException $e) {
923
-                        echo "error : ".$e->getMessage();
924
-                }
925
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
926
-                return $all[0]['total'];
927
-        }
917
+				}
918
+				$query_values = array(':type' => $type, ':stats_airline' => $stats_airline, ':filter_name' => $filter_name);
919
+				 try {
920
+						$sth = $this->db->prepare($query);
921
+						$sth->execute($query_values);
922
+				} catch(PDOException $e) {
923
+						echo "error : ".$e->getMessage();
924
+				}
925
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
926
+				return $all[0]['total'];
927
+		}
928 928
 	public function getStatsAircraftTotal($stats_airline = '', $filter_name = '') {
929
-    		global $globalArchiveMonths, $globalDBdriver;
929
+			global $globalArchiveMonths, $globalDBdriver;
930 930
 		if ($filter_name == '') $filter_name = $this->filter_name;
931
-    		if ($globalDBdriver == 'mysql') {
931
+			if ($globalDBdriver == 'mysql') {
932 932
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
933
-                } else {
933
+				} else {
934 934
 			$query = "SELECT SUM(cnt) as total FROM stats_aircraft WHERE stats_airline = :stats_airline AND filter_name = :filter_name";
935
-                }
936
-                 try {
937
-                        $sth = $this->db->prepare($query);
938
-                        $sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
939
-                } catch(PDOException $e) {
940
-                        echo "error : ".$e->getMessage();
941
-                }
942
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
943
-                return $all[0]['total'];
944
-        }
935
+				}
936
+				 try {
937
+						$sth = $this->db->prepare($query);
938
+						$sth->execute(array(':stats_airline' => $stats_airline, ':filter_name' => $filter_name));
939
+				} catch(PDOException $e) {
940
+						echo "error : ".$e->getMessage();
941
+				}
942
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
943
+				return $all[0]['total'];
944
+		}
945 945
 	public function getStatsAirlineTotal($filter_name = '') {
946
-    		global $globalArchiveMonths, $globalDBdriver;
946
+			global $globalArchiveMonths, $globalDBdriver;
947 947
 		if ($filter_name == '') $filter_name = $this->filter_name;
948
-    		if ($globalDBdriver == 'mysql') {
948
+			if ($globalDBdriver == 'mysql') {
949 949
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
950
-                } else {
950
+				} else {
951 951
 			$query = "SELECT SUM(cnt) as total FROM stats_airline WHERE filter_name = :filter_name";
952
-                }
953
-                 try {
954
-                        $sth = $this->db->prepare($query);
955
-                        $sth->execute(array(':filter_name' => $filter_name));
956
-                } catch(PDOException $e) {
957
-                        echo "error : ".$e->getMessage();
958
-                }
959
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
960
-                return $all[0]['total'];
961
-        }
952
+				}
953
+				 try {
954
+						$sth = $this->db->prepare($query);
955
+						$sth->execute(array(':filter_name' => $filter_name));
956
+				} catch(PDOException $e) {
957
+						echo "error : ".$e->getMessage();
958
+				}
959
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
960
+				return $all[0]['total'];
961
+		}
962 962
 	public function getStatsOwnerTotal($filter_name = '') {
963
-    		global $globalArchiveMonths, $globalDBdriver;
963
+			global $globalArchiveMonths, $globalDBdriver;
964 964
 		if ($filter_name == '') $filter_name = $this->filter_name;
965
-    		if ($globalDBdriver == 'mysql') {
965
+			if ($globalDBdriver == 'mysql') {
966 966
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
967 967
 		} else {
968 968
 			$query = "SELECT SUM(cnt) as total FROM stats_owner WHERE filter_name = :filter_name";
969
-                }
970
-                 try {
971
-                        $sth = $this->db->prepare($query);
972
-                        $sth->execute(array(':filter_name' => $filter_name));
973
-                } catch(PDOException $e) {
974
-                        echo "error : ".$e->getMessage();
975
-                }
976
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
977
-                return $all[0]['total'];
978
-        }
969
+				}
970
+				 try {
971
+						$sth = $this->db->prepare($query);
972
+						$sth->execute(array(':filter_name' => $filter_name));
973
+				} catch(PDOException $e) {
974
+						echo "error : ".$e->getMessage();
975
+				}
976
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
977
+				return $all[0]['total'];
978
+		}
979 979
 	public function getStatsOwner($owner_name,$filter_name = '') {
980
-    		global $globalArchiveMonths, $globalDBdriver;
980
+			global $globalArchiveMonths, $globalDBdriver;
981 981
 		if ($filter_name == '') $filter_name = $this->filter_name;
982 982
 		$query = "SELECT cnt FROM stats_owner WHERE filter_name = :filter_name AND owner_name = :owner_name";
983
-                 try {
984
-                        $sth = $this->db->prepare($query);
985
-                        $sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
986
-                } catch(PDOException $e) {
987
-                        echo "error : ".$e->getMessage();
988
-                }
989
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
990
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
991
-                else return 0;
992
-        }
983
+				 try {
984
+						$sth = $this->db->prepare($query);
985
+						$sth->execute(array(':filter_name' => $filter_name,':owner_name' => $owner_name));
986
+				} catch(PDOException $e) {
987
+						echo "error : ".$e->getMessage();
988
+				}
989
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
990
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
991
+				else return 0;
992
+		}
993 993
 	public function getStatsPilotTotal($filter_name = '') {
994
-    		global $globalArchiveMonths, $globalDBdriver;
994
+			global $globalArchiveMonths, $globalDBdriver;
995 995
 		if ($filter_name == '') $filter_name = $this->filter_name;
996
-    		if ($globalDBdriver == 'mysql') {
997
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
998
-            	} else {
999
-            		$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1000
-            	}
1001
-                 try {
1002
-                        $sth = $this->db->prepare($query);
1003
-                        $sth->execute(array(':filter_name' => $filter_name));
1004
-                } catch(PDOException $e) {
1005
-                        echo "error : ".$e->getMessage();
1006
-                }
1007
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1008
-                return $all[0]['total'];
1009
-        }
996
+			if ($globalDBdriver == 'mysql') {
997
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
998
+				} else {
999
+					$query = "SELECT SUM(cnt) as total FROM stats_pilot WHERE filter_name = :filter_name";
1000
+				}
1001
+				 try {
1002
+						$sth = $this->db->prepare($query);
1003
+						$sth->execute(array(':filter_name' => $filter_name));
1004
+				} catch(PDOException $e) {
1005
+						echo "error : ".$e->getMessage();
1006
+				}
1007
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1008
+				return $all[0]['total'];
1009
+		}
1010 1010
 	public function getStatsPilot($pilot,$filter_name = '') {
1011
-    		global $globalArchiveMonths, $globalDBdriver;
1011
+			global $globalArchiveMonths, $globalDBdriver;
1012 1012
 		if ($filter_name == '') $filter_name = $this->filter_name;
1013 1013
 		$query = "SELECT cnt FROM stats_pilot WHERE filter_name = :filter_name AND (pilot_name = :pilot OR pilot_id = :pilot)";
1014
-                 try {
1015
-                        $sth = $this->db->prepare($query);
1016
-                        $sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1017
-                } catch(PDOException $e) {
1018
-                        echo "error : ".$e->getMessage();
1019
-                }
1020
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
1021
-                if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1022
-                else return 0;
1023
-        }
1014
+				 try {
1015
+						$sth = $this->db->prepare($query);
1016
+						$sth->execute(array(':filter_name' => $filter_name,':pilot' => $pilot));
1017
+				} catch(PDOException $e) {
1018
+						echo "error : ".$e->getMessage();
1019
+				}
1020
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1021
+				if (isset($all[0]['cnt'])) return $all[0]['cnt'];
1022
+				else return 0;
1023
+		}
1024 1024
 
1025 1025
 	public function addStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1026 1026
 		global $globalDBdriver;
1027 1027
 		if ($filter_name == '') $filter_name = $this->filter_name;
1028 1028
 		if ($globalDBdriver == 'mysql') {
1029 1029
 			$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";
1030
-                } else {
1030
+				} else {
1031 1031
 			$query = "UPDATE stats SET cnt = :cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1032 1032
 		}
1033
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1034
-                 try {
1035
-                        $sth = $this->db->prepare($query);
1036
-                        $sth->execute($query_values);
1037
-                } catch(PDOException $e) {
1038
-                        return "error : ".$e->getMessage();
1039
-                }
1040
-        }
1033
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1034
+				 try {
1035
+						$sth = $this->db->prepare($query);
1036
+						$sth->execute($query_values);
1037
+				} catch(PDOException $e) {
1038
+						return "error : ".$e->getMessage();
1039
+				}
1040
+		}
1041 1041
 	public function updateStat($type,$cnt,$stats_date,$stats_airline = '',$filter_name = '') {
1042 1042
 		global $globalDBdriver;
1043 1043
 		if ($filter_name == '') $filter_name = $this->filter_name;
1044 1044
 		if ($globalDBdriver == 'mysql') {
1045 1045
 			$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";
1046 1046
 		} else {
1047
-            		//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1047
+					//$query = "INSERT INTO stats (stats_type,cnt,stats_date) VALUES (:type,:cnt,:stats_date) ON DUPLICATE KEY UPDATE cnt = cnt+:cnt, stats_date = :date";
1048 1048
 			$query = "UPDATE stats SET cnt = cnt+:cnt WHERE stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats (stats_type,cnt,stats_date,stats_airline,filter_name) SELECT :type,:cnt,:stats_date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats WHERE  stats_type = :type AND stats_date = :stats_date AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1049
-                }
1050
-                $query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1051
-                 try {
1052
-                        $sth = $this->db->prepare($query);
1053
-                        $sth->execute($query_values);
1054
-                } catch(PDOException $e) {
1055
-                        return "error : ".$e->getMessage();
1056
-                }
1057
-        }
1058
-        /*
1049
+				}
1050
+				$query_values = array(':type' => $type,':cnt' => $cnt,':stats_date' => $stats_date,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1051
+				 try {
1052
+						$sth = $this->db->prepare($query);
1053
+						$sth->execute($query_values);
1054
+				} catch(PDOException $e) {
1055
+						return "error : ".$e->getMessage();
1056
+				}
1057
+		}
1058
+		/*
1059 1059
 	public function getStatsSource($date,$stats_type = '') {
1060 1060
 		if ($stats_type == '') {
1061 1061
 			$query = "SELECT * FROM stats_source WHERE stats_date = :date ORDER BY source_name";
@@ -1124,25 +1124,25 @@  discard block
 block discarded – undo
1124 1124
 			$query = "INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) VALUES (:data,:source_name,:stats_type,:stats_date) ON DUPLICATE KEY UPDATE source_data = :data";
1125 1125
 		} else {
1126 1126
 			$query = "UPDATE stats_source SET source_data = :data WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type; INSERT INTO stats_source (source_data,source_name,stats_type,stats_date) SELECT :data,:source_name,:stats_type,:stats_date WHERE NOT EXISTS (SELECT 1 FROM stats_source WHERE stats_date = :stats_date AND source_name = :source_name AND stats_type = :stats_type);"; 
1127
-                }
1128
-                $query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1129
-                 try {
1130
-                        $sth = $this->db->prepare($query);
1131
-                        $sth->execute($query_values);
1132
-                } catch(PDOException $e) {
1133
-                        return "error : ".$e->getMessage();
1134
-                }
1135
-        }
1136
-	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1137
-                $query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138
-                $query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1139
-                 try {
1140
-                        $sth = $this->db->prepare($query);
1141
-                        $sth->execute($query_values);
1142
-                } catch(PDOException $e) {
1143
-                        return "error : ".$e->getMessage();
1144
-                }
1145
-        }
1127
+				}
1128
+				$query_values = array(':data' => $data,':stats_date' => $date,':source_name' => $source_name,':stats_type' => $stats_type);
1129
+				 try {
1130
+						$sth = $this->db->prepare($query);
1131
+						$sth->execute($query_values);
1132
+				} catch(PDOException $e) {
1133
+						return "error : ".$e->getMessage();
1134
+				}
1135
+		}
1136
+	public function addStatFlight($type,$date_name,$cnt,$stats_airline = '',$filter_name = '') {
1137
+				$query = "INSERT INTO stats_flight (stats_type,flight_date,cnt,stats_airline,filter_name) VALUES (:type,:flight_date,:cnt,:stats_airline,:filter_name)";
1138
+				$query_values = array(':type' => $type,':flight_date' => $date_name,':cnt' => $cnt, ':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1139
+				 try {
1140
+						$sth = $this->db->prepare($query);
1141
+						$sth->execute($query_values);
1142
+				} catch(PDOException $e) {
1143
+						return "error : ".$e->getMessage();
1144
+				}
1145
+		}
1146 1146
 	public function addStatAircraftRegistration($registration,$cnt,$aircraft_icao = '',$airline_icao = '',$filter_name = '',$reset = false) {
1147 1147
 		global $globalDBdriver;
1148 1148
 		if ($globalDBdriver == 'mysql') {
@@ -1158,14 +1158,14 @@  discard block
 block discarded – undo
1158 1158
 				$query = "UPDATE stats_registration SET cnt = cnt+:cnt WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_registration (aircraft_icao,registration,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:registration,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_registration WHERE registration = :registration AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1159 1159
 			}
1160 1160
 		}
1161
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1162
-                 try {
1163
-                        $sth = $this->db->prepare($query);
1164
-                        $sth->execute($query_values);
1165
-                } catch(PDOException $e) {
1166
-                        return "error : ".$e->getMessage();
1167
-                }
1168
-        }
1161
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':registration' => $registration,':cnt' => $cnt,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1162
+				 try {
1163
+						$sth = $this->db->prepare($query);
1164
+						$sth->execute($query_values);
1165
+				} catch(PDOException $e) {
1166
+						return "error : ".$e->getMessage();
1167
+				}
1168
+		}
1169 1169
 	public function addStatCallsign($callsign_icao,$cnt,$airline_icao = '', $filter_name = '', $reset = false) {
1170 1170
 		global $globalDBdriver;
1171 1171
 		if ($globalDBdriver == 'mysql') {
@@ -1181,14 +1181,14 @@  discard block
 block discarded – undo
1181 1181
 				$query = "UPDATE stats_callsign SET cnt = cnt+:cnt WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name; INSERT INTO stats_callsign (callsign_icao,airline_icao,cnt,filter_name) SELECT :callsign_icao,:airline_icao,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_callsign WHERE callsign_icao = :callsign_icao AND filter_name = :filter_name);"; 
1182 1182
 			}
1183 1183
 		}
1184
-                $query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1185
-                 try {
1186
-                        $sth = $this->db->prepare($query);
1187
-                        $sth->execute($query_values);
1188
-                } catch(PDOException $e) {
1189
-                        return "error : ".$e->getMessage();
1190
-                }
1191
-        }
1184
+				$query_values = array(':callsign_icao' => $callsign_icao,':airline_icao' => $airline_icao,':cnt' => $cnt, ':filter_name' => $filter_name);
1185
+				 try {
1186
+						$sth = $this->db->prepare($query);
1187
+						$sth->execute($query_values);
1188
+				} catch(PDOException $e) {
1189
+						return "error : ".$e->getMessage();
1190
+				}
1191
+		}
1192 1192
 	public function addStatCountry($iso2,$iso3,$name,$cnt,$airline_icao = '',$filter_name = '',$reset = false) {
1193 1193
 		global $globalDBdriver;
1194 1194
 		if ($globalDBdriver == 'mysql') {
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
 				$query = "UPDATE stats_country SET cnt = cnt+:cnt WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline; INSERT INTO stats_country (iso2,iso3,name,cnt,stats_airline,filter_name) SELECT :iso2,:iso3,:name,:cnt,:airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_country WHERE iso2 = :iso2 AND filter_name = :filter_name AND stats_airline = :airline);"; 
1205 1205
 			}
1206 1206
 		}
1207
-                $query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1208
-                 try {
1209
-                        $sth = $this->db->prepare($query);
1210
-                        $sth->execute($query_values);
1211
-                } catch(PDOException $e) {
1212
-                        return "error : ".$e->getMessage();
1213
-                }
1214
-        }
1207
+				$query_values = array(':iso2' => $iso2,':iso3' => $iso3,':name' => $name,':cnt' => $cnt,':filter_name' => $filter_name,':airline' => $airline_icao);
1208
+				 try {
1209
+						$sth = $this->db->prepare($query);
1210
+						$sth->execute($query_values);
1211
+				} catch(PDOException $e) {
1212
+						return "error : ".$e->getMessage();
1213
+				}
1214
+		}
1215 1215
 	public function addStatAircraft($aircraft_icao,$cnt,$aircraft_name = '',$aircraft_manufacturer = '', $airline_icao = '', $filter_name = '', $reset = false) {
1216 1216
 		global $globalDBdriver;
1217 1217
 		if ($globalDBdriver == 'mysql') {
@@ -1227,14 +1227,14 @@  discard block
 block discarded – undo
1227 1227
 				$query = "UPDATE stats_aircraft SET cnt = cnt+:cnt, aircraft_name = :aircraft_name, aircraft_manufacturer = :aircraft_manufacturer, filter_name = :filter_name WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_aircraft (aircraft_icao,aircraft_name,aircraft_manufacturer,cnt,stats_airline,filter_name) SELECT :aircraft_icao,:aircraft_name,:aircraft_manufacturer,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_aircraft WHERE aircraft_icao = :aircraft_icao AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1228 1228
 			}
1229 1229
 		}
1230
-                $query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1231
-                 try {
1232
-                        $sth = $this->db->prepare($query);
1233
-                        $sth->execute($query_values);
1234
-                } catch(PDOException $e) {
1235
-                        return "error : ".$e->getMessage();
1236
-                }
1237
-        }
1230
+				$query_values = array(':aircraft_icao' => $aircraft_icao,':aircraft_name' => $aircraft_name,':cnt' => $cnt, ':aircraft_manufacturer' => $aircraft_manufacturer,':stats_airline' => $airline_icao, ':filter_name' => $filter_name);
1231
+				 try {
1232
+						$sth = $this->db->prepare($query);
1233
+						$sth->execute($query_values);
1234
+				} catch(PDOException $e) {
1235
+						return "error : ".$e->getMessage();
1236
+				}
1237
+		}
1238 1238
 	public function addStatAirline($airline_icao,$cnt,$airline_name = '',$filter_name = '', $reset = false) {
1239 1239
 		global $globalDBdriver;
1240 1240
 		if ($globalDBdriver == 'mysql') {
@@ -1250,14 +1250,14 @@  discard block
 block discarded – undo
1250 1250
 				$query = "UPDATE stats_airline SET cnt = cnt+:cnt WHERE airline_icao = :airline_icao AND filter_name = :filter_name; INSERT INTO stats_airline (airline_icao,airline_name,cnt,filter_name) SELECT :airline_icao,:airline_name,:cnt,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airline WHERE airline_icao = :airline_icao AND filter_name = :filter_name);"; 
1251 1251
 			}
1252 1252
 		}
1253
-                $query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1254
-                 try {
1255
-                        $sth = $this->db->prepare($query);
1256
-                        $sth->execute($query_values);
1257
-                } catch(PDOException $e) {
1258
-                        return "error : ".$e->getMessage();
1259
-                }
1260
-        }
1253
+				$query_values = array(':airline_icao' => $airline_icao,':airline_name' => $airline_name,':cnt' => $cnt,':filter_name' => $filter_name);
1254
+				 try {
1255
+						$sth = $this->db->prepare($query);
1256
+						$sth->execute($query_values);
1257
+				} catch(PDOException $e) {
1258
+						return "error : ".$e->getMessage();
1259
+				}
1260
+		}
1261 1261
 	public function addStatOwner($owner_name,$cnt,$stats_airline = '', $filter_name = '', $reset = false) {
1262 1262
 		global $globalDBdriver;
1263 1263
 		if ($globalDBdriver == 'mysql') {
@@ -1273,14 +1273,14 @@  discard block
 block discarded – undo
1273 1273
 				$query = "UPDATE stats_owner SET cnt = cnt+:cnt WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name; INSERT INTO stats_owner (owner_name,cnt,stats_airline,filter_name) SELECT :owner_name,:cnt,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_owner WHERE owner_name = :owner_name AND stats_airline = :stats_airline AND filter_name = :filter_name);"; 
1274 1274
 			}
1275 1275
 		}
1276
-                $query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1277
-                 try {
1278
-                        $sth = $this->db->prepare($query);
1279
-                        $sth->execute($query_values);
1280
-                } catch(PDOException $e) {
1281
-                        return "error : ".$e->getMessage();
1282
-                }
1283
-        }
1276
+				$query_values = array(':owner_name' => $owner_name,':cnt' => $cnt,':stats_airline' => $stats_airline,':filter_name' => $filter_name);
1277
+				 try {
1278
+						$sth = $this->db->prepare($query);
1279
+						$sth->execute($query_values);
1280
+				} catch(PDOException $e) {
1281
+						return "error : ".$e->getMessage();
1282
+				}
1283
+		}
1284 1284
 	public function addStatPilot($pilot_id,$cnt,$pilot_name,$stats_airline = '',$filter_name = '',$format_source = '',$reset = false) {
1285 1285
 		global $globalDBdriver;
1286 1286
 		if ($globalDBdriver == 'mysql') {
@@ -1296,14 +1296,14 @@  discard block
 block discarded – undo
1296 1296
 				$query = "UPDATE stats_pilot SET cnt = cnt+:cnt, pilot_name = :pilot_name WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source; INSERT INTO stats_pilot (pilot_id,cnt,pilot_name,stats_airline,filter_name,format_source) SELECT :pilot_id,:cnt,:pilot_name,:stats_airline,:filter_name,:format_source WHERE NOT EXISTS (SELECT 1 FROM stats_pilot WHERE pilot_id = :pilot_id AND stats_airline = :stats_airline AND filter_name = :filter_name AND format_source = :format_source);"; 
1297 1297
 			}
1298 1298
 		}
1299
-                $query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1300
-                 try {
1301
-                        $sth = $this->db->prepare($query);
1302
-                        $sth->execute($query_values);
1303
-                } catch(PDOException $e) {
1304
-                        return "error : ".$e->getMessage();
1305
-                }
1306
-        }
1299
+				$query_values = array(':pilot_id' => $pilot_id,':cnt' => $cnt,':pilot_name' => $pilot_name,':stats_airline' => $stats_airline,':filter_name' => $filter_name,':format_source' => $format_source);
1300
+				 try {
1301
+						$sth = $this->db->prepare($query);
1302
+						$sth->execute($query_values);
1303
+				} catch(PDOException $e) {
1304
+						return "error : ".$e->getMessage();
1305
+				}
1306
+		}
1307 1307
 	public function addStatDepartureAirports($airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '',$reset = false) {
1308 1308
 		global $globalDBdriver;
1309 1309
 		if ($airport_icao != '') {
@@ -1327,8 +1327,8 @@  discard block
 block discarded – undo
1327 1327
 			} catch(PDOException $e) {
1328 1328
 				return "error : ".$e->getMessage();
1329 1329
 			}
1330
-                }
1331
-        }
1330
+				}
1331
+		}
1332 1332
 	public function addStatDepartureAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$departure,$airline_icao = '',$filter_name = '') {
1333 1333
 		global $globalDBdriver;
1334 1334
 		if ($airport_icao != '') {
@@ -1344,8 +1344,8 @@  discard block
 block discarded – undo
1344 1344
 			} catch(PDOException $e) {
1345 1345
 				return "error : ".$e->getMessage();
1346 1346
 			}
1347
-                }
1348
-        }
1347
+				}
1348
+		}
1349 1349
 	public function addStatArrivalAirports($airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '',$reset = false) {
1350 1350
 		global $globalDBdriver;
1351 1351
 		if ($airport_icao != '') {
@@ -1362,15 +1362,15 @@  discard block
 block discarded – undo
1362 1362
 					$query = "UPDATE stats_airport SET arrival = arrival+:arrival WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name; INSERT INTO stats_airport (airport_icao,airport_name,airport_city,airport_country,arrival,stats_type,date,stats_airline,filter_name) SELECT :airport_icao,:airport_name,:airport_city,:airport_country,:arrival,'yearly',:date,:stats_airline,:filter_name WHERE NOT EXISTS (SELECT 1 FROM stats_airport WHERE airport_icao = :airport_icao AND stats_type = 'yearly' AND stats_airline = :stats_airline AND date = :date AND filter_name = :filter_name);"; 
1363 1363
 				}
1364 1364
 			}
1365
-	                $query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1365
+					$query_values = array(':airport_icao' => $airport_icao,':airport_name' => $airport_name,':airport_city' => $airport_city,':airport_country' => $airport_country,':arrival' => $arrival,':date' => date('Y').'-01-01 00:00:00',':stats_airline' => $airline_icao,':filter_name' => $filter_name);
1366 1366
 			 try {
1367
-                    		$sth = $this->db->prepare($query);
1368
-	                        $sth->execute($query_values);
1369
-    		        } catch(PDOException $e) {
1370
-            		        return "error : ".$e->getMessage();
1371
-	                }
1372
-	        }
1373
-        }
1367
+							$sth = $this->db->prepare($query);
1368
+							$sth->execute($query_values);
1369
+					} catch(PDOException $e) {
1370
+							return "error : ".$e->getMessage();
1371
+					}
1372
+			}
1373
+		}
1374 1374
 	public function addStatArrivalAirportsDaily($date,$airport_icao,$airport_name,$airport_city,$airport_country,$arrival,$airline_icao = '',$filter_name = '') {
1375 1375
 		global $globalDBdriver;
1376 1376
 		if ($airport_icao != '') {
@@ -1386,46 +1386,46 @@  discard block
 block discarded – undo
1386 1386
 			} catch(PDOException $e) {
1387 1387
 				return "error : ".$e->getMessage();
1388 1388
 			}
1389
-                }
1390
-        }
1389
+				}
1390
+		}
1391 1391
 
1392 1392
 	public function deleteStat($id) {
1393
-                $query = "DELETE FROM stats WHERE stats_id = :id";
1394
-                $query_values = array(':id' => $id);
1395
-                 try {
1396
-                        $sth = $this->db->prepare($query);
1397
-                        $sth->execute($query_values);
1398
-                } catch(PDOException $e) {
1399
-                        return "error : ".$e->getMessage();
1400
-                }
1401
-        }
1393
+				$query = "DELETE FROM stats WHERE stats_id = :id";
1394
+				$query_values = array(':id' => $id);
1395
+				 try {
1396
+						$sth = $this->db->prepare($query);
1397
+						$sth->execute($query_values);
1398
+				} catch(PDOException $e) {
1399
+						return "error : ".$e->getMessage();
1400
+				}
1401
+		}
1402 1402
 	public function deleteStatFlight($type) {
1403
-                $query = "DELETE FROM stats_flight WHERE stats_type = :type";
1404
-                $query_values = array(':type' => $type);
1405
-                 try {
1406
-                        $sth = $this->db->prepare($query);
1407
-                        $sth->execute($query_values);
1408
-                } catch(PDOException $e) {
1409
-                        return "error : ".$e->getMessage();
1410
-                }
1411
-        }
1403
+				$query = "DELETE FROM stats_flight WHERE stats_type = :type";
1404
+				$query_values = array(':type' => $type);
1405
+				 try {
1406
+						$sth = $this->db->prepare($query);
1407
+						$sth->execute($query_values);
1408
+				} catch(PDOException $e) {
1409
+						return "error : ".$e->getMessage();
1410
+				}
1411
+		}
1412 1412
 	public function deleteStatAirport($type) {
1413
-                $query = "DELETE FROM stats_airport WHERE stats_type = :type";
1414
-                $query_values = array(':type' => $type);
1415
-                 try {
1416
-                        $sth = $this->db->prepare($query);
1417
-                        $sth->execute($query_values);
1418
-                } catch(PDOException $e) {
1419
-                        return "error : ".$e->getMessage();
1420
-                }
1421
-        }
1413
+				$query = "DELETE FROM stats_airport WHERE stats_type = :type";
1414
+				$query_values = array(':type' => $type);
1415
+				 try {
1416
+						$sth = $this->db->prepare($query);
1417
+						$sth->execute($query_values);
1418
+				} catch(PDOException $e) {
1419
+						return "error : ".$e->getMessage();
1420
+				}
1421
+		}
1422 1422
         
1423
-        public function addOldStats() {
1424
-    		global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1425
-    		$Common = new Common();
1426
-    		$Connection = new Connection();
1427
-    		date_default_timezone_set('UTC');
1428
-    		$last_update = $this->getLastStatsUpdate('last_update_stats');
1423
+		public function addOldStats() {
1424
+			global $globalDebug, $globalArchiveMonths, $globalArchive, $globalArchiveYear, $globalDBdriver, $globalStatsFilters,$globalDeleteLastYearStats,$globalStatsReset,$globalStatsResetYear;
1425
+			$Common = new Common();
1426
+			$Connection = new Connection();
1427
+			date_default_timezone_set('UTC');
1428
+			$last_update = $this->getLastStatsUpdate('last_update_stats');
1429 1429
 			if ($globalDebug) echo 'Update stats !'."\n";
1430 1430
 			if (isset($last_update[0]['value'])) {
1431 1431
 				$last_update_day = $last_update[0]['value'];
@@ -1471,24 +1471,24 @@  discard block
 block discarded – undo
1471 1471
 			if ($globalDebug) echo 'Count all departure airports...'."\n";
1472 1472
 			$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day);
1473 1473
 			if ($globalDebug) echo 'Count all detected departure airports...'."\n";
1474
-        		$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1474
+				$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day);
1475 1475
 			if ($globalDebug) echo 'Order departure airports...'."\n";
1476
-	        	$alldata = array();
1476
+				$alldata = array();
1477 1477
 	        	
1478
-    			foreach ($pall as $value) {
1479
-	        		$icao = $value['airport_departure_icao'];
1480
-    				$alldata[$icao] = $value;
1481
-	        	}
1482
-	        	foreach ($dall as $value) {
1483
-    				$icao = $value['airport_departure_icao'];
1484
-        			if (isset($alldata[$icao])) {
1485
-    					$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1486
-        			} else $alldata[$icao] = $value;
1487
-			}
1488
-    			$count = array();
1489
-    			foreach ($alldata as $key => $row) {
1490
-    				$count[$key] = $row['airport_departure_icao_count'];
1491
-        		}
1478
+				foreach ($pall as $value) {
1479
+					$icao = $value['airport_departure_icao'];
1480
+					$alldata[$icao] = $value;
1481
+				}
1482
+				foreach ($dall as $value) {
1483
+					$icao = $value['airport_departure_icao'];
1484
+					if (isset($alldata[$icao])) {
1485
+						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1486
+					} else $alldata[$icao] = $value;
1487
+			}
1488
+				$count = array();
1489
+				foreach ($alldata as $key => $row) {
1490
+					$count[$key] = $row['airport_departure_icao_count'];
1491
+				}
1492 1492
 			array_multisort($count,SORT_DESC,$alldata);
1493 1493
 			foreach ($alldata as $number) {
1494 1494
 				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);
@@ -1496,25 +1496,25 @@  discard block
 block discarded – undo
1496 1496
 			if ($globalDebug) echo 'Count all arrival airports...'."\n";
1497 1497
 			$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day);
1498 1498
 			if ($globalDebug) echo 'Count all detected arrival airports...'."\n";
1499
-        		$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1499
+				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day);
1500 1500
 			if ($globalDebug) echo 'Order arrival airports...'."\n";
1501
-	        	$alldata = array();
1502
-    			foreach ($pall as $value) {
1503
-	        		$icao = $value['airport_arrival_icao'];
1504
-    				$alldata[$icao] = $value;
1505
-	        	}
1506
-	        	foreach ($dall as $value) {
1507
-    				$icao = $value['airport_arrival_icao'];
1508
-        			if (isset($alldata[$icao])) {
1509
-        				$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1510
-	        		} else $alldata[$icao] = $value;
1511
-    			}
1512
-        		$count = array();
1513
-        		foreach ($alldata as $key => $row) {
1514
-        			$count[$key] = $row['airport_arrival_icao_count'];
1515
-	        	}
1516
-    			array_multisort($count,SORT_DESC,$alldata);
1517
-                        foreach ($alldata as $number) {
1501
+				$alldata = array();
1502
+				foreach ($pall as $value) {
1503
+					$icao = $value['airport_arrival_icao'];
1504
+					$alldata[$icao] = $value;
1505
+				}
1506
+				foreach ($dall as $value) {
1507
+					$icao = $value['airport_arrival_icao'];
1508
+					if (isset($alldata[$icao])) {
1509
+						$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1510
+					} else $alldata[$icao] = $value;
1511
+				}
1512
+				$count = array();
1513
+				foreach ($alldata as $key => $row) {
1514
+					$count[$key] = $row['airport_arrival_icao_count'];
1515
+				}
1516
+				array_multisort($count,SORT_DESC,$alldata);
1517
+						foreach ($alldata as $number) {
1518 1518
 				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);
1519 1519
 			}
1520 1520
 			if ($Connection->tableExists('countries')) {
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 //			$pall = $Spotter->getLast7DaysAirportsDeparture();
1575 1575
   //      		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1576 1576
 			$pall = $Spotter->getLast7DaysAirportsDeparture();
1577
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1578
-        		/*
1577
+				$dall = $Spotter->getLast7DaysDetectedAirportsDeparture();
1578
+				/*
1579 1579
 	        	$alldata = array();
1580 1580
     			foreach ($pall as $value) {
1581 1581
 	        		$icao = $value['departure_airport_icao'];
@@ -1594,29 +1594,29 @@  discard block
 block discarded – undo
1594 1594
 	        	}
1595 1595
     			array_multisort($count,SORT_DESC,$alldata);
1596 1596
     			*/
1597
-    			foreach ($dall as $value) {
1598
-    				$icao = $value['departure_airport_icao'];
1599
-    				$ddate = $value['date'];
1600
-    				$find = false;
1601
-    				foreach ($pall as $pvalue) {
1602
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1603
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1604
-    						$find = true;
1605
-    						break;
1606
-    					}
1607
-    				}
1608
-    				if ($find === false) {
1609
-    					$pall[] = $value;
1610
-    				}
1611
-    			}
1612
-    			$alldata = $pall;
1597
+				foreach ($dall as $value) {
1598
+					$icao = $value['departure_airport_icao'];
1599
+					$ddate = $value['date'];
1600
+					$find = false;
1601
+					foreach ($pall as $pvalue) {
1602
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1603
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1604
+							$find = true;
1605
+							break;
1606
+						}
1607
+					}
1608
+					if ($find === false) {
1609
+						$pall[] = $value;
1610
+					}
1611
+				}
1612
+				$alldata = $pall;
1613 1613
 			foreach ($alldata as $number) {
1614 1614
 				$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count']);
1615 1615
 			}
1616 1616
 			echo '...Arrival'."\n";
1617 1617
 			$pall = $Spotter->getLast7DaysAirportsArrival();
1618
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1619
-        		/*
1618
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrival();
1619
+				/*
1620 1620
 	        	$alldata = array();
1621 1621
     			foreach ($pall as $value) {
1622 1622
 	        		$icao = $value['arrival_airport_icao'];
@@ -1636,22 +1636,22 @@  discard block
 block discarded – undo
1636 1636
     			*/
1637 1637
 
1638 1638
 
1639
-    			foreach ($dall as $value) {
1640
-    				$icao = $value['arrival_airport_icao'];
1641
-    				$ddate = $value['date'];
1642
-    				$find = false;
1643
-    				foreach ($pall as $pvalue) {
1644
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1645
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1646
-    						$find = true;
1647
-    						break;
1648
-    					}
1649
-    				}
1650
-    				if ($find === false) {
1651
-    					$pall[] = $value;
1652
-    				}
1653
-    			}
1654
-    			$alldata = $pall;
1639
+				foreach ($dall as $value) {
1640
+					$icao = $value['arrival_airport_icao'];
1641
+					$ddate = $value['date'];
1642
+					$find = false;
1643
+					foreach ($pall as $pvalue) {
1644
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1645
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1646
+							$find = true;
1647
+							break;
1648
+						}
1649
+					}
1650
+					if ($find === false) {
1651
+						$pall[] = $value;
1652
+					}
1653
+				}
1654
+				$alldata = $pall;
1655 1655
 			foreach ($alldata as $number) {
1656 1656
 				$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count']);
1657 1657
 			}
@@ -1726,51 +1726,51 @@  discard block
 block discarded – undo
1726 1726
 			if ($globalDebug) echo 'Count all departure airports by airlines...'."\n";
1727 1727
 			$pall = $Spotter->countAllDepartureAirportsByAirlines(false,0,$last_update_day);
1728 1728
 			if ($globalDebug) echo 'Count all detected departure airports by airlines...'."\n";
1729
-       			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1729
+	   			$dall = $Spotter->countAllDetectedDepartureAirportsByAirlines(false,0,$last_update_day);
1730 1730
 			if ($globalDebug) echo 'Order detected departure airports by airlines...'."\n";
1731
-	        	//$alldata = array();
1732
-    			foreach ($dall as $value) {
1733
-    				$icao = $value['airport_departure_icao'];
1734
-    				$dicao = $value['airline_icao'];
1735
-    				$find = false;
1736
-    				foreach ($pall as $pvalue) {
1737
-    					if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1738
-    						$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1739
-    						$find = true;
1740
-    						break;
1741
-    					}
1742
-    				}
1743
-    				if ($find === false) {
1744
-    					$pall[] = $value;
1745
-    				}
1746
-    			}
1747
-    			$alldata = $pall;
1731
+				//$alldata = array();
1732
+				foreach ($dall as $value) {
1733
+					$icao = $value['airport_departure_icao'];
1734
+					$dicao = $value['airline_icao'];
1735
+					$find = false;
1736
+					foreach ($pall as $pvalue) {
1737
+						if ($pvalue['airport_departure_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1738
+							$pvalue['airport_departure_icao_count'] = $pvalue['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1739
+							$find = true;
1740
+							break;
1741
+						}
1742
+					}
1743
+					if ($find === false) {
1744
+						$pall[] = $value;
1745
+					}
1746
+				}
1747
+				$alldata = $pall;
1748 1748
 			foreach ($alldata as $number) {
1749 1749
 				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);
1750 1750
 			}
1751 1751
 			if ($globalDebug) echo 'Count all arrival airports by airlines...'."\n";
1752 1752
 			$pall = $Spotter->countAllArrivalAirportsByAirlines(false,0,$last_update_day);
1753 1753
 			if ($globalDebug) echo 'Count all detected arrival airports by airlines...'."\n";
1754
-        		$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1754
+				$dall = $Spotter->countAllDetectedArrivalAirportsByAirlines(false,0,$last_update_day);
1755 1755
 			if ($globalDebug) echo 'Order arrival airports by airlines...'."\n";
1756
-	        	//$alldata = array();
1757
-    			foreach ($dall as $value) {
1758
-    				$icao = $value['airport_arrival_icao'];
1759
-    				$dicao = $value['airline_icao'];
1760
-    				$find = false;
1761
-    				foreach ($pall as $pvalue) {
1762
-    					if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1763
-    						$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1764
-    						$find = true;
1765
-    						break;
1766
-    					}
1767
-    				}
1768
-    				if ($find === false) {
1769
-    					$pall[] = $value;
1770
-    				}
1771
-    			}
1772
-    			$alldata = $pall;
1773
-                        foreach ($alldata as $number) {
1756
+				//$alldata = array();
1757
+				foreach ($dall as $value) {
1758
+					$icao = $value['airport_arrival_icao'];
1759
+					$dicao = $value['airline_icao'];
1760
+					$find = false;
1761
+					foreach ($pall as $pvalue) {
1762
+						if ($pvalue['airport_arrival_icao'] == $icao && $pvalue['airline_icao'] = $dicao) {
1763
+							$pvalue['airport_arrival_icao_count'] = $pvalue['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1764
+							$find = true;
1765
+							break;
1766
+						}
1767
+					}
1768
+					if ($find === false) {
1769
+						$pall[] = $value;
1770
+					}
1771
+				}
1772
+				$alldata = $pall;
1773
+						foreach ($alldata as $number) {
1774 1774
 				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);
1775 1775
 			}
1776 1776
 			if ($globalDebug) echo 'Count all flights by months by airlines...'."\n";
@@ -1803,47 +1803,47 @@  discard block
 block discarded – undo
1803 1803
 			}
1804 1804
 			if ($globalDebug) echo '...Departure'."\n";
1805 1805
 			$pall = $Spotter->getLast7DaysAirportsDepartureByAirlines();
1806
-        		$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1807
-    			foreach ($dall as $value) {
1808
-    				$icao = $value['departure_airport_icao'];
1809
-    				$airline = $value['airline_icao'];
1810
-    				$ddate = $value['date'];
1811
-    				$find = false;
1812
-    				foreach ($pall as $pvalue) {
1813
-    					if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1814
-    						$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1815
-    						$find = true;
1816
-    						break;
1817
-    					}
1818
-    				}
1819
-    				if ($find === false) {
1820
-    					$pall[] = $value;
1821
-    				}
1822
-    			}
1823
-    			$alldata = $pall;
1806
+				$dall = $Spotter->getLast7DaysDetectedAirportsDepartureByAirlines();
1807
+				foreach ($dall as $value) {
1808
+					$icao = $value['departure_airport_icao'];
1809
+					$airline = $value['airline_icao'];
1810
+					$ddate = $value['date'];
1811
+					$find = false;
1812
+					foreach ($pall as $pvalue) {
1813
+						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] = $airline) {
1814
+							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1815
+							$find = true;
1816
+							break;
1817
+						}
1818
+					}
1819
+					if ($find === false) {
1820
+						$pall[] = $value;
1821
+					}
1822
+				}
1823
+				$alldata = $pall;
1824 1824
 			foreach ($alldata as $number) {
1825 1825
 				$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']);
1826 1826
 			}
1827 1827
 			if ($globalDebug) echo '...Arrival'."\n";
1828 1828
 			$pall = $Spotter->getLast7DaysAirportsArrivalByAirlines();
1829
-        		$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1830
-    			foreach ($dall as $value) {
1831
-    				$icao = $value['arrival_airport_icao'];
1832
-    				$airline = $value['airline_icao'];
1833
-    				$ddate = $value['date'];
1834
-    				$find = false;
1835
-    				foreach ($pall as $pvalue) {
1836
-    					if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1837
-    						$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1838
-    						$find = true;
1839
-    						break;
1840
-    					}
1841
-    				}
1842
-    				if ($find === false) {
1843
-    					$pall[] = $value;
1844
-    				}
1845
-    			}
1846
-    			$alldata = $pall;
1829
+				$dall = $Spotter->getLast7DaysDetectedAirportsArrivalByAirlines();
1830
+				foreach ($dall as $value) {
1831
+					$icao = $value['arrival_airport_icao'];
1832
+					$airline = $value['airline_icao'];
1833
+					$ddate = $value['date'];
1834
+					$find = false;
1835
+					foreach ($pall as $pvalue) {
1836
+						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate && $pvalue['airline_icao'] == $airline) {
1837
+							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
1838
+							$find = true;
1839
+							break;
1840
+						}
1841
+					}
1842
+					if ($find === false) {
1843
+						$pall[] = $value;
1844
+					}
1845
+				}
1846
+				$alldata = $pall;
1847 1847
 			foreach ($alldata as $number) {
1848 1848
 				$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']);
1849 1849
 			}
@@ -1914,44 +1914,44 @@  discard block
 block discarded – undo
1914 1914
 					$this->addStatPilot($number['pilot_id'],$number['pilot_count'],$number['pilot_name'],'',$filter_name,$number['format_source'],$reset);
1915 1915
 				}
1916 1916
 				$pall = $Spotter->countAllDepartureAirports(false,0,$last_update_day,$filter);
1917
-	       			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1918
-		        	$alldata = array();
1919
-	    			foreach ($pall as $value) {
1920
-		        		$icao = $value['airport_departure_icao'];
1921
-    					$alldata[$icao] = $value;
1922
-	    			}
1923
-		        	foreach ($dall as $value) {
1924
-	    				$icao = $value['airport_departure_icao'];
1925
-        				if (isset($alldata[$icao])) {
1926
-    						$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1927
-        				} else $alldata[$icao] = $value;
1928
-				}
1929
-	    			$count = array();
1930
-    				foreach ($alldata as $key => $row) {
1931
-    					$count[$key] = $row['airport_departure_icao_count'];
1932
-    				}
1917
+		   			$dall = $Spotter->countAllDetectedDepartureAirports(false,0,$last_update_day,$filter);
1918
+					$alldata = array();
1919
+					foreach ($pall as $value) {
1920
+						$icao = $value['airport_departure_icao'];
1921
+						$alldata[$icao] = $value;
1922
+					}
1923
+					foreach ($dall as $value) {
1924
+						$icao = $value['airport_departure_icao'];
1925
+						if (isset($alldata[$icao])) {
1926
+							$alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count'];
1927
+						} else $alldata[$icao] = $value;
1928
+				}
1929
+					$count = array();
1930
+					foreach ($alldata as $key => $row) {
1931
+						$count[$key] = $row['airport_departure_icao_count'];
1932
+					}
1933 1933
 				array_multisort($count,SORT_DESC,$alldata);
1934 1934
 				foreach ($alldata as $number) {
1935
-    					echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1935
+						echo $this->addStatDepartureAirports($number['airport_departure_icao'],$number['airport_departure_name'],$number['airport_departure_city'],$number['airport_departure_country'],$number['airport_departure_icao_count'],'',$filter_name,$reset);
1936 1936
 				}
1937 1937
 				$pall = $Spotter->countAllArrivalAirports(false,0,$last_update_day,false,$filter);
1938
-    				$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1938
+					$dall = $Spotter->countAllDetectedArrivalAirports(false,0,$last_update_day,false,$filter);
1939 1939
 				$alldata = array();
1940
-    				foreach ($pall as $value) {
1941
-		        		$icao = $value['airport_arrival_icao'];
1942
-    					$alldata[$icao] = $value;
1943
-	    			}
1944
-		        	foreach ($dall as $value) {
1945
-	    				$icao = $value['airport_arrival_icao'];
1946
-        				if (isset($alldata[$icao])) {
1947
-        					$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1948
-		        		} else $alldata[$icao] = $value;
1949
-	    			}
1950
-        			$count = array();
1951
-        			foreach ($alldata as $key => $row) {
1952
-    					$count[$key] = $row['airport_arrival_icao_count'];
1953
-		        	}
1954
-        			array_multisort($count,SORT_DESC,$alldata);
1940
+					foreach ($pall as $value) {
1941
+						$icao = $value['airport_arrival_icao'];
1942
+						$alldata[$icao] = $value;
1943
+					}
1944
+					foreach ($dall as $value) {
1945
+						$icao = $value['airport_arrival_icao'];
1946
+						if (isset($alldata[$icao])) {
1947
+							$alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count'];
1948
+						} else $alldata[$icao] = $value;
1949
+					}
1950
+					$count = array();
1951
+					foreach ($alldata as $key => $row) {
1952
+						$count[$key] = $row['airport_arrival_icao_count'];
1953
+					}
1954
+					array_multisort($count,SORT_DESC,$alldata);
1955 1955
 				foreach ($alldata as $number) {
1956 1956
 					echo $this->addStatArrivalAirports($number['airport_arrival_icao'],$number['airport_arrival_name'],$number['airport_arrival_city'],$number['airport_arrival_country'],$number['airport_arrival_icao_count'],'',$filter_name,$reset);
1957 1957
 				}
@@ -1984,45 +1984,45 @@  discard block
 block discarded – undo
1984 1984
 				}
1985 1985
 				echo '...Departure'."\n";
1986 1986
 				$pall = $Spotter->getLast7DaysAirportsDeparture('',$filter);
1987
-        			$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1987
+					$dall = $Spotter->getLast7DaysDetectedAirportsDeparture('',$filter);
1988 1988
 				foreach ($dall as $value) {
1989
-    					$icao = $value['departure_airport_icao'];
1990
-    					$ddate = $value['date'];
1991
-    					$find = false;
1992
-    					foreach ($pall as $pvalue) {
1993
-    						if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1994
-    							$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1995
-	    						$find = true;
1996
-    							break;
1997
-    						}
1998
-    					}
1999
-    					if ($find === false) {
2000
-    						$pall[] = $value;
2001
-	    				}
2002
-    				}
2003
-	    			$alldata = $pall;
1989
+						$icao = $value['departure_airport_icao'];
1990
+						$ddate = $value['date'];
1991
+						$find = false;
1992
+						foreach ($pall as $pvalue) {
1993
+							if ($pvalue['departure_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
1994
+								$pvalue['departure_airport_count'] = $pvalue['departure_airport_count'] + $value['departure_airport_count'];
1995
+								$find = true;
1996
+								break;
1997
+							}
1998
+						}
1999
+						if ($find === false) {
2000
+							$pall[] = $value;
2001
+						}
2002
+					}
2003
+					$alldata = $pall;
2004 2004
 				foreach ($alldata as $number) {
2005 2005
 					$this->addStatDepartureAirportsDaily($number['date'],$number['departure_airport_icao'],$number['departure_airport_name'],$number['departure_airport_city'],$number['departure_airport_country'],$number['departure_airport_count'],'',$filter_name);
2006 2006
 				}
2007 2007
 				echo '...Arrival'."\n";
2008 2008
 				$pall = $Spotter->getLast7DaysAirportsArrival('',$filter);
2009
-    				$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2009
+					$dall = $Spotter->getLast7DaysDetectedAirportsArrival('',$filter);
2010 2010
 				foreach ($dall as $value) {
2011 2011
 					$icao = $value['arrival_airport_icao'];
2012 2012
 					$ddate = $value['date'];
2013
-    					$find = false;
2013
+						$find = false;
2014 2014
 					foreach ($pall as $pvalue) {
2015
-    						if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2016
-    							$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2017
-    							$find = true;
2018
-    							break;
2019
-	    					}
2020
-    					}
2021
-    					if ($find === false) {
2022
-    						$pall[] = $value;
2023
-	    				}
2024
-    				}
2025
-    				$alldata = $pall;
2015
+							if ($pvalue['arrival_airport_icao'] == $icao && $pvalue['date'] == $ddate) {
2016
+								$pvalue['arrival_airport_count'] = $pvalue['arrival_airport_count'] + $value['arrival_airport_count'];
2017
+								$find = true;
2018
+								break;
2019
+							}
2020
+						}
2021
+						if ($find === false) {
2022
+							$pall[] = $value;
2023
+						}
2024
+					}
2025
+					$alldata = $pall;
2026 2026
 				foreach ($alldata as $number) {
2027 2027
 					$this->addStatArrivalAirportsDaily($number['date'],$number['arrival_airport_icao'],$number['arrival_airport_name'],$number['arrival_airport_city'],$number['arrival_airport_country'],$number['arrival_airport_count'],'',$filter_name);
2028 2028
 				}
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -9,16 +9,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
220 220
 	
221 221
 	// SBS format is CSV format
222 222
 	if(is_array($line) && isset($line['hex'])) {
223
-	    //print_r($line);
224
-  	    if ($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 ($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,17 +247,17 @@  discard block
 block discarded – undo
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
 		//print_r($this->all_flights);
254 254
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
255
-		    $this->all_flights[$id] = array('hex' => $hex);
256
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
257
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
255
+			$this->all_flights[$id] = array('hex' => $hex);
256
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
257
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
258 258
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
259
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
260
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
259
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
260
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????')) {
261 261
 
262 262
 			$timeelapsed = microtime(true);
263 263
 			$Spotter = new Spotter($this->db);
@@ -266,39 +266,39 @@  discard block
 block discarded – undo
266 266
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
267 267
 
268 268
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
269
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
270
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
271
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
269
+				if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
270
+				elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
271
+				elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272
+				elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
273 273
 			}
274 274
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
275
-		    } else if (isset($line['aircraft_name'])) {
275
+			} else if (isset($line['aircraft_name'])) {
276 276
 			// Get aircraft ICAO from aircraft name
277 277
 			$Spotter = new Spotter($this->db);
278 278
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
279 279
 			$Spotter->db = null;
280 280
 			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
281 281
 			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
282
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
283
-		    $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));
284
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
285
-		    if (!isset($line['id'])) {
282
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
283
+			$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));
284
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
285
+			if (!isset($line['id'])) {
286 286
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
287 287
 //			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')));
288 288
 //			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')));
289 289
 			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' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
290
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
292 292
 
293
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
293
+			if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294
+			if ($globalAllFlights !== FALSE) $dataFound = true;
295 295
 		}
296 296
 		
297 297
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
298 298
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60) {
299
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
299
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
300 300
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301
-		    } else {
301
+			} else {
302 302
 				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";
303 303
 				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";
304 304
 				/*
@@ -307,41 +307,41 @@  discard block
 block discarded – undo
307 307
 				print_r($line);
308 308
 				*/
309 309
 				return '';
310
-		    }
310
+			}
311 311
 		} else {
312 312
 			date_default_timezone_set('UTC');
313 313
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
314 314
 		}
315 315
 
316 316
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
317
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
317
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
318 318
 		}
319 319
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
320
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
321 321
 		}
322 322
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
323
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
323
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => $line['pilot_id']));
324 324
 		}
325 325
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
326
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
326
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => $line['pilot_name']));
327 327
 		}
328 328
  
329 329
 		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'])) {
330
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
331
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
330
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
331
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
332 332
 			$timeelapsed = microtime(true);
333
-            		$Spotter = new Spotter($this->db);
334
-            		$fromsource = NULL;
335
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
336
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
333
+					$Spotter = new Spotter($this->db);
334
+					$fromsource = NULL;
335
+					if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
336
+					elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
337 337
 			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
338 338
 			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
339 339
 			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
340
-            		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
340
+					$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
341 341
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
342 342
 			$Spotter->db = null;
343 343
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
344
-		    }
344
+			}
345 345
 
346 346
 /*
347 347
 		    if (!isset($line['id'])) {
@@ -351,26 +351,26 @@  discard block
 block discarded – undo
351 351
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
352 352
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
353 353
   */
354
-		    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']));
354
+			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']));
355 355
 
356
-		    //$putinarchive = true;
357
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
356
+			//$putinarchive = true;
357
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
358 358
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
359
-		    }
360
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
359
+			}
360
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
361 361
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
362
-		    }
363
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
364
-		    		$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' => ''));
365
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
362
+			}
363
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
364
+					$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' => ''));
365
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
366 366
 				$timeelapsed = microtime(true);
367 367
 				$Spotter = new Spotter($this->db);
368 368
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
369 369
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
370
-		    		$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' => ''));
370
+					$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' => ''));
371 371
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
372 372
 
373
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
373
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
374 374
 			$timeelapsed = microtime(true);
375 375
 			$Spotter = new Spotter($this->db);
376 376
 			$route = $Spotter->getRouteInfo(trim($line['ident']));
@@ -384,43 +384,43 @@  discard block
 block discarded – undo
384 384
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
385 385
 
386 386
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
387
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
388
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
387
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
388
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
389 389
 				//    $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']));
390
-		    		$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']));
391
-		    	    }
390
+					$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']));
391
+					}
392 392
 			}
393 393
 			if (!isset($globalFork)) $globalFork = TRUE;
394 394
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
395 395
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
396 396
 			}
397
-		    }
397
+			}
398 398
 		}
399 399
 
400 400
 		if (isset($line['speed']) && $line['speed'] != '') {
401 401
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
402
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
403
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
404
-		    //$dataFound = true;
402
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
403
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
404
+			//$dataFound = true;
405 405
 		} 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'])) {
406
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
407
-		    if ($distance > 1000 && $distance < 10000) {
408
-		    // use datetime
406
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
407
+			if ($distance > 1000 && $distance < 10000) {
408
+			// use datetime
409 409
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
410 410
 			$speed = $speed*3.6;
411 411
 			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
412 412
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
413
-		    }
413
+			}
414 414
 		}
415 415
 
416 416
 
417 417
 
418
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
419
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
420
-	    	    else unset($timediff);
421
-	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && 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')))) {
418
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
419
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
420
+				else unset($timediff);
421
+				if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && 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')))) {
422 422
 			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'])) {
423
-			    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'])) {
423
+				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'])) {
424 424
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
425 425
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
426 426
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -434,16 +434,16 @@  discard block
 block discarded – undo
434 434
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
435 435
 				$this->tmd = 0;
436 436
 				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
437
-			    }
437
+				}
438 438
 			}
439 439
 
440 440
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
441
-			    //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) {
441
+				//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) {
442 442
 				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
443 443
 				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') {
444
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
445
-				    $dataFound = true;
446
-				    $this->all_flights[$id]['time_last_coord'] = time();
444
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
445
+					$dataFound = true;
446
+					$this->all_flights[$id]['time_last_coord'] = time();
447 447
 				}
448 448
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
449 449
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -454,20 +454,20 @@  discard block
 block discarded – undo
454 454
 				    //$putinarchive = true;
455 455
 				}
456 456
 				*/
457
-			    /*
457
+				/*
458 458
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
459 459
 				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";
460 460
 			    }
461 461
 			    */
462 462
 			}
463 463
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
464
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
465
-			    //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) {
464
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
465
+				//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) {
466 466
 				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
467 467
 				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') {
468
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
469
-				    $dataFound = true;
470
-				    $this->all_flights[$id]['time_last_coord'] = time();
468
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
469
+					$dataFound = true;
470
+					$this->all_flights[$id]['time_last_coord'] = time();
471 471
 				}
472 472
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
473 473
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -485,53 +485,53 @@  discard block
 block discarded – undo
485 485
 			    */
486 486
 			}
487 487
 
488
-		    } else if ($globalDebug && $timediff > 20) {
488
+			} else if ($globalDebug && $timediff > 20) {
489 489
 			$this->tmd = $this->tmd + 1;
490 490
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
491 491
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
492 492
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
493 493
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
494
-		    }
494
+			}
495 495
 		}
496 496
 		if (isset($line['last_update']) && $line['last_update'] != '') {
497
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
498
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
497
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
498
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
499 499
 		}
500 500
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
501
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
502
-		    //$dataFound = true;
501
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
502
+			//$dataFound = true;
503 503
 		}
504 504
 		if (isset($line['format_source']) && $line['format_source'] != '') {
505
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
505
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
506 506
 		}
507 507
 		if (isset($line['source_name']) && $line['source_name'] != '') {
508
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
508
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
509 509
 		}
510 510
 		if (isset($line['emergency']) && $line['emergency'] != '') {
511
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
512
-		    //$dataFound = true;
511
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
512
+			//$dataFound = true;
513 513
 		}
514 514
 		if (isset($line['ground']) && $line['ground'] != '') {
515
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
515
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
516 516
 			// Here we force archive of flight because after ground it's a new one (or should be)
517 517
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
518 518
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
519 519
 			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')));
520
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
520
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
521 521
 			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']));
522
-		    }
523
-		    if ($line['ground'] != 1) $line['ground'] = 0;
524
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
525
-		    //$dataFound = true;
522
+			}
523
+			if ($line['ground'] != 1) $line['ground'] = 0;
524
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
525
+			//$dataFound = true;
526 526
 		}
527 527
 		if (isset($line['squawk']) && $line['squawk'] != '') {
528
-		    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'])) {
529
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
530
-			    $highlight = '';
531
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
532
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
533
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
534
-			    if ($highlight != '') {
528
+			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'])) {
529
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
530
+				$highlight = '';
531
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
532
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
533
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
534
+				if ($highlight != '') {
535 535
 				$timeelapsed = microtime(true);
536 536
 				$Spotter = new Spotter($this->db);
537 537
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
@@ -541,38 +541,38 @@  discard block
 block discarded – undo
541 541
 				$this->all_flights[$id]['putinarchive'] = true;
542 542
 				//$putinarchive = true;
543 543
 				//$highlight = '';
544
-			    }
544
+				}
545 545
 			    
546
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
547
-		    //$dataFound = true;
546
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
547
+			//$dataFound = true;
548 548
 		}
549 549
 
550 550
 		if (isset($line['altitude']) && $line['altitude'] != '') {
551
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
551
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
552 552
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
553 553
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
554 554
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
555 555
 			//$dataFound = true;
556
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
556
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
557 557
   		}
558 558
 
559 559
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
560
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
560
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
561 561
 		}
562 562
 		
563 563
 		if (isset($line['heading']) && $line['heading'] != '') {
564
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
565
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
566
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
567
-		    //$dataFound = true;
564
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
565
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
566
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
567
+			//$dataFound = true;
568 568
   		} 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']) {
569
-  		    $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']);
570
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
571
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
572
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
569
+  			$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']);
570
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
571
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
572
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
573 573
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
574
-  		    // If not enough messages and ACARS set heading to 0
575
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
574
+  			// If not enough messages and ACARS set heading to 0
575
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
576 576
   		}
577 577
 		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
578 578
 		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -583,119 +583,119 @@  discard block
 block discarded – undo
583 583
 		//if ($dataFound == true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['ident'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
584 584
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
585 585
 		if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
586
-		    $this->all_flights[$id]['lastupdate'] = time();
587
-		    if ($this->all_flights[$id]['addedSpotter'] == 0) {
588
-		        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'])) {
589
-			    //print_r($this->all_flights);
590
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
591
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
592
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
586
+			$this->all_flights[$id]['lastupdate'] = time();
587
+			if ($this->all_flights[$id]['addedSpotter'] == 0) {
588
+				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'])) {
589
+				//print_r($this->all_flights);
590
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
591
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
592
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
593 593
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
594 594
 				$timeelapsed = microtime(true);
595 595
 				$SpotterLive = new SpotterLive($this->db);
596 596
 				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')) {
597
-				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
598
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
597
+					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
598
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
599 599
 				} elseif (isset($line['id'])) {
600
-				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
601
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
600
+					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
601
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
602 602
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
603
-				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
604
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
603
+					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
604
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
605 605
 				} else $recent_ident = '';
606 606
 				$SpotterLive->db=null;
607 607
 
608 608
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
609 609
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
610
-			    } else {
610
+				} else {
611 611
 				$recent_ident = '';
612 612
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
613
-			    }
614
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
615
-			    if($recent_ident == "")
616
-			    {
613
+				}
614
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
615
+				if($recent_ident == "")
616
+				{
617 617
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
618 618
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
619 619
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
620 620
 				//adds the spotter data for the archive
621 621
 				$ignoreImport = false;
622 622
 				foreach($globalAirportIgnore as $airportIgnore) {
623
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
623
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
624 624
 					$ignoreImport = true;
625
-				    }
625
+					}
626 626
 				}
627 627
 				if (count($globalAirportAccept) > 0) {
628
-				    $ignoreImport = true;
629
-				    foreach($globalAirportIgnore as $airportIgnore) {
628
+					$ignoreImport = true;
629
+					foreach($globalAirportIgnore as $airportIgnore) {
630 630
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
631
-					    $ignoreImport = false;
631
+						$ignoreImport = false;
632
+					}
632 633
 					}
633
-				    }
634 634
 				}
635 635
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
636
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
636
+					foreach($globalAirlineIgnore as $airlineIgnore) {
637 637
 					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)) {
638
-					    $ignoreImport = true;
638
+						$ignoreImport = true;
639
+					}
639 640
 					}
640
-				    }
641 641
 				}
642 642
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
643
-				    $ignoreImport = true;
644
-				    foreach($globalAirlineAccept as $airlineAccept) {
643
+					$ignoreImport = true;
644
+					foreach($globalAirlineAccept as $airlineAccept) {
645 645
 					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)) {
646
-					    $ignoreImport = false;
646
+						$ignoreImport = false;
647
+					}
647 648
 					}
648
-				    }
649 649
 				}
650 650
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
651
-				    $ignoreImport = true;
652
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
651
+					$ignoreImport = true;
652
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
653 653
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
654
-					    $ignoreImport = false;
654
+						$ignoreImport = false;
655
+					}
655 656
 					}
656
-				    }
657 657
 				}
658 658
 				
659 659
 				if (!$ignoreImport) {
660
-				    $highlight = '';
661
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
662
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
663
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
664
-				    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')));
665
-				    $timeelapsed = microtime(true);
666
-				    $Spotter = new Spotter($this->db);
667
-				    $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']);
668
-				    $Spotter->db = null;
669
-				    if ($globalDebug && isset($result)) echo $result."\n";
670
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
660
+					$highlight = '';
661
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
662
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
663
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
664
+					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')));
665
+					$timeelapsed = microtime(true);
666
+					$Spotter = new Spotter($this->db);
667
+					$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']);
668
+					$Spotter->db = null;
669
+					if ($globalDebug && isset($result)) echo $result."\n";
670
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
671 671
 				    
672
-				    // Add source stat in DB
673
-				    $Stats = new Stats($this->db);
674
-				    if (!empty($this->stats)) {
672
+					// Add source stat in DB
673
+					$Stats = new Stats($this->db);
674
+					if (!empty($this->stats)) {
675 675
 					if ($globalDebug) echo 'Add source stats : ';
676
-				        foreach($this->stats as $date => $data) {
677
-					    foreach($data as $source => $sourced) {
678
-					        //print_r($sourced);
679
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
680
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
681
-				    		if (isset($sourced['msg'])) {
682
-				    		    if (time() - $sourced['msg']['date'] > 10) {
683
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
684
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
685
-			    			        unset($this->stats[$date][$source]['msg']);
686
-			    			    }
687
-			    			}
688
-			    		    }
689
-			    		    if ($date != date('Y-m-d')) {
690
-			    			unset($this->stats[$date]);
691
-			    		    }
692
-				    	}
693
-				    	if ($globalDebug) echo 'Done'."\n";
694
-
695
-				    }
696
-				    $Stats->db = null;
676
+						foreach($this->stats as $date => $data) {
677
+						foreach($data as $source => $sourced) {
678
+							//print_r($sourced);
679
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
680
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
681
+							if (isset($sourced['msg'])) {
682
+								if (time() - $sourced['msg']['date'] > 10) {
683
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
684
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
685
+									unset($this->stats[$date][$source]['msg']);
686
+								}
687
+							}
688
+							}
689
+							if ($date != date('Y-m-d')) {
690
+							unset($this->stats[$date]);
691
+							}
692
+						}
693
+						if ($globalDebug) echo 'Done'."\n";
694
+
695
+					}
696
+					$Stats->db = null;
697 697
 				    
698
-				    $this->del();
698
+					$this->del();
699 699
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
700 700
 				//$ignoreImport = false;
701 701
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -713,18 +713,18 @@  discard block
 block discarded – undo
713 713
 			*/
714 714
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
715 715
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
716
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
717
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
718
-				    $SpotterLive = new SpotterLive($this->db);
719
-				    $SpotterLive->deleteLiveSpotterData();
720
-				    $SpotterLive->db=null;
721
-				    if ($globalDebug) echo " Done\n";
722
-				    $this->last_delete = time();
716
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
717
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
718
+					$SpotterLive = new SpotterLive($this->db);
719
+					$SpotterLive->deleteLiveSpotterData();
720
+					$SpotterLive->db=null;
721
+					if ($globalDebug) echo " Done\n";
722
+					$this->last_delete = time();
723 723
 				}
724
-			    } else {
724
+				} else {
725 725
 				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')) {
726
-				    $this->all_flights[$id]['id'] = $recent_ident;
727
-				    $this->all_flights[$id]['addedSpotter'] = 1;
726
+					$this->all_flights[$id]['id'] = $recent_ident;
727
+					$this->all_flights[$id]['addedSpotter'] = 1;
728 728
 				}
729 729
 				if (isset($globalDaemon) && !$globalDaemon) {
730 730
 					$Spotter = new Spotter($this->db);
@@ -732,14 +732,14 @@  discard block
 block discarded – undo
732 732
 					$Spotter->db = null;
733 733
 				}
734 734
 				
735
-			    }
735
+				}
736
+			}
736 737
 			}
737
-		    }
738
-		    //adds the spotter LIVE data
739
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
740
-		    //echo "\nAdd in Live !! \n";
741
-		    //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";
742
-		    if ($globalDebug) {
738
+			//adds the spotter LIVE data
739
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
740
+			//echo "\nAdd in Live !! \n";
741
+			//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";
742
+			if ($globalDebug) {
743 743
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
744 744
 				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";
745 745
 				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";
@@ -747,49 +747,49 @@  discard block
 block discarded – undo
747 747
 				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";
748 748
 				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";
749 749
 			}
750
-		    }
751
-		    $ignoreImport = false;
752
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
753
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
750
+			}
751
+			$ignoreImport = false;
752
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
753
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
754 754
 
755
-		    foreach($globalAirportIgnore as $airportIgnore) {
756
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
757
-			    $ignoreImport = true;
755
+			foreach($globalAirportIgnore as $airportIgnore) {
756
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
757
+				$ignoreImport = true;
758
+			}
758 759
 			}
759
-		    }
760
-		    if (count($globalAirportAccept) > 0) {
761
-		        $ignoreImport = true;
762
-		        foreach($globalAirportIgnore as $airportIgnore) {
763
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
760
+			if (count($globalAirportAccept) > 0) {
761
+				$ignoreImport = true;
762
+				foreach($globalAirportIgnore as $airportIgnore) {
763
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
764 764
 				$ignoreImport = false;
765
-			    }
765
+				}
766 766
 			}
767
-		    }
768
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
767
+			}
768
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
769 769
 			foreach($globalAirlineIgnore as $airlineIgnore) {
770
-			    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)) {
770
+				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)) {
771 771
 				$ignoreImport = true;
772
-			    }
772
+				}
773 773
 			}
774
-		    }
775
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
774
+			}
775
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
776 776
 			$ignoreImport = true;
777 777
 			foreach($globalAirlineAccept as $airlineAccept) {
778
-			    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)) {
778
+				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)) {
779 779
 				$ignoreImport = false;
780
-			    }
780
+				}
781 781
 			}
782
-		    }
783
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
782
+			}
783
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
784 784
 			$ignoreImport = true;
785 785
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
786
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
787
-			        $ignoreImport = false;
788
-			    }
786
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
787
+					$ignoreImport = false;
788
+				}
789
+			}
789 790
 			}
790
-		    }
791 791
 
792
-		    if (!$ignoreImport) {
792
+			if (!$ignoreImport) {
793 793
 			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'])) {
794 794
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
795 795
 				$timeelapsed = microtime(true);
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 					if ($stats_heading == 16) $stats_heading = 0;
828 828
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
829 829
 						for ($i=0;$i<=15;$i++) {
830
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
830
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
831 831
 						}
832 832
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
833 833
 					} else {
@@ -840,11 +840,11 @@  discard block
 block discarded – undo
840 840
 					//var_dump($this->stats);
841 841
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
842 842
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
843
-						    end($this->stats[$current_date][$source]['hist']);
844
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
843
+							end($this->stats[$current_date][$source]['hist']);
844
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
845 845
 						} else $mini = 0;
846 846
 						for ($i=$mini;$i<=$distance;$i+=10) {
847
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
847
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
848 848
 						}
849 849
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
850 850
 					} else {
@@ -861,22 +861,22 @@  discard block
 block discarded – undo
861 861
 			
862 862
 			
863 863
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
864
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
865
-			    $SpotterLive = new SpotterLive($this->db);
866
-			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
867
-			    $SpotterLive->db = null;
868
-			    //SpotterLive->deleteLiveSpotterData();
869
-			    if ($globalDebug) echo " Done\n";
870
-			    $this->last_delete_hourly = time();
864
+				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
865
+				$SpotterLive = new SpotterLive($this->db);
866
+				$SpotterLive->deleteLiveSpotterDataNotUpdated();
867
+				$SpotterLive->db = null;
868
+				//SpotterLive->deleteLiveSpotterData();
869
+				if ($globalDebug) echo " Done\n";
870
+				$this->last_delete_hourly = time();
871 871
 			}
872 872
 			
873
-		    }
874
-		    //$ignoreImport = false;
873
+			}
874
+			//$ignoreImport = false;
875 875
 		}
876 876
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
877 877
 		if ($send) return $this->all_flights[$id];
878
-	    }
878
+		}
879
+	}
879 880
 	}
880
-    }
881 881
 }
882 882
 ?>
Please login to merge, or discard this patch.