Completed
Pull Request — master (#448)
by
unknown
10:23
created
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.
require/class.Tracker.php 1 patch
Braces   +172 added lines, -61 removed lines patch added patch discarded remove patch
@@ -17,7 +17,9 @@  discard block
 block discarded – undo
17 17
 	public function __construct($dbc = null) {
18 18
 		$Connection = new Connection($dbc);
19 19
 		$this->db = $Connection->db();
20
-		if ($this->db === null) die('Error: No DB connection. (Tracker)');
20
+		if ($this->db === null) {
21
+			die('Error: No DB connection. (Tracker)');
22
+		}
21 23
 	}
22 24
 
23 25
     /**
@@ -41,7 +43,9 @@  discard block
 block discarded – undo
41 43
 		if (isset($filter[0]['source'])) {
42 44
 			$filters = array_merge($filters,$filter);
43 45
 		}
44
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
46
+		if (is_array($globalFilter)) {
47
+			$filter = array_merge($filter,$globalFilter);
48
+		}
45 49
 		$filter_query_join = '';
46 50
 		$filter_query_where = '';
47 51
 		foreach($filters as $flt) {
@@ -83,8 +87,11 @@  discard block
 block discarded – undo
83 87
 				$filter_query_where .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
84 88
 			}
85 89
 		}
86
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
87
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
90
+		if ($filter_query_where == '' && $where) {
91
+			$filter_query_where = ' WHERE';
92
+		} elseif ($filter_query_where != '' && $and) {
93
+			$filter_query_where .= ' AND';
94
+		}
88 95
 		if ($filter_query_where != '') {
89 96
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
90 97
 		}
@@ -138,26 +145,43 @@  discard block
 block discarded – undo
138 145
 				$temp_array['tracker_id'] = $row['tracker_archive_id'];
139 146
 			} elseif (isset($row['tracker_archive_output_id'])) {
140 147
 				$temp_array['tracker_id'] = $row['tracker_archive_output_id'];
141
-			*/} 
142
-			elseif (isset($row['trackerid'])) {
148
+			*/} elseif (isset($row['trackerid'])) {
143 149
 				$temp_array['trackerid'] = $row['trackerid'];
144 150
 			} else {
145 151
 				$temp_array['trackerid'] = '';
146 152
 			}
147
-			if (isset($row['famtrackid'])) $temp_array['famtrackid'] = $row['famtrackid'];
148
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
149
-			if (isset($row['comment'])) $temp_array['comment'] = $row['comment'];
153
+			if (isset($row['famtrackid'])) {
154
+				$temp_array['famtrackid'] = $row['famtrackid'];
155
+			}
156
+			if (isset($row['type'])) {
157
+				$temp_array['type'] = $row['type'];
158
+			}
159
+			if (isset($row['comment'])) {
160
+				$temp_array['comment'] = $row['comment'];
161
+			}
150 162
 			$temp_array['ident'] = $row['ident'];
151
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
152
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
153
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
154
-			if (isset($row['altitude'])) $temp_array['altitude'] = $row['altitude'];
163
+			if (isset($row['latitude'])) {
164
+				$temp_array['latitude'] = $row['latitude'];
165
+			}
166
+			if (isset($row['longitude'])) {
167
+				$temp_array['longitude'] = $row['longitude'];
168
+			}
169
+			if (isset($row['format_source'])) {
170
+				$temp_array['format_source'] = $row['format_source'];
171
+			}
172
+			if (isset($row['altitude'])) {
173
+				$temp_array['altitude'] = $row['altitude'];
174
+			}
155 175
 			if (isset($row['heading'])) {
156 176
 				$temp_array['heading'] = $row['heading'];
157 177
 				$heading_direction = $this->parseDirection($row['heading']);
158
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
178
+				if (isset($heading_direction[0]['direction_fullname'])) {
179
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
180
+				}
181
+			}
182
+			if (isset($row['ground_speed'])) {
183
+				$temp_array['ground_speed'] = $row['ground_speed'];
159 184
 			}
160
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
161 185
 			
162 186
 			if (isset($row['date'])) {
163 187
 				$dateArray = $this->parseDateString($row['date']);
@@ -200,13 +224,21 @@  discard block
 block discarded – undo
200 224
 			}
201 225
 			
202 226
 			$fromsource = NULL;
203
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
204
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
205
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
227
+			if (isset($row['source_name']) && $row['source_name'] != '') {
228
+				$temp_array['source_name'] = $row['source_name'];
229
+			}
230
+			if (isset($row['over_country']) && $row['over_country'] != '') {
231
+				$temp_array['over_country'] = $row['over_country'];
232
+			}
233
+			if (isset($row['distance']) && $row['distance'] != '') {
234
+				$temp_array['distance'] = $row['distance'];
235
+			}
206 236
 			$temp_array['query_number_rows'] = $num_rows;
207 237
 			$tracker_array[] = $temp_array;
208 238
 		}
209
-		if ($num_rows == 0) return array();
239
+		if ($num_rows == 0) {
240
+			return array();
241
+		}
210 242
 		$tracker_array[0]['query_number_rows'] = $num_rows;
211 243
 		return $tracker_array;
212 244
 	}
@@ -239,8 +271,12 @@  discard block
 block discarded – undo
239 271
 			{
240 272
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
241 273
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
242
-			} else $limit_query = "";
243
-		} else $limit_query = "";
274
+			} else {
275
+				$limit_query = "";
276
+			}
277
+		} else {
278
+			$limit_query = "";
279
+		}
244 280
 		
245 281
 		if ($sort != "")
246 282
 		{
@@ -268,7 +304,9 @@  discard block
 block discarded – undo
268 304
 		global $global_tracker_query;
269 305
 		
270 306
 		date_default_timezone_set('UTC');
271
-		if ($id == '') return array();
307
+		if ($id == '') {
308
+			return array();
309
+		}
272 310
 		$additional_query = "tracker_output.famtrackid = :id";
273 311
 		$query_values = array(':id' => $id);
274 312
 		$query  = $global_tracker_query." WHERE ".$additional_query." ";
@@ -413,8 +451,11 @@  discard block
 block discarded – undo
413 451
 		$query .= " ORDER BY tracker_output.source_name ASC";
414 452
 
415 453
 		$sth = $this->db->prepare($query);
416
-		if (!empty($query_values)) $sth->execute($query_values);
417
-		else $sth->execute();
454
+		if (!empty($query_values)) {
455
+			$sth->execute($query_values);
456
+		} else {
457
+			$sth->execute();
458
+		}
418 459
 
419 460
 		$source_array = array();
420 461
 		$temp_array = array();
@@ -469,7 +510,9 @@  discard block
 block discarded – undo
469 510
 			date_default_timezone_set($globalTimezone);
470 511
 			$datetime = new DateTime();
471 512
 			$offset = $datetime->format('P');
472
-		} else $offset = '+00:00';
513
+		} else {
514
+			$offset = '+00:00';
515
+		}
473 516
 
474 517
 		if ($globalDBdriver == 'mysql') {
475 518
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) as date
@@ -617,7 +660,9 @@  discard block
 block discarded – undo
617 660
 			{
618 661
 				return false;
619 662
 			}
620
-		} else $altitude = 0;
663
+		} else {
664
+			$altitude = 0;
665
+		}
621 666
 		
622 667
 		if ($heading != "")
623 668
 		{
@@ -656,8 +701,12 @@  discard block
 block discarded – undo
656 701
             		$latitude = 0;
657 702
             		$longitude = 0;
658 703
             	}
659
-                if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
660
-                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
704
+                if ($heading == '' || $Common->isInteger($heading) === false) {
705
+                	$heading = 0;
706
+                }
707
+                if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
708
+                	$groundspeed = 0;
709
+                }
661 710
                 $query  = "INSERT INTO tracker_output (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, comment, type) 
662 711
                 VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:speed,:date,:format_source, :source_name,:comment,:type)";
663 712
 
@@ -764,7 +813,9 @@  discard block
 block discarded – undo
764 813
 		global $globalDBdriver, $globalArchive;
765 814
 		//$filter_query = $this->getFilter($filters,true,true);
766 815
 		$Connection= new Connection($this->db);
767
-		if (!$Connection->tableExists('countries')) return array();
816
+		if (!$Connection->tableExists('countries')) {
817
+			return array();
818
+		}
768 819
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
769 820
 			require_once('class.TrackerLive.php');
770 821
 			$TrackerLive = new TrackerLive($this->db);
@@ -807,7 +858,9 @@  discard block
 block discarded – undo
807 858
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT famtrackid,over_country FROM tracker_archive".$filter_query.") l ON c.iso2 = l.over_country ";
808 859
 		}
809 860
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
810
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
861
+		if ($limit) {
862
+			$query .= " LIMIT 10 OFFSET 0";
863
+		}
811 864
       
812 865
 		
813 866
 		$sth = $this->db->prepare($query);
@@ -846,12 +899,18 @@  discard block
 block discarded – undo
846 899
 		$query  = "SELECT DISTINCT tracker_output.ident, COUNT(tracker_output.ident) AS callsign_icao_count 
847 900
                     FROM tracker_output".$filter_query." tracker_output.ident <> ''";
848 901
 		 if ($olderthanmonths > 0) {
849
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
850
-			else $query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
902
+			if ($globalDBdriver == 'mysql') {
903
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
904
+			} else {
905
+				$query .= " AND tracker_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
906
+			}
851 907
 		}
852 908
 		if ($sincedate != '') {
853
-			if ($globalDBdriver == 'mysql') $query .= " AND tracker_output.date > '".$sincedate."'";
854
-			else $query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
909
+			if ($globalDBdriver == 'mysql') {
910
+				$query .= " AND tracker_output.date > '".$sincedate."'";
911
+			} else {
912
+				$query .= " AND tracker_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
913
+			}
855 914
 		}
856 915
 		$query_values = array();
857 916
 		if ($year != '') {
@@ -882,7 +941,9 @@  discard block
 block discarded – undo
882 941
 			}
883 942
 		}
884 943
 		$query .= " GROUP BY tracker_output.ident ORDER BY callsign_icao_count DESC";
885
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
944
+		if ($limit) {
945
+			$query .= " LIMIT 10 OFFSET 0";
946
+		}
886 947
       		
887 948
 		$sth = $this->db->prepare($query);
888 949
 		$sth->execute($query_values);
@@ -917,7 +978,9 @@  discard block
 block discarded – undo
917 978
 			date_default_timezone_set($globalTimezone);
918 979
 			$datetime = new DateTime();
919 980
 			$offset = $datetime->format('P');
920
-		} else $offset = '+00:00';
981
+		} else {
982
+			$offset = '+00:00';
983
+		}
921 984
 
922 985
 		if ($globalDBdriver == 'mysql') {
923 986
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -967,7 +1030,9 @@  discard block
 block discarded – undo
967 1030
 			date_default_timezone_set($globalTimezone);
968 1031
 			$datetime = new DateTime();
969 1032
 			$offset = $datetime->format('P');
970
-		} else $offset = '+00:00';
1033
+		} else {
1034
+			$offset = '+00:00';
1035
+		}
971 1036
 		$filter_query = $this->getFilter($filters,true,true);
972 1037
 		if ($globalDBdriver == 'mysql') {
973 1038
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1013,7 +1078,9 @@  discard block
 block discarded – undo
1013 1078
 			date_default_timezone_set($globalTimezone);
1014 1079
 			$datetime = new DateTime();
1015 1080
 			$offset = $datetime->format('P');
1016
-		} else $offset = '+00:00';
1081
+		} else {
1082
+			$offset = '+00:00';
1083
+		}
1017 1084
 		$filter_query = $this->getFilter($filters,true,true);
1018 1085
 		if ($globalDBdriver == 'mysql') {
1019 1086
 			$query  = "SELECT DATE(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1060,7 +1127,9 @@  discard block
 block discarded – undo
1060 1127
 			date_default_timezone_set($globalTimezone);
1061 1128
 			$datetime = new DateTime();
1062 1129
 			$offset = $datetime->format('P');
1063
-		} else $offset = '+00:00';
1130
+		} else {
1131
+			$offset = '+00:00';
1132
+		}
1064 1133
 
1065 1134
 		if ($globalDBdriver == 'mysql') {
1066 1135
 			$query  = "SELECT YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1107,7 +1176,9 @@  discard block
 block discarded – undo
1107 1176
 			date_default_timezone_set($globalTimezone);
1108 1177
 			$datetime = new DateTime();
1109 1178
 			$offset = $datetime->format('P');
1110
-		} else $offset = '+00:00';
1179
+		} else {
1180
+			$offset = '+00:00';
1181
+		}
1111 1182
 		$filter_query = $this->getFilter($filters,true,true);
1112 1183
 		if ($globalDBdriver == 'mysql') {
1113 1184
 			$query  = "SELECT MONTH(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1156,7 +1227,9 @@  discard block
 block discarded – undo
1156 1227
 			date_default_timezone_set($globalTimezone);
1157 1228
 			$datetime = new DateTime();
1158 1229
 			$offset = $datetime->format('P');
1159
-		} else $offset = '+00:00';
1230
+		} else {
1231
+			$offset = '+00:00';
1232
+		}
1160 1233
 
1161 1234
 		$orderby_sql = '';
1162 1235
 		if ($orderby == "hour")
@@ -1225,7 +1298,9 @@  discard block
 block discarded – undo
1225 1298
 			date_default_timezone_set($globalTimezone);
1226 1299
 			$datetime = new DateTime($date);
1227 1300
 			$offset = $datetime->format('P');
1228
-		} else $offset = '+00:00';
1301
+		} else {
1302
+			$offset = '+00:00';
1303
+		}
1229 1304
 
1230 1305
 		if ($globalDBdriver == 'mysql') {
1231 1306
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1273,7 +1348,9 @@  discard block
 block discarded – undo
1273 1348
 			date_default_timezone_set($globalTimezone);
1274 1349
 			$datetime = new DateTime();
1275 1350
 			$offset = $datetime->format('P');
1276
-		} else $offset = '+00:00';
1351
+		} else {
1352
+			$offset = '+00:00';
1353
+		}
1277 1354
 
1278 1355
 		if ($globalDBdriver == 'mysql') {
1279 1356
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1339,8 +1416,11 @@  discard block
 block discarded – undo
1339 1416
 				$query_values = array_merge($query_values,array(':month' => $month));
1340 1417
 			}
1341 1418
 		}
1342
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1343
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1419
+		if (empty($query_values)) {
1420
+			$queryi .= $this->getFilter($filters);
1421
+		} else {
1422
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1423
+		}
1344 1424
 		
1345 1425
 		$sth = $this->db->prepare($queryi);
1346 1426
 		$sth->execute($query_values);
@@ -1379,8 +1459,11 @@  discard block
 block discarded – undo
1379 1459
 				$query_values = array_merge($query_values,array(':month' => $month));
1380 1460
 			}
1381 1461
 		}
1382
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1383
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1462
+		if (empty($query_values)) {
1463
+			$queryi .= $this->getFilter($filters);
1464
+		} else {
1465
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1466
+		}
1384 1467
 		
1385 1468
 		$sth = $this->db->prepare($queryi);
1386 1469
 		$sth->execute($query_values);
@@ -1402,7 +1485,9 @@  discard block
 block discarded – undo
1402 1485
 			date_default_timezone_set($globalTimezone);
1403 1486
 			$datetime = new DateTime();
1404 1487
 			$offset = $datetime->format('P');
1405
-		} else $offset = '+00:00';
1488
+		} else {
1489
+			$offset = '+00:00';
1490
+		}
1406 1491
 
1407 1492
 		if ($globalDBdriver == 'mysql') {
1408 1493
 			$query  = "SELECT HOUR(CONVERT_TZ(tracker_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1506,7 +1591,9 @@  discard block
 block discarded – undo
1506 1591
 	*/
1507 1592
 	public function parseDirection($direction = 0)
1508 1593
 	{
1509
-		if ($direction == '') $direction = 0;
1594
+		if ($direction == '') {
1595
+			$direction = 0;
1596
+		}
1510 1597
 		$direction_array = array();
1511 1598
 		$temp_array = array();
1512 1599
 
@@ -1595,7 +1682,9 @@  discard block
 block discarded – undo
1595 1682
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1596 1683
 	
1597 1684
 		$Connection = new Connection($this->db);
1598
-		if (!$Connection->tableExists('countries')) return '';
1685
+		if (!$Connection->tableExists('countries')) {
1686
+			return '';
1687
+		}
1599 1688
 	
1600 1689
 		try {
1601 1690
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE ST_Within(ST_GeomFromText('POINT(".$longitude." ".$latitude.")',4326), ogc_geom) LIMIT 1";
@@ -1606,9 +1695,13 @@  discard block
 block discarded – undo
1606 1695
 			$sth->closeCursor();
1607 1696
 			if (count($row) > 0) {
1608 1697
 				return $row;
1609
-			} else return '';
1698
+			} else {
1699
+				return '';
1700
+			}
1610 1701
 		} catch (PDOException $e) {
1611
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1702
+			if (isset($globalDebug) && $globalDebug) {
1703
+				echo 'Error : '.$e->getMessage()."\n";
1704
+			}
1612 1705
 			return '';
1613 1706
 		}
1614 1707
 	
@@ -1626,7 +1719,9 @@  discard block
 block discarded – undo
1626 1719
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1627 1720
 	
1628 1721
 		$Connection = new Connection($this->db);
1629
-		if (!$Connection->tableExists('countries')) return '';
1722
+		if (!$Connection->tableExists('countries')) {
1723
+			return '';
1724
+		}
1630 1725
 	
1631 1726
 		try {
1632 1727
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1638,9 +1733,13 @@  discard block
 block discarded – undo
1638 1733
 			$sth->closeCursor();
1639 1734
 			if (count($row) > 0) {
1640 1735
 				return $row;
1641
-			} else return '';
1736
+			} else {
1737
+				return '';
1738
+			}
1642 1739
 		} catch (PDOException $e) {
1643
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1740
+			if (isset($globalDebug) && $globalDebug) {
1741
+				echo 'Error : '.$e->getMessage()."\n";
1742
+			}
1644 1743
 			return '';
1645 1744
 		}
1646 1745
 	
@@ -1707,7 +1806,9 @@  discard block
 block discarded – undo
1707 1806
 			}
1708 1807
 		}
1709 1808
 		$query .= " GROUP BY tracker_output.type ORDER BY tracker_type_count DESC";
1710
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1809
+		if ($limit) {
1810
+			$query .= " LIMIT 10 OFFSET 0";
1811
+		}
1711 1812
 		$sth = $this->db->prepare($query);
1712 1813
 		$sth->execute($query_values);
1713 1814
 		$tracker_array = array();
@@ -1753,7 +1854,9 @@  discard block
 block discarded – undo
1753 1854
 				foreach ($q_array as $q_item){
1754 1855
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1755 1856
 					$additional_query .= " AND (";
1756
-					if (is_int($q_item)) $additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1857
+					if (is_int($q_item)) {
1858
+						$additional_query .= "(tracker_output.tracker_id = '".$q_item."') OR ";
1859
+					}
1757 1860
 					$additional_query .= "(tracker_output.ident like '%".$q_item."%') OR ";
1758 1861
 					$additional_query .= ")";
1759 1862
 				}
@@ -1779,7 +1882,9 @@  discard block
 block discarded – undo
1779 1882
 				date_default_timezone_set($globalTimezone);
1780 1883
 				$datetime = new DateTime();
1781 1884
 				$offset = $datetime->format('P');
1782
-			} else $offset = '+00:00';
1885
+			} else {
1886
+				$offset = '+00:00';
1887
+			}
1783 1888
 			if ($date_array[1] != "")
1784 1889
 			{
1785 1890
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -1806,8 +1911,12 @@  discard block
 block discarded – undo
1806 1911
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1807 1912
 			{
1808 1913
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1809
-			} else $limit_query = "";
1810
-		} else $limit_query = "";
1914
+			} else {
1915
+				$limit_query = "";
1916
+			}
1917
+		} else {
1918
+			$limit_query = "";
1919
+		}
1811 1920
 		if ($sort != "")
1812 1921
 		{
1813 1922
 			$search_orderby_array = $this->getOrderBy();
@@ -1850,7 +1959,9 @@  discard block
 block discarded – undo
1850 1959
 	{
1851 1960
 		global $globalBitlyAccessToken;
1852 1961
 		
1853
-		if ($globalBitlyAccessToken == '') return $url;
1962
+		if ($globalBitlyAccessToken == '') {
1963
+			return $url;
1964
+		}
1854 1965
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1855 1966
 		$ch = curl_init();
1856 1967
 		curl_setopt($ch, CURLOPT_HEADER, 0);
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Braces   +86 added lines, -33 removed lines patch added patch discarded remove patch
@@ -76,8 +76,11 @@  discard block
 block discarded – undo
76 76
 				$globalDBSname = $globalDBname;
77 77
 				$globalDBSuser = $globalDBuser;
78 78
 				$globalDBSpass = $globalDBpass;
79
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
80
-				else $globalDBSport = $globalDBport;
79
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
80
+					$globalDBSport = 3306;
81
+				} else {
82
+					$globalDBSport = $globalDBport;
83
+				}
81 84
 			} else {
82 85
 				$DBname = 'default';
83 86
 				$globalDBSdriver = $globalDBdriver;
@@ -85,8 +88,11 @@  discard block
 block discarded – undo
85 88
 				$globalDBSname = $globalDBname;
86 89
 				$globalDBSuser = $user;
87 90
 				$globalDBSpass = $pass;
88
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
89
-				else $globalDBSport = $globalDBport;
91
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
92
+					$globalDBSport = 3306;
93
+				} else {
94
+					$globalDBSport = $globalDBport;
95
+				}
90 96
 			}
91 97
 		} else {
92 98
 			$globalDBSdriver = $globalDB[$DBname]['driver'];
@@ -94,12 +100,19 @@  discard block
 block discarded – undo
94 100
 			$globalDBSname = $globalDB[$DBname]['name'];
95 101
 			$globalDBSuser = $globalDB[$DBname]['user'];
96 102
 			$globalDBSpass = $globalDB[$DBname]['pass'];
97
-			if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port'];
98
-			else $globalDBSport = 3306;
103
+			if (isset($globalDB[$DBname]['port'])) {
104
+				$globalDBSport = $globalDB[$DBname]['port'];
105
+			} else {
106
+				$globalDBSport = 3306;
107
+			}
108
+		}
109
+		if ($globalDBSname == '' || $globalDBSuser == '') {
110
+			return false;
99 111
 		}
100
-		if ($globalDBSname == '' || $globalDBSuser == '') return false;
101 112
 		// Set number of try to connect to DB
102
-		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5;
113
+		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) {
114
+			$globalDBretry = 5;
115
+		}
103 116
 		$i = 0;
104 117
 		while (true) {
105 118
 			try {
@@ -108,10 +121,16 @@  discard block
 block discarded – undo
108 121
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
109 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
110 123
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
111
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
112
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
113
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
114
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
124
+					if (!isset($globalDBTimeOut)) {
125
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
126
+					} else {
127
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
128
+					}
129
+					if (!isset($globalDBPersistent)) {
130
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
131
+					} else {
132
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
133
+					}
115 134
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
116 135
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
117 136
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -125,24 +144,36 @@  discard block
 block discarded – undo
125 144
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
126 145
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
127 146
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
128
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
129
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
130
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
131
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
147
+					if (!isset($globalDBTimeOut)) {
148
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
149
+					} else {
150
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
151
+					}
152
+					if (!isset($globalDBPersistent)) {
153
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
154
+					} else {
155
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
156
+					}
132 157
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
133 158
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
134 159
 				}
135 160
 				break;
136 161
 			} catch(PDOException $e) {
137 162
 				$i++;
138
-				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
163
+				if (isset($globalDebug) && $globalDebug) {
164
+					echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
165
+				}
139 166
 				//exit;
140
-				if ($i > $globalDBretry) return false;
167
+				if ($i > $globalDBretry) {
168
+					return false;
169
+				}
141 170
 				//return false;
142 171
 			}
143 172
 			sleep(2);
144 173
 		}
145
-		if ($DBname === 'default') $this->db = $this->dbs['default'];
174
+		if ($DBname === 'default') {
175
+			$this->db = $this->dbs['default'];
176
+		}
146 177
 		return true;
147 178
 	}
148 179
 
@@ -154,7 +185,9 @@  discard block
 block discarded – undo
154 185
 		} else {
155 186
 			$query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'";
156 187
 		}
157
-		if ($this->db == NULL) return false;
188
+		if ($this->db == NULL) {
189
+			return false;
190
+		}
158 191
 		try {
159 192
 			//$Connection = new Connection();
160 193
 			$results = $this->db->query($query);
@@ -163,22 +196,31 @@  discard block
 block discarded – undo
163 196
 		}
164 197
 		if($results->rowCount()>0) {
165 198
 		    return true; 
199
+		} else {
200
+			return false;
166 201
 		}
167
-		else return false;
168 202
 	}
169 203
 
170 204
 	public function connectionExists()
171 205
 	{
172 206
 		global $globalDBCheckConnection, $globalNoDB;
173
-		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true;
174
-		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
207
+		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) {
208
+			return true;
209
+		}
210
+		if (isset($globalNoDB) && $globalNoDB === TRUE) {
211
+			return true;
212
+		}
175 213
 		$query = "SELECT 1 + 1";
176
-		if ($this->db === null) return false;
214
+		if ($this->db === null) {
215
+			return false;
216
+		}
177 217
 		try {
178 218
 			$sum = @$this->db->query($query);
179 219
 			if ($sum instanceof \PDOStatement) {
180 220
 				$sum = $sum->fetchColumn(0);
181
-			} else $sum = 0;
221
+			} else {
222
+				$sum = 0;
223
+			}
182 224
 			if (intval($sum) !== 2) {
183 225
 			     return false;
184 226
 			}
@@ -213,8 +255,9 @@  discard block
 block discarded – undo
213 255
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
214 256
 		if($nb[0]['nb'] > 0) {
215 257
 			return true; 
258
+		} else {
259
+			return false;
216 260
 		}
217
-		else return false;
218 261
 	}
219 262
 
220 263
 	/*
@@ -265,9 +308,12 @@  discard block
 block discarded – undo
265 308
 			}
266 309
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
267 310
 			$sth->closeCursor();
268
-			if ($result['nb'] > 0) return true;
269
-			else return false;
270
-/*		} else {
311
+			if ($result['nb'] > 0) {
312
+				return true;
313
+			} else {
314
+				return false;
315
+			}
316
+			/*		} else {
271 317
 			$query = "SELECT * FROM ".$table." LIMIT 0";
272 318
 			try {
273 319
 				$results = $this->db->query($query);
@@ -306,7 +352,9 @@  discard block
 block discarded – undo
306 352
 				$sth->closeCursor();
307 353
 				return $result['value'];
308 354
 			}
309
-		} else return $version;
355
+		} else {
356
+			return $version;
357
+		}
310 358
 	}
311 359
 	
312 360
 	/*
@@ -315,9 +363,14 @@  discard block
 block discarded – undo
315 363
 	*/
316 364
 	public function latest() {
317 365
 	    global $globalNoDB;
318
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
319
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
320
-	    else return false;
366
+	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
367
+	    	return true;
368
+	    }
369
+	    if ($this->check_schema_version() == $this->latest_schema) {
370
+	    	return true;
371
+	    } else {
372
+	    	return false;
373
+	    }
321 374
 	}
322 375
 
323 376
 }
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Braces   +87 added lines, -31 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. (Accident)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Accident)');
25
+		}
24 26
 	}
25 27
 
26 28
 	/*
@@ -126,8 +128,11 @@  discard block
 block discarded – undo
126 128
 				$data = array();
127 129
 				if ($row['registration'] != '') {
128 130
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
131
+					if (count($image_array) > 0) {
132
+						$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
133
+					} else {
134
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
135
+					}
131 136
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 137
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 138
 					if (!empty($aircraft_info)) {
@@ -143,17 +148,30 @@  discard block
 block discarded – undo
143 148
 						$data['aircraft_base'] = $owner_data['base'];
144 149
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 150
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
147
-				if ($row['registration'] == '') $row['registration'] = 'NA';
148
-				if ($row['ident'] == '') $row['ident'] = 'NA';
151
+				} else {
152
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
153
+				}
154
+				if ($row['registration'] == '') {
155
+					$row['registration'] = 'NA';
156
+				}
157
+				if ($row['ident'] == '') {
158
+					$row['ident'] = 'NA';
159
+				}
149 160
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
150 161
 				if (isset($identicao[0])) {
151 162
 					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
163
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
164
+							$icao = $row['ident'];
165
+						} else {
166
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
167
+						}
168
+					} else {
169
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
170
+					}
155 171
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
156
-				} else $icao = $row['ident'];
172
+				} else {
173
+					$icao = $row['ident'];
174
+				}
157 175
 				$icao = $Translation->checkTranslation($icao,false);
158 176
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 177
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -168,10 +186,14 @@  discard block
 block discarded – undo
168 186
 					//else echo 'No data...'."\n";
169 187
 				}
170 188
 				$data = array_merge($row,$data);
171
-				if ($data['ident'] == null) $data['ident'] = $icao;
189
+				if ($data['ident'] == null) {
190
+					$data['ident'] = $icao;
191
+				}
172 192
 				if ($data['title'] == null) {
173 193
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174
-				} else $data['message'] = strtolower($data['title']);
194
+				} else {
195
+					$data['message'] = strtolower($data['title']);
196
+				}
175 197
 				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
176 198
 				$date = $data['date'];
177 199
 				if (isset($ids[$date])) {
@@ -190,8 +212,9 @@  discard block
 block discarded – undo
190 212
 		if (isset($result)) {
191 213
 			$result[0]['query_number_rows'] = $i;
192 214
 			return $result;
215
+		} else {
216
+			return array();
193 217
 		}
194
-		else return array();
195 218
 	}
196 219
 
197 220
 	/*
@@ -238,7 +261,9 @@  discard block
 block discarded – undo
238 261
 	*/
239 262
 	public function import($file) {
240 263
 		global $globalDebug;
241
-		if ($globalDebug) echo 'Import '.$file."\n";
264
+		if ($globalDebug) {
265
+			echo 'Import '.$file."\n";
266
+		}
242 267
 		$result = array();
243 268
 		if (file_exists($file)) {
244 269
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -249,8 +274,11 @@  discard block
 block discarded – undo
249 274
 				}
250 275
 				fclose($handle);
251 276
 			}
252
-			if (!empty($result)) $this->add($result,true);
253
-			elseif ($globalDebug) echo 'Nothing to import';
277
+			if (!empty($result)) {
278
+				$this->add($result,true);
279
+			} elseif ($globalDebug) {
280
+				echo 'Nothing to import';
281
+			}
254 282
 		}
255 283
 	}
256 284
 
@@ -286,14 +314,23 @@  discard block
 block discarded – undo
286 314
 					}
287 315
 				}
288 316
 				fclose($handle);
289
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
317
+			} elseif ($globalDebug) {
318
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
319
+			}
320
+		} elseif ($globalDebug) {
321
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
322
+		}
291 323
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
292
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
324
+		if (empty($result) && $globalDebug) {
325
+			echo 'Nothing to update';
326
+		}
293 327
 		foreach ($result as $file => $md5) {
294 328
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
295
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
329
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
330
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
331
+			} elseif ($globalDebug) {
332
+				echo 'Download '.$file.' failed';
333
+			}
297 334
 		}
298 335
 	}
299 336
 
@@ -310,13 +347,17 @@  discard block
 block discarded – undo
310 347
 		$Image = new Image($this->db);
311 348
 		$Spotter = new Spotter($this->db);
312 349
 
313
-		if (empty($crash)) return false;
350
+		if (empty($crash)) {
351
+			return false;
352
+		}
314 353
 		if ($new === false) {
315 354
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
316 355
 			$sthd = $Connection->db->prepare($query_delete);
317 356
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 357
 		}
319
-		if ($globalTransaction) $Connection->db->beginTransaction();
358
+		if ($globalTransaction) {
359
+			$Connection->db->beginTransaction();
360
+		}
320 361
 		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
321 362
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 363
 		$sth_check = $Connection->db->prepare($query_check);
@@ -331,7 +372,9 @@  discard block
 block discarded – undo
331 372
 					return $value === "" ? NULL : $value;
332 373
 				}, $cr);
333 374
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
375
+					if (strpos($cr['registration'],'-') === FALSE) {
376
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
377
+					}
335 378
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
336 379
 					$sth_check->execute($query_check_values);
337 380
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
@@ -342,13 +385,19 @@  discard block
 block discarded – undo
342 385
 							if ($globalAircraftImageFetch) {
343 386
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 387
 								if (empty($imgchk)) {
345
-									if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
388
+									if ($globalDebug) {
389
+										echo "\t".'Get image for '.$cr['registration'].'...';
390
+									}
346 391
 									$Image->addSpotterImage($cr['registration']);
347
-									if ($globalDebug) echo "\t".'Done'."\n";
392
+									if ($globalDebug) {
393
+										echo "\t".'Done'."\n";
394
+									}
348 395
 								}
349 396
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 397
 							}
351
-							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
398
+							if ($cr['title'] == '') {
399
+								$cr['title'] = $cr['registration'].' '.$cr['type'];
400
+							}
352 401
 							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
353 402
 						}
354 403
 					}
@@ -358,9 +407,13 @@  discard block
 block discarded – undo
358 407
 					$Connection->db->beginTransaction();
359 408
 				}
360 409
 			}
361
-			if ($globalTransaction) $Connection->db->commit();
410
+			if ($globalTransaction) {
411
+				$Connection->db->commit();
412
+			}
362 413
 		} catch(PDOException $e) {
363
-			if ($globalTransaction) $Connection->db->rollBack();
414
+			if ($globalTransaction) {
415
+				$Connection->db->rollBack();
416
+			}
364 417
 			echo $e->getMessage();
365 418
 		}
366 419
 		$sth_check->closeCursor();
@@ -403,8 +456,11 @@  discard block
 block discarded – undo
403 456
 			return "error : ".$e->getMessage();
404 457
 		}
405 458
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
406
-		if ($row['nb'] > 0) return false;
407
-		else return true;
459
+		if ($row['nb'] > 0) {
460
+			return false;
461
+		} else {
462
+			return true;
463
+		}
408 464
 	}
409 465
 
410 466
     /**
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Braces   +170 added lines, -57 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (SpotterLive)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (SpotterLive)');
13
+		}
12 14
 	}
13 15
 
14 16
 
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -129,8 +133,11 @@  discard block
 block discarded – undo
129 133
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
130 134
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
131 135
 		}
132
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
133
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
136
+		if ($filter_query_where == '' && $where) {
137
+			$filter_query_where = ' WHERE';
138
+		} elseif ($filter_query_where != '' && $and) {
139
+			$filter_query_where .= ' AND';
140
+		}
134 141
 		if ($filter_query_where != '') {
135 142
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
136 143
 		}
@@ -173,9 +180,13 @@  discard block
 block discarded – undo
173 180
 				$orderby_query = ' '.$search_orderby_array[$sort]['sql'];
174 181
 			}
175 182
 		}
176
-		if ($orderby_query == '') $orderby_query = ' ORDER BY date DESC';
183
+		if ($orderby_query == '') {
184
+			$orderby_query = ' ORDER BY date DESC';
185
+		}
177 186
 
178
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
187
+		if (!isset($globalLiveInterval)) {
188
+			$globalLiveInterval = '200';
189
+		}
179 190
 		if ($globalDBdriver == 'mysql') {
180 191
 			//$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
181 192
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query;
@@ -199,7 +210,9 @@  discard block
 block discarded – undo
199 210
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap2DAircraftsLimit;
200 211
 		date_default_timezone_set('UTC');
201 212
 		$filter_query = $this->getFilter($filter,true,true);
202
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
213
+		if (!isset($globalLiveInterval)) {
214
+			$globalLiveInterval = '200';
215
+		}
203 216
 		if ($globalDBdriver == 'mysql') {
204 217
 			if (isset($globalArchive) && $globalArchive === TRUE) {
205 218
 			//	$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
@@ -263,14 +276,22 @@  discard block
 block discarded – undo
263 276
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
264 277
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
265 278
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
266
-			if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') $usecoord = true;
279
+			if ($minlong != '' && $minlat != '' && $maxlong != '' && $maxlat != '') {
280
+				$usecoord = true;
281
+			}
267 282
 		}
268 283
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
269 284
 		$filter_query = $this->getFilter($filter,true,true);
270 285
 
271
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
272
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
273
-		if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit;
286
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
287
+			$globalLiveInterval = '200';
288
+		}
289
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
290
+			$globalMap3DAircraftsLimit = '300';
291
+		}
292
+		if ($limit == 0 || $limit == '') {
293
+			$limit = $globalMap3DAircraftsLimit;
294
+		}
274 295
 		if ($globalDBdriver == 'mysql') {
275 296
 			if (isset($globalArchive) && $globalArchive === TRUE) {
276 297
 				/*
@@ -283,26 +304,42 @@  discard block
 block discarded – undo
283 304
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
284 305
 				//if ($limit > 0) $query .= " LIMIT ".$limit;
285 306
 				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
286
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
287
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
307
+				if ($usecoord) {
308
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
309
+				}
310
+				if ($id != '') {
311
+					$query .= "OR spotter_archive.flightaware_id = :id ";
312
+				}
288 313
 				$query .= "UNION
289 314
 				SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
290 315
 				FROM spotter_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date";
291
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
292
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
316
+				if ($usecoord) {
317
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
318
+				}
319
+				if ($id != '') {
320
+					$query .= " OR spotter_live.flightaware_id = :id";
321
+				}
293 322
 				//if ($limit > 0) $query .= " LIMIT ".$limit;
294 323
 				$query .= ") AS spotter 
295 324
 				WHERE latitude <> '0' AND longitude <> '0' 
296 325
 				ORDER BY flightaware_id, date";
297
-				if ($limit > 0) $query .= " LIMIT ".$limit;
326
+				if ($limit > 0) {
327
+					$query .= " LIMIT ".$limit;
328
+				}
298 329
 			} else {
299 330
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
300 331
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date ";
301
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
302
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
332
+				if ($usecoord) {
333
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
334
+				}
335
+				if ($id != '') {
336
+					$query .= "OR spotter_live.flightaware_id = :id ";
337
+				}
303 338
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
304 339
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
305
-				if ($limit > 0) $query .= " LIMIT ".$limit;
340
+				if ($limit > 0) {
341
+					$query .= " LIMIT ".$limit;
342
+				}
306 343
 			}
307 344
 		} else {
308 345
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -320,29 +357,47 @@  discard block
 block discarded – undo
320 357
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
321 358
 				//if ($limit > 0) $query .= " ORDER BY spotter_live.date ASC LIMIT ".$limit;
322 359
 				$query .= ") l ON l.flightaware_id = spotter_archive.flightaware_id ";
323
-				if ($usecoord) $query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
324
-				if ($id != '') $query .= "OR spotter_archive.flightaware_id = :id ";
360
+				if ($usecoord) {
361
+					$query .= "AND (spotter_archive.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_archive.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
362
+				}
363
+				if ($id != '') {
364
+					$query .= "OR spotter_archive.flightaware_id = :id ";
365
+				}
325 366
 				$query .= "UNION
326 367
 				    SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
327 368
 				    FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date";
328
-				if ($usecoord) $query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
329
-				if ($id != '') $query .= " OR spotter_live.flightaware_id = :id";
369
+				if ($usecoord) {
370
+					$query .= " AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")";
371
+				}
372
+				if ($id != '') {
373
+					$query .= " OR spotter_live.flightaware_id = :id";
374
+				}
330 375
 				//if ($limit > 0) $query .= " ORDER BY date ASC LIMIT ".$limit;
331 376
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
332 377
 				$query .= "ORDER BY flightaware_id, date";
333
-				if ($limit > 0) $query .= " LIMIT ".$limit;
378
+				if ($limit > 0) {
379
+					$query .= " LIMIT ".$limit;
380
+				}
334 381
 			} else {
335 382
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
336 383
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date ";
337
-				if ($usecoord) $query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
338
-				if ($id != '') $query .= "OR spotter_live.flightaware_id = :id ";
384
+				if ($usecoord) {
385
+					$query .= "AND (spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.") ";
386
+				}
387
+				if ($id != '') {
388
+					$query .= "OR spotter_live.flightaware_id = :id ";
389
+				}
339 390
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
340 391
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
341
-				if ($limit > 0) $query .= " LIMIT ".$limit;
392
+				if ($limit > 0) {
393
+					$query .= " LIMIT ".$limit;
394
+				}
342 395
 			}
343 396
 		}
344 397
 		$query_values = array();
345
-		if ($id != '') $query_values = array(':id' => $id);
398
+		if ($id != '') {
399
+			$query_values = array(':id' => $id);
400
+		}
346 401
 		try {
347 402
 			$sth = $this->db->prepare($query);
348 403
 			$sth->execute($query_values);
@@ -369,9 +424,15 @@  discard block
 block discarded – undo
369 424
 		$id = filter_var($id,FILTER_SANITIZE_STRING);
370 425
 		$filter_query = $this->getFilter($filter,true,true);
371 426
 
372
-		if (!isset($globalLiveInterval) || $globalLiveInterval == '') $globalLiveInterval = '200';
373
-		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') $globalMap3DAircraftsLimit = '300';
374
-		if ($limit == 0 || $limit == '') $limit = $globalMap3DAircraftsLimit;
427
+		if (!isset($globalLiveInterval) || $globalLiveInterval == '') {
428
+			$globalLiveInterval = '200';
429
+		}
430
+		if (!isset($globalMap3DAircraftsLimit) || $globalMap3DAircraftsLimit == '') {
431
+			$globalMap3DAircraftsLimit = '300';
432
+		}
433
+		if ($limit == 0 || $limit == '') {
434
+			$limit = $globalMap3DAircraftsLimit;
435
+		}
375 436
 		if ($globalDBdriver == 'mysql') {
376 437
 			if (isset($globalArchive) && $globalArchive === TRUE) {
377 438
 				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source, spotter_archive.registration 
@@ -382,13 +443,17 @@  discard block
 block discarded – undo
382 443
 				$query .= ") AS spotter 
383 444
 				WHERE latitude <> '0' AND longitude <> '0' 
384 445
 				ORDER BY flightaware_id, date";
385
-				if ($limit > 0) $query .= " LIMIT ".$limit;
446
+				if ($limit > 0) {
447
+					$query .= " LIMIT ".$limit;
448
+				}
386 449
 			} else {
387 450
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
388 451
 				FROM spotter_live'.$filter_query.' spotter_live.flightaware_id = :id ';
389 452
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
390 453
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
391
-				if ($limit > 0) $query .= " LIMIT ".$limit;
454
+				if ($limit > 0) {
455
+					$query .= " LIMIT ".$limit;
456
+				}
392 457
 			}
393 458
 		} else {
394 459
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -404,13 +469,17 @@  discard block
 block discarded – undo
404 469
 				    FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id";
405 470
 				$query .= ") AS spotter WHERE latitude <> '0' AND longitude <> '0' ";
406 471
 				$query .= "ORDER BY flightaware_id, date";
407
-				if ($limit > 0) $query .= " LIMIT ".$limit;
472
+				if ($limit > 0) {
473
+					$query .= " LIMIT ".$limit;
474
+				}
408 475
 			} else {
409 476
 				$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
410 477
 				FROM spotter_live".$filter_query." spotter_live.flightaware_id = :id ";
411 478
 				$query .= "AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
412 479
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
413
-				if ($limit > 0) $query .= " LIMIT ".$limit;
480
+				if ($limit > 0) {
481
+					$query .= " LIMIT ".$limit;
482
+				}
414 483
 			}
415 484
 		}
416 485
 		$query_values = array(':id' => $id);
@@ -436,7 +505,9 @@  discard block
 block discarded – undo
436 505
 		global $globalDBdriver, $globalLiveInterval;
437 506
 		$filter_query = $this->getFilter($filter,true,true);
438 507
 
439
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
508
+		if (!isset($globalLiveInterval)) {
509
+			$globalLiveInterval = '200';
510
+		}
440 511
 		if ($globalDBdriver == 'mysql') {
441 512
 			//$query  = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query;
442 513
 			$query = 'SELECT COUNT(DISTINCT spotter_live.flightaware_id) as nb FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
@@ -467,7 +538,9 @@  discard block
 block discarded – undo
467 538
 	{
468 539
 		global $globalDBdriver, $globalLiveInterval,$globalMap2DAircraftsLimit;
469 540
 		$Spotter = new Spotter($this->db);
470
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
541
+		if (!isset($globalLiveInterval)) {
542
+			$globalLiveInterval = '200';
543
+		}
471 544
 		$filter_query = $this->getFilter($filter);
472 545
 
473 546
 		if (is_array($coord)) {
@@ -475,7 +548,9 @@  discard block
 block discarded – undo
475 548
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
476 549
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
477 550
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
478
-		} else return array();
551
+		} else {
552
+			return array();
553
+		}
479 554
 		if ($globalDBdriver == 'mysql') {
480 555
 			$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query;
481 556
 		} else {
@@ -500,7 +575,9 @@  discard block
 block discarded – undo
500 575
 	public function getMinLiveSpotterDatabyCoord($coord,$limit = 0, $filter = array())
501 576
 	{
502 577
 		global $globalDBdriver, $globalLiveInterval, $globalArchive,$globalMap2DAircraftsLimit;
503
-		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
578
+		if (!isset($globalLiveInterval)) {
579
+			$globalLiveInterval = '200';
580
+		}
504 581
 		$filter_query = $this->getFilter($filter,true,true);
505 582
 
506 583
 		if (is_array($coord)) {
@@ -508,7 +585,9 @@  discard block
 block discarded – undo
508 585
 			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
509 586
 			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
510 587
 			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
511
-		} else return array();
588
+		} else {
589
+			return array();
590
+		}
512 591
 		if ($globalDBdriver == 'mysql') {
513 592
 			if (isset($globalArchive) && $globalArchive === TRUE) {
514 593
 				$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.real_altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, spotter_live.date, spotter_live.format_source, spotter_live.registration 
@@ -763,11 +842,15 @@  discard block
 block discarded – undo
763 842
 		//$query  = self::$global_query.' WHERE spotter_live.flightaware_id = :id ORDER BY date';
764 843
 		if ($globalDBdriver == 'mysql') {
765 844
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
766
-			if ($liveinterval) $query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
845
+			if ($liveinterval) {
846
+				$query .= ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date';
847
+			}
767 848
 			$query .= ' ORDER BY date';
768 849
 		} else {
769 850
 			$query = 'SELECT spotter_live.* FROM spotter_live WHERE spotter_live.flightaware_id = :id';
770
-			if ($liveinterval) $query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
851
+			if ($liveinterval) {
852
+				$query .= " AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= date";
853
+			}
771 854
 			$query .= ' ORDER BY date';
772 855
 		}
773 856
 
@@ -862,7 +945,9 @@  discard block
 block discarded – undo
862 945
 				$i++;
863 946
 				$j++;
864 947
 				if ($j == 30) {
865
-					if ($globalDebug) echo ".";
948
+					if ($globalDebug) {
949
+						echo ".";
950
+					}
866 951
 				    	try {
867 952
 						
868 953
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
@@ -1237,7 +1322,9 @@  discard block
 block discarded – undo
1237 1322
 			{
1238 1323
 				return false;
1239 1324
 			}
1240
-		} else return '';
1325
+		} else {
1326
+			return '';
1327
+		}
1241 1328
 
1242 1329
 		if ($longitude != '')
1243 1330
 		{
@@ -1245,7 +1332,9 @@  discard block
 block discarded – undo
1245 1332
 			{
1246 1333
 				return false;
1247 1334
 			}
1248
-		} else return '';
1335
+		} else {
1336
+			return '';
1337
+		}
1249 1338
 
1250 1339
 		if ($waypoints != '')
1251 1340
 		{
@@ -1261,14 +1350,18 @@  discard block
 block discarded – undo
1261 1350
 			{
1262 1351
 				return false;
1263 1352
 			}
1264
-		} else $altitude = 0;
1353
+		} else {
1354
+			$altitude = 0;
1355
+		}
1265 1356
 		if ($altitude_real != '')
1266 1357
 		{
1267 1358
 			if (!is_numeric($altitude_real))
1268 1359
 			{
1269 1360
 				return false;
1270 1361
 			}
1271
-		} else $altitude_real = 0;
1362
+		} else {
1363
+			$altitude_real = 0;
1364
+		}
1272 1365
 
1273 1366
 		if ($heading != '')
1274 1367
 		{
@@ -1276,7 +1369,9 @@  discard block
 block discarded – undo
1276 1369
 			{
1277 1370
 				return false;
1278 1371
 			}
1279
-		} else $heading = 0;
1372
+		} else {
1373
+			$heading = 0;
1374
+		}
1280 1375
 
1281 1376
 		if ($groundspeed != '')
1282 1377
 		{
@@ -1284,9 +1379,13 @@  discard block
 block discarded – undo
1284 1379
 			{
1285 1380
 				return false;
1286 1381
 			}
1287
-		} else $groundspeed = 0;
1382
+		} else {
1383
+			$groundspeed = 0;
1384
+		}
1288 1385
 		date_default_timezone_set('UTC');
1289
-		if ($date == '') $date = date("Y-m-d H:i:s", time());
1386
+		if ($date == '') {
1387
+			$date = date("Y-m-d H:i:s", time());
1388
+		}
1290 1389
 
1291 1390
         
1292 1391
 		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
@@ -1331,14 +1430,24 @@  discard block
 block discarded – undo
1331 1430
 		$arrival_airport_country = '';
1332 1431
 		
1333 1432
             	
1334
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1335
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1336
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1337
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1433
+            	if ($squawk == '' || $Common->isInteger($squawk) === false ) {
1434
+            		$squawk = NULL;
1435
+            	}
1436
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) {
1437
+            		$verticalrate = NULL;
1438
+            	}
1439
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) {
1440
+            		$groundspeed = 0;
1441
+            	}
1442
+            	if ($heading == '' || $Common->isInteger($heading) === false ) {
1443
+            		$heading = 0;
1444
+            	}
1338 1445
 		
1339 1446
 		$query = '';
1340 1447
 		if ($globalArchive) {
1341
-			if ($globalDebug) echo '-- Delete previous data -- ';
1448
+			if ($globalDebug) {
1449
+				echo '-- Delete previous data -- ';
1450
+			}
1342 1451
 			$query .= 'DELETE FROM spotter_live WHERE flightaware_id = :flightaware_id;';
1343 1452
 		}
1344 1453
 
@@ -1355,10 +1464,14 @@  discard block
 block discarded – undo
1355 1464
 			return "error : ".$e->getMessage();
1356 1465
 		}
1357 1466
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1358
-		    if ($globalDebug) echo '(Add to Spotter archive : ';
1467
+		    if ($globalDebug) {
1468
+		    	echo '(Add to Spotter archive : ';
1469
+		    }
1359 1470
 		    $SpotterArchive = new SpotterArchive($this->db);
1360 1471
 		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1361
-		    if ($globalDebug) echo $result.')';
1472
+		    if ($globalDebug) {
1473
+		    	echo $result.')';
1474
+		    }
1362 1475
 		} elseif ($globalDebug && $putinarchive !== true) {
1363 1476
 			echo '(Not adding to archive)';
1364 1477
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.