Completed
Push — master ( e565ed...055e12 )
by Yannick
58:46 queued 27:49
created
require/class.MarineArchive.php 1 patch
Braces   +37 added lines, -13 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 	public function __construct($dbc = null) {
14 14
 		$Connection = new Connection($dbc);
15 15
 		$this->db = $Connection->db;
16
-		if ($this->db === null) die('Error: No DB connection. (MarineArchive)');
16
+		if ($this->db === null) {
17
+			die('Error: No DB connection. (MarineArchive)');
18
+		}
17 19
 	}
18 20
 
19 21
     /**
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 		if (isset($filter[0]['source'])) {
37 39
 			$filters = array_merge($filters,$filter);
38 40
 		}
39
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
41
+		if (is_array($globalFilter)) {
42
+			$filter = array_merge($filter,$globalFilter);
43
+		}
40 44
 		$filter_query_join = '';
41 45
 		$filter_query_where = '';
42 46
 		foreach($filters as $flt) {
@@ -82,8 +86,11 @@  discard block
 block discarded – undo
82 86
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
83 87
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
84 88
 		}
85
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
86
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
89
+		if ($filter_query_where == '' && $where) {
90
+			$filter_query_where = ' WHERE';
91
+		} elseif ($filter_query_where != '' && $and) {
92
+			$filter_query_where .= ' AND';
93
+		}
87 94
 		if ($filter_query_where != '') {
88 95
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
89 96
 		}
@@ -129,9 +136,14 @@  discard block
 block discarded – undo
129 136
 		if ($over_country == '') {
130 137
 			$Marine = new Marine($this->db);
131 138
 			$data_country = $Marine->getCountryFromLatitudeLongitude($latitude,$longitude);
132
-			if (!empty($data_country)) $country = $data_country['iso2'];
133
-			else $country = '';
134
-		} else $country = $over_country;
139
+			if (!empty($data_country)) {
140
+				$country = $data_country['iso2'];
141
+			} else {
142
+				$country = '';
143
+			}
144
+		} else {
145
+			$country = $over_country;
146
+		}
135 147
 		
136 148
 		//$country = $over_country;
137 149
 		// Route is not added in marine_archive
@@ -661,7 +673,9 @@  discard block
 block discarded – undo
661 673
                     $additional_query .= "(marine_archive_output.pilot_name like '%".$q_item."%') OR ";
662 674
                     $additional_query .= "(marine_archive_output.ident like '%".$q_item."%') OR ";
663 675
                     $translate = $Translation->ident2icao($q_item);
664
-                    if ($translate != $q_item) $additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
676
+                    if ($translate != $q_item) {
677
+                    	$additional_query .= "(marine_archive_output.ident like '%".$translate."%') OR ";
678
+                    }
665 679
                     $additional_query .= "(marine_archive_output.highlight like '%".$q_item."%')";
666 680
                     $additional_query .= ")";
667 681
                 }
@@ -879,7 +893,9 @@  discard block
 block discarded – undo
879 893
                 date_default_timezone_set($globalTimezone);
880 894
                 $datetime = new DateTime();
881 895
                 $offset = $datetime->format('P');
882
-            } else $offset = '+00:00';
896
+            } else {
897
+            	$offset = '+00:00';
898
+            }
883 899
 
884 900
 
885 901
             if ($date_array[1] != "")
@@ -1165,9 +1181,13 @@  discard block
 block discarded – undo
1165 1181
 				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1166 1182
 			}
1167 1183
 		}
1168
-                if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1184
+                if ($sincedate != '') {
1185
+                	$query .= "AND date > '".$sincedate."' ";
1186
+                }
1169 1187
 	$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1170
-	if ($limit) $query .= " LIMIT 0,10";
1188
+	if ($limit) {
1189
+		$query .= " LIMIT 0,10";
1190
+	}
1171 1191
       
1172 1192
 	
1173 1193
 	$sth = $this->db->prepare($query);
@@ -1213,9 +1233,13 @@  discard block
 block discarded – undo
1213 1233
 				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1214 1234
 			}
1215 1235
 		}
1216
-                if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1236
+                if ($sincedate != '') {
1237
+                	$query .= "AND s.date > '".$sincedate."' ";
1238
+                }
1217 1239
 	$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1218
-	if ($limit) $query .= " LIMIT 0,10";
1240
+	if ($limit) {
1241
+		$query .= " LIMIT 0,10";
1242
+	}
1219 1243
       
1220 1244
 	
1221 1245
 	$sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Braces   +424 added lines, -151 removed lines patch added patch discarded remove patch
@@ -59,7 +59,9 @@  discard block
 block discarded – undo
59 59
 		try {
60 60
 			$GeoidClass = new GeoidHeight();
61 61
 		} catch(Exception $e) {
62
-			if ($globalDebug) echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
62
+			if ($globalDebug) {
63
+				echo "Can't calculate geoid, check that you downloaded it via update_db.php (".$e.")\n";
64
+			}
63 65
 			$GeoidClass = FALSE;
64 66
 		}
65 67
 	}
@@ -78,7 +80,9 @@  discard block
 block discarded – undo
78 80
 	$dbc = $this->db;
79 81
 	$this->all_flights[$id]['schedule_check'] = true;
80 82
 	if ($globalSchedulesFetch) {
81
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
83
+	if ($globalDebug) {
84
+		echo 'Getting schedule info...'."\n";
85
+	}
82 86
 	$Spotter = new Spotter($dbc);
83 87
 	$Schedule = new Schedule($dbc);
84 88
 	$Translation = new Translation($dbc);
@@ -89,7 +93,9 @@  discard block
 block discarded – undo
89 93
 	    if ($Schedule->checkSchedule($operator) == 0) {
90 94
 		$schedule = $Schedule->fetchSchedule($operator);
91 95
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
92
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
96
+		    if ($globalDebug) {
97
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
98
+		    }
93 99
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
94 100
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
95 101
 		    // Should also check if route schedule = route from DB
@@ -98,7 +104,9 @@  discard block
 block discarded – undo
98 104
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
99 105
 			    if (trim($airport_icao) != '') {
100 106
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
101
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
107
+				if ($globalDebug) {
108
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
109
+				}
102 110
 			    }
103 111
 			}
104 112
 		    }
@@ -107,20 +115,30 @@  discard block
 block discarded – undo
107 115
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
108 116
 			    if (trim($airport_icao) != '') {
109 117
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
110
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
118
+				if ($globalDebug) {
119
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
120
+				}
111 121
 			    }
112 122
 			}
113 123
 		    }
114 124
 		    $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']);
115 125
 		}
116
-	    } else $scheduleexist = true;
117
-	} else $scheduleexist = true;
126
+	    } else {
127
+	    	$scheduleexist = true;
128
+	    }
129
+	} else {
130
+		$scheduleexist = true;
131
+	}
118 132
 	// close connection, at least one way will work ?
119 133
        if ($scheduleexist) {
120
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
134
+		if ($globalDebug) {
135
+			echo "-> get arrival/departure airport info for ".$ident."\n";
136
+		}
121 137
     		$sch = $Schedule->getSchedule($operator);
122 138
 		$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']));
123
-		if ($this->all_flights[$id]['addedSpotter'] == 1) $Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
139
+		if ($this->all_flights[$id]['addedSpotter'] == 1) {
140
+			$Spotter->updateLatestScheduleSpotterData($this->all_flights[$id]['id'],$sch['departure_airport_icao'],$sch['departure_airport_time'],$sch['arrival_airport_icao'],$sch['arrival_airport_time']);
141
+		}
124 142
        }
125 143
 	$Spotter->db = null;
126 144
 	$Schedule->db = null;
@@ -140,14 +158,18 @@  discard block
 block discarded – undo
140 158
 
141 159
     public function checkAll() {
142 160
 	global $globalDebug, $globalNoImport;
143
-	if ($globalDebug) echo "Update last seen flights data...\n";
161
+	if ($globalDebug) {
162
+		echo "Update last seen flights data...\n";
163
+	}
144 164
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
145 165
 	    foreach ($this->all_flights as $key => $flight) {
146 166
 		if (isset($this->all_flights[$key]['id'])) {
147 167
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
148 168
     		    $Spotter = new Spotter($this->db);
149 169
         	    $real_arrival = $this->arrival($key);
150
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']);
170
+        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) {
171
+        	    	$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']);
172
+        	    }
151 173
         	}
152 174
 	    }
153 175
 	}
@@ -155,24 +177,32 @@  discard block
 block discarded – undo
155 177
 
156 178
     public function arrival($key) {
157 179
 	global $globalClosestMinDist, $globalDebug;
158
-	if ($globalDebug) echo 'Update arrival...'."\n";
180
+	if ($globalDebug) {
181
+		echo 'Update arrival...'."\n";
182
+	}
159 183
 	$Spotter = new Spotter($this->db);
160 184
         $airport_icao = '';
161 185
         $airport_time = '';
162
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
186
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
187
+        	$globalClosestMinDist = 50;
188
+        }
163 189
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
164 190
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
165 191
     	    if (isset($closestAirports[0])) {
166 192
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
167 193
         	    $airport_icao = $closestAirports[0]['icao'];
168 194
         	    $airport_time = $this->all_flights[$key]['datetime'];
169
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
195
+        	    if ($globalDebug) {
196
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
197
+        	    }
170 198
         	} elseif (count($closestAirports) > 1 && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
171 199
         	    foreach ($closestAirports as $airport) {
172 200
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
173 201
         		    $airport_icao = $airport['icao'];
174 202
         		    $airport_time = $this->all_flights[$key]['datetime'];
175
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
203
+        		    if ($globalDebug) {
204
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
205
+        		    }
176 206
         		    break;
177 207
         		}
178 208
         	    }
@@ -180,14 +210,20 @@  discard block
 block discarded – undo
180 210
         		$airport_icao = $closestAirports[0]['icao'];
181 211
         		$airport_time = $this->all_flights[$key]['datetime'];
182 212
         	} else {
183
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
213
+        		if ($globalDebug) {
214
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
215
+        		}
184 216
         	}
185 217
     	    } else {
186
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
218
+    		    if ($globalDebug) {
219
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
220
+    		    }
187 221
     	    }
188 222
 
189 223
         } else {
190
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
224
+        	if ($globalDebug) {
225
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
226
+        	}
191 227
         }
192 228
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
193 229
     }
@@ -197,7 +233,9 @@  discard block
 block discarded – undo
197 233
     public function del() {
198 234
 	global $globalDebug, $globalNoImport, $globalNoDB;
199 235
 	// Delete old infos
200
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
236
+	if ($globalDebug) {
237
+		echo 'Delete old values and update latest data...'."\n";
238
+	}
201 239
 	
202 240
 	foreach ($this->all_flights as $key => $flight) {
203 241
 		if (isset($flight['lastupdate'])) {
@@ -212,22 +250,30 @@  discard block
 block discarded – undo
212 250
 	global $globalDebug, $globalNoImport, $globalNoDB;
213 251
 	// Delete old infos
214 252
 	if (isset($this->all_flights[$key]['id'])) {
215
-		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
253
+		if ($globalDebug) {
254
+			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
255
+		}
216 256
 		if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
217 257
 			$real_arrival = $this->arrival($key);
218 258
 			$Spotter = new Spotter($this->db);
219 259
 			$SpotterLive = new SpotterLive($this->db);
220 260
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
221 261
 				$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']);
222
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
262
+				if ($globalDebug && $result != 'success') {
263
+					echo '!!! ERROR : '.$result."\n";
264
+				}
223 265
 				$this->all_flights[$key]['putinarchive'] = true;
224 266
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['aircraft_icao'], $this->all_flights[$key]['departure_airport'], $this->all_flights[$key]['arrival_airport'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['waypoints'], $this->all_flights[$key]['altitude'],$this->all_flights[$key]['altitude_real'], $this->all_flights[$key]['heading'], $this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'], $this->all_flights[$key]['departure_airport_time'], $this->all_flights[$key]['arrival_airport_time'], $this->all_flights[$key]['squawk'],$this->all_flights[$key]['route_stop'],$this->all_flights[$key]['hex'],$this->all_flights[$key]['putinarchive'],$this->all_flights[$key]['registration'],$this->all_flights[$key]['pilot_id'],$this->all_flights[$key]['pilot_name'], $this->all_flights[$key]['verticalrate'], $this->all_flights[$key]['noarchive'], $this->all_flights[$key]['ground'],$this->all_flights[$key]['format_source'],$this->all_flights[$key]['source_name'],$this->all_flights[$key]['over_country']);
225
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
267
+				if ($globalDebug && $result != 'success') {
268
+					echo '!!! ERROR : '.$result."\n";
269
+				}
226 270
 			}
227 271
 			$Spotter->db = null;
228 272
 			$SpotterLive->db = null;
229 273
 		}
230
-		if ($globalDebug) echo "\n";
274
+		if ($globalDebug) {
275
+			echo "\n";
276
+		}
231 277
 	}
232 278
 	unset($this->all_flights[$key]);
233 279
     }
@@ -235,9 +281,13 @@  discard block
 block discarded – undo
235 281
     public function add($line) {
236 282
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
237 283
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
238
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
239
-	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') $globalAircraftMaxUpdate = 3000;
240
-/*
284
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
285
+		$globalCoordMinChange = '0.01';
286
+	}
287
+	if (!isset($globalAircraftMaxUpdate) || $globalAircraftMaxUpdate == '') {
288
+		$globalAircraftMaxUpdate = 3000;
289
+	}
290
+	/*
241 291
 	$Spotter = new Spotter();
242 292
 	$dbc = $Spotter->db;
243 293
 	$SpotterLive = new SpotterLive($dbc);
@@ -259,19 +309,28 @@  discard block
 block discarded – undo
259 309
 	// SBS format is CSV format
260 310
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
261 311
 	    //print_r($line);
262
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
312
+	    if (isset($line['hex'])) {
313
+	    	$line['hex'] = strtoupper($line['hex']);
314
+	    }
263 315
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && substr($line['hex'],0,1) != '~' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
264 316
 
265 317
 		// Increment message number
266 318
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
267 319
 		    $current_date = date('Y-m-d');
268
-		    if (isset($line['source_name'])) $source = $line['source_name'];
269
-		    else $source = '';
270
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
320
+		    if (isset($line['source_name'])) {
321
+		    	$source = $line['source_name'];
322
+		    } else {
323
+		    	$source = '';
324
+		    }
325
+		    if ($source == '' || $line['format_source'] == 'aprs') {
326
+		    	$source = $line['format_source'];
327
+		    }
271 328
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
272 329
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
273 330
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
274
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
331
+		    } else {
332
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
333
+		    }
275 334
 		}
276 335
 		
277 336
 		/*
@@ -287,23 +346,38 @@  discard block
 block discarded – undo
287 346
 		//$this->db = $dbc;
288 347
 
289 348
 		//$hex = trim($line['hex']);
290
-	        if (!isset($line['id'])) $id = trim($line['hex']);
291
-	        else $id = trim($line['id']);
349
+	        if (!isset($line['id'])) {
350
+	        	$id = trim($line['hex']);
351
+	        } else {
352
+	        	$id = trim($line['id']);
353
+	        }
292 354
 		
293 355
 		if (!isset($this->all_flights[$id])) {
294
-		    if ($globalDebug) echo 'New flight...'."\n";
356
+		    if ($globalDebug) {
357
+		    	echo 'New flight...'."\n";
358
+		    }
295 359
 		    $this->all_flights[$id] = array();
296 360
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
297 361
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', '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,'source_type' => '','coordinates' => 0));
298
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
362
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) {
363
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
364
+		    }
299 365
 		    if (!isset($line['id'])) {
300
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
301
-//			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')));
366
+			if (!isset($globalDaemon)) {
367
+				$globalDaemon = TRUE;
368
+			}
369
+			//			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')));
302 370
 //			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')));
303
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
371
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) {
372
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
373
+			}
304 374
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
305
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
306
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
375
+		     } else {
376
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
377
+		     }
378
+		    if ($globalAllFlights !== FALSE) {
379
+		    	$dataFound = true;
380
+		    }
307 381
 		}
308 382
 		if (isset($line['source_type']) && $line['source_type'] != '') {
309 383
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
@@ -325,12 +399,20 @@  discard block
 block discarded – undo
325 399
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
326 400
 			    }
327 401
 			    $Spotter->db = null;
328
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
329
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
402
+			    if ($globalDebugTimeElapsed) {
403
+			    	echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
404
+			    }
405
+			    if ($aircraft_icao != '') {
406
+			    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
407
+			    }
330 408
 			}
331 409
 		    }
332
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
333
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
410
+		    if ($globalAllFlights !== FALSE) {
411
+		    	$dataFound = true;
412
+		    }
413
+		    if ($globalDebug) {
414
+		    	echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
415
+		    }
334 416
 		}
335 417
 	        if (isset($line['id']) && !isset($line['hex'])) {
336 418
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
@@ -339,7 +421,9 @@  discard block
 block discarded – undo
339 421
 			$icao = $line['aircraft_icao'];
340 422
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341 423
 				$Spotter = new Spotter($this->db);
342
-				if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
424
+				if (isset($Spotter->aircraft_correct_icaotype[$icao])) {
425
+					$icao = $Spotter->aircraft_correct_icaotype[$icao];
426
+				}
343 427
 				$Spotter->db = null;
344 428
 			}
345 429
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
@@ -349,15 +433,24 @@  discard block
 block discarded – undo
349 433
 				$Spotter = new Spotter($this->db);
350 434
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
351 435
 				$Spotter->db = null;
352
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
436
+				if ($aircraft_icao != '') {
437
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
438
+				}
353 439
 			}
354 440
 		}
355 441
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
356
-			if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
357
-			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
358
-			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
359
-			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
360
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
442
+			if ($line['aircraft_type'] == 'PARA_GLIDER') {
443
+				$aircraft_icao = 'GLID';
444
+			} elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
445
+				$aircraft_icao = 'UHEL';
446
+			} elseif ($line['aircraft_type'] == 'TOW_PLANE') {
447
+				$aircraft_icao = 'TOWPLANE';
448
+			} elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
449
+				$aircraft_icao = 'POWAIRC';
450
+			}
451
+			if (isset($aircraft_icao)) {
452
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
453
+			}
361 454
 		}
362 455
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
363 456
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
@@ -367,8 +460,11 @@  discard block
 block discarded – undo
367 460
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
368 461
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
369 462
 		    } else {
370
-				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";
371
-				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";
463
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
464
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
465
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
466
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
467
+				}
372 468
 				/*
373 469
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
374 470
 				print_r($this->all_flights[$id]);
@@ -377,16 +473,22 @@  discard block
 block discarded – undo
377 473
 				return '';
378 474
 		    }
379 475
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
380
-			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
476
+			if ($globalDebug) {
477
+				echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
478
+			}
381 479
 			return '';
382 480
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
383
-			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
481
+			if ($globalDebug) {
482
+				echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
483
+			}
384 484
 			return '';
385 485
 		} elseif (!isset($line['datetime'])) {
386 486
 			date_default_timezone_set('UTC');
387 487
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
388 488
 		} else {
389
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
489
+			if ($globalDebug) {
490
+				echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
491
+			}
390 492
 			return '';
391 493
 		}
392 494
 
@@ -407,30 +509,48 @@  discard block
 block discarded – undo
407 509
 
408 510
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
409 511
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
410
-				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
512
+				if ($globalDebug) {
513
+					echo '---!!!! New ident, reset aircraft data...'."\n";
514
+				}
411 515
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
412 516
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
413
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
414
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
415
-				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']));
517
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) {
518
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
519
+				} elseif (isset($line['id'])) {
520
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
521
+				} elseif (isset($this->all_flights[$id]['ident'])) {
522
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
523
+				}
416 524
 			} else {
417 525
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418 526
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
419 527
 				$timeelapsed = microtime(true);
420 528
             			$Spotter = new Spotter($this->db);
421 529
             			$fromsource = NULL;
422
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
423
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
424
-				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
425
-				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
426
-				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
530
+            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
531
+            				$fromsource = $globalAirlinesSource;
532
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
533
+            				$fromsource = 'vatsim';
534
+            			} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
535
+					$fromsource = 'ivao';
536
+				} elseif (isset($globalVATSIM) && $globalVATSIM) {
537
+					$fromsource = 'vatsim';
538
+				} elseif (isset($globalIVAO) && $globalIVAO) {
539
+					$fromsource = 'ivao';
540
+				}
427 541
             			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource,$this->all_flights[$id]['source_type']);
428
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
542
+				if ($globalDebug && $result != 'success') {
543
+					echo '!!! ERROR : '.$result."\n";
544
+				}
429 545
 				$Spotter->db = null;
430
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
546
+				if ($globalDebugTimeElapsed) {
547
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
548
+				}
431 549
 			    }
432 550
 			}
433
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
551
+		    } else {
552
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
553
+		    }
434 554
 		    
435 555
 /*
436 556
 		    if (!isset($line['id'])) {
@@ -440,7 +560,9 @@  discard block
 block discarded – undo
440 560
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
441 561
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
442 562
   */
443
-		    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']));
563
+		    if (!isset($this->all_flights[$id]['id'])) {
564
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
565
+		    }
444 566
 
445 567
 		    //$putinarchive = true;
446 568
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -458,7 +580,9 @@  discard block
 block discarded – undo
458 580
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
459 581
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
460 582
 		    		$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' => ''));
461
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
583
+				if ($globalDebugTimeElapsed) {
584
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
585
+				}
462 586
                         }
463 587
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
464 588
 			$timeelapsed = microtime(true);
@@ -472,7 +596,9 @@  discard block
 block discarded – undo
472 596
 				$Translation->db = null;
473 597
 			    }
474 598
 			    $Spotter->db = null;
475
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
599
+			    if ($globalDebugTimeElapsed) {
600
+			    	echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
601
+			    }
476 602
                     	}
477 603
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
478 604
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -481,9 +607,13 @@  discard block
 block discarded – undo
481 607
 		    		$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']));
482 608
 		    	    }
483 609
 			}
484
-			if (!isset($globalFork)) $globalFork = TRUE;
610
+			if (!isset($globalFork)) {
611
+				$globalFork = TRUE;
612
+			}
485 613
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
486
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
614
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
615
+					$this->get_Schedule($id,trim($line['ident']));
616
+				}
487 617
 			}
488 618
 		    }
489 619
 		}
@@ -501,9 +631,13 @@  discard block
 block discarded – undo
501 631
 			$speed = $speed*3.6;
502 632
 			if ($speed < 1000) {
503 633
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
504
-	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
634
+	  			if ($globalDebug) {
635
+	  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
636
+	  			}
505 637
 	  		} else {
506
-	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
638
+	  			if ($globalDebug) {
639
+	  				echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
640
+	  			}
507 641
 	  		}
508 642
 		    }
509 643
 		}
@@ -512,13 +646,21 @@  discard block
 block discarded – undo
512 646
 
513 647
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
514 648
 	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
515
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
649
+	    	    	if ($globalDebug) {
650
+	    	    		echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
651
+	    	    	}
516 652
 	    	    	return false;
517 653
 	    	    }
518
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
519
-	    	    else unset($timediff);
520
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
521
-	    	    else unset($timediff_archive);
654
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
655
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
656
+	    	    } else {
657
+	    	    	unset($timediff);
658
+	    	    }
659
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) {
660
+	    	    	$timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
661
+	    	    } else {
662
+	    	    	unset($timediff_archive);
663
+	    	    }
522 664
 	    	    if ($this->tmd > 5
523 665
 	    	        || (isset($line['format_source']) 
524 666
 	    	    	    && $line['format_source'] == 'airwhere' 
@@ -554,21 +696,32 @@  discard block
 block discarded – undo
554 696
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
555 697
 				$this->all_flights[$id]['putinarchive'] = true;
556 698
 				if ($this->tmd > 5 && $this->all_flights[$id]['putinarchive'] == true) {
557
-					if ($globalDebug) echo "\n".' Update Initial data ! '."\n";
699
+					if ($globalDebug) {
700
+						echo "\n".' Update Initial data ! '."\n";
701
+					}
558 702
 					$updateinitial = true;
559 703
 				}
560 704
 				$this->tmd = 0;
561 705
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
562
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
706
+				    if ($globalDebug) {
707
+				    	echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
708
+				    }
563 709
 				    $timeelapsed = microtime(true);
564 710
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
565 711
 					$Spotter = new Spotter($this->db);
566 712
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
567
-					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
568
-					else $this->all_flights[$id]['over_country'] = '';
713
+					if (!empty($all_country)) {
714
+						$this->all_flights[$id]['over_country'] = $all_country['iso2'];
715
+					} else {
716
+						$this->all_flights[$id]['over_country'] = '';
717
+					}
569 718
 					$Spotter->db = null;
570
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
571
-					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
719
+					if ($globalDebugTimeElapsed) {
720
+						echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
721
+					}
722
+					if ($globalDebug) {
723
+						echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
724
+					}
572 725
 				    }
573 726
 				}
574 727
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
@@ -614,7 +767,9 @@  discard block
 block discarded – undo
614 767
 			    */
615 768
 			}
616 769
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
617
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
770
+			    if ($line['longitude'] > 180) {
771
+			    	$line['longitude'] = $line['longitude'] - 360;
772
+			    }
618 773
 			    //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) {
619 774
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
620 775
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -643,7 +798,9 @@  discard block
 block discarded – undo
643 798
 			    */
644 799
 			}
645 800
 			if ($globalDaemon === TRUE && isset($updateinitial) && $updateinitial && $this->all_flights[$id]['addedSpotter'] == 1) {
646
-			    if ($globalDebug) echo "\n".'>>> Update initial data !'."\n";
801
+			    if ($globalDebug) {
802
+			    	echo "\n".'>>> Update initial data !'."\n";
803
+			    }
647 804
 			    unset($updateinitial);
648 805
 			    $SpotterArchive = new SpotterArchive();
649 806
 			    $SpotterArchive->deleteSpotterArchiveTrackDataByID($this->all_flights[$id]['id']);
@@ -661,7 +818,9 @@  discard block
 block discarded – undo
661 818
 		    }
662 819
 		}
663 820
 		if (isset($line['last_update']) && $line['last_update'] != '') {
664
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
821
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
822
+		    	$dataFound = true;
823
+		    }
665 824
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
666 825
 		}
667 826
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -683,35 +842,53 @@  discard block
 block discarded – undo
683 842
 			// Here we force archive of flight because after ground it's a new one (or should be)
684 843
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
685 844
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
686
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
687
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
688
-			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']));
845
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) {
846
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
847
+			} elseif (isset($line['id'])) {
848
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
849
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
850
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
851
+			}
852
+		    }
853
+		    if ($line['ground'] != 1) {
854
+		    	$line['ground'] = 0;
689 855
 		    }
690
-		    if ($line['ground'] != 1) $line['ground'] = 0;
691 856
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
692 857
 		    //$dataFound = true;
693 858
 		}
694 859
 		if (isset($line['squawk']) && $line['squawk'] != '') {
695 860
 		    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'])) {
696
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
861
+			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) {
862
+			    	$this->all_flights[$id]['putinarchive'] = true;
863
+			    }
697 864
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
698 865
 			    $highlight = '';
699
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
700
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
701
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
866
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
867
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
868
+			    }
869
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
870
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
871
+			    }
872
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
873
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
874
+			    }
702 875
 			    if ($highlight != '') {
703 876
 				$timeelapsed = microtime(true);
704 877
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
705 878
 				    $Spotter = new Spotter($this->db);
706 879
 				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
707 880
 				    $Spotter->db = null;
708
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
881
+				    if ($globalDebugTimeElapsed) {
882
+				    	echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
883
+				    }
709 884
 				}
710 885
 				//$putinarchive = true;
711 886
 				//$highlight = '';
712 887
 			    }
713 888
 			    
714
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
889
+		    } else {
890
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
891
+		    }
715 892
 		    //$dataFound = true;
716 893
 		}
717 894
 
@@ -724,19 +901,27 @@  discard block
 block discarded – undo
724 901
 				}
725 902
 			}
726 903
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
727
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
904
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) {
905
+				$this->all_flights[$id]['putinarchive'] = true;
906
+			}
728 907
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
729 908
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
730 909
 			//$dataFound = true;
731 910
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
732 911
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
733 912
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
734
-				if ($globalDebug) echo '--- Reset because of altitude'."\n";
913
+				if ($globalDebug) {
914
+					echo '--- Reset because of altitude'."\n";
915
+				}
735 916
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
736 917
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
737
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
738
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
739
-				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']));
918
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) {
919
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
920
+				} elseif (isset($line['id'])) {
921
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
922
+				} elseif (isset($this->all_flights[$id]['ident'])) {
923
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
924
+				}
740 925
 			}
741 926
 		    }
742 927
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
@@ -747,22 +932,32 @@  discard block
 block discarded – undo
747 932
 		}
748 933
 		
749 934
 		if (isset($line['heading']) && $line['heading'] != '') {
750
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
935
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) {
936
+		    	$this->all_flights[$id]['putinarchive'] = true;
937
+		    }
751 938
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
752 939
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
753 940
 		    //$dataFound = true;
754 941
   		} 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']) {
755 942
   		    $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']);
756 943
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
757
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
758
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
944
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) {
945
+		    	$this->all_flights[$id]['putinarchive'] = true;
946
+		    }
947
+  		    if ($globalDebug) {
948
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
949
+  		    }
759 950
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
760 951
   		    // If not enough messages and ACARS set heading to 0
761 952
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
762 953
   		}
763
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
764
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
765
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) $dataFound = false;
954
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
955
+			$dataFound = false;
956
+		} elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
957
+			$dataFound = false;
958
+		} elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalAircraftMinUpdate) {
959
+			$dataFound = false;
960
+		}
766 961
 
767 962
 //		print_r($this->all_flights[$id]);
768 963
 		//gets the callsign from the last hour
@@ -779,23 +974,38 @@  discard block
 block discarded – undo
779 974
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
780 975
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
781 976
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
782
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
977
+				    if ($globalDebug) {
978
+				    	echo "Check if aircraft is already in DB...";
979
+				    }
783 980
 				    $timeelapsed = microtime(true);
784 981
 				    $SpotterLive = new SpotterLive($this->db);
785 982
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'aircraftjson' || $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' || $line['format_source'] === 'famaprs')) {
786 983
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
787
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
984
+					if ($globalDebugTimeElapsed) {
985
+						echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
986
+					}
788 987
 				    } elseif (isset($line['id'])) {
789 988
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
790
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
989
+					if ($globalDebugTimeElapsed) {
990
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
991
+					}
791 992
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
792 993
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
793
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
794
-				    } else $recent_ident = '';
994
+					if ($globalDebugTimeElapsed) {
995
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
996
+					}
997
+				    } else {
998
+				    	$recent_ident = '';
999
+				    }
795 1000
 				    $SpotterLive->db=null;
796
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
797
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
798
-				} else $recent_ident = '';
1001
+				    if ($globalDebug && $recent_ident == '') {
1002
+				    	echo " Not in DB.\n";
1003
+				    } elseif ($globalDebug && $recent_ident != '') {
1004
+				    	echo " Already in DB.\n";
1005
+				    }
1006
+				} else {
1007
+					$recent_ident = '';
1008
+				}
799 1009
 			    } else {
800 1010
 				$recent_ident = '';
801 1011
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -803,7 +1013,9 @@  discard block
 block discarded – undo
803 1013
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
804 1014
 			    if($recent_ident == "")
805 1015
 			    {
806
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
1016
+				if ($globalDebug) {
1017
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
1018
+				}
807 1019
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
808 1020
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
809 1021
 				//adds the spotter data for the archive
@@ -847,10 +1059,18 @@  discard block
 block discarded – undo
847 1059
 				
848 1060
 				if (!$ignoreImport) {
849 1061
 				    $highlight = '';
850
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
851
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
852
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
853
-				    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')));
1062
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
1063
+				    	$highlight = 'Squawk 7500 : Hijack';
1064
+				    }
1065
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
1066
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
1067
+				    }
1068
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
1069
+				    	$highlight = 'Squawk 7700 : Emergency';
1070
+				    }
1071
+				    if (!isset($this->all_flights[$id]['id'])) {
1072
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1073
+				    }
854 1074
 				    $timeelapsed = microtime(true);
855 1075
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
856 1076
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -858,28 +1078,43 @@  discard block
 block discarded – undo
858 1078
 					    $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]['altitude_real'], $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'],$this->all_flights[$id]['source_type']);
859 1079
 					    $Spotter->db = null;
860 1080
 					    if ($globalDebug) {
861
-						if (isset($result['error'])) echo 'Error: '.$result['error']."\n";
862
-						else echo 'Success';
1081
+						if (isset($result['error'])) {
1082
+							echo 'Error: '.$result['error']."\n";
1083
+						} else {
1084
+							echo 'Success';
1085
+						}
863 1086
 					    }
864 1087
 					    if (count($result) > 1) {
865 1088
 					    // ':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,
866
-						if ($this->all_flights[$id]['aircraft_icao'] == '') $this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
867
-						if ($this->all_flights[$id]['registration'] == '') $this->all_flights[$id]['registration'] = $result[':registration'];
1089
+						if ($this->all_flights[$id]['aircraft_icao'] == '') {
1090
+							$this->all_flights[$id]['aircraft_icao'] = $result[':aircraft_icao'];
1091
+						}
1092
+						if ($this->all_flights[$id]['registration'] == '') {
1093
+							$this->all_flights[$id]['registration'] = $result[':registration'];
1094
+						}
868 1095
 					    }
869 1096
 					}
870 1097
 				    }
871
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1098
+				    if ($globalDebugTimeElapsed) {
1099
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1100
+				    }
872 1101
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
873 1102
 
874 1103
 				    // Add source stat in DB
875 1104
 				    $Stats = new Stats($this->db);
876 1105
 				    if (!empty($this->stats)) {
877
-					if ($globalDebug) echo 'Add source stats : ';
1106
+					if ($globalDebug) {
1107
+						echo 'Add source stats : ';
1108
+					}
878 1109
 				        foreach($this->stats as $date => $data) {
879 1110
 					    foreach($data as $source => $sourced) {
880 1111
 					        //print_r($sourced);
881
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
882
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1112
+				    	        if (isset($sourced['polar'])) {
1113
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
1114
+				    	        }
1115
+				    	        if (isset($sourced['hist'])) {
1116
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
1117
+				    	        }
883 1118
 				    		if (isset($sourced['msg'])) {
884 1119
 				    		    if (time() - $sourced['msg']['date'] > 10) {
885 1120
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -892,13 +1127,17 @@  discard block
 block discarded – undo
892 1127
 			    			unset($this->stats[$date]);
893 1128
 			    		    }
894 1129
 				    	}
895
-				    	if ($globalDebug) echo 'Done'."\n";
1130
+				    	if ($globalDebug) {
1131
+				    		echo 'Done'."\n";
1132
+				    	}
896 1133
 
897 1134
 				    }
898 1135
 				    $Stats->db = null;
899 1136
 				    }
900 1137
 				    $this->del();
901
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
1138
+				} elseif ($globalDebug) {
1139
+					echo 'Ignore data'."\n";
1140
+				}
902 1141
 				//$ignoreImport = false;
903 1142
 				$this->all_flights[$id]['addedSpotter'] = 1;
904 1143
 				//print_r($this->all_flights[$id]);
@@ -915,7 +1154,9 @@  discard block
 block discarded – undo
915 1154
 			*/
916 1155
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
917 1156
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
918
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
1157
+				    if ($globalDebug) {
1158
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
1159
+				    }
919 1160
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
920 1161
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
921 1162
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -924,7 +1165,9 @@  discard block
 block discarded – undo
924 1165
 					    $SpotterLive->db=null;
925 1166
 					}
926 1167
 				    }
927
-				    if ($globalDebug) echo " Done\n";
1168
+				    if ($globalDebug) {
1169
+				    	echo " Done\n";
1170
+				    }
928 1171
 				    $this->last_delete = time();
929 1172
 				}
930 1173
 			    } else {
@@ -951,11 +1194,17 @@  discard block
 block discarded – undo
951 1194
 		    //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";
952 1195
 		    if ($globalDebug) {
953 1196
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
954
-				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";
955
-				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";
1197
+				if (isset($this->all_flights[$id]['source_name'])) {
1198
+					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";
1199
+				} else {
1200
+					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";
1201
+				}
956 1202
 			} else {
957
-				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";
958
-				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";
1203
+				if (isset($this->all_flights[$id]['source_name'])) {
1204
+					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";
1205
+				} else {
1206
+					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";
1207
+				}
959 1208
 			}
960 1209
 		    }
961 1210
 		    $ignoreImport = false;
@@ -1001,23 +1250,31 @@  discard block
 block discarded – undo
1001 1250
 
1002 1251
 		    if (!$ignoreImport) {
1003 1252
 			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'])) {
1004
-				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')));
1253
+				if (!isset($this->all_flights[$id]['id'])) {
1254
+					$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
1255
+				}
1005 1256
 				$timeelapsed = microtime(true);
1006 1257
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
1007 1258
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1008
-					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1259
+					if ($globalDebug) {
1260
+						echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
1261
+					}
1009 1262
 					$SpotterLive = new SpotterLive($this->db);
1010 1263
 					//var_dump($this->all_flights[$id]);
1011 1264
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
1012 1265
 					$SpotterLive->db = null;
1013
-					if ($globalDebug) echo $result."\n";
1266
+					if ($globalDebug) {
1267
+						echo $result."\n";
1268
+					}
1014 1269
 				    }
1015 1270
 				}
1016 1271
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
1017 1272
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
1018 1273
 				}
1019 1274
 				$this->all_flights[$id]['putinarchive'] = false;
1020
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1275
+				if ($globalDebugTimeElapsed) {
1276
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
1277
+				}
1021 1278
 
1022 1279
 				// Put statistics in $this->stats variable
1023 1280
 				//if ($line['format_source'] != 'aprs') {
@@ -1025,7 +1282,9 @@  discard block
 block discarded – undo
1025 1282
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
1026 1283
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
1027 1284
 					$source = $this->all_flights[$id]['source_name'];
1028
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
1285
+					if ($source == '') {
1286
+						$source = $this->all_flights[$id]['format_source'];
1287
+					}
1029 1288
 					if (!isset($this->source_location[$source])) {
1030 1289
 						$Location = new Source($this->db);
1031 1290
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -1046,7 +1305,9 @@  discard block
 block discarded – undo
1046 1305
 					$stats_heading = round($stats_heading/22.5);
1047 1306
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
1048 1307
 					$current_date = date('Y-m-d');
1049
-					if ($stats_heading == 16) $stats_heading = 0;
1308
+					if ($stats_heading == 16) {
1309
+						$stats_heading = 0;
1310
+					}
1050 1311
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1051 1312
 						for ($i=0;$i<=15;$i++) {
1052 1313
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -1064,7 +1325,9 @@  discard block
 block discarded – undo
1064 1325
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1065 1326
 						    end($this->stats[$current_date][$source]['hist']);
1066 1327
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1067
-						} else $mini = 0;
1328
+						} else {
1329
+							$mini = 0;
1330
+						}
1068 1331
 						for ($i=$mini;$i<=$distance;$i+=10) {
1069 1332
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1070 1333
 						}
@@ -1076,19 +1339,27 @@  discard block
 block discarded – undo
1076 1339
 				}
1077 1340
 
1078 1341
 				$this->all_flights[$id]['lastupdate'] = time();
1079
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1342
+				if ($this->all_flights[$id]['putinarchive']) {
1343
+					$send = true;
1344
+				}
1080 1345
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1081
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1346
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1347
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1348
+			}
1082 1349
 			//$this->del();
1083 1350
 			
1084 1351
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1085 1352
 			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1086
-				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1353
+				if ($globalDebug) {
1354
+					echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1355
+				}
1087 1356
 				$SpotterLive = new SpotterLive($this->db);
1088 1357
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
1089 1358
 				$SpotterLive->db = null;
1090 1359
 				//SpotterLive->deleteLiveSpotterData();
1091
-				if ($globalDebug) echo " Done\n";
1360
+				if ($globalDebug) {
1361
+					echo " Done\n";
1362
+				}
1092 1363
 				$this->last_delete_hourly = time();
1093 1364
 			    } else {
1094 1365
 				$this->del();
@@ -1100,7 +1371,9 @@  discard block
 block discarded – undo
1100 1371
 		    //$ignoreImport = false;
1101 1372
 		}
1102 1373
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1103
-		if ($send) return $this->all_flights[$id];
1374
+		if ($send) {
1375
+			return $this->all_flights[$id];
1376
+		}
1104 1377
 	    }
1105 1378
 	}
1106 1379
     }
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Braces   +282 added lines, -100 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  discard block
 block discarded – undo
15 15
 	public function __construct($dbc = null) {
16 16
 		$Connection = new Connection($dbc);
17 17
 		$this->db = $Connection->db();
18
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
18
+		if ($this->db === null) {
19
+			die('Error: No DB connection. (Marine)');
20
+		}
19 21
 	}
20 22
 
21 23
     /**
@@ -38,7 +40,9 @@  discard block
 block discarded – undo
38 40
 		if (isset($filter[0]['source'])) {
39 41
 			$filters = array_merge($filters,$filter);
40 42
 		}
41
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
43
+		if (is_array($globalFilter)) {
44
+			$filter = array_merge($filter,$globalFilter);
45
+		}
42 46
 		$filter_query_join = '';
43 47
 		$filter_query_where = '';
44 48
 		foreach($filters as $flt) {
@@ -86,8 +90,11 @@  discard block
 block discarded – undo
86 90
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
87 91
 			}
88 92
 		}
89
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
90
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
93
+		if ($filter_query_where == '' && $where) {
94
+			$filter_query_where = ' WHERE';
95
+		} elseif ($filter_query_where != '' && $and) {
96
+			$filter_query_where .= ' AND';
97
+		}
91 98
 		if ($filter_query_where != '') {
92 99
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
93 100
 		}
@@ -142,42 +149,84 @@  discard block
 block discarded – undo
142 149
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
143 150
 			} elseif (isset($row['spotter_archive_output_id'])) {
144 151
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
145
-			*/} 
146
-			elseif (isset($row['marineid'])) {
152
+			*/} elseif (isset($row['marineid'])) {
147 153
 				$temp_array['marine_id'] = $row['marineid'];
148 154
 			} else {
149 155
 				$temp_array['marine_id'] = '';
150 156
 			}
151
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
152
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
153
-			if (isset($row['type'])) $temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
154
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
155
-			if (isset($row['status'])) $temp_array['status'] = $row['status'];
156
-			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
157
-			if (isset($row['captain_id'])) $temp_array['captain_id'] = $row['captain_id'];
158
-			if (isset($row['captain_name'])) $temp_array['captain_name'] = $row['captain_name'];
159
-			if (isset($row['race_id'])) $temp_array['race_id'] = $row['race_id'];
160
-			if (isset($row['race_name'])) $temp_array['race_name'] = $row['race_name'];
161
-			if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) $temp_array['race_time'] = $row['race_time'];
162
-			if (isset($row['race_rank'])) $temp_array['race_rank'] = $row['race_rank'];
163
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
164
-			if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name'];
165
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
166
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
167
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
168
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
157
+			if (isset($row['fammarine_id'])) {
158
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
159
+			}
160
+			if (isset($row['mmsi'])) {
161
+				$temp_array['mmsi'] = $row['mmsi'];
162
+			}
163
+			if (isset($row['type'])) {
164
+				$temp_array['type'] = html_entity_decode($row['type'],ENT_QUOTES);
165
+			}
166
+			if (isset($row['type_id'])) {
167
+				$temp_array['type_id'] = $row['type_id'];
168
+			}
169
+			if (isset($row['status'])) {
170
+				$temp_array['status'] = $row['status'];
171
+			}
172
+			if (isset($row['status_id'])) {
173
+				$temp_array['status_id'] = $row['status_id'];
174
+			}
175
+			if (isset($row['captain_id'])) {
176
+				$temp_array['captain_id'] = $row['captain_id'];
177
+			}
178
+			if (isset($row['captain_name'])) {
179
+				$temp_array['captain_name'] = $row['captain_name'];
180
+			}
181
+			if (isset($row['race_id'])) {
182
+				$temp_array['race_id'] = $row['race_id'];
183
+			}
184
+			if (isset($row['race_name'])) {
185
+				$temp_array['race_name'] = $row['race_name'];
186
+			}
187
+			if (isset($row['race_time']) && isset($row['status']) && $row['status'] != 'Racing' && $row['race_time'] > 0) {
188
+				$temp_array['race_time'] = $row['race_time'];
189
+			}
190
+			if (isset($row['race_rank'])) {
191
+				$temp_array['race_rank'] = $row['race_rank'];
192
+			}
193
+			if (isset($row['ident'])) {
194
+				$temp_array['ident'] = $row['ident'];
195
+			}
196
+			if (isset($row['arrival_port_name'])) {
197
+				$temp_array['arrival_port_name'] = $row['arrival_port_name'];
198
+			}
199
+			if (isset($row['latitude'])) {
200
+				$temp_array['latitude'] = $row['latitude'];
201
+			}
202
+			if (isset($row['longitude'])) {
203
+				$temp_array['longitude'] = $row['longitude'];
204
+			}
205
+			if (isset($row['distance']) && $row['distance'] != '') {
206
+				$temp_array['distance'] = $row['distance'];
207
+			}
208
+			if (isset($row['format_source'])) {
209
+				$temp_array['format_source'] = $row['format_source'];
210
+			}
169 211
 			if (isset($row['heading'])) {
170 212
 				$temp_array['heading'] = $row['heading'];
171 213
 				$heading_direction = $this->parseDirection($row['heading']);
172
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
214
+				if (isset($heading_direction[0]['direction_fullname'])) {
215
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
216
+				}
217
+			}
218
+			if (isset($row['ground_speed'])) {
219
+				$temp_array['ground_speed'] = $row['ground_speed'];
173 220
 			}
174
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
175 221
 
176 222
 			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
177 223
 			{
178 224
 				$Image = new Image($this->db);
179
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
180
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
225
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
226
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
227
+				} else {
228
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
229
+				}
181 230
 				unset($Image);
182 231
 				if (count($image_array) > 0) {
183 232
 					$temp_array['image'] = $image_array[0]['image'];
@@ -241,13 +290,21 @@  discard block
 block discarded – undo
241 290
 			}
242 291
 			
243 292
 			$fromsource = NULL;
244
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
245
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
246
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
293
+			if (isset($row['source_name']) && $row['source_name'] != '') {
294
+				$temp_array['source_name'] = $row['source_name'];
295
+			}
296
+			if (isset($row['over_country']) && $row['over_country'] != '') {
297
+				$temp_array['over_country'] = $row['over_country'];
298
+			}
299
+			if (isset($row['distance']) && $row['distance'] != '') {
300
+				$temp_array['distance'] = $row['distance'];
301
+			}
247 302
 			$temp_array['query_number_rows'] = $num_rows;
248 303
 			$spotter_array[] = $temp_array;
249 304
 		}
250
-		if ($num_rows == 0) return array();
305
+		if ($num_rows == 0) {
306
+			return array();
307
+		}
251 308
 		$spotter_array[0]['query_number_rows'] = $num_rows;
252 309
 		return $spotter_array;
253 310
 	}
@@ -275,8 +332,12 @@  discard block
 block discarded – undo
275 332
 			{
276 333
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
277 334
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
278
-			} else $limit_query = "";
279
-		} else $limit_query = "";
335
+			} else {
336
+				$limit_query = "";
337
+			}
338
+		} else {
339
+			$limit_query = "";
340
+		}
280 341
 		if ($sort != "")
281 342
 		{
282 343
 			$search_orderby_array = $this->getOrderBy();
@@ -300,7 +361,9 @@  discard block
 block discarded – undo
300 361
 		global $global_marine_query;
301 362
 		
302 363
 		date_default_timezone_set('UTC');
303
-		if ($id == '') return array();
364
+		if ($id == '') {
365
+			return array();
366
+		}
304 367
 		$additional_query = "marine_output.fammarine_id = :id";
305 368
 		$query_values = array(':id' => $id);
306 369
 		$query  = $global_marine_query." WHERE ".$additional_query." ";
@@ -781,8 +844,11 @@  discard block
 block discarded – undo
781 844
 		$sth = $this->db->prepare($query);
782 845
 		$sth->execute($query_values);
783 846
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
784
-		if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
785
-		else return $result[0]['duration'];
847
+		if (is_int($result[0]['duration'])) {
848
+			return gmdate('H:i:s',$result[0]['duration']);
849
+		} else {
850
+			return $result[0]['duration'];
851
+		}
786 852
 	}
787 853
 
788 854
     /**
@@ -830,7 +896,9 @@  discard block
 block discarded – undo
830 896
 			}
831 897
 		}
832 898
 		$query .= " GROUP BY marine_output.captain_id,marine_output.captain_name ORDER BY duration DESC";
833
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
899
+		if ($limit) {
900
+			$query .= " LIMIT 10 OFFSET 0";
901
+		}
834 902
 		$sth = $this->db->prepare($query);
835 903
 		$sth->execute($query_values);
836 904
 		//if (is_int($result[0]['duration'])) return gmdate('H:i:s',$result[0]['duration']);
@@ -909,8 +977,11 @@  discard block
 block discarded – undo
909 977
 		$query .= " ORDER BY marine_output.source_name ASC";
910 978
 
911 979
 		$sth = $this->db->prepare($query);
912
-		if (!empty($query_values)) $sth->execute($query_values);
913
-		else $sth->execute();
980
+		if (!empty($query_values)) {
981
+			$sth->execute($query_values);
982
+		} else {
983
+			$sth->execute();
984
+		}
914 985
 
915 986
 		$source_array = array();
916 987
 		$temp_array = array();
@@ -965,8 +1036,11 @@  discard block
 block discarded – undo
965 1036
 		$sth = $this->db->prepare($query);
966 1037
 		$sth->execute(array(':mmsi' => $mmsi));
967 1038
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
968
-		if (isset($result[0])) return $result[0];
969
-		else return array();
1039
+		if (isset($result[0])) {
1040
+			return $result[0];
1041
+		} else {
1042
+			return array();
1043
+		}
970 1044
 	}
971 1045
 
972 1046
     /**
@@ -1011,7 +1085,9 @@  discard block
 block discarded – undo
1011 1085
 			date_default_timezone_set($globalTimezone);
1012 1086
 			$datetime = new DateTime();
1013 1087
 			$offset = $datetime->format('P');
1014
-		} else $offset = '+00:00';
1088
+		} else {
1089
+			$offset = '+00:00';
1090
+		}
1015 1091
 
1016 1092
 		if ($globalDBdriver == 'mysql') {
1017 1093
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -1127,8 +1203,12 @@  discard block
 block discarded – undo
1127 1203
      */
1128 1204
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '',$distance = NULL,$race_rank = NULL, $race_time = NULL, $status = '', $race_begin = '')
1129 1205
 	{
1130
-		if ($latitude == '') $latitude = NULL;
1131
-		if ($longitude == '') $longitude = NULL;
1206
+		if ($latitude == '') {
1207
+			$latitude = NULL;
1208
+		}
1209
+		if ($longitude == '') {
1210
+			$longitude = NULL;
1211
+		}
1132 1212
 		$groundspeed = round($groundspeed);
1133 1213
 		if ($race_begin != '') {
1134 1214
 			$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed, distance = :distance, race_rank = :race_rank, race_time = :race_time, status = :status, date = :race_begin WHERE fammarine_id = :fammarine_id';
@@ -1286,14 +1366,28 @@  discard block
 block discarded – undo
1286 1366
 			$latitude = 0;
1287 1367
 			$longitude = 0;
1288 1368
 		}
1289
-		if ($type_id == '') $type_id = NULL;
1290
-		if ($status_id == '') $status_id = NULL;
1291
-		if ($distance == '') $distance = NULL;
1292
-		if ($race_rank == '') $race_rank = NULL;
1293
-		if ($race_time == '') $race_time = NULL;
1294
-		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1369
+		if ($type_id == '') {
1370
+			$type_id = NULL;
1371
+		}
1372
+		if ($status_id == '') {
1373
+			$status_id = NULL;
1374
+		}
1375
+		if ($distance == '') {
1376
+			$distance = NULL;
1377
+		}
1378
+		if ($race_rank == '') {
1379
+			$race_rank = NULL;
1380
+		}
1381
+		if ($race_time == '') {
1382
+			$race_time = NULL;
1383
+		}
1384
+		if ($heading == '' || $Common->isInteger($heading) === false) {
1385
+			$heading = 0;
1386
+		}
1295 1387
 		//if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1296
-		if ($arrival_date == '') $arrival_date = NULL;
1388
+		if ($arrival_date == '') {
1389
+			$arrival_date = NULL;
1390
+		}
1297 1391
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date,captain_id,captain_name,race_id,race_name, distance, race_rank,race_time) 
1298 1392
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date,:captain_id,:captain_name,:race_id,:race_name, :distance, :race_rank,:race_time)";
1299 1393
 
@@ -1401,7 +1495,9 @@  discard block
 block discarded – undo
1401 1495
 		global $globalDBdriver, $globalArchive;
1402 1496
 		//$filter_query = $this->getFilter($filters,true,true);
1403 1497
 		$Connection= new Connection($this->db);
1404
-		if (!$Connection->tableExists('countries')) return array();
1498
+		if (!$Connection->tableExists('countries')) {
1499
+			return array();
1500
+		}
1405 1501
 		require_once('class.SpotterLive.php');
1406 1502
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
1407 1503
 			$MarineLive = new MarineLive($this->db);
@@ -1445,7 +1541,9 @@  discard block
 block discarded – undo
1445 1541
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
1446 1542
 		}
1447 1543
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
1448
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1544
+		if ($limit) {
1545
+			$query .= " LIMIT 10 OFFSET 0";
1546
+		}
1449 1547
 
1450 1548
 		$sth = $this->db->prepare($query);
1451 1549
 		$sth->execute();
@@ -1484,12 +1582,18 @@  discard block
 block discarded – undo
1484 1582
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
1485 1583
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
1486 1584
 		 if ($olderthanmonths > 0) {
1487
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1488
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1585
+			if ($globalDBdriver == 'mysql') {
1586
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1587
+			} else {
1588
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1589
+			}
1489 1590
 		}
1490 1591
 		if ($sincedate != '') {
1491
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
1492
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1592
+			if ($globalDBdriver == 'mysql') {
1593
+				$query .= " AND marine_output.date > '".$sincedate."'";
1594
+			} else {
1595
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1596
+			}
1493 1597
 		}
1494 1598
 		$query_values = array();
1495 1599
 		if ($year != '') {
@@ -1520,7 +1624,9 @@  discard block
 block discarded – undo
1520 1624
 			}
1521 1625
 		}
1522 1626
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
1523
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1627
+		if ($limit) {
1628
+			$query .= " LIMIT 10 OFFSET 0";
1629
+		}
1524 1630
       		
1525 1631
 		$sth = $this->db->prepare($query);
1526 1632
 		$sth->execute($query_values);
@@ -1555,7 +1661,9 @@  discard block
 block discarded – undo
1555 1661
 			date_default_timezone_set($globalTimezone);
1556 1662
 			$datetime = new DateTime();
1557 1663
 			$offset = $datetime->format('P');
1558
-		} else $offset = '+00:00';
1664
+		} else {
1665
+			$offset = '+00:00';
1666
+		}
1559 1667
 
1560 1668
 		if ($globalDBdriver == 'mysql') {
1561 1669
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1605,7 +1713,9 @@  discard block
 block discarded – undo
1605 1713
 			date_default_timezone_set($globalTimezone);
1606 1714
 			$datetime = new DateTime();
1607 1715
 			$offset = $datetime->format('P');
1608
-		} else $offset = '+00:00';
1716
+		} else {
1717
+			$offset = '+00:00';
1718
+		}
1609 1719
 		$filter_query = $this->getFilter($filters,true,true);
1610 1720
 		if ($globalDBdriver == 'mysql') {
1611 1721
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1651,7 +1761,9 @@  discard block
 block discarded – undo
1651 1761
 			date_default_timezone_set($globalTimezone);
1652 1762
 			$datetime = new DateTime();
1653 1763
 			$offset = $datetime->format('P');
1654
-		} else $offset = '+00:00';
1764
+		} else {
1765
+			$offset = '+00:00';
1766
+		}
1655 1767
 		$filter_query = $this->getFilter($filters,true,true);
1656 1768
 		if ($globalDBdriver == 'mysql') {
1657 1769
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1699,7 +1811,9 @@  discard block
 block discarded – undo
1699 1811
 			date_default_timezone_set($globalTimezone);
1700 1812
 			$datetime = new DateTime();
1701 1813
 			$offset = $datetime->format('P');
1702
-		} else $offset = '+00:00';
1814
+		} else {
1815
+			$offset = '+00:00';
1816
+		}
1703 1817
 
1704 1818
 		if ($globalDBdriver == 'mysql') {
1705 1819
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1746,7 +1860,9 @@  discard block
 block discarded – undo
1746 1860
 			date_default_timezone_set($globalTimezone);
1747 1861
 			$datetime = new DateTime();
1748 1862
 			$offset = $datetime->format('P');
1749
-		} else $offset = '+00:00';
1863
+		} else {
1864
+			$offset = '+00:00';
1865
+		}
1750 1866
 		$filter_query = $this->getFilter($filters,true,true);
1751 1867
 		if ($globalDBdriver == 'mysql') {
1752 1868
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1795,7 +1911,9 @@  discard block
 block discarded – undo
1795 1911
 			date_default_timezone_set($globalTimezone);
1796 1912
 			$datetime = new DateTime();
1797 1913
 			$offset = $datetime->format('P');
1798
-		} else $offset = '+00:00';
1914
+		} else {
1915
+			$offset = '+00:00';
1916
+		}
1799 1917
 
1800 1918
 		$orderby_sql = '';
1801 1919
 		if ($orderby == "hour")
@@ -1864,7 +1982,9 @@  discard block
 block discarded – undo
1864 1982
 			date_default_timezone_set($globalTimezone);
1865 1983
 			$datetime = new DateTime($date);
1866 1984
 			$offset = $datetime->format('P');
1867
-		} else $offset = '+00:00';
1985
+		} else {
1986
+			$offset = '+00:00';
1987
+		}
1868 1988
 
1869 1989
 		if ($globalDBdriver == 'mysql') {
1870 1990
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1912,7 +2032,9 @@  discard block
 block discarded – undo
1912 2032
 			date_default_timezone_set($globalTimezone);
1913 2033
 			$datetime = new DateTime();
1914 2034
 			$offset = $datetime->format('P');
1915
-		} else $offset = '+00:00';
2035
+		} else {
2036
+			$offset = '+00:00';
2037
+		}
1916 2038
 
1917 2039
 		if ($globalDBdriver == 'mysql') {
1918 2040
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1974,7 +2096,9 @@  discard block
 block discarded – undo
1974 2096
 			}
1975 2097
 		}
1976 2098
 		$query .= " GROUP BY marine_output.race_id,marine_output.race_name ORDER BY captain_count DESC";
1977
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2099
+		if ($limit) {
2100
+			$query .= " LIMIT 10 OFFSET 0";
2101
+		}
1978 2102
 		$sth = $this->db->prepare($query);
1979 2103
 		$sth->execute();
1980 2104
 		$marine_array = array();
@@ -2023,8 +2147,11 @@  discard block
 block discarded – undo
2023 2147
 				$query_values = array_merge($query_values,array(':month' => $month));
2024 2148
 			}
2025 2149
 		}
2026
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2027
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2150
+		if (empty($query_values)) {
2151
+			$queryi .= $this->getFilter($filters);
2152
+		} else {
2153
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2154
+		}
2028 2155
 		
2029 2156
 		$sth = $this->db->prepare($queryi);
2030 2157
 		$sth->execute($query_values);
@@ -2063,8 +2190,11 @@  discard block
 block discarded – undo
2063 2190
 				$query_values = array_merge($query_values,array(':month' => $month));
2064 2191
 			}
2065 2192
 		}
2066
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2067
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2193
+		if (empty($query_values)) {
2194
+			$queryi .= $this->getFilter($filters);
2195
+		} else {
2196
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2197
+		}
2068 2198
 		
2069 2199
 		$sth = $this->db->prepare($queryi);
2070 2200
 		$sth->execute($query_values);
@@ -2103,8 +2233,11 @@  discard block
 block discarded – undo
2103 2233
 				$query_values = array_merge($query_values,array(':month' => $month));
2104 2234
 			}
2105 2235
 		}
2106
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2107
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2236
+		if (empty($query_values)) {
2237
+			$queryi .= $this->getFilter($filters);
2238
+		} else {
2239
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2240
+		}
2108 2241
 		
2109 2242
 		$sth = $this->db->prepare($queryi);
2110 2243
 		$sth->execute($query_values);
@@ -2143,8 +2276,11 @@  discard block
 block discarded – undo
2143 2276
 				$query_values = array_merge($query_values,array(':month' => $month));
2144 2277
 			}
2145 2278
 		}
2146
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
2147
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
2279
+		if (empty($query_values)) {
2280
+			$queryi .= $this->getFilter($filters);
2281
+		} else {
2282
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
2283
+		}
2148 2284
 		
2149 2285
 		$sth = $this->db->prepare($queryi);
2150 2286
 		$sth->execute($query_values);
@@ -2165,7 +2301,9 @@  discard block
 block discarded – undo
2165 2301
 			date_default_timezone_set($globalTimezone);
2166 2302
 			$datetime = new DateTime();
2167 2303
 			$offset = $datetime->format('P');
2168
-		} else $offset = '+00:00';
2304
+		} else {
2305
+			$offset = '+00:00';
2306
+		}
2169 2307
 
2170 2308
 		if ($globalDBdriver == 'mysql') {
2171 2309
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -2269,7 +2407,9 @@  discard block
 block discarded – undo
2269 2407
 	*/
2270 2408
 	public function parseDirection($direction = 0)
2271 2409
 	{
2272
-		if ($direction == '') $direction = 0;
2410
+		if ($direction == '') {
2411
+			$direction = 0;
2412
+		}
2273 2413
 		$direction_array = array();
2274 2414
 		$temp_array = array();
2275 2415
 
@@ -2358,7 +2498,9 @@  discard block
 block discarded – undo
2358 2498
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
2359 2499
 	
2360 2500
 		$Connection = new Connection($this->db);
2361
-		if (!$Connection->tableExists('countries')) return '';
2501
+		if (!$Connection->tableExists('countries')) {
2502
+			return '';
2503
+		}
2362 2504
 	
2363 2505
 		try {
2364 2506
 			/*
@@ -2378,9 +2520,13 @@  discard block
 block discarded – undo
2378 2520
 			$sth->closeCursor();
2379 2521
 			if (count($row) > 0) {
2380 2522
 				return $row;
2381
-			} else return '';
2523
+			} else {
2524
+				return '';
2525
+			}
2382 2526
 		} catch (PDOException $e) {
2383
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2527
+			if (isset($globalDebug) && $globalDebug) {
2528
+				echo 'Error : '.$e->getMessage()."\n";
2529
+			}
2384 2530
 			return '';
2385 2531
 		}
2386 2532
 	
@@ -2398,7 +2544,9 @@  discard block
 block discarded – undo
2398 2544
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
2399 2545
 	
2400 2546
 		$Connection = new Connection($this->db);
2401
-		if (!$Connection->tableExists('countries')) return '';
2547
+		if (!$Connection->tableExists('countries')) {
2548
+			return '';
2549
+		}
2402 2550
 	
2403 2551
 		try {
2404 2552
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -2410,9 +2558,13 @@  discard block
 block discarded – undo
2410 2558
 			$sth->closeCursor();
2411 2559
 			if (count($row) > 0) {
2412 2560
 				return $row;
2413
-			} else return '';
2561
+			} else {
2562
+				return '';
2563
+			}
2414 2564
 		} catch (PDOException $e) {
2415
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
2565
+			if (isset($globalDebug) && $globalDebug) {
2566
+				echo 'Error : '.$e->getMessage()."\n";
2567
+			}
2416 2568
 			return '';
2417 2569
 		}
2418 2570
 	
@@ -2430,7 +2582,9 @@  discard block
 block discarded – undo
2430 2582
 	{
2431 2583
 		global $globalBitlyAccessToken;
2432 2584
 		
2433
-		if ($globalBitlyAccessToken == '') return $url;
2585
+		if ($globalBitlyAccessToken == '') {
2586
+			return $url;
2587
+		}
2434 2588
         
2435 2589
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
2436 2590
 		
@@ -2512,7 +2666,9 @@  discard block
 block discarded – undo
2512 2666
 			}
2513 2667
 		}
2514 2668
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
2515
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2669
+		if ($limit) {
2670
+			$query .= " LIMIT 10 OFFSET 0";
2671
+		}
2516 2672
 		$sth = $this->db->prepare($query);
2517 2673
 		$sth->execute($query_values);
2518 2674
 		$marine_array = array();
@@ -2565,13 +2721,27 @@  discard block
 block discarded – undo
2565 2721
 				foreach ($q_array as $q_item){
2566 2722
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
2567 2723
 					$additional_query .= " AND (";
2568
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2569
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2570
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2571
-					if (is_int($q_item)) $additional_query .= "(marine_output.captain_id = '".$q_item."') OR ";
2572
-					if (is_int($q_item)) $additional_query .= "(marine_output.race_id = '".$q_item."') OR ";
2573
-					if (!is_int($q_item)) $additional_query .= "(marine_output.captain_name = '".$q_item."') OR ";
2574
-					if (!is_int($q_item)) $additional_query .= "(marine_output.race_name = '".$q_item."') OR ";
2724
+					if (is_int($q_item)) {
2725
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2726
+					}
2727
+					if (is_int($q_item)) {
2728
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2729
+					}
2730
+					if (is_int($q_item)) {
2731
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2732
+					}
2733
+					if (is_int($q_item)) {
2734
+						$additional_query .= "(marine_output.captain_id = '".$q_item."') OR ";
2735
+					}
2736
+					if (is_int($q_item)) {
2737
+						$additional_query .= "(marine_output.race_id = '".$q_item."') OR ";
2738
+					}
2739
+					if (!is_int($q_item)) {
2740
+						$additional_query .= "(marine_output.captain_name = '".$q_item."') OR ";
2741
+					}
2742
+					if (!is_int($q_item)) {
2743
+						$additional_query .= "(marine_output.race_name = '".$q_item."') OR ";
2744
+					}
2575 2745
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
2576 2746
 					$additional_query .= ")";
2577 2747
 				}
@@ -2663,7 +2833,9 @@  discard block
 block discarded – undo
2663 2833
 				date_default_timezone_set($globalTimezone);
2664 2834
 				$datetime = new DateTime();
2665 2835
 				$offset = $datetime->format('P');
2666
-			} else $offset = '+00:00';
2836
+			} else {
2837
+				$offset = '+00:00';
2838
+			}
2667 2839
 			if ($date_array[1] != "")
2668 2840
 			{
2669 2841
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -2690,8 +2862,12 @@  discard block
 block discarded – undo
2690 2862
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2691 2863
 			{
2692 2864
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
2693
-			} else $limit_query = "";
2694
-		} else $limit_query = "";
2865
+			} else {
2866
+				$limit_query = "";
2867
+			}
2868
+		} else {
2869
+			$limit_query = "";
2870
+		}
2695 2871
 		if ($sort != "")
2696 2872
 		{
2697 2873
 			$search_orderby_array = $this->getOrderBy();
@@ -2757,8 +2933,11 @@  discard block
 block discarded – undo
2757 2933
 		$sth = $this->db->prepare($query);
2758 2934
 		$sth->execute(array(':race_name' => $race_name));
2759 2935
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2760
-		if (isset($result[0])) return $result[0];
2761
-		else return array();
2936
+		if (isset($result[0])) {
2937
+			return $result[0];
2938
+		} else {
2939
+			return array();
2940
+		}
2762 2941
 	}
2763 2942
 
2764 2943
     /**
@@ -2774,8 +2953,11 @@  discard block
 block discarded – undo
2774 2953
 		$sth = $this->db->prepare($query);
2775 2954
 		$sth->execute(array(':race_id' => $race_id));
2776 2955
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
2777
-		if (isset($result[0])) return $result[0];
2778
-		else return array();
2956
+		if (isset($result[0])) {
2957
+			return $result[0];
2958
+		} else {
2959
+			return array();
2960
+		}
2779 2961
 	}
2780 2962
 
2781 2963
     /**
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Braces   +223 added lines, -82 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 	public function __construct($dbc = null) {
20 20
 		$Connection = new Connection($dbc);
21 21
 		$this->db = $Connection->db();
22
-		if ($this->db === null) die('Error: No DB connection. (Image)');
22
+		if ($this->db === null) {
23
+			die('Error: No DB connection. (Image)');
24
+		}
23 25
 	}
24 26
 
25 27
     /**
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
37 39
 		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
38 40
 		$reg = $registration;
39
-		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
41
+		if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') {
42
+			$reg = $aircraft_icao.$airline_icao;
43
+		}
40 44
 		$reg = trim($reg);
41 45
 		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
42 46
 			FROM spotter_image 
@@ -44,9 +48,13 @@  discard block
 block discarded – undo
44 48
 		$sth = $this->db->prepare($query);
45 49
 		$sth->execute(array(':registration' => $reg));
46 50
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
47
-		if (!empty($result)) return $result;
48
-		elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
49
-		else return array();
51
+		if (!empty($result)) {
52
+			return $result;
53
+		} elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) {
54
+			return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
55
+		} else {
56
+			return array();
57
+		}
50 58
 	}
51 59
 
52 60
     /**
@@ -74,7 +82,9 @@  discard block
 block discarded – undo
74 82
 			}
75 83
 		}
76 84
 		$name = trim($name);
77
-		if ($mmsi == '' && $imo == '' && $name == '') return array();
85
+		if ($mmsi == '' && $imo == '' && $name == '') {
86
+			return array();
87
+		}
78 88
 		$query  = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
79 89
 			FROM marine_image 
80 90
 			WHERE marine_image.mmsi = :mmsi";
@@ -103,8 +113,11 @@  discard block
 block discarded – undo
103 113
 	public function getExifCopyright($url) {
104 114
 		$exif = exif_read_data($url);
105 115
 		$copyright = '';
106
-		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
107
-		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
116
+		if (isset($exif['COMPUTED']['copyright'])) {
117
+			$copyright = $exif['COMPUTED']['copyright'];
118
+		} elseif (isset($exif['copyright'])) {
119
+			$copyright = $exif['copyright'];
120
+		}
108 121
 		if ($copyright != '') {
109 122
 			$copyright = str_replace('Copyright ','',$copyright);
110 123
 			$copyright = str_replace('© ','',$copyright);
@@ -124,17 +137,27 @@  discard block
 block discarded – undo
124 137
 	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
125 138
 	{
126 139
 		global $globalDebug,$globalAircraftImageFetch, $globalOffline;
127
-		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
140
+		if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) {
141
+			return '';
142
+		}
128 143
 		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
129 144
 		$registration = trim($registration);
130 145
 		//getting the aircraft image
131
-		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
132
-		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
133
-		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
146
+		if ($globalDebug && $registration != '') {
147
+			echo 'Try to find an aircraft image for '.$registration.'...';
148
+		} elseif ($globalDebug && $aircraft_icao != '') {
149
+			echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
150
+		} elseif ($globalDebug && $airline_icao != '') {
151
+			echo 'Try to find an aircraft image for '.$airline_icao.'...';
152
+		}
134 153
 		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
135
-		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
154
+		if ($registration == '' && $aircraft_icao != '') {
155
+			$registration = $aircraft_icao.$airline_icao;
156
+		}
136 157
 		if ($image_url['original'] != '') {
137
-			if ($globalDebug) echo 'Found !'."\n";
158
+			if ($globalDebug) {
159
+				echo 'Found !'."\n";
160
+			}
138 161
 			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
139 162
 			try {
140 163
 				$sth = $this->db->prepare($query);
@@ -143,7 +166,9 @@  discard block
 block discarded – undo
143 166
 				echo $e->getMessage()."\n";
144 167
 				return "error";
145 168
 			}
146
-		} elseif ($globalDebug) echo "Not found :'(\n";
169
+		} elseif ($globalDebug) {
170
+			echo "Not found :'(\n";
171
+		}
147 172
 		return "success";
148 173
 	}
149 174
 
@@ -158,7 +183,9 @@  discard block
 block discarded – undo
158 183
 	public function addMarineImage($mmsi,$imo = '',$name = '')
159 184
 	{
160 185
 		global $globalDebug,$globalMarineImageFetch, $globalOffline;
161
-		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return '';
186
+		if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) {
187
+			return '';
188
+		}
162 189
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
163 190
 		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
164 191
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
@@ -168,16 +195,22 @@  discard block
 block discarded – undo
168 195
 			$identity = $Marine->getIdentity($mmsi);
169 196
 			if (isset($identity[0]['mmsi'])) {
170 197
 				$imo = $identity[0]['imo'];
171
-				if ($identity[0]['ship_name'] != '') $name = $identity[0]['ship_name'];
198
+				if ($identity[0]['ship_name'] != '') {
199
+					$name = $identity[0]['ship_name'];
200
+				}
172 201
 			}
173 202
 		}
174 203
 		unset($Marine);
175 204
 
176 205
 		//getting the aircraft image
177
-		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
206
+		if ($globalDebug && $name != '') {
207
+			echo 'Try to find an vessel image for '.$name.'...';
208
+		}
178 209
 		$image_url = $this->findMarineImage($mmsi,$imo,$name);
179 210
 		if ($image_url['original'] != '') {
180
-			if ($globalDebug) echo 'Found !'."\n";
211
+			if ($globalDebug) {
212
+				echo 'Found !'."\n";
213
+			}
181 214
 			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
182 215
 			try {
183 216
 				$sth = $this->db->prepare($query);
@@ -186,7 +219,9 @@  discard block
 block discarded – undo
186 219
 				echo $e->getMessage()."\n";
187 220
 				return "error";
188 221
 			}
189
-		} elseif ($globalDebug) echo "Not found :'(\n";
222
+		} elseif ($globalDebug) {
223
+			echo "Not found :'(\n";
224
+		}
190 225
 		return "success";
191 226
 	}
192 227
 
@@ -202,41 +237,85 @@  discard block
 block discarded – undo
202 237
 	{
203 238
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA;
204 239
 		$Spotter = new Spotter($this->db);
205
-		if (!isset($globalIVAO)) $globalIVAO = FALSE;
240
+		if (!isset($globalIVAO)) {
241
+			$globalIVAO = FALSE;
242
+		}
206 243
 		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
207 244
 		if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) {
208
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
245
+			if (strpos($aircraft_registration,'/') !== false) {
246
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
247
+			}
209 248
 			$aircraft_registration = urlencode(trim($aircraft_registration));
210 249
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
211
-			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
212
-			else $aircraft_name = '';
213
-			if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao'];
214
-			else $aircraft_icao = '';
215
-			if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao'];
216
-			else $airline_icao = '';
250
+			if (isset($aircraft_info[0]['aircraft_name'])) {
251
+				$aircraft_name = $aircraft_info[0]['aircraft_name'];
252
+			} else {
253
+				$aircraft_name = '';
254
+			}
255
+			if (isset($aircraft_info[0]['aircraft_icao'])) {
256
+				$aircraft_name = $aircraft_info[0]['aircraft_icao'];
257
+			} else {
258
+				$aircraft_icao = '';
259
+			}
260
+			if (isset($aircraft_info[0]['airline_icao'])) {
261
+				$airline_icao = $aircraft_info[0]['airline_icao'];
262
+			} else {
263
+				$airline_icao = '';
264
+			}
217 265
 		} elseif ($aircraft_icao != '') {
218 266
 			$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_icao);
219
-			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
220
-			else $aircraft_name = '';
267
+			if (isset($aircraft_info[0]['type'])) {
268
+				$aircraft_name = $aircraft_info[0]['type'];
269
+			} else {
270
+				$aircraft_name = '';
271
+			}
221 272
 			$aircraft_registration = $aircraft_icao;
222
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
273
+		} else {
274
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
275
+		}
223 276
 		unset($Spotter);
224
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
277
+		if (!isset($globalAircraftImageSources)) {
278
+			$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
279
+		}
225 280
 		foreach ($globalAircraftImageSources as $source) {
226 281
 			$source = strtolower($source);
227
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
228
-			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
229
-			if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
230
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
231
-			if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
232
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
233
-			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
234
-			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
235
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
236
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
237
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
238
-		}
239
-		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
282
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') {
283
+				$images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
284
+			}
285
+			if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) {
286
+				$images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
287
+			}
288
+			if ($source == 'flickr' && extension_loaded('simplexml')) {
289
+				$images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
290
+			}
291
+			if ($source == 'bing') {
292
+				$images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
293
+			}
294
+			if ($source == 'deviantart' && extension_loaded('simplexml')) {
295
+				$images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
296
+			}
297
+			if ($source == 'wikimedia') {
298
+				$images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
299
+			}
300
+			if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) {
301
+				$images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
302
+			}
303
+			if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) {
304
+				$images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
305
+			}
306
+			if ($source == 'airportdata' && !$globalIVAO) {
307
+				$images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
308
+			}
309
+			if ($source == 'customsources') {
310
+				$images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
311
+			}
312
+			if (isset($images_array) && $images_array['original'] != '') {
313
+				return $images_array;
314
+			}
315
+		}
316
+		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) {
317
+			return $this->findAircraftImage($aircraft_icao);
318
+		}
240 319
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
241 320
 	}
242 321
 
@@ -256,7 +335,9 @@  discard block
 block discarded – undo
256 335
 		//$imo = filter_var($imo,FILTER_SANITIZE_STRING);
257 336
 		$name = filter_var($name,FILTER_SANITIZE_STRING);
258 337
 		$name = trim($name);
259
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
338
+		if (strlen($name) < 4) {
339
+			return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
340
+		}
260 341
 		/*
261 342
 		$Marine = new Marine($this->db);
262 343
 		if ($imo == '' || $name == '') {
@@ -268,15 +349,29 @@  discard block
 block discarded – undo
268 349
 		}
269 350
 		unset($Marine);
270 351
 		*/
271
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
352
+		if (!isset($globalMarineImageSources)) {
353
+			$globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
354
+		}
272 355
 		foreach ($globalMarineImageSources as $source) {
273 356
 			$source = strtolower($source);
274
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
275
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
276
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
277
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
278
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
279
-			if (isset($images_array) && $images_array['original'] != '') return $images_array;
357
+			if ($source == 'flickr') {
358
+				$images_array = $this->fromFlickr('marine',$mmsi,$name);
359
+			}
360
+			if ($source == 'bing') {
361
+				$images_array = $this->fromBing('marine',$mmsi,$name);
362
+			}
363
+			if ($source == 'deviantart') {
364
+				$images_array = $this->fromDeviantart('marine',$mmsi,$name);
365
+			}
366
+			if ($source == 'wikimedia') {
367
+				$images_array = $this->fromWikimedia('marine',$mmsi,$name);
368
+			}
369
+			if ($source == 'customsources') {
370
+				$images_array = $this->fromCustomSource('marine',$mmsi,$name);
371
+			}
372
+			if (isset($images_array) && $images_array['original'] != '') {
373
+				return $images_array;
374
+			}
280 375
 		}
281 376
 		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
282 377
 	}
@@ -299,7 +394,9 @@  discard block
 block discarded – undo
299 394
 			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
300 395
 		}
301 396
 		$data = $Common->getData($url);
302
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
397
+		if (substr($data, 0, 5) != "<?xml") {
398
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
399
+		}
303 400
 		if ($xml = simplexml_load_string($data)) {
304 401
 			if (isset($xml->channel->item)) {
305 402
 				$image_url = array();
@@ -338,7 +435,9 @@  discard block
 block discarded – undo
338 435
 			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
339 436
 		}
340 437
 		$data = $Common->getData($url);
341
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
438
+		if (substr($data, 0, 5) != "<?xml") {
439
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
440
+		}
342 441
 		if ($xml = simplexml_load_string($data)) {
343 442
 			if (isset($xml->channel->item->link)) {
344 443
 				$image_url = array();
@@ -442,14 +541,22 @@  discard block
 block discarded – undo
442 541
 	public function fromFlickr($type,$registration,$name='') {
443 542
 		$Common = new Common();
444 543
 		if ($type == 'aircraft') {
445
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
446
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
544
+			if ($name != '') {
545
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
546
+			} else {
547
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',aircraft';
548
+			}
447 549
 		} elseif ($type == 'marine') {
448
-			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
449
-			else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
550
+			if ($name != '') {
551
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags=ship,'.urlencode($name);
552
+			} else {
553
+				$url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.',ship';
554
+			}
450 555
 		}
451 556
 		$data = $Common->getData($url);
452
-		if (substr($data, 0, 5) != "<?xml") return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
557
+		if (substr($data, 0, 5) != "<?xml") {
558
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
559
+		}
453 560
 		if ($xml = simplexml_load_string($data)) {
454 561
 			if (isset($xml->channel->item)) {
455 562
 				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
@@ -498,13 +605,21 @@  discard block
 block discarded – undo
498 605
 	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
499 606
 		global $globalImageBingKey;
500 607
 		$Common = new Common();
501
-		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
608
+		if (!isset($globalImageBingKey) || $globalImageBingKey == '') {
609
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
610
+		}
502 611
 		if ($type == 'aircraft') {
503
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
504
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
612
+			if ($aircraft_name != '') {
613
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
614
+			} else {
615
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
616
+			}
505 617
 		} elseif ($type == 'marine') {
506
-			if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
507
-			else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
618
+			if ($aircraft_name != '') {
619
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27';
620
+			} else {
621
+				$url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27';
622
+			}
508 623
 		}
509 624
 		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
510 625
 		$data = $Common->getData($url,'get','',$headers);
@@ -560,17 +675,25 @@  discard block
 block discarded – undo
560 675
 	public function fromWikimedia($type,$registration,$name='') {
561 676
 		$Common = new Common();
562 677
 		if ($type == 'aircraft') {
563
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
564
-			else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
678
+			if ($name != '') {
679
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
680
+			} else {
681
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20aircraft';
682
+			}
565 683
 		} elseif ($type == 'marine') {
566
-			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
567
-			else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
684
+			if ($name != '') {
685
+				$url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.urlencode($name).'%20ship"';
686
+			} else {
687
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
688
+			}
568 689
 		}
569 690
 		$data = $Common->getData($url);
570 691
 		$result = json_decode($data);
571 692
 		if (isset($result->query->search[0]->title)) {
572 693
 			$fileo = $result->query->search[0]->title;
573
-			if (substr($fileo,-3) == 'pdf') return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
694
+			if (substr($fileo,-3) == 'pdf') {
695
+				return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
696
+			}
574 697
 			$file = urlencode($fileo);
575 698
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
576 699
 			$data2 = $Common->getData($url2);
@@ -641,18 +764,27 @@  discard block
 block discarded – undo
641 764
 					$image_url = array();
642 765
 					$image_url['thumbnail'] = $url_thumbnail;
643 766
 					$image_url['original'] = $url;
644
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
645
-					else $exifCopyright = '';
646
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
647
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
648
-					else $image_url['copyright'] = $source['source_website'];
767
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
768
+						$exifCopyright = $this->getExifCopyright($url);
769
+					} else {
770
+						$exifCopyright = '';
771
+					}
772
+					if ($exifCopyright  != '') {
773
+						$image_url['copyright'] = $exifCopyright;
774
+					} elseif (isset($source['copyright'])) {
775
+						$image_url['copyright'] = $source['copyright'];
776
+					} else {
777
+						$image_url['copyright'] = $source['source_website'];
778
+					}
649 779
 					$image_url['source_website'] = $source['source_website'];
650 780
 					$image_url['source'] = $source['source'];
651 781
 					return $image_url;
652 782
 				}
653 783
 			}
654 784
 			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
655
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
785
+		} else {
786
+			return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
787
+		}
656 788
 
657 789
 		if (!empty($globalMarineImageCustomSources) && $type == 'marine') {
658 790
 			$customsources = array();
@@ -678,18 +810,27 @@  discard block
 block discarded – undo
678 810
 					$image_url = array();
679 811
 					$image_url['thumbnail'] = $url_thumbnail;
680 812
 					$image_url['original'] = $url;
681
-					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
682
-					else $exifCopyright = '';
683
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
684
-					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
685
-					else $image_url['copyright'] = $source['source_website'];
813
+					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) {
814
+						$exifCopyright = $this->getExifCopyright($url);
815
+					} else {
816
+						$exifCopyright = '';
817
+					}
818
+					if ($exifCopyright  != '') {
819
+						$image_url['copyright'] = $exifCopyright;
820
+					} elseif (isset($source['copyright'])) {
821
+						$image_url['copyright'] = $source['copyright'];
822
+					} else {
823
+						$image_url['copyright'] = $source['source_website'];
824
+					}
686 825
 					$image_url['source_website'] = $source['source_website'];
687 826
 					$image_url['source'] = $source['source'];
688 827
 					return $image_url;
689 828
 				}
690 829
 			}
691 830
 			return false;
692
-		} else return false;
831
+		} else {
832
+			return false;
833
+		}
693 834
 	}
694 835
 }
695 836
 
Please login to merge, or discard this patch.
require/class.Satellite.php 1 patch
Braces   +63 added lines, -23 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 	public function __construct($dbc = null) {
21 21
 		$Connection = new Connection($dbc);
22 22
 		$this->db = $Connection->db();
23
-		if ($this->db === null) die('Error: No DB connection.');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection.');
25
+		}
24 26
 	}
25 27
 
26 28
 	public function get_tle($name) {
@@ -32,8 +34,11 @@  discard block
 block discarded – undo
32 34
 			echo $e->getMessage();
33 35
 		}
34 36
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
35
-		if (isset($result[0])) return $result[0];
36
-		else return array();
37
+		if (isset($result[0])) {
38
+			return $result[0];
39
+		} else {
40
+			return array();
41
+		}
37 42
 	}
38 43
 	public function get_tle_types() {
39 44
 		$query = 'SELECT DISTINCT tle_type FROM tle ORDER BY tle_type';
@@ -44,8 +49,11 @@  discard block
 block discarded – undo
44 49
 			echo $e->getMessage();
45 50
 		}
46 51
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
47
-		if (isset($result[0])) return $result;
48
-		else return array();
52
+		if (isset($result[0])) {
53
+			return $result;
54
+		} else {
55
+			return array();
56
+		}
49 57
 	}
50 58
 	public function get_tle_names() {
51 59
 		$query = 'SELECT DISTINCT tle_name, tle_type FROM tle';
@@ -56,8 +64,11 @@  discard block
 block discarded – undo
56 64
 			echo $e->getMessage();
57 65
 		}
58 66
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
59
-		if (isset($result[0])) return $result;
60
-		else return array();
67
+		if (isset($result[0])) {
68
+			return $result;
69
+		} else {
70
+			return array();
71
+		}
61 72
 	}
62 73
 	public function get_tle_names_type($type) {
63 74
 		$query = 'SELECT tle_name, tle_type FROM tle WHERE tle_type = :type ORDER BY tle_name';
@@ -68,8 +79,11 @@  discard block
 block discarded – undo
68 79
 			echo $e->getMessage();
69 80
 		}
70 81
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
71
-		if (isset($result[0])) return $result;
72
-		else return array();
82
+		if (isset($result[0])) {
83
+			return $result;
84
+		} else {
85
+			return array();
86
+		}
73 87
 	}
74 88
 	
75 89
 	public function position_all($timestamp_begin = '',$timestamp_end = '',$second = 10) {
@@ -87,8 +101,11 @@  discard block
 block discarded – undo
87 101
 		$result = array();
88 102
 		foreach ($all_sat as $sat) {
89 103
 			$position = $this->position($sat['tle_name'],$timestamp_begin,$timestamp_end,$second);
90
-			if (isset($position[0])) $result = array_merge($position,$result);
91
-			else $result[] = $position;
104
+			if (isset($position[0])) {
105
+				$result = array_merge($position,$result);
106
+			} else {
107
+				$result[] = $position;
108
+			}
92 109
 		}
93 110
 		return $result;
94 111
 	}
@@ -104,7 +121,9 @@  discard block
 block discarded – undo
104 121
 		$sat = new Predict_Sat($tle);
105 122
 		$predict = new Predict();
106 123
 		//if ($timestamp == '') $now = Predict_Time::get_current_daynum();
107
-		if ($timestamp_begin == '') $timestamp_begin = time();
124
+		if ($timestamp_begin == '') {
125
+			$timestamp_begin = time();
126
+		}
108 127
 		if ($timestamp_end == '') {
109 128
 			$now = Predict_Time::unix2daynum($timestamp_begin);
110 129
 			$predict->predict_calc($sat,$qth,$now);
@@ -129,8 +148,11 @@  discard block
 block discarded – undo
129 148
 			echo $e->getMessage();
130 149
 		}
131 150
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
132
-		if (isset($result[0])) return $result[0];
133
-		else return array();
151
+		if (isset($result[0])) {
152
+			return $result[0];
153
+		} else {
154
+			return array();
155
+		}
134 156
 	}
135 157
 
136 158
     /**
@@ -148,7 +170,9 @@  discard block
 block discarded – undo
148 170
 		    FROM satellite".$filter_query." satellite.launch_site <> '' AND satellite.launch_site IS NOT NULL";
149 171
 		$query_values = array();
150 172
 		$query .= " GROUP BY satellite.launch_site ORDER BY launch_site_count DESC";
151
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
173
+		if ($limit) {
174
+			$query .= " LIMIT 10 OFFSET 0";
175
+		}
152 176
 		$sth = $this->db->prepare($query);
153 177
 		$sth->execute($query_values);
154 178
 		$launch_site_array = array();
@@ -176,7 +200,9 @@  discard block
 block discarded – undo
176 200
 		    FROM satellite".$filter_query." satellite.owner <> '' AND satellite.owner IS NOT NULL";
177 201
 		$query_values = array();
178 202
 		$query .= " GROUP BY satellite.owner ORDER BY owner_count DESC";
179
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
203
+		if ($limit) {
204
+			$query .= " LIMIT 10 OFFSET 0";
205
+		}
180 206
 		$sth = $this->db->prepare($query);
181 207
 		$sth->execute($query_values);
182 208
 		$owner_array = array();
@@ -206,7 +232,9 @@  discard block
 block discarded – undo
206 232
 		    FROM satellite".$filter_query." satellite.country_owner <> '' AND satellite.country_owner IS NOT NULL";
207 233
 		$query_values = array();
208 234
 		$query .= " GROUP BY satellite.country_owner ORDER BY country_count DESC";
209
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
235
+		if ($limit) {
236
+			$query .= " LIMIT 10 OFFSET 0";
237
+		}
210 238
 		$sth = $this->db->prepare($query);
211 239
 		$sth->execute($query_values);
212 240
 		$owner_array = array();
@@ -234,20 +262,26 @@  discard block
 block discarded – undo
234 262
 			date_default_timezone_set($globalTimezone);
235 263
 			$datetime = new DateTime();
236 264
 			$offset = $datetime->format('P');
237
-		} else $offset = '+00:00';
265
+		} else {
266
+			$offset = '+00:00';
267
+		}
238 268
 		//$filter_query = $this->getFilter($filters,true,true);
239 269
 		$filter_query = ' WHERE';
240 270
 		if ($globalDBdriver == 'mysql') {
241 271
 			$query  = "SELECT MONTH(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count
242 272
 				FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
243
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
273
+			if ($sincedate != '') {
274
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
275
+			}
244 276
 			$query .= " GROUP BY year_name, month_name
245 277
 				ORDER BY year_name, month_name ASC";
246 278
 			$query_data = array(':offset' => $offset);
247 279
 		} else {
248 280
 			$query  = "SELECT EXTRACT(MONTH FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS month_name, EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count
249 281
 				FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '1 YEARS'";
250
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
282
+			if ($sincedate != '') {
283
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
284
+			}
251 285
 			$query .= " GROUP BY year_name, month_name
252 286
 				ORDER BY year_name, month_name ASC";
253 287
 			$query_data = array(':offset' => $offset);
@@ -280,20 +314,26 @@  discard block
 block discarded – undo
280 314
 			date_default_timezone_set($globalTimezone);
281 315
 			$datetime = new DateTime();
282 316
 			$offset = $datetime->format('P');
283
-		} else $offset = '+00:00';
317
+		} else {
318
+			$offset = '+00:00';
319
+		}
284 320
 		//$filter_query = $this->getFilter($filters,true,true);
285 321
 		$filter_query = ' WHERE';
286 322
 		if ($globalDBdriver == 'mysql') {
287 323
 			$query  = "SELECT YEAR(CONVERT_TZ(satellite.launch_date,'+00:00', :offset)) AS year_name, count(*) as date_count
288 324
 				FROM satellite".$filter_query." satellite.launch_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 YEAR)";
289
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
325
+			if ($sincedate != '') {
326
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
327
+			}
290 328
 			$query .= " GROUP BY year_name
291 329
 				ORDER BY year_name ASC";
292 330
 			$query_data = array(':offset' => $offset);
293 331
 		} else {
294 332
 			$query  = "SELECT EXTRACT(YEAR FROM satellite.launch_date AT TIME ZONE INTERVAL :offset) AS year_name, count(*) as date_count
295 333
 				FROM satellite".$filter_query." satellite.launch_date >= CURRENT_TIMESTAMP AT TIME ZONE INTERVAL :offset - INTERVAL '10 YEARS'";
296
-			if ($sincedate != '') $query .= " AND satellite.launch_date > '".$sincedate."'";
334
+			if ($sincedate != '') {
335
+				$query .= " AND satellite.launch_date > '".$sincedate."'";
336
+			}
297 337
 			$query .= " GROUP BY year_name
298 338
 				ORDER BY year_name ASC";
299 339
 			$query_data = array(':offset' => $offset);
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 1 patch
Braces   +42 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 	public function __construct($dbc = null) {
14 14
 		$Connection = new Connection($dbc);
15 15
 		$this->db = $Connection->db;
16
-		if ($this->db === null) die('Error: No DB connection. (TrackerArchive)');
16
+		if ($this->db === null) {
17
+			die('Error: No DB connection. (TrackerArchive)');
18
+		}
17 19
 	}
18 20
 
19 21
     /**
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 		if (isset($filter[0]['source'])) {
37 39
 			$filters = array_merge($filters,$filter);
38 40
 		}
39
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
41
+		if (is_array($globalFilter)) {
42
+			$filter = array_merge($filter,$globalFilter);
43
+		}
40 44
 		$filter_query_join = '';
41 45
 		$filter_query_where = '';
42 46
 		foreach($filters as $flt) {
@@ -82,8 +86,11 @@  discard block
 block discarded – undo
82 86
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
83 87
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
84 88
 		}
85
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
86
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
89
+		if ($filter_query_where == '' && $where) {
90
+			$filter_query_where = ' WHERE';
91
+		} elseif ($filter_query_where != '' && $and) {
92
+			$filter_query_where .= ' AND';
93
+		}
87 94
 		if ($filter_query_where != '') {
88 95
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
89 96
 		}
@@ -116,9 +123,14 @@  discard block
 block discarded – undo
116 123
 		if ($over_country == '') {
117 124
 			$Tracker = new Tracker($this->db);
118 125
 			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
119
-			if (!empty($data_country)) $country = $data_country['iso2'];
120
-			else $country = '';
121
-		} else $country = $over_country;
126
+			if (!empty($data_country)) {
127
+				$country = $data_country['iso2'];
128
+			} else {
129
+				$country = '';
130
+			}
131
+		} else {
132
+			$country = $over_country;
133
+		}
122 134
 		// Route is not added in tracker_archive
123 135
 		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
124 136
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -193,8 +205,11 @@  discard block
 block discarded – undo
193 205
     {
194 206
         date_default_timezone_set('UTC');
195 207
         $id = filter_var($id, FILTER_SANITIZE_STRING);
196
-        if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
197
-        else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
208
+        if ($date == '') {
209
+        	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
210
+        } else {
211
+        	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
212
+        }
198 213
 
199 214
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
200 215
 
@@ -649,7 +664,9 @@  discard block
 block discarded – undo
649 664
                     $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
650 665
                     $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
651 666
                     $translate = $Translation->ident2icao($q_item);
652
-                    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
667
+                    if ($translate != $q_item) {
668
+                    	$additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
669
+                    }
653 670
                     $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
654 671
                     $additional_query .= ")";
655 672
                 }
@@ -867,7 +884,9 @@  discard block
 block discarded – undo
867 884
                 date_default_timezone_set($globalTimezone);
868 885
                 $datetime = new DateTime();
869 886
                 $offset = $datetime->format('P');
870
-            } else $offset = '+00:00';
887
+            } else {
888
+            	$offset = '+00:00';
889
+            }
871 890
 
872 891
 
873 892
             if ($date_array[1] != "")
@@ -1154,9 +1173,13 @@  discard block
 block discarded – undo
1154 1173
                 $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1155 1174
             }
1156 1175
         }
1157
-        if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1176
+        if ($sincedate != '') {
1177
+        	$query .= "AND date > '".$sincedate."' ";
1178
+        }
1158 1179
         $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1159
-        if ($limit) $query .= " LIMIT 0,10";
1180
+        if ($limit) {
1181
+        	$query .= " LIMIT 0,10";
1182
+        }
1160 1183
       
1161 1184
 	
1162 1185
         $sth = $this->db->prepare($query);
@@ -1202,9 +1225,13 @@  discard block
 block discarded – undo
1202 1225
                 $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1203 1226
             }
1204 1227
         }
1205
-        if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1228
+        if ($sincedate != '') {
1229
+        	$query .= "AND s.date > '".$sincedate."' ";
1230
+        }
1206 1231
         $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1207
-        if ($limit) $query .= " LIMIT 0,10";
1232
+        if ($limit) {
1233
+        	$query .= " LIMIT 0,10";
1234
+        }
1208 1235
       
1209 1236
 	
1210 1237
         $sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
require/class.MapMatching.php 1 patch
Braces   +54 added lines, -18 removed lines patch added patch discarded remove patch
@@ -46,7 +46,9 @@  discard block
 block discarded – undo
46 46
 		$gpx .= '<trkseg>';
47 47
 		foreach($spotter_history_array as $spotter_data) {
48 48
 			$gpx .= '<trkpt lat="'.sprintf("%.8f",$spotter_data['latitude']).'" lon="'.sprintf("%.8f",$spotter_data['longitude']).'">';
49
-			if (isset($spotter_data['altitude'])) $gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
49
+			if (isset($spotter_data['altitude'])) {
50
+				$gpx .= '<ele>'.sprintf("%.6f",$spotter_data['altitude']).'</ele>';
51
+			}
50 52
 			$gpx .= '<time>'.date("Y-m-d\TH:i:s\Z",strtotime($spotter_data['date'])).'</time>';
51 53
 			$gpx .= '</trkpt>';
52 54
 		}
@@ -82,9 +84,15 @@  discard block
 block discarded – undo
82 84
 
83 85
 	public function TrackMatching($spotter_history_array) {
84 86
 		global $globalMapMatchingMaxPts, $globalTrackMatchingAppKey, $globalTrackMatchingAppId;
85
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
86
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
87
-		if (count($spotter_history_array) > $globalMapMatchingMaxPts) $spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
87
+		if (!isset($globalMapMatchingMaxPts)) {
88
+			$globalMapMatchingMaxPts = 100;
89
+		}
90
+		if (count($spotter_history_array) < 2) {
91
+			return $spotter_history_array;
92
+		}
93
+		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
94
+			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
95
+		}
88 96
 		$data = $this->create_gpx($spotter_history_array);
89 97
 		$url = 'https://test.roadmatching.com/rest/mapmatch/?app_id='.$globalTrackMatchingAppId.'&app_key='.$globalTrackMatchingAppKey.'&output.waypoints=true';
90 98
 		$Common = new Common();
@@ -111,8 +119,12 @@  discard block
 block discarded – undo
111 119
 	*/
112 120
 	public function GraphHopper($spotter_history_array) {
113 121
 		global $globalMapMatchingMaxPts, $globalGraphHopperKey;
114
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
115
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
122
+		if (!isset($globalMapMatchingMaxPts)) {
123
+			$globalMapMatchingMaxPts = 100;
124
+		}
125
+		if (count($spotter_history_array) < 2) {
126
+			return $spotter_history_array;
127
+		}
116 128
 		$spotter_history_initial_array = array();
117 129
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
118 130
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -142,8 +154,12 @@  discard block
 block discarded – undo
142 154
 	*/
143 155
 	public function FAMMapMatching($spotter_history_array) {
144 156
 		global $globalMapMatchingMaxPts;
145
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 100;
146
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
157
+		if (!isset($globalMapMatchingMaxPts)) {
158
+			$globalMapMatchingMaxPts = 100;
159
+		}
160
+		if (count($spotter_history_array) < 2) {
161
+			return $spotter_history_array;
162
+		}
147 163
 		$spotter_history_initial_array = array();
148 164
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
149 165
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -174,8 +190,12 @@  discard block
 block discarded – undo
174 190
 	*/
175 191
 	public function osmr($spotter_history_array) {
176 192
 		global $globalMapMatchingMaxPts;
177
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 50;
178
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
193
+		if (!isset($globalMapMatchingMaxPts)) {
194
+			$globalMapMatchingMaxPts = 50;
195
+		}
196
+		if (count($spotter_history_array) < 2) {
197
+			return $spotter_history_array;
198
+		}
179 199
 		$spotter_history_initial_array = array();
180 200
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
181 201
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -185,11 +205,17 @@  discard block
 block discarded – undo
185 205
 		$ts = '';
186 206
 		$rd = '';
187 207
 		foreach ($spotter_history_array as $spotter_data) {
188
-			if ($coord != '') $coord .= ';';
208
+			if ($coord != '') {
209
+				$coord .= ';';
210
+			}
189 211
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
190
-			if ($ts != '') $ts .= ';';
212
+			if ($ts != '') {
213
+				$ts .= ';';
214
+			}
191 215
 			$ts .= strtotime($spotter_data['date']);
192
-			if ($rd != '') $rd .= ';';
216
+			if ($rd != '') {
217
+				$rd .= ';';
218
+			}
193 219
 			$rd .= '20';
194 220
 		}
195 221
 		$url = 'https://router.project-osrm.org/match/v1/driving/'.$coord.'?timestamps='.$ts.'&overview=full&geometries=geojson&tidy=true&gaps=ignore';
@@ -215,8 +241,12 @@  discard block
 block discarded – undo
215 241
 	*/
216 242
 	public function mapbox($spotter_history_array) {
217 243
 		global $globalMapMatchingMaxPts, $globalMapboxToken;
218
-		if (!isset($globalMapMatchingMaxPts)) $globalMapMatchingMaxPts = 60;
219
-		if (count($spotter_history_array) < 2) return $spotter_history_array;
244
+		if (!isset($globalMapMatchingMaxPts)) {
245
+			$globalMapMatchingMaxPts = 60;
246
+		}
247
+		if (count($spotter_history_array) < 2) {
248
+			return $spotter_history_array;
249
+		}
220 250
 		$spotter_history_initial_array = array();
221 251
 		if (count($spotter_history_array) > $globalMapMatchingMaxPts) {
222 252
 			$spotter_history_array = array_slice($spotter_history_array,-$globalMapMatchingMaxPts);
@@ -226,11 +256,17 @@  discard block
 block discarded – undo
226 256
 		$ts = '';
227 257
 		$rd = '';
228 258
 		foreach ($spotter_history_array as $spotter_data) {
229
-			if ($coord != '') $coord .= ';';
259
+			if ($coord != '') {
260
+				$coord .= ';';
261
+			}
230 262
 			$coord .= $spotter_data['longitude'].','.$spotter_data['latitude'];
231
-			if ($ts != '') $ts .= ';';
263
+			if ($ts != '') {
264
+				$ts .= ';';
265
+			}
232 266
 			$ts .= strtotime($spotter_data['date']);
233
-			if ($rd != '') $rd .= ';';
267
+			if ($rd != '') {
268
+				$rd .= ';';
269
+			}
234 270
 			$rd .= '20';
235 271
 		}
236 272
 		//$url = 'https://api.mapbox.com/matching/v5/mapbox/driving/'.$coord.'?access_token='.$globalMapboxToken.'&timestamps='.$ts.'&overview=full&tidy=true&geometries=geojson&radiuses='.$rd;
Please login to merge, or discard this patch.
require/class.Scheduler.php 1 patch
Braces   +180 added lines, -62 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection.');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection.');
29
+		}
28 30
 	}
29 31
 
30 32
     /**
@@ -141,7 +143,9 @@  discard block
 block discarded – undo
141 143
 		$sth->closeCursor();
142 144
 		if (is_array($row) && count($row) > 0) {
143 145
 			return $row;
144
-		} else return array();
146
+		} else {
147
+			return array();
148
+		}
145 149
 	}
146 150
 
147 151
 	/*
@@ -182,7 +186,9 @@  discard block
 block discarded – undo
182 186
 		$Common = new Common();
183 187
 		$check_date = new Datetime($date);
184 188
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
185
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
189
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
190
+			return array();
191
+		}
186 192
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
187 193
 		$json = $Common->getData($url);
188 194
 		var_dump($json);
@@ -209,7 +215,9 @@  discard block
 block discarded – undo
209 215
 			*/
210 216
 		
211 217
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
212
-		} else return array();
218
+		} else {
219
+			return array();
220
+		}
213 221
 	}
214 222
 
215 223
     /**
@@ -224,7 +232,9 @@  discard block
 block discarded – undo
224 232
 		date_default_timezone_set($globalTimezone);
225 233
 		$check_date = new Datetime($date);
226 234
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
227
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
235
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
236
+			return array();
237
+		}
228 238
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
229 239
 		$json = $Common->getData($url);
230 240
 		$parsed_json = json_decode($json);
@@ -237,7 +247,9 @@  discard block
 block discarded – undo
237 247
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
238 248
 
239 249
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
240
-		} else return array();
250
+		} else {
251
+			return array();
252
+		}
241 253
 	}
242 254
 
243 255
     /**
@@ -248,7 +260,9 @@  discard block
 block discarded – undo
248 260
 	private function getRyanair($callsign) {
249 261
 		$Common = new Common();
250 262
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
251
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
263
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
264
+			return array();
265
+		}
252 266
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
253 267
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
254 268
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -262,8 +276,12 @@  discard block
 block discarded – undo
262 276
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
263 277
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
264 278
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
265
-			} else return array();
266
-		} else return array();
279
+			} else {
280
+				return array();
281
+			}
282
+		} else {
283
+			return array();
284
+		}
267 285
 	}
268 286
 
269 287
 	/**
@@ -274,7 +292,9 @@  discard block
 block discarded – undo
274 292
 	private function getSwiss($callsign) {
275 293
 		$Common = new Common();
276 294
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
277
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
295
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
296
+			return array();
297
+		}
278 298
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
279 299
 		$json = $Common->getData($url);
280 300
 		$parsed_json = json_decode($json);
@@ -294,8 +314,12 @@  discard block
 block discarded – undo
294 314
 			}
295 315
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
296 316
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
297
-			} else return array();
298
-		} else return array();
317
+			} else {
318
+				return array();
319
+			}
320
+		} else {
321
+			return array();
322
+		}
299 323
 	}
300 324
 	
301 325
 	/**
@@ -309,12 +333,18 @@  discard block
 block discarded – undo
309 333
 		$Common = new Common();
310 334
 		$check_date = new Datetime($date);
311 335
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
312
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
313
-		if ($globalBritishAirwaysKey == '') return array();
336
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
337
+			return array();
338
+		}
339
+		if ($globalBritishAirwaysKey == '') {
340
+			return array();
341
+		}
314 342
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
315 343
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
316 344
 		$json = $Common->getData($url,'get','',$headers);
317
-		if ($json == '') return array();
345
+		if ($json == '') {
346
+			return array();
347
+		}
318 348
 		$parsed_json = json_decode($json);
319 349
 		$flights = $parsed_json->{'FlightsResponse'};
320 350
 		if (count($flights) > 0) {
@@ -323,7 +353,9 @@  discard block
 block discarded – undo
323 353
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324 354
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325 355
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
326
-		} else return array();
356
+		} else {
357
+			return array();
358
+		}
327 359
 	}
328 360
 
329 361
 	/**
@@ -337,19 +369,27 @@  discard block
 block discarded – undo
337 369
 		$Common = new Common();
338 370
 		$check_date = new Datetime($date);
339 371
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
340
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
341
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
372
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
373
+			return array();
374
+		}
375
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
376
+			return array();
377
+		}
342 378
 		$url = "https://api.lufthansa.com/v1/oauth/token";
343 379
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
344 380
 		$data = $Common->getData($url,'post',$post);
345 381
 		$parsed_data = json_decode($data);
346
-		if (!isset($parsed_data->{'access_token'})) return array();
382
+		if (!isset($parsed_data->{'access_token'})) {
383
+			return array();
384
+		}
347 385
 		$token = $parsed_data->{'access_token'};
348 386
 		
349 387
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
350 388
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
351 389
 		$json = $Common->getData($url,'get','',$headers);
352
-		if ($json == '') return array();
390
+		if ($json == '') {
391
+			return array();
392
+		}
353 393
 		$parsed_json = json_decode($json);
354 394
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
355 395
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -357,7 +397,9 @@  discard block
 block discarded – undo
357 397
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
358 398
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359 399
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
360
-		} else return array();
400
+		} else {
401
+			return array();
402
+		}
361 403
 	}
362 404
 
363 405
 	/**
@@ -371,14 +413,20 @@  discard block
 block discarded – undo
371 413
 		$Common = new Common();
372 414
 		$check_date = new Datetime($date);
373 415
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
374
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
375
-		if ($globalTransaviaKey == '') return array();
416
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
417
+			return array();
418
+		}
419
+		if ($globalTransaviaKey == '') {
420
+			return array();
421
+		}
376 422
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
377 423
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
378 424
 		$headers = array('apikey: '.$globalTransaviaKey);
379 425
 		$json = $Common->getData($url,'get','',$headers);
380 426
 		//echo 'result : '.$json;
381
-		if ($json == '') return array();
427
+		if ($json == '') {
428
+			return array();
429
+		}
382 430
 		$parsed_json = json_decode($json);
383 431
 		
384 432
 		if (isset($parsed_json->{'data'}[0])) {
@@ -387,7 +435,9 @@  discard block
 block discarded – undo
387 435
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
388 436
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389 437
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
390
-		} else return array();
438
+		} else {
439
+			return array();
440
+		}
391 441
 	}
392 442
 
393 443
 	/**
@@ -398,7 +448,9 @@  discard block
 block discarded – undo
398 448
 	public function getTunisair($callsign) {
399 449
 		$Common = new Common();
400 450
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
401
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
451
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
452
+			return array();
453
+		}
402 454
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
403 455
 		$data = $Common->getData($url);
404 456
 		$table = $Common->table2array($data);
@@ -420,7 +472,9 @@  discard block
 block discarded – undo
420 472
 		$Common = new Common();
421 473
 		$check_date = new Datetime($date);
422 474
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
475
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
476
+			return array();
477
+		}
424 478
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
425 479
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
426 480
 		$data = $Common->getData($url);
@@ -430,8 +484,11 @@  discard block
 block discarded – undo
430 484
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
431 485
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
432 486
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
433
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
434
-			else return array();
487
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
488
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
489
+			} else {
490
+				return array();
491
+			}
435 492
 		}
436 493
 		return array();
437 494
 	}
@@ -446,7 +503,9 @@  discard block
 block discarded – undo
446 503
 		$Common = new Common();
447 504
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
448 505
 		$check_date = new Datetime($date);
449
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
506
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
507
+			return array();
508
+		}
450 509
 		$url = "https://www.iberia.com/web/flightDetail.do";
451 510
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
452 511
 		$data = $Common->getData($url,'post',$post);
@@ -463,7 +522,9 @@  discard block
 block discarded – undo
463 522
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
464 523
 				if ($arrivalTime == 'Hora estimada de llegada') {
465 524
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
466
-				} else $arrivalTime = substr($arrivalTime,0,5);
525
+				} else {
526
+					$arrivalTime = substr($arrivalTime,0,5);
527
+				}
467 528
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
468 529
 			}
469 530
 		}
@@ -482,7 +543,9 @@  discard block
 block discarded – undo
482 543
 		$Common = new Common();
483 544
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
484 545
 		$check_date = new Datetime($date);
485
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
546
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
547
+			return array();
548
+		}
486 549
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
487 550
 		$data = $Common->getData($url);
488 551
 		if ($data != '') {
@@ -498,7 +561,9 @@  discard block
 block discarded – undo
498 561
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
499 562
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
500 563
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
501
-				} else return array();
564
+				} else {
565
+					return array();
566
+				}
502 567
 			}
503 568
 			
504 569
 
@@ -518,7 +583,9 @@  discard block
 block discarded – undo
518 583
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
519 584
 		$check_date = new Datetime($date);
520 585
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
586
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
587
+			return array();
588
+		}
522 589
 		$data = $Common->getData($url);
523 590
 		if ($data != '') {
524 591
 			$table = $Common->text2array($data);
@@ -543,7 +610,9 @@  discard block
 block discarded – undo
543 610
 		$check_date = new Datetime($date);
544 611
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
545 612
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
546
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
613
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
614
+			return array();
615
+		}
547 616
 		$data = $Common->getData($url);
548 617
 		if ($data != '') {
549 618
 		    //echo $data;
@@ -634,7 +703,9 @@  discard block
 block discarded – undo
634 703
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
635 704
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
636 705
 		//$check_date = new Datetime($date);
637
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
706
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
707
+			return array();
708
+		}
638 709
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
639 710
 		$data = $Common->getData($url,'post',$post);
640 711
 		if ($data != '') {
@@ -666,11 +737,15 @@  discard block
 block discarded – undo
666 737
 				$airline_icao = substr($callsign, 0, 3);
667 738
 			} 
668 739
 		}
669
-		if ($airline_icao == '') return array();
740
+		if ($airline_icao == '') {
741
+			return array();
742
+		}
670 743
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
671 744
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
672 745
 		//$check_date = new Datetime($date);
673
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
746
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
747
+			return array();
748
+		}
674 749
 		$data = $Common->getData($url);
675 750
 		if ($data != '') {
676 751
 			$table = $Common->table2array($data);
@@ -763,10 +838,16 @@  discard block
 block discarded – undo
763 838
 		if ($data != '') {
764 839
 			$table = $Common->table2array($data);
765 840
 			if (isset($table[11][1])) {
766
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
767
-				else $departureTime = '';
768
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
769
-				else $arrivalTime = '';
841
+				if (is_numeric(substr($table[11][1],0,1))) {
842
+					$departureTime = substr($table[11][1],0,5);
843
+				} else {
844
+					$departureTime = '';
845
+				}
846
+				if (is_numeric(substr($table[17][1],0,1))) {
847
+					$arrivalTime = substr($table[17][1],0,5);
848
+				} else {
849
+					$arrivalTime = '';
850
+				}
770 851
 				$DepartureAirportIata = substr($table[13][1],0,3);
771 852
 				$ArrivalAirportIata = substr($table[15][1],0,3);
772 853
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
@@ -783,16 +864,22 @@  discard block
 block discarded – undo
783 864
 	*/
784 865
 	private function getAirCanada($callsign,$date = 'NOW') {
785 866
 		$Common = new Common();
786
-		if (class_exists("DomDocument") === FALSE) return array();
867
+		if (class_exists("DomDocument") === FALSE) {
868
+			return array();
869
+		}
787 870
 		date_default_timezone_set('UTC');
788 871
 		$check_date = new Datetime($date);
789 872
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
790 873
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
874
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
875
+			return array();
876
+		}
792 877
 		$data = $Common->getData($url);
793 878
 		$dom = new DomDocument();
794 879
 		$dom->loadXML($data);
795
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
880
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
881
+			return array();
882
+		}
796 883
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
797 884
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
798 885
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -801,7 +888,9 @@  discard block
 block discarded – undo
801 888
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
802 889
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803 890
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
804
-		} else return array();
891
+		} else {
892
+			return array();
893
+		}
805 894
 	}
806 895
 
807 896
 	/**
@@ -815,7 +904,9 @@  discard block
 block discarded – undo
815 904
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
816 905
 		$check_date = new Datetime($date);
817 906
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
907
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
908
+			return array();
909
+		}
819 910
 		$data = $Common->getData($url);
820 911
 		if ($data != '') {
821 912
 			$table = $Common->table2array($data);
@@ -845,7 +936,9 @@  discard block
 block discarded – undo
845 936
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
846 937
 		$check_date = new Datetime($date);
847 938
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
848
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
939
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
940
+			return array();
941
+		}
849 942
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
850 943
 		$data = $Common->getData($url,'post',$post);
851 944
 		//echo $data;
@@ -855,11 +948,19 @@  discard block
 block discarded – undo
855 948
 		if ($data != '') {
856 949
 			$table = $Common->table2array($data);
857 950
 			$flight = $table;
858
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
859
-			else $departureTime = '';
860
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
861
-			else $departureAirport = '';
862
-		} else return array();
951
+			if (isset($flight[5][4])) {
952
+				$departureTime = $flight[5][4];
953
+			} else {
954
+				$departureTime = '';
955
+			}
956
+			if (isset($flight[5][2])) {
957
+				$departureAirport = $flight[5][2];
958
+			} else {
959
+				$departureAirport = '';
960
+			}
961
+		} else {
962
+			return array();
963
+		}
863 964
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
864 965
 		$data = $Common->getData($url,'post',$post);
865 966
 		if ($data != '') {
@@ -872,10 +973,14 @@  discard block
 block discarded – undo
872 973
 			    $arrivalTime = '';
873 974
 			    $arrivalAirport = '';
874 975
 			}
875
-		} else return array();
976
+		} else {
977
+			return array();
978
+		}
876 979
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
877 980
 		$json = $Common->getData($url);
878
-		if ($json == '') return array();
981
+		if ($json == '') {
982
+			return array();
983
+		}
879 984
 		$parsed_json = json_decode($json);
880 985
 		$airports = $parsed_json->{'suggestList'};
881 986
 		if (count($airports) > 0) {
@@ -890,7 +995,9 @@  discard block
 block discarded – undo
890 995
 		}
891 996
 		if (isset($DepartureAirportIata)) {
892 997
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
893
-		} else return array();
998
+		} else {
999
+			return array();
1000
+		}
894 1001
 	}
895 1002
 
896 1003
 	/*
@@ -902,7 +1009,9 @@  discard block
 block discarded – undo
902 1009
 	public function fetchSchedule($ident,$date = 'NOW') {
903 1010
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
904 1011
 		//$Common = new Common();
905
-		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
1012
+		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) {
1013
+			return array();
1014
+		}
906 1015
 		$airline_icao = '';
907 1016
 		if (!is_numeric(substr($ident, 0, 3)))
908 1017
 		{
@@ -1137,18 +1246,27 @@  discard block
 block discarded – undo
1137 1246
 					if (strlen($airline_icao) == 3) {
1138 1247
 						$Spotter = new Spotter($this->db);
1139 1248
 						$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
1140
-						if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata'];
1249
+						if (isset($airline_info[0]['iata'])) {
1250
+							$airline_icao = $airline_info[0]['iata'];
1251
+						}
1141 1252
 					}
1142 1253
 					// Randomly use a generic function to get hours
1143 1254
 					if (strlen($airline_icao) == 2) {
1144
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1255
+						if (!isset($globalSchedulesSources)) {
1256
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1257
+						}
1145 1258
 						if (count($globalSchedulesSources) > 0) {
1146 1259
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1147 1260
 							$source = $globalSchedulesSources[$rand];
1148
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1149
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1261
+							if ($source == 'flightmapper') {
1262
+								return $this->getFlightMapper($ident);
1263
+							} elseif ($source == 'costtotravel') {
1264
+								return $this->getCostToTravel($ident);
1265
+							}
1150 1266
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1151
-							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident);
1267
+							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') {
1268
+								return $this->getFlightAware($ident);
1269
+							}
1152 1270
 						}
1153 1271
 					}
1154 1272
 			}
Please login to merge, or discard this patch.
require/class.Translation.php 1 patch
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,16 +38,25 @@  discard block
 block discarded – undo
38 38
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
39 39
 				//$airline_icao = substr($ident, 0, 3);
40 40
 				return $ident;
41
-			} else return $ident;
42
-		} else return $ident;
41
+			} else {
42
+				return $ident;
43
+			}
44
+		} else {
45
+			return $ident;
46
+		}
43 47
 		if ($airline_icao == 'AF') {
44
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
45
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
48
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
49
+				$icao = $ident;
50
+			} else {
51
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
52
+			}
46 53
 		} else {
47 54
 			$identicao = $Spotter->getAllAirlineInfo($airline_icao);
48 55
 			if (isset($identicao[0])) {
49 56
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
50
-			} else $icao = $ident;
57
+			} else {
58
+				$icao = $ident;
59
+			}
51 60
 		}
52 61
 		return $icao;
53 62
 	}
@@ -69,7 +78,9 @@  discard block
 block discarded – undo
69 78
 		$sth->closeCursor();
70 79
 		if (isset($row['operator_correct'])) {
71 80
 			return $row['operator_correct'];
72
-		} else return $ident;
81
+		} else {
82
+			return $ident;
83
+		}
73 84
 	}
74 85
 
75 86
     /**
@@ -115,7 +126,9 @@  discard block
 block discarded – undo
115 126
 		global $globalTranslationSources, $globalTranslationFetch;
116 127
 		//if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
117 128
 		$globalTranslationSources = array();
118
-		if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE;
129
+		if (!isset($globalTranslationFetch)) {
130
+			$globalTranslationFetch = TRUE;
131
+		}
119 132
 		//echo "Check Translation for ".$ident."...";
120 133
 		$correct = $this->getOperator($ident);
121 134
 		if ($correct != '' && $correct != $ident) {
Please login to merge, or discard this patch.