Completed
Push — master ( 6c4f55...213543 )
by Yannick
10:31
created
require/class.SpotterArchive.php 1 patch
Spacing   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -13,62 +13,62 @@  discard block
 block discarded – undo
13 13
     * @param Array $filter the filter
14 14
     * @return Array the SQL part
15 15
     */
16
-    public function getFilter($filter = array(),$where = false,$and = false) {
16
+    public function getFilter($filter = array(), $where = false, $and = false) {
17 17
 	global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
18 18
 	$filters = array();
19 19
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
20 20
 		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21 21
 			$filters = $globalStatsFilters[$globalFilterName];
22 22
 		} else {
23
-			$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
23
+			$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
24 24
 		}
25 25
 	}
26 26
 	if (isset($filter[0]['source'])) {
27
-		$filters = array_merge($filters,$filter);
27
+		$filters = array_merge($filters, $filter);
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32
-	foreach($filters as $flt) {
32
+	foreach ($filters as $flt) {
33 33
 	    if (isset($flt['airlines']) && !empty($flt['airlines'])) {
34 34
 		if ($flt['airlines'][0] != '') {
35 35
 		    if (isset($flt['source'])) {
36
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
36
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
37 37
 		    } else {
38
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
38
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saff ON saff.flightaware_id = spotter_archive_output.flightaware_id";
39 39
 		    }
40 40
 		}
41 41
 	    }
42 42
 	    if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
43 43
 		if (isset($flt['source'])) {
44
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
44
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
45 45
 		} else {
46
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
46
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) sp ON sp.flightaware_id = spotter_archive_output.flightaware_id";
47 47
 		}
48 48
 	    }
49 49
 	    if (isset($flt['idents']) && !empty($flt['idents'])) {
50 50
 		if (isset($flt['source'])) {
51
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
51
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
52 52
 		} else {
53
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
53
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
54 54
 		}
55 55
 	    }
56 56
 	    if (isset($flt['registrations']) && !empty($flt['registrations'])) {
57 57
 		if (isset($flt['source'])) {
58
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
58
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_archive_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
59 59
 		} else {
60
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
60
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_archive_output.flightaware_id";
61 61
 		}
62 62
 	    }
63 63
 	    if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents']) && isset($flt['registrations']) && empty($flt['registrations'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
64 64
 		if (isset($flt['source'])) {
65
-		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
65
+		    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saa ON saa.flightaware_id = spotter_archive_output.flightaware_id";
66 66
 		}
67 67
 	    }
68 68
 	}
69 69
 	if (isset($filter['airlines']) && !empty($filter['airlines'])) {
70 70
 	    if ($filter['airlines'][0] != '') {
71
-		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
71
+		$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) saf ON saf.flightaware_id = spotter_archive_output.flightaware_id";
72 72
 	    }
73 73
 	}
74 74
 	
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
 	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive_output.flightaware_id ";
77 77
 	}
78 78
 	if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
79
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
79
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) spi ON spi.flightaware_id = spotter_archive_output.flightaware_id";
80 80
 	}
81 81
 	if (isset($filter['source']) && !empty($filter['source'])) {
82
-	    $filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
82
+	    $filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
83 83
 	}
84 84
 	if (isset($filter['ident']) && !empty($filter['ident'])) {
85 85
 	    $filter_query_where .= " AND ident = '".$filter['ident']."'";
86 86
 	}
87 87
 	if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
88
-		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
88
+		$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
89 89
 	}
90 90
 	if ((isset($filter['year']) && $filter['year'] != '') || (isset($filter['month']) && $filter['month'] != '') || (isset($filter['day']) && $filter['day'] != '')) {
91 91
 	    $filter_query_date = '';
@@ -111,40 +111,40 @@  discard block
 block discarded – undo
111 111
 		    $filter_query_date .= " AND EXTRACT(DAY FROM spotter_archive_output.date) = '".$filter['day']."'";
112 112
 		}
113 113
 	    }
114
-	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
114
+	    $filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_archive_output.flightaware_id";
115 115
 	}
116 116
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
117 117
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
118 118
 	if ($filter_query_where != '') {
119
-		$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
119
+		$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
120 120
 	}
121 121
 	$filter_query = $filter_query_join.$filter_query_where;
122 122
 	return $filter_query;
123 123
     }
124 124
 
125 125
 	// Spotter_archive
126
-	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '',$arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city ='', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '',$latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '',$verticalrate = '',$format_source = '', $source_name = '', $over_country = '') {
126
+	public function addSpotterArchiveData($flightaware_id = '', $ident = '', $registration = '', $airline_name = '', $airline_icao = '', $airline_country = '', $airline_type = '', $aircraft_icao = '', $aircraft_shadow = '', $aircraft_name = '', $aircraft_manufacturer = '', $departure_airport_icao = '', $departure_airport_name = '', $departure_airport_city = '', $departure_airport_country = '', $departure_airport_time = '', $arrival_airport_icao = '', $arrival_airport_name = '', $arrival_airport_city = '', $arrival_airport_country = '', $arrival_airport_time = '', $route_stop = '', $date = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $heading = '', $ground_speed = '', $squawk = '', $ModeS = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $format_source = '', $source_name = '', $over_country = '') {
127 127
 		require_once(dirname(__FILE__).'/class.Spotter.php');
128 128
 		if ($over_country == '') {
129 129
 			$Spotter = new Spotter($this->db);
130
-			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude);
130
+			$data_country = $Spotter->getCountryFromLatitudeLongitude($latitude, $longitude);
131 131
 			if (!empty($data_country)) $country = $data_country['iso2'];
132 132
 			else $country = '';
133 133
 		} else $country = $over_country;
134
-		if ($airline_type === NULL) $airline_type ='';
134
+		if ($airline_type === NULL) $airline_type = '';
135 135
 	
136 136
 		//if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n";
137 137
 		//else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n";
138 138
 
139 139
 		// Route is not added in spotter_archive
140
-		$query  = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
140
+		$query = "INSERT INTO spotter_archive (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, departure_airport_time,arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, arrival_airport_time, route_stop, date,latitude, longitude, waypoints, altitude, heading, ground_speed, squawk, ModeS, pilot_id, pilot_name, verticalrate,format_source,over_country,source_name)
141 141
 		        VALUES (:flightaware_id, :ident, :registration, :airline_name, :airline_icao, :airline_country, :airline_type, :aircraft_icao, :aircraft_shadow, :aircraft_name, :aircraft_manufacturer, :departure_airport_icao, :departure_airport_name, :departure_airport_city, :departure_airport_country, :departure_airport_time,:arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :arrival_airport_time, :route_stop, :date,:latitude, :longitude, :waypoints, :altitude, :heading, :ground_speed, :squawk, :ModeS, :pilot_id, :pilot_name, :verticalrate, :format_source, :over_country, :source_name)";
142 142
 
143
-		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date,':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
143
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_name' => $aircraft_name, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':arrival_airport_time' => $arrival_airport_time, ':route_stop' => $route_stop, ':date' => $date, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':ground_speed' => $ground_speed, ':squawk' => $squawk, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':over_country' => $country, ':source_name' => $source_name);
144 144
 		try {
145 145
 			$sth = $this->db->prepare($query);
146 146
 			$sth->execute($query_values);
147
-		} catch(PDOException $e) {
147
+		} catch (PDOException $e) {
148 148
 			return "error : ".$e->getMessage();
149 149
 		}
150 150
 		return "success";
@@ -164,9 +164,9 @@  discard block
 block discarded – undo
164 164
 
165 165
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
166 166
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
167
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
167
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
168 168
 
169
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
169
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
170 170
 
171 171
                 return $spotter_array;
172 172
         }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
186 186
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
187 187
                 //$query  = "SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
188
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
188
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
189 189
 
190 190
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
191 191
                   /*
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
                 }
199 199
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
200 200
                 */
201
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
201
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
202 202
 
203 203
                 return $spotter_array;
204 204
         }
@@ -213,14 +213,14 @@  discard block
 block discarded – undo
213 213
         {
214 214
                 date_default_timezone_set('UTC');
215 215
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
216
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
216
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
217 217
 
218 218
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
219 219
 
220 220
                 try {
221 221
                         $sth = $this->db->prepare($query);
222 222
                         $sth->execute(array(':id' => $id));
223
-                } catch(PDOException $e) {
223
+                } catch (PDOException $e) {
224 224
                         echo $e->getMessage();
225 225
                         die;
226 226
                 }
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
         {
240 240
                 date_default_timezone_set('UTC');
241 241
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
242
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
242
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
243 243
 
244 244
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
245 245
 
246 246
                 try {
247 247
                         $sth = $this->db->prepare($query);
248 248
                         $sth->execute(array(':id' => $id));
249
-                } catch(PDOException $e) {
249
+                } catch (PDOException $e) {
250 250
                         echo $e->getMessage();
251 251
                         die;
252 252
                 }
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
                 date_default_timezone_set('UTC');
269 269
 
270 270
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
271
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
271
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
272 272
 
273 273
                 try {
274 274
                         $sth = $this->db->prepare($query);
275 275
                         $sth->execute(array(':ident' => $ident));
276
-                } catch(PDOException $e) {
276
+                } catch (PDOException $e) {
277 277
                         echo $e->getMessage();
278 278
                         die;
279 279
                 }
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
                 date_default_timezone_set('UTC');
295 295
 
296 296
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
297
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
297
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id AND spotter_archive.latitude <> 0 AND spotter_archive.longitude <> 0 ORDER BY date";
298 298
 
299 299
                 try {
300 300
                         $sth = $this->db->prepare($query);
301 301
                         $sth->execute(array(':id' => $id));
302
-                } catch(PDOException $e) {
302
+                } catch (PDOException $e) {
303 303
                         echo $e->getMessage();
304 304
                         die;
305 305
                 }
@@ -320,12 +320,12 @@  discard block
 block discarded – undo
320 320
                 date_default_timezone_set('UTC');
321 321
 
322 322
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
323
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
323
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
324 324
 
325 325
                 try {
326 326
                         $sth = $this->db->prepare($query);
327 327
                         $sth->execute(array(':id' => $id));
328
-                } catch(PDOException $e) {
328
+                } catch (PDOException $e) {
329 329
                         echo $e->getMessage();
330 330
                         die;
331 331
                 }
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
                 date_default_timezone_set('UTC');
348 348
 
349 349
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
350
-                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
350
+                $query = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate LIMIT 1";
351 351
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
352 352
 
353 353
                 try {
354 354
                         $sth = $this->db->prepare($query);
355 355
                         $sth->execute(array(':ident' => $ident));
356
-                } catch(PDOException $e) {
356
+                } catch (PDOException $e) {
357 357
                         echo $e->getMessage();
358 358
                         die;
359 359
                 }
@@ -370,13 +370,13 @@  discard block
 block discarded – undo
370 370
         * @return Array the spotter information
371 371
         *
372 372
         */
373
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
373
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
374 374
         {
375 375
     		$Spotter = new Spotter($this->db);
376 376
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
377
-                $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
377
+                $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.flightaware_id = :flightaware_id AND l.date LIKE :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate";
378 378
 
379
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
379
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
380 380
 
381 381
                 return $spotter_array;
382 382
         }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
                 try {
390 390
                         $sth = $this->db->prepare($query);
391 391
                         $sth->execute();
392
-                } catch(PDOException $e) {
392
+                } catch (PDOException $e) {
393 393
                         echo $e->getMessage();
394 394
                         die;
395 395
                 }
@@ -401,24 +401,24 @@  discard block
 block discarded – undo
401 401
         * @return Array the spotter information
402 402
         *
403 403
         */
404
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
404
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
405 405
         {
406 406
                 global $globalDBdriver, $globalLiveInterval;
407 407
                 date_default_timezone_set('UTC');
408 408
 
409 409
                 $filter_query = '';
410 410
                 if (isset($filter['source']) && !empty($filter['source'])) {
411
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
411
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
412 412
                 }
413 413
                 // Use spotter_output also ?
414 414
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
415
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
415
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
416 416
                 }
417 417
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
418 418
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
419 419
                 }
420 420
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
421
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
421
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
422 422
                 }
423 423
 
424 424
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -437,14 +437,14 @@  discard block
 block discarded – undo
437 437
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
438 438
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
439 439
 */
440
-			$query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
440
+			$query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
441 441
 				    FROM spotter_archive 
442 442
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
443 443
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
444 444
                         	    '.$filter_query.' ORDER BY flightaware_id';
445 445
                 } else {
446 446
                         //$query  = 'SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao';
447
-                        $query  = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
447
+                        $query = 'SELECT spotter_archive.date,spotter_archive.flightaware_id, spotter_archive.ident, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
448 448
                         	    FROM spotter_archive 
449 449
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
450 450
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
                 try {
455 455
                         $sth = $this->db->prepare($query);
456 456
                         $sth->execute();
457
-                } catch(PDOException $e) {
457
+                } catch (PDOException $e) {
458 458
                         echo $e->getMessage();
459 459
                         die;
460 460
                 }
@@ -469,24 +469,24 @@  discard block
 block discarded – undo
469 469
         * @return Array the spotter information
470 470
         *
471 471
         */
472
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
472
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
473 473
         {
474 474
                 global $globalDBdriver, $globalLiveInterval;
475 475
                 date_default_timezone_set('UTC');
476 476
 
477 477
                 $filter_query = '';
478 478
                 if (isset($filter['source']) && !empty($filter['source'])) {
479
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
479
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
480 480
                 }
481 481
                 // Should use spotter_output also ?
482 482
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
483
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
483
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
484 484
                 }
485 485
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
486 486
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_archive_output WHERE spotter_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
487 487
                 }
488 488
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
489
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
489
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
490 490
                 }
491 491
 
492 492
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
                     		    FROM spotter_archive 
497 497
                     		    INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
498 498
 			*/
499
-			$query  = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
499
+			$query = 'SELECT a.aircraft_shadow, spotter_archive_output.ident, spotter_archive_output.flightaware_id, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk 
500 500
 				    FROM spotter_archive_output 
501 501
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
502 502
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
512 512
                         	    '.$filter_query.' GROUP BY spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao, spotter_archive_output.arrival_airport_icao, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow';
513 513
                         */
514
-                        $query  = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
514
+                        $query = 'SELECT DISTINCT spotter_archive_output.flightaware_id, spotter_archive_output.ident, spotter_archive_output.aircraft_icao, spotter_archive_output.departure_airport_icao as departure_airport, spotter_archive_output.arrival_airport_icao as arrival_airport, spotter_archive_output.latitude, spotter_archive_output.longitude, spotter_archive_output.altitude, spotter_archive_output.heading, spotter_archive_output.ground_speed, spotter_archive_output.squawk, a.aircraft_shadow
515 515
                         	    FROM spotter_archive_output 
516 516
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
517 517
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
                 try {
524 524
                         $sth = $this->db->prepare($query);
525 525
                         $sth->execute();
526
-                } catch(PDOException $e) {
526
+                } catch (PDOException $e) {
527 527
                         echo $e->getMessage();
528 528
                         die;
529 529
                 }
@@ -538,23 +538,23 @@  discard block
 block discarded – undo
538 538
         * @return Array the spotter information
539 539
         *
540 540
         */
541
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
541
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
542 542
         {
543 543
                 global $globalDBdriver, $globalLiveInterval;
544 544
                 date_default_timezone_set('UTC');
545 545
 
546 546
                 $filter_query = '';
547 547
                 if (isset($filter['source']) && !empty($filter['source'])) {
548
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
548
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
549 549
                 }
550 550
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
551
-                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
551
+                        $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.flightaware_id = spotter_archive.flightaware_id ";
552 552
                 }
553 553
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
554 554
                         $filter_query .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_archive.flightaware_id ";
555 555
                 }
556 556
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
557
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
557
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
558 558
                 }
559 559
 
560 560
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
                 try {
570 570
                         $sth = $this->db->prepare($query);
571 571
                         $sth->execute();
572
-                } catch(PDOException $e) {
572
+                } catch (PDOException $e) {
573 573
                         echo $e->getMessage();
574 574
                         die;
575 575
                 }
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
     * @return Array the spotter information
590 590
     *
591 591
     */
592
-    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '',$pilot_id = '',$pilot_name = '',$altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '', $filters=array())
592
+    public function searchSpotterData($q = '', $registration = '', $aircraft_icao = '', $aircraft_manufacturer = '', $highlights = '', $airline_icao = '', $airline_country = '', $airline_type = '', $airport = '', $airport_country = '', $callsign = '', $departure_airport_route = '', $arrival_airport_route = '', $owner = '', $pilot_id = '', $pilot_name = '', $altitude = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
593 593
     {
594 594
 	global $globalTimezone, $globalDBdriver;
595 595
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	        
612 612
 		$q_array = explode(" ", $q);
613 613
 		
614
-		foreach ($q_array as $q_item){
614
+		foreach ($q_array as $q_item) {
615 615
 		    $additional_query .= " AND (";
616 616
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
617 617
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 	
644 644
 	if ($registration != "")
645 645
 	{
646
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
646
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
647 647
 	    if (!is_string($registration))
648 648
 	    {
649 649
 		return false;
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 	
655 655
 	if ($aircraft_icao != "")
656 656
 	{
657
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
657
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
658 658
 	    if (!is_string($aircraft_icao))
659 659
 	    {
660 660
 		return false;
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 	
666 666
 	if ($aircraft_manufacturer != "")
667 667
 	{
668
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
668
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
669 669
 	    if (!is_string($aircraft_manufacturer))
670 670
 	    {
671 671
 		return false;
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 	
687 687
 	if ($airline_icao != "")
688 688
 	{
689
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
689
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
690 690
 	    if (!is_string($airline_icao))
691 691
 	    {
692 692
 		return false;
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 	
698 698
 	if ($airline_country != "")
699 699
 	{
700
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
700
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
701 701
 	    if (!is_string($airline_country))
702 702
 	    {
703 703
 		return false;
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 	
709 709
 	if ($airline_type != "")
710 710
 	{
711
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
711
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
712 712
 	    if (!is_string($airline_type))
713 713
 	    {
714 714
 		return false;
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	
731 731
 	if ($airport != "")
732 732
 	{
733
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
733
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
734 734
 	    if (!is_string($airport))
735 735
 	    {
736 736
 		return false;
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
 	
742 742
 	if ($airport_country != "")
743 743
 	{
744
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
744
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
745 745
 	    if (!is_string($airport_country))
746 746
 	    {
747 747
 		return false;
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
     
753 753
 	if ($callsign != "")
754 754
 	{
755
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
755
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
756 756
 	    if (!is_string($callsign))
757 757
 	    {
758 758
 		return false;
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 		$translate = $Translation->ident2icao($callsign);
761 761
 		if ($translate != $callsign) {
762 762
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
763
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
763
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
764 764
 		} else {
765 765
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
766 766
 		}
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 
770 770
 	if ($owner != "")
771 771
 	{
772
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
772
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
773 773
 	    if (!is_string($owner))
774 774
 	    {
775 775
 		return false;
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 
781 781
 	if ($pilot_name != "")
782 782
 	{
783
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
783
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
784 784
 	    if (!is_string($pilot_name))
785 785
 	    {
786 786
 		return false;
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	
792 792
 	if ($pilot_id != "")
793 793
 	{
794
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
794
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
795 795
 	    if (!is_string($pilot_id))
796 796
 	    {
797 797
 		return false;
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
 	
803 803
 	if ($departure_airport_route != "")
804 804
 	{
805
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
805
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
806 806
 	    if (!is_string($departure_airport_route))
807 807
 	    {
808 808
 		return false;
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
 	
814 814
 	if ($arrival_airport_route != "")
815 815
 	{
816
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
816
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
817 817
 	    if (!is_string($arrival_airport_route))
818 818
 	    {
819 819
 		return false;
@@ -826,8 +826,8 @@  discard block
 block discarded – undo
826 826
 	{
827 827
 	    $altitude_array = explode(",", $altitude);
828 828
 	    
829
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
829
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
830
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
831 831
 	    
832 832
 
833 833
 	    if ($altitude_array[1] != "")
@@ -845,8 +845,8 @@  discard block
 block discarded – undo
845 845
 	{
846 846
 	    $date_array = explode(",", $date_posted);
847 847
 	    
848
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
849
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
848
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
849
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
850 850
 	    
851 851
 	    if ($globalTimezone != '') {
852 852
 		date_default_timezone_set($globalTimezone);
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	{
879 879
 	    $limit_array = explode(",", $limit);
880 880
 	    
881
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
882
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
881
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
882
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
883 883
 	    
884 884
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
885 885
 	    {
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
 	
891 891
 
892 892
 	if ($origLat != "" && $origLon != "" && $dist != "") {
893
-		$dist = number_format($dist*0.621371,2,'.','');
894
-		$query="SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
893
+		$dist = number_format($dist*0.621371, 2, '.', '');
894
+		$query = "SELECT spotter_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2))) as distance 
895 895
                           FROM spotter_archive_output, spotter_archive WHERE spotter_output_archive.flightaware_id = spotter_archive.flightaware_id AND spotter_output.ident <> '' ".$additional_query."AND CAST(spotter_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(spotter_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
896 896
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(spotter_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(spotter_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(spotter_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
897 897
 	} else {
@@ -908,12 +908,12 @@  discard block
 block discarded – undo
908 908
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
909 909
 		}
910 910
 
911
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
911
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
912 912
 		    WHERE spotter_archive_output.ident <> '' 
913 913
 		    ".$additional_query."
914 914
 		    ".$filter_query.$orderby_query;
915 915
 	}
916
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
916
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
917 917
 
918 918
 	return $spotter_array;
919 919
     }
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
                 try {
931 931
                         $sth = $this->db->prepare($query);
932 932
                         $sth->execute();
933
-                } catch(PDOException $e) {
933
+                } catch (PDOException $e) {
934 934
                         return "error";
935 935
                 }
936 936
 	}
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
 	{
968 968
 	    $limit_array = explode(",", $limit);
969 969
 	    
970
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
971
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
970
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
971
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
972 972
 	    
973 973
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
974 974
 	    {
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 	$query_values = array();
1010 1010
 	$limit_query = '';
1011 1011
 	$additional_query = '';
1012
-	$filter_query = $this->getFilter($filter,true,true);
1012
+	$filter_query = $this->getFilter($filter, true, true);
1013 1013
 	
1014 1014
 	if ($owner != "")
1015 1015
 	{
@@ -1026,8 +1026,8 @@  discard block
 block discarded – undo
1026 1026
 	{
1027 1027
 	    $limit_array = explode(",", $limit);
1028 1028
 	    
1029
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1030
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1029
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1030
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1031 1031
 	    
1032 1032
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1033 1033
 	    {
@@ -1067,7 +1067,7 @@  discard block
 block discarded – undo
1067 1067
 	$query_values = array();
1068 1068
 	$limit_query = '';
1069 1069
 	$additional_query = '';
1070
-	$filter_query = $this->getFilter($filter,true,true);
1070
+	$filter_query = $this->getFilter($filter, true, true);
1071 1071
 	
1072 1072
 	if ($pilot != "")
1073 1073
 	{
@@ -1079,8 +1079,8 @@  discard block
 block discarded – undo
1079 1079
 	{
1080 1080
 	    $limit_array = explode(",", $limit);
1081 1081
 	    
1082
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1083
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1082
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1083
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1084 1084
 	    
1085 1085
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1086 1086
 	    {
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
     * @return Array the airline country list
1111 1111
     *
1112 1112
     */
1113
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1113
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1114 1114
     {
1115 1115
 	global $globalDBdriver;
1116 1116
 	/*
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 	$flight_array = array();
1140 1140
 	$temp_array = array();
1141 1141
         
1142
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1142
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1143 1143
 	{
1144 1144
 	    $temp_array['flight_count'] = $row['nb'];
1145 1145
 	    $temp_array['flight_country'] = $row['name'];
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
     * @return Array the airline country list
1157 1157
     *
1158 1158
     */
1159
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1159
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1160 1160
     {
1161 1161
 	global $globalDBdriver;
1162 1162
 	/*
@@ -1185,7 +1185,7 @@  discard block
 block discarded – undo
1185 1185
 	$flight_array = array();
1186 1186
 	$temp_array = array();
1187 1187
         
1188
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1188
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1189 1189
 	{
1190 1190
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1191 1191
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1203,14 +1203,14 @@  discard block
 block discarded – undo
1203 1203
     * @return Array the spotter information
1204 1204
     *
1205 1205
     */
1206
-    public function getDateArchiveSpotterDataById($id,$date)
1206
+    public function getDateArchiveSpotterDataById($id, $date)
1207 1207
     {
1208 1208
 	$Spotter = new Spotter($this->db);
1209 1209
 	date_default_timezone_set('UTC');
1210 1210
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1211
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1212
-	$date = date('c',$date);
1213
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1211
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1212
+	$date = date('c', $date);
1213
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1214 1214
 	return $spotter_array;
1215 1215
     }
1216 1216
 
@@ -1220,14 +1220,14 @@  discard block
 block discarded – undo
1220 1220
     * @return Array the spotter information
1221 1221
     *
1222 1222
     */
1223
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1223
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1224 1224
     {
1225 1225
 	$Spotter = new Spotter($this->db);
1226 1226
 	date_default_timezone_set('UTC');
1227 1227
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1228
-	$query  = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1229
-	$date = date('c',$date);
1230
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1228
+	$query = 'SELECT spotter_archive.* FROM spotter_archive INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id AND spotter_archive.date = s.maxdate ORDER BY spotter_archive.date DESC';
1229
+	$date = date('c', $date);
1230
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1231 1231
 	return $spotter_array;
1232 1232
     }
1233 1233
 
@@ -1237,7 +1237,7 @@  discard block
 block discarded – undo
1237 1237
     * @return Array the spotter information
1238 1238
     *
1239 1239
     */
1240
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1240
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1241 1241
     {
1242 1242
 	global $global_query;
1243 1243
 	$Spotter = new Spotter();
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
 	$query_values = array();
1246 1246
 	$limit_query = '';
1247 1247
 	$additional_query = '';
1248
-	$filter_query = $this->getFilter($filters,true,true);
1248
+	$filter_query = $this->getFilter($filters, true, true);
1249 1249
 	
1250 1250
 	if ($airport != "")
1251 1251
 	{
@@ -1262,8 +1262,8 @@  discard block
 block discarded – undo
1262 1262
 	{
1263 1263
 	    $limit_array = explode(",", $limit);
1264 1264
 	    
1265
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1266
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1265
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1266
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1267 1267
 	    
1268 1268
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1269 1269
 	    {
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	    if (isset($this->all_tracked[$key]['id'])) {
59 59
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
60 60
     		$Marine = new Marine($this->db);
61
-        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
61
+        	$Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
62 62
             }
63 63
 	}
64 64
     }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
70 70
 	foreach ($this->all_tracked as $key => $flight) {
71 71
     	    if (isset($flight['lastupdate'])) {
72
-        	if ($flight['lastupdate'] < (time()-3000)) {
72
+        	if ($flight['lastupdate'] < (time() - 3000)) {
73 73
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
74 74
             		if (isset($this->all_tracked[$key]['id'])) {
75 75
             		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
             		    //$real_arrival = $this->arrival($key);
82 82
             		    $Marine = new Marine($this->db);
83 83
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
84
-				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
84
+				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
85 85
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
86 86
 			    }
87 87
 			    // Put in archive
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
     }
96 96
 
97 97
     public function add($line) {
98
-	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
98
+	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS, $APRSMarine;
99 99
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
100 100
 	date_default_timezone_set('UTC');
101 101
 	$dataFound = false;
102 102
 	$send = false;
103 103
 	
104 104
 	// SBS format is CSV format
105
-	if(is_array($line) && isset($line['mmsi'])) {
105
+	if (is_array($line) && isset($line['mmsi'])) {
106 106
 	    //print_r($line);
107 107
   	    if (isset($line['mmsi'])) {
108 108
 
@@ -126,18 +126,18 @@  discard block
 block discarded – undo
126 126
 		
127 127
 		if (!isset($this->all_tracked[$id])) {
128 128
 		    $this->all_tracked[$id] = array();
129
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
130
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
131
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
129
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedMarine' => 0));
130
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'typeid' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => '', 'mmsi' => '', 'status' => '', 'imo' => '', 'callsign' => '', 'arrival_code' => '', 'arrival_date' => '', 'mmsi_type' => ''));
131
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
132 132
 		    if (!isset($line['id'])) {
133 133
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
134
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
135
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
134
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
135
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
136 136
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
137 137
 		}
138 138
 		
139 139
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
140
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
140
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
141 141
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
142 142
 			$Marine = new Marine($this->db);
143 143
 			$identity = $Marine->getIdentity($line['mmsi']);
@@ -151,66 +151,66 @@  discard block
 block discarded – undo
151 151
 		    }
152 152
 		}
153 153
 		if (isset($line['type_id']) && $line['type_id'] != '') {
154
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
154
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
155 155
 		}
156 156
 		if (isset($line['type']) && $line['type'] != '') {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
157
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
158 158
 		}
159 159
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
160
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
160
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
161 161
 		}
162 162
 		if (isset($line['imo']) && $line['imo'] != '') {
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
163
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
164 164
 		}
165 165
 		if (isset($line['callsign']) && $line['callsign'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
166
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
167 167
 		}
168 168
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
169
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
170 170
 		}
171 171
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
172
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
172
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
173 173
 		}
174 174
 
175 175
 
176 176
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
177 177
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
178
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
178
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
179 179
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
180 180
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
181 181
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
182 182
 				$timeelapsed = microtime(true);
183 183
 				$Marine = new Marine($this->db);
184 184
 				$fromsource = NULL;
185
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
185
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
186 186
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
187 187
 				$Marine->db = null;
188
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
188
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
189 189
 			    }
190 190
 			}
191 191
 		    }
192
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
192
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
193 193
 		}
194 194
 
195 195
 		if (isset($line['speed']) && $line['speed'] != '') {
196
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
197
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
196
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
197
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
198 198
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
199
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
199
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
200 200
 		    if ($distance > 1000 && $distance < 10000) {
201 201
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
202 202
 			$speed = $speed*3.6;
203
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
203
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
204 204
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
205 205
 		    }
206 206
 		}
207 207
 
208 208
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
209
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
209
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
210 210
 	    	    else unset($timediff);
211
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
211
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
212 212
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
213
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
213
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
214 214
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
215 215
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
216 216
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 				$timeelapsed = microtime(true);
220 220
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
221 221
 				    $Marine = new Marine($this->db);
222
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
222
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
223 223
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
224 224
 				    $Marine->db = null;
225
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
225
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
226 226
 				}
227 227
 				$this->tmd = 0;
228 228
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -231,66 +231,66 @@  discard block
 block discarded – undo
231 231
 
232 232
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
233 233
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
234
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
234
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
235 235
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
236 236
 				    $dataFound = true;
237 237
 				    $this->all_tracked[$id]['time_last_coord'] = time();
238 238
 				}
239
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
239
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
240 240
 			}
241 241
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
242 242
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
243 243
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
244
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
244
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
245 245
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
246 246
 				    $dataFound = true;
247 247
 				    $this->all_tracked[$id]['time_last_coord'] = time();
248 248
 				}
249
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
249
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
250 250
 			}
251 251
 
252 252
 		    } else if ($globalDebug && $timediff > 20) {
253 253
 			$this->tmd = $this->tmd + 1;
254 254
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
255
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
256
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
255
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
256
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
257 257
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
258 258
 		    }
259 259
 		}
260 260
 		if (isset($line['last_update']) && $line['last_update'] != '') {
261 261
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
263 263
 		}
264 264
 		if (isset($line['format_source']) && $line['format_source'] != '') {
265
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
265
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
266 266
 		}
267 267
 		if (isset($line['source_name']) && $line['source_name'] != '') {
268
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
268
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
269 269
 		}
270 270
 		if (isset($line['status']) && $line['status'] != '') {
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
271
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
272 272
 		}
273 273
 
274 274
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
275
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
275
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
276 276
 		}
277 277
 		
278 278
 		if (isset($line['heading']) && $line['heading'] != '') {
279
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
280
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
281
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
279
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
280
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
281
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
282 282
 		    //$dataFound = true;
283 283
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
284
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
285
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
286
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
284
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
285
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
286
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
287 287
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
288 288
   		}
289 289
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
290 290
 
291 291
 		if (isset($line['datetime'])) {
292 292
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
293
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
293
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
294 294
 		    } else {
295 295
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
296 296
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
 		    }
299 299
 		} else {
300 300
 			date_default_timezone_set('UTC');
301
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
301
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
302 302
 		}
303 303
 
304 304
 
305 305
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
306 306
 		    $this->all_tracked[$id]['lastupdate'] = time();
307 307
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
308
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
308
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
309 309
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
310 310
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
311 311
 				    if ($globalDebug) echo "Check if aircraft is already in DB...";
@@ -313,37 +313,37 @@  discard block
 block discarded – undo
313 313
 				    $MarineLive = new MarineLive($this->db);
314 314
 				    if (isset($line['id'])) {
315 315
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
316
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
316
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
317 317
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
318 318
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
319
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
319
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
320 320
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
321 321
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
322
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
322
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
323 323
 				    } else $recent_ident = '';
324
-				    $MarineLive->db=null;
324
+				    $MarineLive->db = null;
325 325
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
326 326
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
327 327
 				} else $recent_ident = '';
328 328
 			    } else {
329 329
 				$recent_ident = '';
330
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
330
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
331 331
 			    }
332 332
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
333
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
333
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
334 334
 			    {
335 335
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
336 336
 				//adds the spotter data for the archive
337 337
 				    $highlight = '';
338
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
338
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
339 339
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
340 340
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
341 341
 					    $timeelapsed = microtime(true);
342 342
 					    $Marine = new Marine($this->db);
343
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
343
+					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
344 344
 					    $Marine->db = null;
345 345
 					    if ($globalDebug && isset($result)) echo $result."\n";
346
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
346
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
347 347
 					}
348 348
 				    }
349 349
 				    /*
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
384 384
 					$MarineLive = new MarineLive($this->db);
385 385
 					$MarineLive->deleteLiveMarineData();
386
-					$MarineLive->db=null;
386
+					$MarineLive->db = null;
387 387
 					if ($globalDebug) echo " Done\n";
388 388
 				    }
389 389
 				    $this->last_delete = time();
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
395 395
 				    if (isset($globalDaemon) && !$globalDaemon) {
396 396
 					$Marine = new Marine($this->db);
397
-					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
397
+					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
398 398
 					$Marine->db = null;
399 399
 				    }
400 400
 				}
@@ -409,20 +409,20 @@  discard block
 block discarded – undo
409 409
 		    $ignoreImport = false;
410 410
 
411 411
 		    if (!$ignoreImport) {
412
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
412
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
413 413
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
414 414
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
415 415
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
416 416
 					$timeelapsed = microtime(true);
417 417
 					$MarineLive = new MarineLive($this->db);
418
-					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
418
+					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
419 419
 					$MarineLive->db = null;
420 420
 					if ($globalDebug) echo $result."\n";
421
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
422 422
 				    }
423 423
 				}
424 424
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
425
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
425
+				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['typeid'], $this->all_tracked[$id]['imo'], $this->all_tracked[$id]['callsign'], $this->all_tracked[$id]['arrival_code'], $this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
426 426
 				}
427 427
 				$this->all_tracked[$id]['putinarchive'] = false;
428 428
 
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 
483 483
 				$this->all_tracked[$id]['lastupdate'] = time();
484 484
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
485
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
485
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
486 486
 			//$this->del();
487 487
 			
488 488
 			
Please login to merge, or discard this patch.
require/class.MarineLive.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND marine_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND marine_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.fammarine_id = marine_live.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 					$filter_query_date .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
74
+			$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.fammarine_id = marine_live.fammarine_id";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		} else {
127 127
 			$query  = "SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate".$filter_query.$orderby_query;
128 128
 		}
129
-		$spotter_array = $Marine->getDataFromDB($query.$limit_query,array(),'',true);
129
+		$spotter_array = $Marine->getDataFromDB($query.$limit_query, array(), '', true);
130 130
 
131 131
 		return $spotter_array;
132 132
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		global $globalDBdriver, $globalLiveInterval;
143 143
 		date_default_timezone_set('UTC');
144 144
 
145
-		$filter_query = $this->getFilter($filter,true,true);
145
+		$filter_query = $this->getFilter($filter, true, true);
146 146
 
147 147
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
148 148
 		if ($globalDBdriver == 'mysql') {
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		try {
157 157
 			$sth = $this->db->prepare($query);
158 158
 			$sth->execute();
159
-		} catch(PDOException $e) {
159
+		} catch (PDOException $e) {
160 160
 			echo $e->getMessage();
161 161
 			die;
162 162
 		}
@@ -176,15 +176,15 @@  discard block
 block discarded – undo
176 176
 		global $globalDBdriver, $globalLiveInterval;
177 177
 		date_default_timezone_set('UTC');
178 178
 
179
-		$filter_query = $this->getFilter($filter,true,true);
179
+		$filter_query = $this->getFilter($filter, true, true);
180 180
 
181 181
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
182 182
 		if ($globalDBdriver == 'mysql') {
183
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
183
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
184 184
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
185 185
 			ORDER BY marine_live.fammarine_id, marine_live.date";
186 186
                 } else {
187
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
187
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
188 188
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' 
189 189
 			ORDER BY marine_live.fammarine_id, marine_live.date";
190 190
 		}
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
     		try {
193 193
 			$sth = $this->db->prepare($query);
194 194
 			$sth->execute();
195
-		} catch(PDOException $e) {
195
+		} catch (PDOException $e) {
196 196
 			echo $e->getMessage();
197 197
 			die;
198 198
 		}
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	public function getLiveMarineCount($filter = array())
210 210
 	{
211 211
 		global $globalDBdriver, $globalLiveInterval;
212
-		$filter_query = $this->getFilter($filter,true,true);
212
+		$filter_query = $this->getFilter($filter, true, true);
213 213
 
214 214
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
215 215
 		if ($globalDBdriver == 'mysql') {
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		try {
221 221
 			$sth = $this->db->prepare($query);
222 222
 			$sth->execute();
223
-		} catch(PDOException $e) {
223
+		} catch (PDOException $e) {
224 224
 			echo $e->getMessage();
225 225
 			die;
226 226
 		}
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
 		$filter_query = $this->getFilter($filter);
244 244
 
245 245
 		if (is_array($coord)) {
246
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
247
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
248
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
249
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
246
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
247
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
248
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
249
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
250 250
 		} else return array();
251 251
 		if ($globalDBdriver == 'mysql') {
252 252
 			$query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate AND marine_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY marine_live.fammarine_id'.$filter_query;
@@ -271,17 +271,17 @@  discard block
 block discarded – undo
271 271
 		$filter_query = $this->getFilter($filter);
272 272
 
273 273
 		if (is_array($coord)) {
274
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
275
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
276
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
274
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
275
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
276
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
277
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
278 278
 		} else return array();
279 279
 		if ($globalDBdriver == 'mysql') {
280 280
 			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id,marine_live.type, marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
281 281
 			FROM marine_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND marine_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
282 282
 			ORDER BY marine_live.fammarine_id, marine_live.date";
283 283
 		} else {
284
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
284
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id, marine_live.type,marine_live.latitude, marine_live.longitude, marine_live.heading, marine_live.ground_speed, marine_live.date, marine_live.format_source 
285 285
 			FROM marine_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= marine_live.date AND marine_live.latitude <> '0' AND marine_live.longitude <> '0' AND marine_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND marine_live.longitude BETWEEN ".$minlong." AND ".$maxlong."
286 286
 			ORDER BY marine_live.fammarine_id, marine_live.date";
287 287
 		}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
                 if ($interval == '1m')
331 331
                 {
332 332
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';
333
-                } else if ($interval == '15m'){
333
+                } else if ($interval == '15m') {
334 334
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= marine_live.date ';
335 335
                 } 
336 336
             }
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= marine_live.date ';   
339 339
         }
340 340
 
341
-                $query  = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
341
+                $query = "SELECT marine_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM marine_live 
342 342
                    WHERE marine_live.latitude <> '' 
343 343
                                    AND marine_live.longitude <> '' 
344 344
                    ".$additional_query."
345 345
                    HAVING distance < :radius  
346 346
                                    ORDER BY distance";
347 347
 
348
-                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
348
+                $spotter_array = $Marine->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
349 349
 
350 350
                 return $spotter_array;
351 351
         }
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 		date_default_timezone_set('UTC');
364 364
 
365 365
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
366
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
366
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
367 367
 
368
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident),'',true);
368
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident), '', true);
369 369
 
370 370
 		return $spotter_array;
371 371
 	}
@@ -376,16 +376,16 @@  discard block
 block discarded – undo
376 376
 	* @return Array the spotter information
377 377
 	*
378 378
 	*/
379
-	public function getDateLiveMarineDataByIdent($ident,$date)
379
+	public function getDateLiveMarineDataByIdent($ident, $date)
380 380
 	{
381 381
 		$Marine = new Marine($this->db);
382 382
 		date_default_timezone_set('UTC');
383 383
 
384 384
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
385
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
385
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
386 386
 
387
-                $date = date('c',$date);
388
-		$spotter_array = $Marine->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
387
+                $date = date('c', $date);
388
+		$spotter_array = $Marine->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
389 389
 
390 390
 		return $spotter_array;
391 391
 	}
@@ -402,9 +402,9 @@  discard block
 block discarded – undo
402 402
 		date_default_timezone_set('UTC');
403 403
 
404 404
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
405
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
405
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
406 406
 
407
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id),'',true);
407
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id), '', true);
408 408
 
409 409
 		return $spotter_array;
410 410
 	}
@@ -415,15 +415,15 @@  discard block
 block discarded – undo
415 415
 	* @return Array the spotter information
416 416
 	*
417 417
 	*/
418
-	public function getDateLiveMarineDataById($id,$date)
418
+	public function getDateLiveMarineDataById($id, $date)
419 419
 	{
420 420
 		$Marine = new Marine($this->db);
421 421
 		date_default_timezone_set('UTC');
422 422
 
423 423
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
424
-                $query  = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
425
-                $date = date('c',$date);
426
-		$spotter_array = $Marine->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
424
+                $query = 'SELECT marine_live.* FROM marine_live INNER JOIN (SELECT l.fammarine_id, max(l.date) as maxdate FROM marine_live l WHERE l.fammarine_id = :id AND l.date <= :date GROUP BY l.fammarine_id) s on marine_live.fammarine_id = s.fammarine_id AND marine_live.date = s.maxdate ORDER BY marine_live.date DESC';
425
+                $date = date('c', $date);
426
+		$spotter_array = $Marine->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
427 427
 
428 428
 		return $spotter_array;
429 429
 	}
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	* @return Array the spotter information
436 436
 	*
437 437
 	*/
438
-	public function getAllLiveMarineDataById($id,$liveinterval = false)
438
+	public function getAllLiveMarineDataById($id, $liveinterval = false)
439 439
 	{
440 440
 		global $globalDBdriver, $globalLiveInterval;
441 441
 		date_default_timezone_set('UTC');
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		try {
455 455
 			$sth = $this->db->prepare($query);
456 456
 			$sth->execute(array(':id' => $id));
457
-		} catch(PDOException $e) {
457
+		} catch (PDOException $e) {
458 458
 			echo $e->getMessage();
459 459
 			die;
460 460
 		}
@@ -472,12 +472,12 @@  discard block
 block discarded – undo
472 472
 	{
473 473
 		date_default_timezone_set('UTC');
474 474
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
475
-		$query  = self::$global_query.' WHERE marine_live.ident = :ident';
475
+		$query = self::$global_query.' WHERE marine_live.ident = :ident';
476 476
     		try {
477 477
 			
478 478
 			$sth = $this->db->prepare($query);
479 479
 			$sth->execute(array(':ident' => $ident));
480
-		} catch(PDOException $e) {
480
+		} catch (PDOException $e) {
481 481
 			echo $e->getMessage();
482 482
 			die;
483 483
 		}
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 			
508 508
 			$sth = $this->db->prepare($query);
509 509
 			$sth->execute();
510
-		} catch(PDOException $e) {
510
+		} catch (PDOException $e) {
511 511
 			return "error";
512 512
 		}
513 513
 
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
 				
531 531
 				$sth = $this->db->prepare($query);
532 532
 				$sth->execute();
533
-			} catch(PDOException $e) {
533
+			} catch (PDOException $e) {
534 534
 				return "error";
535 535
 			}
536 536
 			$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
537 537
                         $i = 0;
538
-                        $j =0;
538
+                        $j = 0;
539 539
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
540
-			foreach($all as $row)
540
+			foreach ($all as $row)
541 541
 			{
542 542
 				$i++;
543 543
 				$j++;
@@ -545,9 +545,9 @@  discard block
 block discarded – undo
545 545
 					if ($globalDebug) echo ".";
546 546
 				    	try {
547 547
 						
548
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
548
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
549 549
 						$sth->execute();
550
-					} catch(PDOException $e) {
550
+					} catch (PDOException $e) {
551 551
 						return "error";
552 552
 					}
553 553
                                 	$query_delete = 'DELETE FROM marine_live WHERE fammarine_id IN (';
@@ -558,9 +558,9 @@  discard block
 block discarded – undo
558 558
 			if ($i > 0) {
559 559
     				try {
560 560
 					
561
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
561
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
562 562
 					$sth->execute();
563
-				} catch(PDOException $e) {
563
+				} catch (PDOException $e) {
564 564
 					return "error";
565 565
 				}
566 566
 			}
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
 				
574 574
 				$sth = $this->db->prepare($query);
575 575
 				$sth->execute();
576
-			} catch(PDOException $e) {
576
+			} catch (PDOException $e) {
577 577
 				return "error";
578 578
 			}
579 579
 /*			$query_delete = "DELETE FROM marine_live WHERE fammarine_id IN (";
@@ -621,13 +621,13 @@  discard block
 block discarded – undo
621 621
 	public function deleteLiveMarineDataByIdent($ident)
622 622
 	{
623 623
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
624
-		$query  = 'DELETE FROM marine_live WHERE ident = :ident';
624
+		$query = 'DELETE FROM marine_live WHERE ident = :ident';
625 625
         
626 626
     		try {
627 627
 			
628 628
 			$sth = $this->db->prepare($query);
629 629
 			$sth->execute(array(':ident' => $ident));
630
-		} catch(PDOException $e) {
630
+		} catch (PDOException $e) {
631 631
 			return "error";
632 632
 		}
633 633
 
@@ -643,13 +643,13 @@  discard block
 block discarded – undo
643 643
 	public function deleteLiveMarineDataById($id)
644 644
 	{
645 645
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
646
-		$query  = 'DELETE FROM marine_live WHERE fammarine_id = :id';
646
+		$query = 'DELETE FROM marine_live WHERE fammarine_id = :id';
647 647
         
648 648
     		try {
649 649
 			
650 650
 			$sth = $this->db->prepare($query);
651 651
 			$sth->execute(array(':id' => $id));
652
-		} catch(PDOException $e) {
652
+		} catch (PDOException $e) {
653 653
 			return "error";
654 654
 		}
655 655
 
@@ -667,13 +667,13 @@  discard block
 block discarded – undo
667 667
 	{
668 668
 		global $globalDBdriver, $globalTimezone;
669 669
 		if ($globalDBdriver == 'mysql') {
670
-			$query  = 'SELECT marine_live.ident FROM marine_live 
670
+			$query = 'SELECT marine_live.ident FROM marine_live 
671 671
 				WHERE marine_live.ident = :ident 
672 672
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
673 673
 				AND marine_live.date < UTC_TIMESTAMP()';
674 674
 			$query_data = array(':ident' => $ident);
675 675
 		} else {
676
-			$query  = "SELECT marine_live.ident FROM marine_live 
676
+			$query = "SELECT marine_live.ident FROM marine_live 
677 677
 				WHERE marine_live.ident = :ident 
678 678
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
679 679
 				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
 		
683 683
 		$sth = $this->db->prepare($query);
684 684
 		$sth->execute($query_data);
685
-		$ident_result='';
686
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
685
+		$ident_result = '';
686
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
687 687
 		{
688 688
 			$ident_result = $row['ident'];
689 689
 		}
@@ -700,13 +700,13 @@  discard block
 block discarded – undo
700 700
 	{
701 701
 		global $globalDBdriver, $globalTimezone;
702 702
 		if ($globalDBdriver == 'mysql') {
703
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
703
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
704 704
 				WHERE marine_live.ident = :ident 
705 705
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
706 706
 //				AND marine_live.date < UTC_TIMESTAMP()";
707 707
 			$query_data = array(':ident' => $ident);
708 708
 		} else {
709
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
709
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
710 710
 				WHERE marine_live.ident = :ident 
711 711
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
712 712
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 		
716 716
 		$sth = $this->db->prepare($query);
717 717
 		$sth->execute($query_data);
718
-		$ident_result='';
719
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
718
+		$ident_result = '';
719
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
720 720
 		{
721 721
 			$ident_result = $row['fammarine_id'];
722 722
 		}
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
 	{
734 734
 		global $globalDBdriver, $globalTimezone;
735 735
 		if ($globalDBdriver == 'mysql') {
736
-			$query  = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
736
+			$query = 'SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
737 737
 				WHERE marine_live.fammarine_id = :id 
738 738
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
739 739
 //				AND marine_live.date < UTC_TIMESTAMP()";
740 740
 			$query_data = array(':id' => $id);
741 741
 		} else {
742
-			$query  = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
742
+			$query = "SELECT marine_live.ident, marine_live.fammarine_id FROM marine_live 
743 743
 				WHERE marine_live.fammarine_id = :id 
744 744
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
745 745
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
 		
749 749
 		$sth = $this->db->prepare($query);
750 750
 		$sth->execute($query_data);
751
-		$ident_result='';
752
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
751
+		$ident_result = '';
752
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
753 753
 		{
754 754
 			$ident_result = $row['fammarine_id'];
755 755
 		}
@@ -766,13 +766,13 @@  discard block
 block discarded – undo
766 766
 	{
767 767
 		global $globalDBdriver, $globalTimezone;
768 768
 		if ($globalDBdriver == 'mysql') {
769
-			$query  = 'SELECT marine_live.fammarine_id FROM marine_live 
769
+			$query = 'SELECT marine_live.fammarine_id FROM marine_live 
770 770
 				WHERE marine_live.mmsi = :mmsi 
771 771
 				AND marine_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
772 772
 //				AND marine_live.date < UTC_TIMESTAMP()";
773 773
 			$query_data = array(':mmsi' => $mmsi);
774 774
 		} else {
775
-			$query  = "SELECT marine_live.fammarine_id FROM marine_live 
775
+			$query = "SELECT marine_live.fammarine_id FROM marine_live 
776 776
 				WHERE marine_live.mmsi = :mmsi 
777 777
 				AND marine_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
778 778
 //				AND marine_live.date < now() AT TIME ZONE 'UTC'";
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
 		
782 782
 		$sth = $this->db->prepare($query);
783 783
 		$sth->execute($query_data);
784
-		$ident_result='';
785
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
784
+		$ident_result = '';
785
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
786 786
 		{
787 787
 			$ident_result = $row['fammarine_id'];
788 788
 		}
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 	* @return String success or false
801 801
 	*
802 802
 	*/
803
-	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '',$type = '',$typeid = '',$imo = '', $callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
803
+	public function addLiveMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
804 804
 	{
805 805
 		global $globalURL, $globalArchive, $globalDebug;
806 806
 		$Common = new Common();
@@ -852,36 +852,36 @@  discard block
 block discarded – undo
852 852
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
853 853
 
854 854
         
855
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
856
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
857
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
858
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
859
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
860
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
861
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
862
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
863
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
864
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
865
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
866
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
867
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
868
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
869
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
870
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
855
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
856
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
857
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
858
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
859
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
860
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
861
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
862
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
863
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
864
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
865
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
866
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
867
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
868
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
869
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
870
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
871 871
 		
872 872
 
873
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
874
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
873
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
874
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
875 875
             	if ($arrival_date == '') $arrival_date = NULL;
876
-		$query  = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
876
+		$query = 'INSERT INTO marine_live (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, over_country, mmsi, type,status,imo,arrival_port_name,arrival_port_date) 
877 877
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)';
878 878
 
879
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
879
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
880 880
 		try {
881 881
 			
882 882
 			$sth = $this->db->prepare($query);
883 883
 			$sth->execute($query_values);
884
-                } catch(PDOException $e) {
884
+                } catch (PDOException $e) {
885 885
                 	return "error : ".$e->getMessage();
886 886
                 }
887 887
 		/*
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
 
899 899
 	public function getOrderBy()
900 900
 	{
901
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
901
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_live.date DESC"));
902 902
 		return $orderby;
903 903
 	}
904 904
 
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
38
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
40
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
74
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		} else {
127 127
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
128 128
 		}
129
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
129
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
130 130
 
131 131
 		return $spotter_array;
132 132
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		global $globalDBdriver, $globalLiveInterval;
143 143
 		date_default_timezone_set('UTC');
144 144
 
145
-		$filter_query = $this->getFilter($filter,true,true);
145
+		$filter_query = $this->getFilter($filter, true, true);
146 146
 
147 147
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
148 148
 		if ($globalDBdriver == 'mysql') {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute();
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			echo $e->getMessage();
165 165
 			die;
166 166
 		}
@@ -180,15 +180,15 @@  discard block
 block discarded – undo
180 180
 		global $globalDBdriver, $globalLiveInterval;
181 181
 		date_default_timezone_set('UTC');
182 182
 
183
-		$filter_query = $this->getFilter($filter,true,true);
183
+		$filter_query = $this->getFilter($filter, true, true);
184 184
 
185 185
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
186 186
 		if ($globalDBdriver == 'mysql') {
187
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
187
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
188 188
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
189 189
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
190 190
                 } else {
191
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
191
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
192 192
 			FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
193 193
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
194 194
 		}
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     		try {
197 197
 			$sth = $this->db->prepare($query);
198 198
 			$sth->execute();
199
-		} catch(PDOException $e) {
199
+		} catch (PDOException $e) {
200 200
 			echo $e->getMessage();
201 201
 			die;
202 202
 		}
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 	public function getLiveTrackerCount($filter = array())
214 214
 	{
215 215
 		global $globalDBdriver, $globalLiveInterval;
216
-		$filter_query = $this->getFilter($filter,true,true);
216
+		$filter_query = $this->getFilter($filter, true, true);
217 217
 
218 218
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
219 219
 		if ($globalDBdriver == 'mysql') {
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		try {
225 225
 			$sth = $this->db->prepare($query);
226 226
 			$sth->execute();
227
-		} catch(PDOException $e) {
227
+		} catch (PDOException $e) {
228 228
 			echo $e->getMessage();
229 229
 			die;
230 230
 		}
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 		$filter_query = $this->getFilter($filter);
248 248
 
249 249
 		if (is_array($coord)) {
250
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
251
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
252
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
253
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
250
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
251
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
252
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
253
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
254 254
 		} else return array();
255 255
 		if ($globalDBdriver == 'mysql') {
256 256
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -275,17 +275,17 @@  discard block
 block discarded – undo
275 275
 		$filter_query = $this->getFilter($filter);
276 276
 
277 277
 		if (is_array($coord)) {
278
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
279
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
280
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
281
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
279
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
280
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
281
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
282 282
 		} else return array();
283 283
 		if ($globalDBdriver == 'mysql') {
284 284
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
285 285
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
286 286
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
287 287
 		} else {
288
-			$query  = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
288
+			$query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
289 289
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
290 290
 		}
291 291
 		$spotter_array = $Spotter->getDataFromDB($query);
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
                 if ($interval == '1m')
334 334
                 {
335 335
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
336
-                } else if ($interval == '15m'){
336
+                } else if ($interval == '15m') {
337 337
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
338 338
                 } 
339 339
             }
@@ -341,14 +341,14 @@  discard block
 block discarded – undo
341 341
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
342 342
         }
343 343
 
344
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
344
+                $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
345 345
                    WHERE tracker_live.latitude <> '' 
346 346
                                    AND tracker_live.longitude <> '' 
347 347
                    ".$additional_query."
348 348
                    HAVING distance < :radius  
349 349
                                    ORDER BY distance";
350 350
 
351
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
351
+                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
352 352
 
353 353
                 return $spotter_array;
354 354
         }
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 		date_default_timezone_set('UTC');
367 367
 
368 368
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
369
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
369
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
370 370
 
371
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
371
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
372 372
 
373 373
 		return $spotter_array;
374 374
 	}
@@ -379,16 +379,16 @@  discard block
 block discarded – undo
379 379
 	* @return Array the spotter information
380 380
 	*
381 381
 	*/
382
-	public function getDateLiveTrackerDataByIdent($ident,$date)
382
+	public function getDateLiveTrackerDataByIdent($ident, $date)
383 383
 	{
384 384
 		$Tracker = new Tracker($this->db);
385 385
 		date_default_timezone_set('UTC');
386 386
 
387 387
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
388
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
388
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
389 389
 
390
-                $date = date('c',$date);
391
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
390
+                $date = date('c', $date);
391
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
392 392
 
393 393
 		return $spotter_array;
394 394
 	}
@@ -405,9 +405,9 @@  discard block
 block discarded – undo
405 405
 		date_default_timezone_set('UTC');
406 406
 
407 407
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
408
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
408
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
409 409
 
410
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
410
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
411 411
 
412 412
 		return $spotter_array;
413 413
 	}
@@ -418,15 +418,15 @@  discard block
 block discarded – undo
418 418
 	* @return Array the spotter information
419 419
 	*
420 420
 	*/
421
-	public function getDateLiveTrackerDataById($id,$date)
421
+	public function getDateLiveTrackerDataById($id, $date)
422 422
 	{
423 423
 		$Tracker = new Tracker($this->db);
424 424
 		date_default_timezone_set('UTC');
425 425
 
426 426
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
427
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
-                $date = date('c',$date);
429
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
427
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
428
+                $date = date('c', $date);
429
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
430 430
 
431 431
 		return $spotter_array;
432 432
 	}
@@ -443,13 +443,13 @@  discard block
 block discarded – undo
443 443
 		date_default_timezone_set('UTC');
444 444
 
445 445
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
446
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
446
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
447 447
 
448 448
     		try {
449 449
 			
450 450
 			$sth = $this->db->prepare($query);
451 451
 			$sth->execute(array(':ident' => $ident));
452
-		} catch(PDOException $e) {
452
+		} catch (PDOException $e) {
453 453
 			echo $e->getMessage();
454 454
 			die;
455 455
 		}
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	* @return Array the spotter information
465 465
 	*
466 466
 	*/
467
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
467
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
468 468
 	{
469 469
 		global $globalDBdriver, $globalLiveInterval;
470 470
 		date_default_timezone_set('UTC');
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 		try {
484 484
 			$sth = $this->db->prepare($query);
485 485
 			$sth->execute(array(':id' => $id));
486
-		} catch(PDOException $e) {
486
+		} catch (PDOException $e) {
487 487
 			echo $e->getMessage();
488 488
 			die;
489 489
 		}
@@ -501,12 +501,12 @@  discard block
 block discarded – undo
501 501
 	{
502 502
 		date_default_timezone_set('UTC');
503 503
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
504
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
504
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
505 505
     		try {
506 506
 			
507 507
 			$sth = $this->db->prepare($query);
508 508
 			$sth->execute(array(':ident' => $ident));
509
-		} catch(PDOException $e) {
509
+		} catch (PDOException $e) {
510 510
 			echo $e->getMessage();
511 511
 			die;
512 512
 		}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 			
537 537
 			$sth = $this->db->prepare($query);
538 538
 			$sth->execute();
539
-		} catch(PDOException $e) {
539
+		} catch (PDOException $e) {
540 540
 			return "error";
541 541
 		}
542 542
 
@@ -559,14 +559,14 @@  discard block
 block discarded – undo
559 559
 				
560 560
 				$sth = $this->db->prepare($query);
561 561
 				$sth->execute();
562
-			} catch(PDOException $e) {
562
+			} catch (PDOException $e) {
563 563
 				return "error";
564 564
 			}
565 565
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
566 566
                         $i = 0;
567
-                        $j =0;
567
+                        $j = 0;
568 568
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
569
-			foreach($all as $row)
569
+			foreach ($all as $row)
570 570
 			{
571 571
 				$i++;
572 572
 				$j++;
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
 					if ($globalDebug) echo ".";
575 575
 				    	try {
576 576
 						
577
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
577
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
578 578
 						$sth->execute();
579
-					} catch(PDOException $e) {
579
+					} catch (PDOException $e) {
580 580
 						return "error";
581 581
 					}
582 582
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -587,9 +587,9 @@  discard block
 block discarded – undo
587 587
 			if ($i > 0) {
588 588
     				try {
589 589
 					
590
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
590
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
591 591
 					$sth->execute();
592
-				} catch(PDOException $e) {
592
+				} catch (PDOException $e) {
593 593
 					return "error";
594 594
 				}
595 595
 			}
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 				
603 603
 				$sth = $this->db->prepare($query);
604 604
 				$sth->execute();
605
-			} catch(PDOException $e) {
605
+			} catch (PDOException $e) {
606 606
 				return "error";
607 607
 			}
608 608
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
 	public function deleteLiveTrackerDataByIdent($ident)
651 651
 	{
652 652
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
653
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
653
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
654 654
         
655 655
     		try {
656 656
 			
657 657
 			$sth = $this->db->prepare($query);
658 658
 			$sth->execute(array(':ident' => $ident));
659
-		} catch(PDOException $e) {
659
+		} catch (PDOException $e) {
660 660
 			return "error";
661 661
 		}
662 662
 
@@ -672,13 +672,13 @@  discard block
 block discarded – undo
672 672
 	public function deleteLiveTrackerDataById($id)
673 673
 	{
674 674
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
675
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
675
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
676 676
         
677 677
     		try {
678 678
 			
679 679
 			$sth = $this->db->prepare($query);
680 680
 			$sth->execute(array(':id' => $id));
681
-		} catch(PDOException $e) {
681
+		} catch (PDOException $e) {
682 682
 			return "error";
683 683
 		}
684 684
 
@@ -696,13 +696,13 @@  discard block
 block discarded – undo
696 696
 	{
697 697
 		global $globalDBdriver, $globalTimezone;
698 698
 		if ($globalDBdriver == 'mysql') {
699
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
699
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
700 700
 				WHERE tracker_live.ident = :ident 
701 701
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
702 702
 				AND tracker_live.date < UTC_TIMESTAMP()';
703 703
 			$query_data = array(':ident' => $ident);
704 704
 		} else {
705
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
705
+			$query = "SELECT tracker_live.ident FROM tracker_live 
706 706
 				WHERE tracker_live.ident = :ident 
707 707
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
708 708
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
 		
712 712
 		$sth = $this->db->prepare($query);
713 713
 		$sth->execute($query_data);
714
-		$ident_result='';
715
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
714
+		$ident_result = '';
715
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
716 716
 		{
717 717
 			$ident_result = $row['ident'];
718 718
 		}
@@ -729,13 +729,13 @@  discard block
 block discarded – undo
729 729
 	{
730 730
 		global $globalDBdriver, $globalTimezone;
731 731
 		if ($globalDBdriver == 'mysql') {
732
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
732
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
733 733
 				WHERE tracker_live.ident = :ident 
734 734
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
735 735
 //				AND tracker_live.date < UTC_TIMESTAMP()";
736 736
 			$query_data = array(':ident' => $ident);
737 737
 		} else {
738
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
738
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
739 739
 				WHERE tracker_live.ident = :ident 
740 740
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
741 741
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -744,8 +744,8 @@  discard block
 block discarded – undo
744 744
 		
745 745
 		$sth = $this->db->prepare($query);
746 746
 		$sth->execute($query_data);
747
-		$ident_result='';
748
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
747
+		$ident_result = '';
748
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
749 749
 		{
750 750
 			$ident_result = $row['famtrackid'];
751 751
 		}
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
 	{
763 763
 		global $globalDBdriver, $globalTimezone;
764 764
 		if ($globalDBdriver == 'mysql') {
765
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
765
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
766 766
 				WHERE tracker_live.famtrackid = :id 
767 767
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
768 768
 //				AND tracker_live.date < UTC_TIMESTAMP()";
769 769
 			$query_data = array(':id' => $id);
770 770
 		} else {
771
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
771
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
772 772
 				WHERE tracker_live.famtrackid = :id 
773 773
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
774 774
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 		
778 778
 		$sth = $this->db->prepare($query);
779 779
 		$sth->execute($query_data);
780
-		$ident_result='';
781
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
780
+		$ident_result = '';
781
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
782 782
 		{
783 783
 			$ident_result = $row['famtrackid'];
784 784
 		}
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
 	* @return String success or false
797 797
 	*
798 798
 	*/
799
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
799
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
800 800
 	{
801 801
 		global $globalURL, $globalArchive, $globalDebug;
802 802
 		$Common = new Common();
@@ -855,31 +855,31 @@  discard block
 block discarded – undo
855 855
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
856 856
 
857 857
         
858
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
859
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
860
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
861
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
862
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
863
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
864
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
865
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
866
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
867
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
868
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
869
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
870
-
871
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
872
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
858
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
859
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
860
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
861
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
862
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
863
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
864
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
865
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
866
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
867
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
868
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
869
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
870
+
871
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
872
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
873 873
             	
874
-		$query  = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
874
+		$query = 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
875 875
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
876 876
 
877
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
877
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
878 878
 		try {
879 879
 			
880 880
 			$sth = $this->db->prepare($query);
881 881
 			$sth->execute($query_values);
882
-                } catch(PDOException $e) {
882
+                } catch (PDOException $e) {
883 883
                 	return "error : ".$e->getMessage();
884 884
                 }
885 885
 		/*
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 
897 897
 	public function getOrderBy()
898 898
 	{
899
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
899
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
900 900
 		return $orderby;
901 901
 	}
902 902
 
Please login to merge, or discard this patch.
require/class.Marine.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @return Array the SQL part
17 17
 	*/
18 18
 	
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
38
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
72 72
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
73 73
 		if ($filter_query_where != '') {
74
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
74
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
75 75
 		}
76 76
 		$filter_query = $filter_query_join.$filter_query_where;
77 77
 		return $filter_query;
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @return Array the spotter information
87 87
 	*
88 88
 	*/
89
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
89
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
90 90
 	{
91 91
 		date_default_timezone_set('UTC');
92 92
 		if (!is_string($query))
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 			$sth = $this->db->prepare($query.$limitQuery);
107 107
 			$sth->execute($params);
108 108
 		} catch (PDOException $e) {
109
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
109
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
110 110
 			exit();
111 111
 		}
112 112
 		
113 113
 		$num_rows = 0;
114 114
 		$spotter_array = array();
115
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
115
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
116 116
 		{
117 117
 			$num_rows++;
118 118
 			$temp_array = array();
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 			}
144 144
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
145 145
 
146
-			if($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE)
146
+			if ($temp_array['mmsi'] != "" && isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE)
147 147
 			{
148 148
 				$Image = new Image($this->db);
149
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
149
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
150 150
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
151 151
 				unset($Image);
152 152
 				if (count($image_array) > 0) {
@@ -182,17 +182,17 @@  discard block
 block discarded – undo
182 182
 				{
183 183
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
184 184
 				} else {
185
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
185
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
186 186
 				}
187 187
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
188
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
189
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
188
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
189
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
190 190
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
191 191
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
192 192
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
193 193
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
194
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
195
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
194
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
195
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
196 196
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
197 197
 					}
198 198
 				}
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
 		{
230 230
 			$limit_array = explode(",", $limit);
231 231
 			
232
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
233
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
232
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
233
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
234 234
 			
235 235
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
236 236
 			{
@@ -247,9 +247,9 @@  discard block
 block discarded – undo
247 247
 			$orderby_query = " ORDER BY marine_output.date DESC";
248 248
 		}
249 249
 
250
-		$query  = $global_query.$filter_query." ".$orderby_query;
250
+		$query = $global_query.$filter_query." ".$orderby_query;
251 251
 
252
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
252
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
253 253
 
254 254
 		return $spotter_array;
255 255
 	}
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 		if ($id == '') return array();
269 269
 		$additional_query = "marine_output.fammarine_id = :id";
270 270
 		$query_values = array(':id' => $id);
271
-		$query  = $global_query." WHERE ".$additional_query." ";
272
-		$spotter_array = $this->getDataFromDB($query,$query_values);
271
+		$query = $global_query." WHERE ".$additional_query." ";
272
+		$spotter_array = $this->getDataFromDB($query, $query_values);
273 273
 		return $spotter_array;
274 274
 	}
275 275
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 		$query_values = array();
289 289
 		$limit_query = '';
290 290
 		$additional_query = '';
291
-		$filter_query = $this->getFilter($filter,true,true);
291
+		$filter_query = $this->getFilter($filter, true, true);
292 292
 		if ($ident != "")
293 293
 		{
294 294
 			if (!is_string($ident))
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 		{
305 305
 			$limit_array = explode(",", $limit);
306 306
 			
307
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
308
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
307
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
308
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
309 309
 			
310 310
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
311 311
 			{
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		return $spotter_array;
330 330
 	}
331 331
 	
332
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
332
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
333 333
 	{
334 334
 		global $global_query, $globalTimezone, $globalDBdriver;
335 335
 		
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		$limit_query = '';
338 338
 		$additional_query = '';
339 339
 
340
-		$filter_query = $this->getFilter($filter,true,true);
340
+		$filter_query = $this->getFilter($filter, true, true);
341 341
 		
342 342
 		if ($date != "")
343 343
 		{
@@ -363,8 +363,8 @@  discard block
 block discarded – undo
363 363
 		{
364 364
 			$limit_array = explode(",", $limit);
365 365
 			
366
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
367
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
366
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
367
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
368 368
 			
369 369
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
370 370
 			{
@@ -395,11 +395,11 @@  discard block
 block discarded – undo
395 395
 	* @return Array list of source name
396 396
 	*
397 397
 	*/
398
-	public function getAllSourceName($type = '',$filters = array())
398
+	public function getAllSourceName($type = '', $filters = array())
399 399
 	{
400
-		$filter_query = $this->getFilter($filters,true,true);
400
+		$filter_query = $this->getFilter($filters, true, true);
401 401
 		$query_values = array();
402
-		$query  = "SELECT DISTINCT marine_output.source_name 
402
+		$query = "SELECT DISTINCT marine_output.source_name 
403 403
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
404 404
 		if ($type != '') {
405 405
 			$query_values = array(':type' => $type);
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		$source_array = array();
415 415
 		$temp_array = array();
416 416
 		
417
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
417
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
418 418
 		{
419 419
 			$temp_array['source_name'] = $row['source_name'];
420 420
 			$source_array[] = $temp_array;
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	*/
432 432
 	public function getAllIdents($filters = array())
433 433
 	{
434
-		$filter_query = $this->getFilter($filters,true,true);
435
-		$query  = "SELECT DISTINCT marine_output.ident
434
+		$filter_query = $this->getFilter($filters, true, true);
435
+		$query = "SELECT DISTINCT marine_output.ident
436 436
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
437 437
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
438 438
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 		$ident_array = array();
443 443
 		$temp_array = array();
444 444
 		
445
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
445
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
446 446
 		{
447 447
 			$temp_array['ident'] = $row['ident'];
448 448
 			$ident_array[] = $temp_array;
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 	*/
460 460
 	public function getIdentity($mmsi)
461 461
 	{
462
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
462
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
463 463
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
464 464
 		$sth = $this->db->prepare($query);
465 465
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -484,12 +484,12 @@  discard block
 block discarded – undo
484 484
 		} else $offset = '+00:00';
485 485
 
486 486
 		if ($globalDBdriver == 'mysql') {
487
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
487
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
488 488
 								FROM marine_output
489 489
 								WHERE marine_output.date <> '' 
490 490
 								ORDER BY marine_output.date ASC LIMIT 0,200";
491 491
 		} else {
492
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
492
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
493 493
 								FROM marine_output
494 494
 								WHERE marine_output.date <> '' 
495 495
 								ORDER BY marine_output.date ASC LIMIT 0,200";
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 		$date_array = array();
502 502
 		$temp_array = array();
503 503
 		
504
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
504
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
505 505
 		{
506 506
 			$temp_array['date'] = $row['date'];
507 507
 
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 	* @return String success or false
521 521
 	*
522 522
 	*/	
523
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
523
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
524 524
 	{
525 525
 
526 526
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
527
-                $query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
527
+                $query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
528 528
 
529 529
 		try {
530 530
 			$sth = $this->db->prepare($query);
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
548 548
 	{
549 549
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
550
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
550
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
551 551
 
552 552
 		try {
553 553
 			$sth = $this->db->prepare($query);
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 	* @param String $verticalrate vertival rate of flight
586 586
 	* @return String success or false
587 587
 	*/
588
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$format_source = '', $source_name = '')
588
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $format_source = '', $source_name = '')
589 589
 	{
590 590
 		global $globalURL, $globalMarineImageFetch;
591 591
 		
@@ -652,31 +652,31 @@  discard block
 block discarded – undo
652 652
 		}
653 653
 
654 654
     
655
-		if ($date == "" || strtotime($date) < time()-20*60)
655
+		if ($date == "" || strtotime($date) < time() - 20*60)
656 656
 		{
657 657
 			$date = date("Y-m-d H:i:s", time());
658 658
 		}
659 659
 
660
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
661
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
662
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
663
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
664
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
665
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
666
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
667
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
668
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
669
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
670
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
671
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
672
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
673
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
660
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
661
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
662
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
663
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
664
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
665
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
666
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
667
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
668
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
669
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
670
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
671
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
672
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
673
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
674 674
 	
675 675
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
676 676
 			$Image = new Image($this->db);
677
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
677
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
678 678
 			if (!isset($image_array[0]['mmsi'])) {
679
-				$Image->addMarineImage($mmsi,$imo,$ident);
679
+				$Image->addMarineImage($mmsi, $imo, $ident);
680 680
 			}
681 681
 			unset($Image);
682 682
 		}
@@ -688,10 +688,10 @@  discard block
 block discarded – undo
688 688
                 if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
689 689
                 if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
690 690
                 if ($arrival_date == '') $arrival_date = NULL;
691
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
691
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, status,imo,arrival_port_name,arrival_port_date) 
692 692
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:status,:imo,:arrival_port_name,:arrival_port_date)";
693 693
 
694
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':status' => $status,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
694
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':status' => $status, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
695 695
 		try {
696 696
 		        
697 697
 			$sth = $this->db->prepare($query);
@@ -716,13 +716,13 @@  discard block
 block discarded – undo
716 716
 	{
717 717
 		global $globalDBdriver, $globalTimezone;
718 718
 		if ($globalDBdriver == 'mysql') {
719
-			$query  = "SELECT marine_output.ident FROM marine_output 
719
+			$query = "SELECT marine_output.ident FROM marine_output 
720 720
 								WHERE marine_output.ident = :ident 
721 721
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
722 722
 								AND marine_output.date < UTC_TIMESTAMP()";
723 723
 			$query_data = array(':ident' => $ident);
724 724
 		} else {
725
-			$query  = "SELECT marine_output.ident FROM marine_output 
725
+			$query = "SELECT marine_output.ident FROM marine_output 
726 726
 								WHERE marine_output.ident = :ident 
727 727
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
728 728
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -731,8 +731,8 @@  discard block
 block discarded – undo
731 731
 		
732 732
 		$sth = $this->db->prepare($query);
733 733
 		$sth->execute($query_data);
734
-    		$ident_result='';
735
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
734
+    		$ident_result = '';
735
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
736 736
 		{
737 737
 			$ident_result = $row['ident'];
738 738
 		}
@@ -758,8 +758,8 @@  discard block
 block discarded – undo
758 758
 				return false;
759 759
 			} else {
760 760
 				$q_array = explode(" ", $q);
761
-				foreach ($q_array as $q_item){
762
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
761
+				foreach ($q_array as $q_item) {
762
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
763 763
 					$additional_query .= " AND (";
764 764
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
765 765
 					$additional_query .= ")";
@@ -767,11 +767,11 @@  discard block
 block discarded – undo
767 767
 			}
768 768
 		}
769 769
 		if ($globalDBdriver == 'mysql') {
770
-			$query  = "SELECT marine_output.* FROM marine_output 
770
+			$query = "SELECT marine_output.* FROM marine_output 
771 771
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
772 772
 				AND marine_output.date < UTC_TIMESTAMP()";
773 773
 		} else {
774
-			$query  = "SELECT marine_output.* FROM marine_output 
774
+			$query = "SELECT marine_output.* FROM marine_output 
775 775
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
776 776
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
777 777
 		}
@@ -844,11 +844,11 @@  discard block
 block discarded – undo
844 844
 	* @return Array the callsign list
845 845
 	*
846 846
 	*/
847
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
847
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
848 848
 	{
849 849
 		global $globalDBdriver;
850
-		$filter_query = $this->getFilter($filters,true,true);
851
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
850
+		$filter_query = $this->getFilter($filters, true, true);
851
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
852 852
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
853 853
 		 if ($olderthanmonths > 0) {
854 854
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -862,28 +862,28 @@  discard block
 block discarded – undo
862 862
 		if ($year != '') {
863 863
 			if ($globalDBdriver == 'mysql') {
864 864
 				$query .= " AND YEAR(marine_output.date) = :year";
865
-				$query_values = array_merge($query_values,array(':year' => $year));
865
+				$query_values = array_merge($query_values, array(':year' => $year));
866 866
 			} else {
867 867
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
868
-				$query_values = array_merge($query_values,array(':year' => $year));
868
+				$query_values = array_merge($query_values, array(':year' => $year));
869 869
 			}
870 870
 		}
871 871
 		if ($month != '') {
872 872
 			if ($globalDBdriver == 'mysql') {
873 873
 				$query .= " AND MONTH(marine_output.date) = :month";
874
-				$query_values = array_merge($query_values,array(':month' => $month));
874
+				$query_values = array_merge($query_values, array(':month' => $month));
875 875
 			} else {
876 876
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
877
-				$query_values = array_merge($query_values,array(':month' => $month));
877
+				$query_values = array_merge($query_values, array(':month' => $month));
878 878
 			}
879 879
 		}
880 880
 		if ($day != '') {
881 881
 			if ($globalDBdriver == 'mysql') {
882 882
 				$query .= " AND DAY(marine_output.date) = :day";
883
-				$query_values = array_merge($query_values,array(':day' => $day));
883
+				$query_values = array_merge($query_values, array(':day' => $day));
884 884
 			} else {
885 885
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
886
-				$query_values = array_merge($query_values,array(':day' => $day));
886
+				$query_values = array_merge($query_values, array(':day' => $day));
887 887
 			}
888 888
 		}
889 889
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 		$callsign_array = array();
896 896
 		$temp_array = array();
897 897
         
898
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
898
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
899 899
 		{
900 900
 			$temp_array['callsign_icao'] = $row['ident'];
901 901
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 		$date_array = array();
948 948
 		$temp_array = array();
949 949
         
950
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
950
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
951 951
 		{
952 952
 			$temp_array['date_name'] = $row['date_name'];
953 953
 			$temp_array['date_count'] = $row['date_count'];
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 			$datetime = new DateTime();
974 974
 			$offset = $datetime->format('P');
975 975
 		} else $offset = '+00:00';
976
-		$filter_query = $this->getFilter($filters,true,true);
976
+		$filter_query = $this->getFilter($filters, true, true);
977 977
 		if ($globalDBdriver == 'mysql') {
978 978
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
979 979
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -994,7 +994,7 @@  discard block
 block discarded – undo
994 994
 		$date_array = array();
995 995
 		$temp_array = array();
996 996
         
997
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
997
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
998 998
 		{
999 999
 			$temp_array['date_name'] = $row['date_name'];
1000 1000
 			$temp_array['date_count'] = $row['date_count'];
@@ -1019,7 +1019,7 @@  discard block
 block discarded – undo
1019 1019
 			$datetime = new DateTime();
1020 1020
 			$offset = $datetime->format('P');
1021 1021
 		} else $offset = '+00:00';
1022
-		$filter_query = $this->getFilter($filters,true,true);
1022
+		$filter_query = $this->getFilter($filters, true, true);
1023 1023
 		if ($globalDBdriver == 'mysql') {
1024 1024
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1025 1025
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1040,7 +1040,7 @@  discard block
 block discarded – undo
1040 1040
 		$date_array = array();
1041 1041
 		$temp_array = array();
1042 1042
         
1043
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1043
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1044 1044
 		{
1045 1045
 			$temp_array['date_name'] = $row['date_name'];
1046 1046
 			$temp_array['date_count'] = $row['date_count'];
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 		$date_array = array();
1088 1088
 		$temp_array = array();
1089 1089
         
1090
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1090
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1091 1091
 		{
1092 1092
 			$temp_array['month_name'] = $row['month_name'];
1093 1093
 			$temp_array['year_name'] = $row['year_name'];
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 			$datetime = new DateTime();
1117 1117
 			$offset = $datetime->format('P');
1118 1118
 		} else $offset = '+00:00';
1119
-		$filter_query = $this->getFilter($filters,true,true);
1119
+		$filter_query = $this->getFilter($filters, true, true);
1120 1120
 		if ($globalDBdriver == 'mysql') {
1121 1121
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1122 1122
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 		$date_array = array();
1138 1138
 		$temp_array = array();
1139 1139
         
1140
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1140
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1141 1141
 		{
1142 1142
 			$temp_array['year_name'] = $row['year_name'];
1143 1143
 			$temp_array['month_name'] = $row['month_name'];
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 	* @return Array the hour list
1158 1158
 	*
1159 1159
 	*/
1160
-	public function countAllHours($orderby,$filters = array())
1160
+	public function countAllHours($orderby, $filters = array())
1161 1161
 	{
1162 1162
 		global $globalTimezone, $globalDBdriver;
1163 1163
 		if ($globalTimezone != '') {
@@ -1205,7 +1205,7 @@  discard block
 block discarded – undo
1205 1205
 		$hour_array = array();
1206 1206
 		$temp_array = array();
1207 1207
         
1208
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1208
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1209 1209
 		{
1210 1210
 			$temp_array['hour_name'] = $row['hour_name'];
1211 1211
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1227,8 +1227,8 @@  discard block
 block discarded – undo
1227 1227
 	public function countAllHoursByDate($date, $filters = array())
1228 1228
 	{
1229 1229
 		global $globalTimezone, $globalDBdriver;
1230
-		$filter_query = $this->getFilter($filters,true,true);
1231
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1230
+		$filter_query = $this->getFilter($filters, true, true);
1231
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1232 1232
 		if ($globalTimezone != '') {
1233 1233
 			date_default_timezone_set($globalTimezone);
1234 1234
 			$datetime = new DateTime($date);
@@ -1236,12 +1236,12 @@  discard block
 block discarded – undo
1236 1236
 		} else $offset = '+00:00';
1237 1237
 
1238 1238
 		if ($globalDBdriver == 'mysql') {
1239
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1239
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1240 1240
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1241 1241
 								GROUP BY hour_name 
1242 1242
 								ORDER BY hour_name ASC";
1243 1243
 		} else {
1244
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1244
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1245 1245
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1246 1246
 								GROUP BY hour_name 
1247 1247
 								ORDER BY hour_name ASC";
@@ -1253,7 +1253,7 @@  discard block
 block discarded – undo
1253 1253
 		$hour_array = array();
1254 1254
 		$temp_array = array();
1255 1255
         
1256
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1256
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1257 1257
 		{
1258 1258
 			$temp_array['hour_name'] = $row['hour_name'];
1259 1259
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 	public function countAllHoursByIdent($ident, $filters = array())
1276 1276
 	{
1277 1277
 		global $globalTimezone, $globalDBdriver;
1278
-		$filter_query = $this->getFilter($filters,true,true);
1279
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1278
+		$filter_query = $this->getFilter($filters, true, true);
1279
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1280 1280
 		if ($globalTimezone != '') {
1281 1281
 			date_default_timezone_set($globalTimezone);
1282 1282
 			$datetime = new DateTime();
@@ -1284,12 +1284,12 @@  discard block
 block discarded – undo
1284 1284
 		} else $offset = '+00:00';
1285 1285
 
1286 1286
 		if ($globalDBdriver == 'mysql') {
1287
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1287
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1288 1288
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1289 1289
 								GROUP BY hour_name 
1290 1290
 								ORDER BY hour_name ASC";
1291 1291
 		} else {
1292
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1292
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1293 1293
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1294 1294
 								GROUP BY hour_name 
1295 1295
 								ORDER BY hour_name ASC";
@@ -1297,12 +1297,12 @@  discard block
 block discarded – undo
1297 1297
       
1298 1298
 		
1299 1299
 		$sth = $this->db->prepare($query);
1300
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1300
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1301 1301
       
1302 1302
 		$hour_array = array();
1303 1303
 		$temp_array = array();
1304 1304
         
1305
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1305
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1306 1306
 		{
1307 1307
 			$temp_array['hour_name'] = $row['hour_name'];
1308 1308
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1321,32 +1321,32 @@  discard block
 block discarded – undo
1321 1321
 	* @return Integer the number of flights
1322 1322
 	*
1323 1323
 	*/
1324
-	public function countOverallTracked($filters = array(),$year = '',$month = '')
1324
+	public function countOverallTracked($filters = array(), $year = '', $month = '')
1325 1325
 	{
1326 1326
 		global $globalDBdriver;
1327
-		$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1327
+		$queryi = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1328 1328
 		$query_values = array();
1329 1329
 		$query = '';
1330 1330
 		if ($year != '') {
1331 1331
 			if ($globalDBdriver == 'mysql') {
1332 1332
 				$query .= " AND YEAR(marine_output.date) = :year";
1333
-				$query_values = array_merge($query_values,array(':year' => $year));
1333
+				$query_values = array_merge($query_values, array(':year' => $year));
1334 1334
 			} else {
1335 1335
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1336
-				$query_values = array_merge($query_values,array(':year' => $year));
1336
+				$query_values = array_merge($query_values, array(':year' => $year));
1337 1337
 			}
1338 1338
 		}
1339 1339
 		if ($month != '') {
1340 1340
 			if ($globalDBdriver == 'mysql') {
1341 1341
 				$query .= " AND MONTH(marine_output.date) = :month";
1342
-				$query_values = array_merge($query_values,array(':month' => $month));
1342
+				$query_values = array_merge($query_values, array(':month' => $month));
1343 1343
 			} else {
1344 1344
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1345
-				$query_values = array_merge($query_values,array(':month' => $month));
1345
+				$query_values = array_merge($query_values, array(':month' => $month));
1346 1346
 			}
1347 1347
 		}
1348 1348
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1349
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1349
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1350 1350
 		
1351 1351
 		$sth = $this->db->prepare($queryi);
1352 1352
 		$sth->execute($query_values);
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 	public function countAllHoursFromToday($filters = array())
1364 1364
 	{
1365 1365
 		global $globalTimezone, $globalDBdriver;
1366
-		$filter_query = $this->getFilter($filters,true,true);
1366
+		$filter_query = $this->getFilter($filters, true, true);
1367 1367
 		if ($globalTimezone != '') {
1368 1368
 			date_default_timezone_set($globalTimezone);
1369 1369
 			$datetime = new DateTime();
@@ -1371,12 +1371,12 @@  discard block
 block discarded – undo
1371 1371
 		} else $offset = '+00:00';
1372 1372
 
1373 1373
 		if ($globalDBdriver == 'mysql') {
1374
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1374
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1375 1375
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1376 1376
 								GROUP BY hour_name 
1377 1377
 								ORDER BY hour_name ASC";
1378 1378
 		} else {
1379
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1379
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1380 1380
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1381 1381
 								GROUP BY hour_name 
1382 1382
 								ORDER BY hour_name ASC";
@@ -1388,7 +1388,7 @@  discard block
 block discarded – undo
1388 1388
 		$hour_array = array();
1389 1389
 		$temp_array = array();
1390 1390
         
1391
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1391
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1392 1392
 		{
1393 1393
 			$temp_array['hour_name'] = $row['hour_name'];
1394 1394
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1407,9 +1407,9 @@  discard block
 block discarded – undo
1407 1407
 	*/
1408 1408
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1409 1409
 	{
1410
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1410
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1411 1411
 
1412
-		$query  = "SELECT marine_output.marine_id
1412
+		$query = "SELECT marine_output.marine_id
1413 1413
 				FROM marine_output 
1414 1414
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1415 1415
         
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
 		$sth = $this->db->prepare($query);
1418 1418
 		$sth->execute();
1419 1419
 
1420
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1420
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1421 1421
 		{
1422 1422
 			return $row['marine_id'];
1423 1423
 		}
@@ -1442,23 +1442,23 @@  discard block
 block discarded – undo
1442 1442
 		}
1443 1443
 		
1444 1444
 		$current_date = date("Y-m-d H:i:s");
1445
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1445
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1446 1446
 		
1447 1447
 		$diff = abs(strtotime($current_date) - strtotime($date));
1448 1448
 
1449
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1449
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1450 1450
 		$years = $time_array['years'];
1451 1451
 		
1452
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1452
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1453 1453
 		$months = $time_array['months'];
1454 1454
 		
1455
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1455
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1456 1456
 		$days = $time_array['days'];
1457
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1457
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1458 1458
 		$hours = $time_array['hours'];
1459
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1459
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1460 1460
 		$minutes = $time_array['minutes'];
1461
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1461
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1462 1462
 		
1463 1463
 		return $time_array;
1464 1464
 	}
@@ -1481,63 +1481,63 @@  discard block
 block discarded – undo
1481 1481
 			$temp_array['direction_degree'] = $direction;
1482 1482
 			$temp_array['direction_shortname'] = "N";
1483 1483
 			$temp_array['direction_fullname'] = "North";
1484
-		} elseif ($direction >= 22.5 && $direction < 45){
1484
+		} elseif ($direction >= 22.5 && $direction < 45) {
1485 1485
 			$temp_array['direction_degree'] = $direction;
1486 1486
 			$temp_array['direction_shortname'] = "NNE";
1487 1487
 			$temp_array['direction_fullname'] = "North-Northeast";
1488
-		} elseif ($direction >= 45 && $direction < 67.5){
1488
+		} elseif ($direction >= 45 && $direction < 67.5) {
1489 1489
 			$temp_array['direction_degree'] = $direction;
1490 1490
 			$temp_array['direction_shortname'] = "NE";
1491 1491
 			$temp_array['direction_fullname'] = "Northeast";
1492
-		} elseif ($direction >= 67.5 && $direction < 90){
1492
+		} elseif ($direction >= 67.5 && $direction < 90) {
1493 1493
 			$temp_array['direction_degree'] = $direction;
1494 1494
 			$temp_array['direction_shortname'] = "ENE";
1495 1495
 			$temp_array['direction_fullname'] = "East-Northeast";
1496
-		} elseif ($direction >= 90 && $direction < 112.5){
1496
+		} elseif ($direction >= 90 && $direction < 112.5) {
1497 1497
 			$temp_array['direction_degree'] = $direction;
1498 1498
 			$temp_array['direction_shortname'] = "E";
1499 1499
 			$temp_array['direction_fullname'] = "East";
1500
-		} elseif ($direction >= 112.5 && $direction < 135){
1500
+		} elseif ($direction >= 112.5 && $direction < 135) {
1501 1501
 			$temp_array['direction_degree'] = $direction;
1502 1502
 			$temp_array['direction_shortname'] = "ESE";
1503 1503
 			$temp_array['direction_fullname'] = "East-Southeast";
1504
-		} elseif ($direction >= 135 && $direction < 157.5){
1504
+		} elseif ($direction >= 135 && $direction < 157.5) {
1505 1505
 			$temp_array['direction_degree'] = $direction;
1506 1506
 			$temp_array['direction_shortname'] = "SE";
1507 1507
 			$temp_array['direction_fullname'] = "Southeast";
1508
-		} elseif ($direction >= 157.5 && $direction < 180){
1508
+		} elseif ($direction >= 157.5 && $direction < 180) {
1509 1509
 			$temp_array['direction_degree'] = $direction;
1510 1510
 			$temp_array['direction_shortname'] = "SSE";
1511 1511
 			$temp_array['direction_fullname'] = "South-Southeast";
1512
-		} elseif ($direction >= 180 && $direction < 202.5){
1512
+		} elseif ($direction >= 180 && $direction < 202.5) {
1513 1513
 			$temp_array['direction_degree'] = $direction;
1514 1514
 			$temp_array['direction_shortname'] = "S";
1515 1515
 			$temp_array['direction_fullname'] = "South";
1516
-		} elseif ($direction >= 202.5 && $direction < 225){
1516
+		} elseif ($direction >= 202.5 && $direction < 225) {
1517 1517
 			$temp_array['direction_degree'] = $direction;
1518 1518
 			$temp_array['direction_shortname'] = "SSW";
1519 1519
 			$temp_array['direction_fullname'] = "South-Southwest";
1520
-		} elseif ($direction >= 225 && $direction < 247.5){
1520
+		} elseif ($direction >= 225 && $direction < 247.5) {
1521 1521
 			$temp_array['direction_degree'] = $direction;
1522 1522
 			$temp_array['direction_shortname'] = "SW";
1523 1523
 			$temp_array['direction_fullname'] = "Southwest";
1524
-		} elseif ($direction >= 247.5 && $direction < 270){
1524
+		} elseif ($direction >= 247.5 && $direction < 270) {
1525 1525
 			$temp_array['direction_degree'] = $direction;
1526 1526
 			$temp_array['direction_shortname'] = "WSW";
1527 1527
 			$temp_array['direction_fullname'] = "West-Southwest";
1528
-		} elseif ($direction >= 270 && $direction < 292.5){
1528
+		} elseif ($direction >= 270 && $direction < 292.5) {
1529 1529
 			$temp_array['direction_degree'] = $direction;
1530 1530
 			$temp_array['direction_shortname'] = "W";
1531 1531
 			$temp_array['direction_fullname'] = "West";
1532
-		} elseif ($direction >= 292.5 && $direction < 315){
1532
+		} elseif ($direction >= 292.5 && $direction < 315) {
1533 1533
 			$temp_array['direction_degree'] = $direction;
1534 1534
 			$temp_array['direction_shortname'] = "WNW";
1535 1535
 			$temp_array['direction_fullname'] = "West-Northwest";
1536
-		} elseif ($direction >= 315 && $direction < 337.5){
1536
+		} elseif ($direction >= 315 && $direction < 337.5) {
1537 1537
 			$temp_array['direction_degree'] = $direction;
1538 1538
 			$temp_array['direction_shortname'] = "NW";
1539 1539
 			$temp_array['direction_fullname'] = "Northwest";
1540
-		} elseif ($direction >= 337.5 && $direction < 360){
1540
+		} elseif ($direction >= 337.5 && $direction < 360) {
1541 1541
 			$temp_array['direction_degree'] = $direction;
1542 1542
 			$temp_array['direction_shortname'] = "NNW";
1543 1543
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1554,11 +1554,11 @@  discard block
 block discarded – undo
1554 1554
 	* @param Float $longitude longitute of the flight
1555 1555
 	* @return String the countrie
1556 1556
 	*/
1557
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1557
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1558 1558
 	{
1559 1559
 		global $globalDBdriver, $globalDebug;
1560
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1561
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1560
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1561
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1562 1562
 	
1563 1563
 		$Connection = new Connection($this->db);
1564 1564
 		if (!$Connection->tableExists('countries')) return '';
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
 	public function getCountryFromISO2($iso2)
1599 1599
 	{
1600 1600
 		global $globalDBdriver, $globalDebug;
1601
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1601
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1602 1602
 	
1603 1603
 		$Connection = new Connection($this->db);
1604 1604
 		if (!$Connection->tableExists('countries')) return '';
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
 		
1647 1647
 		$bitly_data = json_decode($bitly_data);
1648 1648
 		$bitly_url = '';
1649
-		if ($bitly_data->status_txt = "OK"){
1649
+		if ($bitly_data->status_txt = "OK") {
1650 1650
 			$bitly_url = $bitly_data->data->url;
1651 1651
 		}
1652 1652
 
@@ -1656,7 +1656,7 @@  discard block
 block discarded – undo
1656 1656
 
1657 1657
 	public function getOrderBy()
1658 1658
 	{
1659
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
1659
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY marine_output.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY marine_output.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
1660 1660
 		
1661 1661
 		return $orderby;
1662 1662
 		
Please login to merge, or discard this patch.
require/class.Image.php 1 patch
Spacing   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	* @return Array the images list
18 18
 	*
19 19
 	*/
20
-	public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
20
+	public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
21 21
 	{
22
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
23
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
24
-		$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
22
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
23
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
24
+		$airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
25 25
 		$reg = $registration;
26 26
 		if ($reg == '' && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao;
27 27
 		$reg = trim($reg);
28
-		$query  = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
28
+		$query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration 
29 29
 			FROM spotter_image 
30 30
 			WHERE spotter_image.registration = :registration LIMIT 1";
31 31
 		$sth = $this->db->prepare($query);
32 32
 		$sth->execute(array(':registration' => $reg));
33 33
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
34 34
 		if (!empty($result)) return $result;
35
-		elseif ($registration != '') return $this->getSpotterImage('',$aircraft_icao,$airline_icao);
35
+		elseif ($registration != '') return $this->getSpotterImage('', $aircraft_icao, $airline_icao);
36 36
 		else return array();
37 37
 	}
38 38
 
@@ -42,23 +42,23 @@  discard block
 block discarded – undo
42 42
 	* @return Array the images list
43 43
 	*
44 44
 	*/
45
-	public function getMarineImage($mmsi,$imo = '',$name = '')
45
+	public function getMarineImage($mmsi, $imo = '', $name = '')
46 46
 	{
47
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
48
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
49
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
47
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
48
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
49
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
50 50
 		$name = trim($name);
51
-		$query  = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
51
+		$query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name 
52 52
 			FROM marine_image 
53 53
 			WHERE marine_image.mmsi = :mmsi";
54 54
 		$query_data = array(':mmsi' => $mmsi);
55 55
 		if ($imo != '') {
56 56
 			$query .= " AND marine_image.imo = :imo";
57
-			$query_data = array_merge($query_data,array(':imo' => $imo));
57
+			$query_data = array_merge($query_data, array(':imo' => $imo));
58 58
 		}
59 59
 		if ($name != '') {
60 60
 			$query .= " AND marine_image.name = :name";
61
-			$query_data = array_merge($query_data,array(':name' => $name));
61
+			$query_data = array_merge($query_data, array(':name' => $name));
62 62
 		}
63 63
 		$query .= " LIMIT 1";
64 64
 		$sth = $this->db->prepare($query);
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 		if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright'];
80 80
 		elseif (isset($exif['copyright'])) $copyright = $exif['copyright'];
81 81
 		if ($copyright != '') {
82
-			$copyright = str_replace('Copyright ','',$copyright);
83
-			$copyright = str_replace('© ','',$copyright);
84
-			$copyright = str_replace('(c) ','',$copyright);
82
+			$copyright = str_replace('Copyright ', '', $copyright);
83
+			$copyright = str_replace('© ', '', $copyright);
84
+			$copyright = str_replace('(c) ', '', $copyright);
85 85
 		}
86 86
 		return $copyright;
87 87
 	}
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
 	* @return String either success or error
93 93
 	*
94 94
 	*/
95
-	public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '')
95
+	public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '')
96 96
 	{
97
-		global $globalDebug,$globalAircraftImageFetch;
97
+		global $globalDebug, $globalAircraftImageFetch;
98 98
 		if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return '';
99
-		$registration = filter_var($registration,FILTER_SANITIZE_STRING);
99
+		$registration = filter_var($registration, FILTER_SANITIZE_STRING);
100 100
 		$registration = trim($registration);
101 101
 		//getting the aircraft image
102 102
 		if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...';
103 103
 		elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...';
104 104
 		elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...';
105
-		$image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao);
105
+		$image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao);
106 106
 		if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao;
107 107
 		if ($image_url['original'] != '') {
108 108
 			if ($globalDebug) echo 'Found !'."\n";
109
-			$query  = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
109
+			$query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)";
110 110
 			try {
111 111
 				$sth = $this->db->prepare($query);
112
-				$sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
113
-			} catch(PDOException $e) {
112
+				$sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
113
+			} catch (PDOException $e) {
114 114
 				echo $e->getMessage()."\n";
115 115
 				return "error";
116 116
 			}
@@ -124,13 +124,13 @@  discard block
 block discarded – undo
124 124
 	* @return String either success or error
125 125
 	*
126 126
 	*/
127
-	public function addMarineImage($mmsi,$imo = '',$name = '')
127
+	public function addMarineImage($mmsi, $imo = '', $name = '')
128 128
 	{
129
-		global $globalDebug,$globalMarineImageFetch;
129
+		global $globalDebug, $globalMarineImageFetch;
130 130
 		if (isset($globalMarineImageFetch) && !$globalMarineImageFetch) return '';
131
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
132
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
133
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
131
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
132
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
133
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
134 134
 		$name = trim($name);
135 135
 		$Marine = new Marine($this->db);
136 136
 		if ($imo == '' || $name == '') {
@@ -144,14 +144,14 @@  discard block
 block discarded – undo
144 144
 
145 145
 		//getting the aircraft image
146 146
 		if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...';
147
-		$image_url = $this->findMarineImage($mmsi,$imo,$name);
147
+		$image_url = $this->findMarineImage($mmsi, $imo, $name);
148 148
 		if ($image_url['original'] != '') {
149 149
 			if ($globalDebug) echo 'Found !'."\n";
150
-			$query  = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
150
+			$query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)";
151 151
 			try {
152 152
 				$sth = $this->db->prepare($query);
153
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website']));
154
-			} catch(PDOException $e) {
153
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website']));
154
+			} catch (PDOException $e) {
155 155
 				echo $e->getMessage()."\n";
156 156
 				return "error";
157 157
 			}
@@ -171,9 +171,9 @@  discard block
 block discarded – undo
171 171
 		global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO;
172 172
 		$Spotter = new Spotter($this->db);
173 173
 		if (!isset($globalIVAO)) $globalIVAO = FALSE;
174
-		$aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING);
174
+		$aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING);
175 175
 		if ($aircraft_registration != '') {
176
-			if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
176
+			if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
177 177
 			$aircraft_registration = urlencode(trim($aircraft_registration));
178 178
 			$aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration);
179 179
 			if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name'];
@@ -187,25 +187,25 @@  discard block
 block discarded – undo
187 187
 			if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type'];
188 188
 			else $aircraft_name = '';
189 189
 			$aircraft_registration = $aircraft_icao;
190
-		} else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
190
+		} else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
191 191
 		unset($Spotter);
192
-		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
192
+		if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters');
193 193
 		foreach ($globalAircraftImageSources as $source) {
194 194
 			$source = strtolower($source);
195
-			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao);
196
-			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name);
197
-			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name);
198
-			if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name);
199
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name);
200
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name);
201
-			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name);
202
-			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name);
203
-			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name);
204
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name);
195
+			if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao);
196
+			if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name);
197
+			if ($source == 'flickr') $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name);
198
+			if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name);
199
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name);
200
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name);
201
+			if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name);
202
+			if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name);
203
+			if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name);
204
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name);
205 205
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
206 206
 		}
207 207
 		if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao);
208
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
208
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
209 209
 	}
210 210
 
211 211
 	/**
@@ -217,14 +217,14 @@  discard block
 block discarded – undo
217 217
 	* @return Array the aircraft thumbnail, orignal url and copyright
218 218
 	*
219 219
 	*/
220
-	public function findMarineImage($mmsi,$imo = '',$name = '')
220
+	public function findMarineImage($mmsi, $imo = '', $name = '')
221 221
 	{
222 222
 		global $globalMarineSources;
223
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
224
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
225
-		$name = filter_var($name,FILTER_SANITIZE_STRING);
223
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
224
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
225
+		$name = filter_var($name, FILTER_SANITIZE_STRING);
226 226
 		$name = trim($name);
227
-		if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => '');
227
+		if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
228 228
 		/*
229 229
 		$Marine = new Marine($this->db);
230 230
 		if ($imo == '' || $name == '') {
@@ -236,17 +236,17 @@  discard block
 block discarded – undo
236 236
 		}
237 237
 		unset($Marine);
238 238
 		*/
239
-		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing');
239
+		if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing');
240 240
 		foreach ($globalMarineImageSources as $source) {
241 241
 			$source = strtolower($source);
242
-			if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name);
243
-			if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name);
244
-			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name);
245
-			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name);
246
-			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name);
242
+			if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name);
243
+			if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name);
244
+			if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name);
245
+			if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name);
246
+			if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name);
247 247
 			if (isset($images_array) && $images_array['original'] != '') return $images_array;
248 248
 		}
249
-		return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => '');
249
+		return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => '');
250 250
 	}
251 251
 
252 252
 	/**
@@ -257,24 +257,24 @@  discard block
 block discarded – undo
257 257
 	* @return Array the aircraft thumbnail, orignal url and copyright
258 258
 	*
259 259
 	*/
260
-	public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') {
260
+	public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') {
261 261
 		$Common = new Common();
262 262
 		// If aircraft registration is only number, also check with aircraft model
263
-		if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') {
264
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
263
+		if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') {
264
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss';
265 265
 		} else {
266 266
 			//$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss';
267
-			$url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
267
+			$url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss';
268 268
 		}
269 269
 		$data = $Common->getData($url);
270 270
 		if ($xml = simplexml_load_string($data)) {
271 271
 			if (isset($xml->channel->item)) {
272 272
 				$image_url = array();
273
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
273
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
274 274
 				$image_url['thumbnail'] = $thumbnail_url;
275
-				$image_url['original'] = str_replace('thumbnail','original',$thumbnail_url);
276
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
277
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
275
+				$image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url);
276
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright);
277
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
278 278
 				$image_url['source'] = 'planespotters';
279 279
 				return $image_url;
280 280
 			}
@@ -290,29 +290,29 @@  discard block
 block discarded – undo
290 290
 	* @return Array the aircraft thumbnail, orignal url and copyright
291 291
 	*
292 292
 	*/
293
-	public function fromDeviantart($type,$registration, $name='') {
293
+	public function fromDeviantart($type, $registration, $name = '') {
294 294
 		$Common = new Common();
295 295
 		if ($type == 'aircraft') {
296 296
 			// If aircraft registration is only number, also check with aircraft model
297
-			if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') {
298
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
297
+			if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') {
298
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name);
299 299
 			} else {
300
-				$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
300
+				$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration;
301 301
 			}
302 302
 		} elseif ($type == 'marine') {
303
-			$url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
303
+			$url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"';
304 304
 		}
305 305
 
306 306
 		$data = $Common->getData($url);
307 307
 		if ($xml = simplexml_load_string($data)) {
308 308
 			if (isset($xml->channel->item->link)) {
309 309
 				$image_url = array();
310
-				$thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
310
+				$thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url);
311 311
 				$image_url['thumbnail'] = $thumbnail_url;
312
-				$original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
312
+				$original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url);
313 313
 				$image_url['original'] = $original_url;
314
-				$image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
315
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
314
+				$image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright));
315
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
316 316
 				$image_url['source'] = 'deviantart';
317 317
 				return $image_url;
318 318
 			}
@@ -328,32 +328,32 @@  discard block
 block discarded – undo
328 328
 	* @return Array the aircraft thumbnail, orignal url and copyright
329 329
 	*
330 330
 	*/
331
-	public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') {
331
+	public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') {
332 332
 		$Common = new Common();
333
-		$url= 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
333
+		$url = 'http://jetphotos.net/showphotos.php?displaymode=2&regsearch='.$aircraft_registration;
334 334
 		$data = $Common->getData($url);
335 335
 		$dom = new DOMDocument();
336 336
 		@$dom->loadHTML($data);
337 337
 		$all_pics = array();
338
-		foreach($dom->getElementsByTagName('img') as $image) {
338
+		foreach ($dom->getElementsByTagName('img') as $image) {
339 339
 			if ($image->getAttribute('itemprop') == "http://schema.org/image") {
340 340
 				$all_pics[] = $image->getAttribute('src');
341 341
 			}
342 342
 		}
343 343
 		$all_authors = array();
344
-		foreach($dom->getElementsByTagName('meta') as $author) {
344
+		foreach ($dom->getElementsByTagName('meta') as $author) {
345 345
 			if ($author->getAttribute('itemprop') == "http://schema.org/author") {
346 346
 				$all_authors[] = $author->getAttribute('content');
347 347
 			}
348 348
 		}
349 349
 		$all_ref = array();
350
-		foreach($dom->getElementsByTagName('a') as $link) {
350
+		foreach ($dom->getElementsByTagName('a') as $link) {
351 351
 			$all_ref[] = $link->getAttribute('href');
352 352
 		}
353 353
 		if (isset($all_pics[0])) {
354 354
 			$image_url = array();
355 355
 			$image_url['thumbnail'] = $all_pics[0];
356
-			$image_url['original'] = str_replace('_tb','',$all_pics[0]);
356
+			$image_url['original'] = str_replace('_tb', '', $all_pics[0]);
357 357
 			$image_url['copyright'] = $all_authors[0];
358 358
 			$image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8];
359 359
 			$image_url['source'] = 'JetPhotos';
@@ -370,24 +370,24 @@  discard block
 block discarded – undo
370 370
 	* @return Array the aircraft thumbnail, orignal url and copyright
371 371
 	*
372 372
 	*/
373
-	public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') {
373
+	public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') {
374 374
 		$Common = new Common();
375
-		$url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
375
+		$url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2';
376 376
 		$data = $Common->getData($url);
377 377
 		$dom = new DOMDocument();
378 378
 		@$dom->loadHTML($data);
379 379
 		$all_pics = array();
380
-		foreach($dom->getElementsByTagName('img') as $image) {
380
+		foreach ($dom->getElementsByTagName('img') as $image) {
381 381
 			$all_pics[] = $image->getAttribute('src');
382 382
 		}
383 383
 		$all_links = array();
384
-		foreach($dom->getElementsByTagName('a') as $link) {
385
-			$all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href'));
384
+		foreach ($dom->getElementsByTagName('a') as $link) {
385
+			$all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href'));
386 386
 		}
387
-		if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) {
387
+		if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) {
388 388
 			$image_url = array();
389 389
 			$image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1];
390
-			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]);
390
+			$image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]);
391 391
 			$image_url['copyright'] = $all_links[6]['text'];
392 392
 			$image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href'];
393 393
 			$image_url['source'] = 'PlanePictures';
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 	* @return Array the aircraft thumbnail, orignal url and copyright
405 405
 	*
406 406
 	*/
407
-	public function fromFlickr($type,$registration,$name='') {
407
+	public function fromFlickr($type, $registration, $name = '') {
408 408
 		$Common = new Common();
409 409
 		if ($type == 'aircraft') {
410 410
 			if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name);
@@ -416,12 +416,12 @@  discard block
 block discarded – undo
416 416
 		$data = $Common->getData($url);
417 417
 		if ($xml = simplexml_load_string($data)) {
418 418
 			if (isset($xml->channel->item)) {
419
-				$original_url = trim((string)$xml->channel->item->enclosure->attributes()->url);
419
+				$original_url = trim((string) $xml->channel->item->enclosure->attributes()->url);
420 420
 				$image_url = array();
421 421
 				$image_url['thumbnail'] = $original_url;
422 422
 				$image_url['original'] = $original_url;
423
-				$image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
424
-				$image_url['source_website'] = trim((string)$xml->channel->item->link);
423
+				$image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit);
424
+				$image_url['source_website'] = trim((string) $xml->channel->item->link);
425 425
 				$image_url['source'] = 'flickr';
426 426
 				return $image_url;
427 427
 			}
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 		return false;
430 430
 	}
431 431
 
432
-	public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) {
432
+	public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) {
433 433
 		$Common = new Common();
434 434
 		//echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg';
435 435
 		if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) {
@@ -453,14 +453,14 @@  discard block
 block discarded – undo
453 453
 	* @return Array the aircraft thumbnail, orignal url and copyright
454 454
 	*
455 455
 	*/
456
-	public function fromBing($type,$aircraft_registration,$aircraft_name='') {
456
+	public function fromBing($type, $aircraft_registration, $aircraft_name = '') {
457 457
 		global $globalImageBingKey;
458 458
 		$Common = new Common();
459 459
 		if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false;
460 460
 		if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27';
461 461
 		else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27';
462
-		$headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey));
463
-		$data = $Common->getData($url,'get','',$headers);
462
+		$headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey));
463
+		$data = $Common->getData($url, 'get', '', $headers);
464 464
 		$result = json_decode($data);
465 465
 		if (isset($result->d->results[0]->MediaUrl)) {
466 466
 			$image_url = array();
@@ -485,14 +485,14 @@  discard block
 block discarded – undo
485 485
 	* @return Array the aircraft thumbnail, orignal url and copyright
486 486
 	*
487 487
 	*/
488
-	public function fromAirportData($type,$aircraft_registration,$aircraft_name='') {
488
+	public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') {
489 489
 		$Common = new Common();
490 490
 		$url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration;
491 491
 		$data = $Common->getData($url);
492 492
 		$result = json_decode($data);
493 493
 		if (isset($result->count) && $result->count > 0) {
494 494
 			$image_url = array();
495
-			$image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image);
495
+			$image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image);
496 496
 			$image_url['source_website'] = $result->data[0]->link;
497 497
 			$image_url['thumbnail'] = $result->data[0]->image;
498 498
 			$image_url['copyright'] = $result->data[0]->photographer;
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 	* @return Array the aircraft thumbnail, orignal url and copyright
511 511
 	*
512 512
 	*/
513
-	public function fromWikimedia($type,$registration,$name='') {
513
+	public function fromWikimedia($type, $registration, $name = '') {
514 514
 		$Common = new Common();
515 515
 		if ($type == 'aircraft') {
516 516
 			if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 		$result = json_decode($data);
524 524
 		if (isset($result->query->search[0]->title)) {
525 525
 			$fileo = $result->query->search[0]->title;
526
-			if (substr($fileo,-3) == 'pdf') return false;
526
+			if (substr($fileo, -3) == 'pdf') return false;
527 527
 			$file = urlencode($fileo);
528 528
 			$url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file;
529 529
 			$data2 = $Common->getData($url2);
@@ -548,11 +548,11 @@  discard block
 block discarded – undo
548 548
 				if (isset($result2->query->pages)) {
549 549
 					foreach ($result2->query->pages as $page) {
550 550
 						if (isset($page->imageinfo[0]->extmetadata->Artist)) {
551
-							$image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
551
+							$image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value));
552 552
 							if (isset($page->imageinfo[0]->extmetadata->License->value)) {
553 553
 								$image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')';
554 554
 							}
555
-							$image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright']));
555
+							$image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright']));
556 556
 							return $image_url;
557 557
 						}
558 558
 					}
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 	* @return Array the aircraft thumbnail, orignal url and copyright
572 572
 	*
573 573
 	*/
574
-	public function fromCustomSource($type,$aircraft_registration,$aircraft_name='') {
574
+	public function fromCustomSource($type, $aircraft_registration, $aircraft_name = '') {
575 575
 		global $globalAircraftImageCustomSources, $globalDebug;
576 576
 		//$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true);
577 577
 		if (!empty($globalAircraftImageCustomSources)) {
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
 					print_r($source);
589 589
 					print_r($customsources);
590 590
 				}
591
-				$url = str_replace('{registration}',$aircraft_registration,$source['original']);
592
-				$url_thumbnail = str_replace('{registration}',$aircraft_registration,$source['thumbnail']);
591
+				$url = str_replace('{registration}', $aircraft_registration, $source['original']);
592
+				$url_thumbnail = str_replace('{registration}', $aircraft_registration, $source['thumbnail']);
593 593
 				if ($Common->urlexist($url)) {
594 594
 					$image_url = array();
595 595
 					$image_url['thumbnail'] = $url_thumbnail;
596 596
 					$image_url['original'] = $url;
597 597
 					if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url);
598 598
 					else $exifCopyright = '';
599
-					if ($exifCopyright  != '') $image_url['copyright'] = $exifCopyright;
599
+					if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright;
600 600
 					elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright'];
601 601
 					else $image_url['copyright'] = $source['source_website'];
602 602
 					$image_url['source_website'] = $source['source_website'];
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -16,62 +16,62 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['airlines']) && !empty($flt['airlines'])) {
37 37
 				if ($flt['airlines'][0] != '') {
38 38
 					if (isset($flt['source'])) {
39
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
39
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
40 40
 					} else {
41
-						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
41
+						$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $flt['airlines'])."')) saf ON saf.flightaware_id = spotter_live.flightaware_id";
42 42
 					}
43 43
 				}
44 44
 			}
45 45
 			if (isset($flt['pilots_id']) && !empty($flt['pilots_id'])) {
46 46
 				if (isset($flt['source'])) {
47
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
47
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
48 48
 				} else {
49
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
49
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $flt['pilots_id'])."')) spi ON spi.flightaware_id = spotter_live.flightaware_id";
50 50
 				}
51 51
 			}
52 52
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
53 53
 				if (isset($flt['source'])) {
54
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
54
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
55 55
 				} else {
56
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
56
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.flightaware_id = spotter_live.flightaware_id";
57 57
 				}
58 58
 			}
59 59
 			if (isset($flt['registrations']) && !empty($flt['registrations'])) {
60 60
 				if (isset($flt['source'])) {
61
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
61
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
62 62
 				} else {
63
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','",$flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
63
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.registration IN ('".implode("','", $flt['registrations'])."')) sre ON sre.flightaware_id = spotter_live.flightaware_id";
64 64
 				}
65 65
 			}
66 66
 			if ((isset($flt['airlines']) && empty($flt['airlines']) && isset($flt['pilots_id']) && empty($flt['pilots_id']) && isset($flt['idents']) && empty($flt['idents'])) || (!isset($flt['airlines']) && !isset($flt['pilots_id']) && !isset($flt['idents']) && !isset($flt['registrations']))) {
67 67
 				if (isset($flt['source'])) {
68
-					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','",$flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
68
+					$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.format_source IN ('".implode("','", $flt['source'])."')) ssf ON ssf.flightaware_id = spotter_live.flightaware_id";
69 69
 				}
70 70
 			}
71 71
 		}
72 72
 		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
73 73
 			if ($filter['airlines'][0] != '') {
74
-				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
74
+				$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) sai ON sai.flightaware_id = spotter_live.flightaware_id";
75 75
 			}
76 76
 		}
77 77
 		if (isset($filter['alliance']) && !empty($filter['alliance'])) {
@@ -81,10 +81,10 @@  discard block
 block discarded – undo
81 81
 			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.flightaware_id = spotter_live.flightaware_id ";
82 82
 		}
83 83
 		if (isset($filter['pilots_id']) && !empty($filter['pilots_id'])) {
84
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','",$filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
84
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output WHERE spotter_output.pilot_id IN ('".implode("','", $filter['pilots_id'])."')) sp ON sp.flightaware_id = spotter_live.flightaware_id";
85 85
 		}
86 86
 		if (isset($filter['source']) && !empty($filter['source'])) {
87
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
87
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
88 88
 		}
89 89
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
90 90
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -113,15 +113,15 @@  discard block
 block discarded – undo
113 113
 					$filter_query_date .= " AND EXTRACT(DAY FROM spotter_output.date) = '".$filter['day']."'";
114 114
 				}
115 115
 			}
116
-			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
116
+			$filter_query_join .= " INNER JOIN (SELECT flightaware_id FROM spotter_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.flightaware_id = spotter_live.flightaware_id";
117 117
 		}
118 118
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
119
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
119
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
120 120
 		}
121 121
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
122 122
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
123 123
 		if ($filter_query_where != '') {
124
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
124
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
125 125
 		}
126 126
 		$filter_query = $filter_query_join.$filter_query_where;
127 127
 		return $filter_query;
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 		if ($limit != '')
145 145
 		{
146 146
 			$limit_array = explode(',', $limit);
147
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
148
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
147
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
148
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
149 149
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
150 150
 			{
151 151
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 		} else {
169 169
 			$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= 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;
170 170
 		}
171
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
171
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
172 172
 
173 173
 		return $spotter_array;
174 174
 	}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		global $globalDBdriver, $globalLiveInterval;
185 185
 		date_default_timezone_set('UTC');
186 186
 
187
-		$filter_query = $this->getFilter($filter,true,true);
187
+		$filter_query = $this->getFilter($filter, true, true);
188 188
 
189 189
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
190 190
 		if ($globalDBdriver == 'mysql') {
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 			$query  = 'SELECT a.aircraft_shadow, 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 
196 196
 			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 LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
197 197
 */
198
-			$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 
198
+			$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 
199 199
 			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." spotter_live.latitude <> 0 AND spotter_live.longitude <> 0";
200 200
 
201 201
 //			$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 FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date ORDER BY spotter_live.date GROUP BY spotter_live.flightaware_id'.$filter_query;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 			FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
211 211
 */
212 212
 
213
-			$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 
213
+			$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 
214 214
 			FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate".$filter_query." spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
215 215
 
216 216
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$sth = $this->db->prepare($query);
223 223
 			$sth->execute();
224
-		} catch(PDOException $e) {
224
+		} catch (PDOException $e) {
225 225
 			echo $e->getMessage();
226 226
 			die;
227 227
 		}
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		global $globalDBdriver, $globalLiveInterval;
242 242
 		date_default_timezone_set('UTC');
243 243
 
244
-		$filter_query = $this->getFilter($filter,true,true);
244
+		$filter_query = $this->getFilter($filter, true, true);
245 245
 
246 246
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
247 247
 		if ($globalDBdriver == 'mysql') {
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category,icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
251 251
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
252 252
 */
253
-			$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 
253
+			$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 
254 254
 			FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
255 255
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
256 256
                 } else {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 			FROM spotter_live LEFT JOIN (SELECT aircraft_shadow,engine_type, engine_count, wake_category, icao FROM aircraft) a ON spotter_live.aircraft_icao = a.icao".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
260 260
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
261 261
 */
262
-			$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 
262
+			$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 
263 263
 			FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
264 264
 			ORDER BY spotter_live.flightaware_id, spotter_live.date";
265 265
 //			echo $query;
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     		try {
269 269
 			$sth = $this->db->prepare($query);
270 270
 			$sth->execute();
271
-		} catch(PDOException $e) {
271
+		} catch (PDOException $e) {
272 272
 			echo $e->getMessage();
273 273
 			die;
274 274
 		}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	public function getLiveSpotterCount($filter = array())
286 286
 	{
287 287
 		global $globalDBdriver, $globalLiveInterval;
288
-		$filter_query = $this->getFilter($filter,true,true);
288
+		$filter_query = $this->getFilter($filter, true, true);
289 289
 
290 290
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
291 291
 		if ($globalDBdriver == 'mysql') {
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 		try {
299 299
 			$sth = $this->db->prepare($query);
300 300
 			$sth->execute();
301
-		} catch(PDOException $e) {
301
+		} catch (PDOException $e) {
302 302
 			echo $e->getMessage();
303 303
 			die;
304 304
 		}
@@ -321,10 +321,10 @@  discard block
 block discarded – undo
321 321
 		$filter_query = $this->getFilter($filter);
322 322
 
323 323
 		if (is_array($coord)) {
324
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
325
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
326
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
327
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
324
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
325
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
326
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
327
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
328 328
 		} else return array();
329 329
 		if ($globalDBdriver == 'mysql') {
330 330
 			$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;
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 		global $globalDBdriver, $globalLiveInterval;
348 348
 		$Spotter = new Spotter($this->db);
349 349
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
350
-		$filter_query = $this->getFilter($filter,true,true);
350
+		$filter_query = $this->getFilter($filter, true, true);
351 351
 
352 352
 		if (is_array($coord)) {
353
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
354
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
355
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
356
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
353
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
354
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
355
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
356
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
357 357
 		} else return array();
358 358
 		if ($globalDBdriver == 'mysql') {
359 359
 			$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 
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 			) s on spotter_live.flightaware_id = s.flightaware_id 
367 367
 			AND spotter_live.date = s.maxdate'.$filter_query.' spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
368 368
 		} else {
369
-			$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 
369
+			$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 
370 370
 			FROM spotter_live 
371 371
 			INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
372 372
 			    FROM spotter_live l 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 		try {
381 381
 			$sth = $this->db->prepare($query);
382 382
 			$sth->execute();
383
-		} catch(PDOException $e) {
383
+		} catch (PDOException $e) {
384 384
 			echo $e->getMessage();
385 385
 			die;
386 386
 		}
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
                 if ($interval == '1m')
430 430
                 {
431 431
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
432
-                } else if ($interval == '15m'){
432
+                } else if ($interval == '15m') {
433 433
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
434 434
                 } 
435 435
             }
@@ -437,14 +437,14 @@  discard block
 block discarded – undo
437 437
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
438 438
         }
439 439
 
440
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
440
+                $query = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
441 441
                    WHERE spotter_live.latitude <> '' 
442 442
                                    AND spotter_live.longitude <> '' 
443 443
                    ".$additional_query."
444 444
                    HAVING distance < :radius  
445 445
                                    ORDER BY distance";
446 446
 
447
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
447
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
448 448
 
449 449
                 return $spotter_array;
450 450
         }
@@ -462,9 +462,9 @@  discard block
 block discarded – undo
462 462
 		date_default_timezone_set('UTC');
463 463
 
464 464
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
465
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
465
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
466 466
 
467
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
467
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
468 468
 
469 469
 		return $spotter_array;
470 470
 	}
@@ -475,16 +475,16 @@  discard block
 block discarded – undo
475 475
 	* @return Array the spotter information
476 476
 	*
477 477
 	*/
478
-	public function getDateLiveSpotterDataByIdent($ident,$date)
478
+	public function getDateLiveSpotterDataByIdent($ident, $date)
479 479
 	{
480 480
 		$Spotter = new Spotter($this->db);
481 481
 		date_default_timezone_set('UTC');
482 482
 
483 483
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
484
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
484
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
485 485
 
486
-                $date = date('c',$date);
487
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
486
+                $date = date('c', $date);
487
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
488 488
 
489 489
 		return $spotter_array;
490 490
 	}
@@ -501,9 +501,9 @@  discard block
 block discarded – undo
501 501
 		date_default_timezone_set('UTC');
502 502
 
503 503
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
504
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
504
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
505 505
 
506
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
506
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
507 507
 
508 508
 		return $spotter_array;
509 509
 	}
@@ -514,15 +514,15 @@  discard block
 block discarded – undo
514 514
 	* @return Array the spotter information
515 515
 	*
516 516
 	*/
517
-	public function getDateLiveSpotterDataById($id,$date)
517
+	public function getDateLiveSpotterDataById($id, $date)
518 518
 	{
519 519
 		$Spotter = new Spotter($this->db);
520 520
 		date_default_timezone_set('UTC');
521 521
 
522 522
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
523
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
524
-                $date = date('c',$date);
525
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
523
+                $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.flightaware_id = :id AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
524
+                $date = date('c', $date);
525
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
526 526
 
527 527
 		return $spotter_array;
528 528
 	}
@@ -539,13 +539,13 @@  discard block
 block discarded – undo
539 539
 		date_default_timezone_set('UTC');
540 540
 
541 541
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
542
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
542
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
543 543
 
544 544
     		try {
545 545
 			
546 546
 			$sth = $this->db->prepare($query);
547 547
 			$sth->execute(array(':ident' => $ident));
548
-		} catch(PDOException $e) {
548
+		} catch (PDOException $e) {
549 549
 			echo $e->getMessage();
550 550
 			die;
551 551
 		}
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 	* @return Array the spotter information
561 561
 	*
562 562
 	*/
563
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
563
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
564 564
 	{
565 565
 		global $globalDBdriver, $globalLiveInterval;
566 566
 		date_default_timezone_set('UTC');
@@ -579,7 +579,7 @@  discard block
 block discarded – undo
579 579
 		try {
580 580
 			$sth = $this->db->prepare($query);
581 581
 			$sth->execute(array(':id' => $id));
582
-		} catch(PDOException $e) {
582
+		} catch (PDOException $e) {
583 583
 			echo $e->getMessage();
584 584
 			die;
585 585
 		}
@@ -597,12 +597,12 @@  discard block
 block discarded – undo
597 597
 	{
598 598
 		date_default_timezone_set('UTC');
599 599
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
600
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
600
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
601 601
     		try {
602 602
 			
603 603
 			$sth = $this->db->prepare($query);
604 604
 			$sth->execute(array(':ident' => $ident));
605
-		} catch(PDOException $e) {
605
+		} catch (PDOException $e) {
606 606
 			echo $e->getMessage();
607 607
 			die;
608 608
 		}
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 			
633 633
 			$sth = $this->db->prepare($query);
634 634
 			$sth->execute();
635
-		} catch(PDOException $e) {
635
+		} catch (PDOException $e) {
636 636
 			return "error";
637 637
 		}
638 638
 
@@ -655,14 +655,14 @@  discard block
 block discarded – undo
655 655
 				
656 656
 				$sth = $this->db->prepare($query);
657 657
 				$sth->execute();
658
-			} catch(PDOException $e) {
658
+			} catch (PDOException $e) {
659 659
 				return "error";
660 660
 			}
661 661
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
662 662
                         $i = 0;
663
-                        $j =0;
663
+                        $j = 0;
664 664
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
665
-			foreach($all as $row)
665
+			foreach ($all as $row)
666 666
 			{
667 667
 				$i++;
668 668
 				$j++;
@@ -670,9 +670,9 @@  discard block
 block discarded – undo
670 670
 					if ($globalDebug) echo ".";
671 671
 				    	try {
672 672
 						
673
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
673
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
674 674
 						$sth->execute();
675
-					} catch(PDOException $e) {
675
+					} catch (PDOException $e) {
676 676
 						return "error";
677 677
 					}
678 678
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 			if ($i > 0) {
684 684
     				try {
685 685
 					
686
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
686
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
687 687
 					$sth->execute();
688
-				} catch(PDOException $e) {
688
+				} catch (PDOException $e) {
689 689
 					return "error";
690 690
 				}
691 691
 			}
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 				
699 699
 				$sth = $this->db->prepare($query);
700 700
 				$sth->execute();
701
-			} catch(PDOException $e) {
701
+			} catch (PDOException $e) {
702 702
 				return "error";
703 703
 			}
704 704
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -746,13 +746,13 @@  discard block
 block discarded – undo
746 746
 	public function deleteLiveSpotterDataByIdent($ident)
747 747
 	{
748 748
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
749
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
749
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
750 750
         
751 751
     		try {
752 752
 			
753 753
 			$sth = $this->db->prepare($query);
754 754
 			$sth->execute(array(':ident' => $ident));
755
-		} catch(PDOException $e) {
755
+		} catch (PDOException $e) {
756 756
 			return "error";
757 757
 		}
758 758
 
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
 	public function deleteLiveSpotterDataById($id)
769 769
 	{
770 770
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
771
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
771
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
772 772
         
773 773
     		try {
774 774
 			
775 775
 			$sth = $this->db->prepare($query);
776 776
 			$sth->execute(array(':id' => $id));
777
-		} catch(PDOException $e) {
777
+		} catch (PDOException $e) {
778 778
 			return "error";
779 779
 		}
780 780
 
@@ -792,13 +792,13 @@  discard block
 block discarded – undo
792 792
 	{
793 793
 		global $globalDBdriver, $globalTimezone;
794 794
 		if ($globalDBdriver == 'mysql') {
795
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
795
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
796 796
 				WHERE spotter_live.ident = :ident 
797 797
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
798 798
 				AND spotter_live.date < UTC_TIMESTAMP()';
799 799
 			$query_data = array(':ident' => $ident);
800 800
 		} else {
801
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
801
+			$query = "SELECT spotter_live.ident FROM spotter_live 
802 802
 				WHERE spotter_live.ident = :ident 
803 803
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
804 804
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
 		
808 808
 		$sth = $this->db->prepare($query);
809 809
 		$sth->execute($query_data);
810
-		$ident_result='';
811
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
810
+		$ident_result = '';
811
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
812 812
 		{
813 813
 			$ident_result = $row['ident'];
814 814
 		}
@@ -825,13 +825,13 @@  discard block
 block discarded – undo
825 825
 	{
826 826
 		global $globalDBdriver, $globalTimezone;
827 827
 		if ($globalDBdriver == 'mysql') {
828
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
828
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
829 829
 				WHERE spotter_live.ident = :ident 
830 830
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
831 831
 //				AND spotter_live.date < UTC_TIMESTAMP()";
832 832
 			$query_data = array(':ident' => $ident);
833 833
 		} else {
834
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
834
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
835 835
 				WHERE spotter_live.ident = :ident 
836 836
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
837 837
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -840,8 +840,8 @@  discard block
 block discarded – undo
840 840
 		
841 841
 		$sth = $this->db->prepare($query);
842 842
 		$sth->execute($query_data);
843
-		$ident_result='';
844
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
843
+		$ident_result = '';
844
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
845 845
 		{
846 846
 			$ident_result = $row['flightaware_id'];
847 847
 		}
@@ -858,13 +858,13 @@  discard block
 block discarded – undo
858 858
 	{
859 859
 		global $globalDBdriver, $globalTimezone;
860 860
 		if ($globalDBdriver == 'mysql') {
861
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
861
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
862 862
 				WHERE spotter_live.flightaware_id = :id 
863 863
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
864 864
 //				AND spotter_live.date < UTC_TIMESTAMP()";
865 865
 			$query_data = array(':id' => $id);
866 866
 		} else {
867
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
867
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
868 868
 				WHERE spotter_live.flightaware_id = :id 
869 869
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
870 870
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 		
874 874
 		$sth = $this->db->prepare($query);
875 875
 		$sth->execute($query_data);
876
-		$ident_result='';
877
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
876
+		$ident_result = '';
877
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
878 878
 		{
879 879
 			$ident_result = $row['flightaware_id'];
880 880
 		}
@@ -891,13 +891,13 @@  discard block
 block discarded – undo
891 891
 	{
892 892
 		global $globalDBdriver, $globalTimezone;
893 893
 		if ($globalDBdriver == 'mysql') {
894
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
894
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
895 895
 				WHERE spotter_live.ModeS = :modes 
896 896
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
897 897
 //				AND spotter_live.date < UTC_TIMESTAMP()";
898 898
 			$query_data = array(':modes' => $modes);
899 899
 		} else {
900
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
900
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
901 901
 				WHERE spotter_live.ModeS = :modes 
902 902
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
903 903
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -906,8 +906,8 @@  discard block
 block discarded – undo
906 906
 		
907 907
 		$sth = $this->db->prepare($query);
908 908
 		$sth->execute($query_data);
909
-		$ident_result='';
910
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
909
+		$ident_result = '';
910
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
911 911
 		{
912 912
 			//$ident_result = $row['spotter_live_id'];
913 913
 			$ident_result = $row['flightaware_id'];
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 	* @return String success or false
927 927
 	*
928 928
 	*/
929
-	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
929
+	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '', $heading = '', $groundspeed = '', $date = '', $departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false, $registration = '', $pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false, $format_source = '', $source_name = '', $over_country = '')
930 930
 	{
931 931
 		global $globalURL, $globalArchive, $globalDebug;
932 932
 		$Common = new Common();
@@ -1019,26 +1019,26 @@  discard block
 block discarded – undo
1019 1019
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1020 1020
 
1021 1021
         
1022
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1023
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1024
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1025
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1026
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1027
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1028
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1029
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1030
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1031
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1032
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1033
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1034
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1035
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1036
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1037
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1038
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1039
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1040
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1041
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1022
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1023
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1024
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1025
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1026
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1027
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1028
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1029
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1030
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1031
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1032
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1033
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1034
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1035
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1036
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1037
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1038
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1039
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1040
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1041
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1042 1042
 
1043 1043
 		$airline_name = '';
1044 1044
 		$airline_icao = '';
@@ -1060,10 +1060,10 @@  discard block
 block discarded – undo
1060 1060
 		$arrival_airport_country = '';
1061 1061
 		
1062 1062
             	
1063
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1064
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1065
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1066
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1063
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1064
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1065
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1066
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1067 1067
 		
1068 1068
 		$query = '';
1069 1069
 		if ($globalArchive) {
@@ -1074,18 +1074,18 @@  discard block
 block discarded – undo
1074 1074
 		$query  .= 'INSERT INTO spotter_live (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, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) 
1075 1075
 		VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)';
1076 1076
 
1077
-		$query_values = array(':flightaware_id' => $flightaware_id,':ident' => $ident, ':registration' => $registration,':airline_name' => $airline_name,':airline_icao' => $airline_icao,':airline_country' => $airline_country,':airline_type' => $airline_type,':aircraft_icao' => $aircraft_icao,':aircraft_shadow' => $aircraft_shadow,':aircraft_type' => $aircraft_type,':aircraft_manufacturer' => $aircraft_manufacturer,':departure_airport_icao' => $departure_airport_icao,':departure_airport_name' => $departure_airport_name,':departure_airport_city' => $departure_airport_city,':departure_airport_country' => $departure_airport_country,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_name' => $arrival_airport_name,':arrival_airport_city' => $arrival_airport_city,':arrival_airport_country' => $arrival_airport_country,':latitude' => $latitude,':longitude' => $longitude, ':waypoints' => $waypoints,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':departure_airport_time' => $departure_airport_time,':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk,':route_stop' => $route_stop,':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source,':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
1077
+		$query_values = array(':flightaware_id' => $flightaware_id, ':ident' => $ident, ':registration' => $registration, ':airline_name' => $airline_name, ':airline_icao' => $airline_icao, ':airline_country' => $airline_country, ':airline_type' => $airline_type, ':aircraft_icao' => $aircraft_icao, ':aircraft_shadow' => $aircraft_shadow, ':aircraft_type' => $aircraft_type, ':aircraft_manufacturer' => $aircraft_manufacturer, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_name' => $departure_airport_name, ':departure_airport_city' => $departure_airport_city, ':departure_airport_country' => $departure_airport_country, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_name' => $arrival_airport_name, ':arrival_airport_city' => $arrival_airport_city, ':arrival_airport_country' => $arrival_airport_country, ':latitude' => $latitude, ':longitude' => $longitude, ':waypoints' => $waypoints, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_time' => $arrival_airport_time, ':squawk' => $squawk, ':route_stop' => $route_stop, ':ModeS' => $ModeS, ':pilot_id' => $pilot_id, ':pilot_name' => $pilot_name, ':verticalrate' => $verticalrate, ':format_source' => $format_source, ':ground' => $ground, ':source_name' => $source_name, ':over_country' => $over_country);
1078 1078
 		try {
1079 1079
 			
1080 1080
 			$sth = $this->db->prepare($query);
1081 1081
 			$sth->execute($query_values);
1082
-		} catch(PDOException $e) {
1082
+		} catch (PDOException $e) {
1083 1083
 			return "error : ".$e->getMessage();
1084 1084
 		}
1085 1085
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1086 1086
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1087 1087
 		    $SpotterArchive = new SpotterArchive($this->db);
1088
-		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1088
+		    $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, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1089 1089
 		    if ($globalDebug) echo $result.')';
1090 1090
 		}
1091 1091
 		return "success";
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 
1095 1095
 	public function getOrderBy()
1096 1096
 	{
1097
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1097
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY spotter_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY spotter_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY spotter_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY spotter_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY spotter_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY spotter_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY spotter_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY spotter_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY spotter_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY spotter_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY spotter_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY spotter_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY spotter_live.date DESC"));
1098 1098
 		return $orderby;
1099 1099
 	}
1100 1100
 
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 require_once(dirname(__FILE__).'/settings.php');
3 3
 
4
-class Connection{
4
+class Connection {
5 5
 	public $db = null;
6 6
 	public $dbs = array();
7 7
 	public $latest_schema = 38;
8 8
 	
9
-	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) {
9
+	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) {
10 10
 	    global $globalDBdriver, $globalNoDB;
11 11
 	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
12 12
 		$this->db = null;
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 			if ($user === null && $pass === null) {
17 17
 			    $this->createDBConnection();
18 18
 			} else {
19
-			    $this->createDBConnection(null,$user,$pass);
19
+			    $this->createDBConnection(null, $user, $pass);
20 20
 			}
21 21
 		    } else {
22 22
 			$this->createDBConnection($dbname);
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 		while (true) {
101 101
 			try {
102 102
 				if ($globalDBSdriver == 'mysql') {
103
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass);
103
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass);
104 104
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 105
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
106
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
107
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500);
108
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
109
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
110
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
111 111
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 112
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 113
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -117,19 +117,19 @@  discard block
 block discarded – undo
117 117
 					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"');
118 118
 					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"');
119 119
 				} else {
120
-					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass);
120
+					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass);
121 121
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 122
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123
-					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
123
+					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
124
+					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200);
125
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut);
126
+					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true);
127
+					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent);
128 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 129
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 130
 				}
131 131
 				break;
132
-			} catch(PDOException $e) {
132
+			} catch (PDOException $e) {
133 133
 				$i++;
134 134
 				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
135 135
 				//exit;
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
 		try {
154 154
 			//$Connection = new Connection();
155 155
 			$results = $this->db->query($query);
156
-		} catch(PDOException $e) {
156
+		} catch (PDOException $e) {
157 157
 			return false;
158 158
 		}
159
-		if($results->rowCount()>0) {
159
+		if ($results->rowCount() > 0) {
160 160
 		    return true; 
161 161
 		}
162 162
 		else return false;
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
 			     return false;
178 178
 			}
179 179
 			
180
-		} catch(PDOException $e) {
181
-			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
180
+		} catch (PDOException $e) {
181
+			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) {
182 182
             			throw $e;
183 183
 	                }
184 184
 	                //echo 'error ! '.$e->getMessage();
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	/*
191 191
 	* Check if index exist
192 192
 	*/
193
-	public function indexExists($table,$index)
193
+	public function indexExists($table, $index)
194 194
 	{
195 195
 		global $globalDBdriver, $globalDBname;
196 196
 		if ($globalDBdriver == 'mysql') {
@@ -201,11 +201,11 @@  discard block
 block discarded – undo
201 201
 		try {
202 202
 			//$Connection = new Connection();
203 203
 			$results = $this->db->query($query);
204
-		} catch(PDOException $e) {
204
+		} catch (PDOException $e) {
205 205
 			return false;
206 206
 		}
207 207
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
208
-		if($nb[0]['nb'] > 0) {
208
+		if ($nb[0]['nb'] > 0) {
209 209
 			return true; 
210 210
 		}
211 211
 		else return false;
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		$query = "SELECT * FROM ".$table." LIMIT 0";
221 221
 		try {
222 222
 			$results = $this->db->query($query);
223
-		} catch(PDOException $e) {
223
+		} catch (PDOException $e) {
224 224
 			return "error : ".$e->getMessage()."\n";
225 225
 		}
226 226
 		$columns = array();
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 		return $columns;
233 233
 	}
234 234
 
235
-	public function getColumnType($table,$column) {
235
+	public function getColumnType($table, $column) {
236 236
 		$select = $this->db->query('SELECT '.$column.' FROM '.$table);
237 237
 		$tomet = $select->getColumnMeta(0);
238 238
 		return $tomet['native_type'];
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	* Check if a column name exist in a table
243 243
 	* @return Boolean column exist or not
244 244
 	*/
245
-	public function checkColumnName($table,$name)
245
+	public function checkColumnName($table, $name)
246 246
 	{
247 247
 		global $globalDBdriver, $globalDBname;
248 248
 		if ($globalDBdriver == 'mysql') {
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 		}
253 253
 			try {
254 254
 				$sth = $this->db()->prepare($query);
255
-				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name));
256
-			} catch(PDOException $e) {
255
+				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name));
256
+			} catch (PDOException $e) {
257 257
 				echo "error : ".$e->getMessage()."\n";
258 258
 			}
259 259
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 				try {
293 293
 					$sth = $this->db->prepare($query);
294 294
 					$sth->execute();
295
-				} catch(PDOException $e) {
295
+				} catch (PDOException $e) {
296 296
 					return "error : ".$e->getMessage()."\n";
297 297
 				}
298 298
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Spacing   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 	    die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
48
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
49 49
     }
50 50
 }
51 51
 
52
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
52
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56 56
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
57
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
58 58
     else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60 60
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
61
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
62 62
     else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77 77
     if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
78
+    $SI = new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
82 82
     $SI->connect();
83 83
 */
84
-} else $SI=new SpotterImport($Connection->db);
84
+} else $SI = new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87 87
     $AIS = new AIS();
88 88
     $MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91
-$SBS=new SBS();
92
-$ACARS=new ACARS($Connection->db);
93
-$Common=new Common();
91
+$SBS = new SBS();
92
+$ACARS = new ACARS($Connection->db);
93
+$Common = new Common();
94 94
 date_default_timezone_set('UTC');
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
98
+    pcntl_signal(SIGINT, function() {
99 99
         global $sockets;
100 100
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101 101
         die("Bye!\n");
@@ -111,35 +111,35 @@  discard block
 block discarded – undo
111 111
 
112 112
 function connect_all($hosts) {
113 113
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
114
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
115 115
     $reset++;
116 116
     if ($globalDebug) echo 'Connect to all...'."\n";
117 117
     foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
121
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
+            if (preg_match('/deltadb.txt$/i', $host)) {
123 123
         	//$formats[$id] = 'deltadbtxt';
124 124
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 125
         	//$last_exec['deltadbtxt'] = 0;
126 126
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
127
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
128 128
         	//$formats[$id] = 'vatsimtxt';
129 129
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 130
         	//$last_exec['vatsimtxt'] = 0;
131 131
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
132
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
133 133
         	//$formats[$id] = 'aircraftlistjson';
134 134
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 135
         	//$last_exec['aircraftlistjson'] = 0;
136 136
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
137
+    	    } else if (preg_match('/opensky/i', $host)) {
138 138
         	//$formats[$id] = 'aircraftlistjson';
139 139
         	$globalSources[$id]['format'] = 'opensky';
140 140
         	//$last_exec['aircraftlistjson'] = 0;
141 141
         	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i',$host)) {
142
+    	    } else if (preg_match('/radarvirtuel.com\/file.json$/i', $host)) {
143 143
         	//$formats[$id] = 'radarvirtueljson';
144 144
         	$globalSources[$id]['format'] = 'radarvirtueljson';
145 145
         	//$last_exec['radarvirtueljson'] = 0;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
149 149
         	    exit(0);
150 150
         	}
151
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
151
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
152 152
         	//$formats[$id] = 'planeupdatefaa';
153 153
         	$globalSources[$id]['format'] = 'planeupdatefaa';
154 154
         	//$last_exec['planeupdatefaa'] = 0;
@@ -157,26 +157,26 @@  discard block
 block discarded – undo
157 157
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
158 158
         	    exit(0);
159 159
         	}
160
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
160
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
161 161
         	//$formats[$id] = 'phpvmacars';
162 162
         	$globalSources[$id]['format'] = 'phpvmacars';
163 163
         	//$last_exec['phpvmacars'] = 0;
164 164
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
165
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
165
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'vam';
168 168
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
169
-            } else if (preg_match('/whazzup/i',$host)) {
169
+            } else if (preg_match('/whazzup/i', $host)) {
170 170
         	//$formats[$id] = 'whazzup';
171 171
         	$globalSources[$id]['format'] = 'whazzup';
172 172
         	//$last_exec['whazzup'] = 0;
173 173
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
174
-            } else if (preg_match('/recentpireps/i',$host)) {
174
+            } else if (preg_match('/recentpireps/i', $host)) {
175 175
         	//$formats[$id] = 'pirepsjson';
176 176
         	$globalSources[$id]['format'] = 'pirepsjson';
177 177
         	//$last_exec['pirepsjson'] = 0;
178 178
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
179
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
179
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
180 180
         	//$formats[$id] = 'fr24json';
181 181
         	$globalSources[$id]['format'] = 'fr24json';
182 182
         	//$last_exec['fr24json'] = 0;
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
186 186
         	    exit(0);
187 187
         	}
188
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
188
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
189 189
         	//$formats[$id] = 'fr24json';
190 190
         	$globalSources[$id]['format'] = 'myshiptracking';
191 191
         	//$last_exec['fr24json'] = 0;
@@ -195,22 +195,22 @@  discard block
 block discarded – undo
195 195
         	    exit(0);
196 196
         	}
197 197
             //} else if (preg_match('/10001/',$host)) {
198
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
198
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
199 199
         	//$formats[$id] = 'tsv';
200 200
         	$globalSources[$id]['format'] = 'tsv';
201 201
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
202 202
             }
203
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
203
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
204 204
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
205
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
205
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
206 206
     		    if ($idf !== false) {
207 207
     			$httpfeeds[$id] = $idf;
208 208
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
209 209
     		    }
210 210
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
211 211
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
213
-	    $hostport = explode(':',$host);
212
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
213
+	    $hostport = explode(':', $host);
214 214
 	    if (isset($hostport[1])) {
215 215
 		$port = $hostport[1];
216 216
 		$hostn = $hostport[0];
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
 	    }
221 221
 	    $Common = new Common();
222 222
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
223
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
223
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
224 224
     	    } else {
225
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
225
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
226 226
 	    }
227 227
 	    if ($s) {
228 228
     	        $sockets[$id] = $s;
229 229
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
230
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
230
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
231 231
 			//$formats[$id] = 'aprs';
232 232
 			$globalSources[$id]['format'] = 'aprs';
233 233
 			//$aprs_connect = 0;
234 234
 			//$use_aprs = true;
235
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
235
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
236 236
 			$globalSources[$id]['format'] = 'vrstcp';
237 237
     		    } elseif ($port == '10001') {
238 238
         		//$formats[$id] = 'tsv';
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
272 272
 else $timeout = 20;
273 273
 $errno = '';
274
-$errstr='';
274
+$errstr = '';
275 275
 
276 276
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
277 277
 /* Initiate connections to all the hosts simultaneously */
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 //connect_all($globalSources);
280 280
 
281 281
 if (isset($globalProxy) && $globalProxy) {
282
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
282
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
283 283
 } else {
284 284
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
285 285
 }
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 
307 307
 if ($use_aprs) {
308 308
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
309
-	$APRS=new APRS();
309
+	$APRS = new APRS();
310 310
 	$aprs_connect = 0;
311 311
 	$aprs_keep = 120;
312 312
 	$aprs_last_tx = time();
313 313
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
314
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
314
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
315 315
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
316
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
316
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
317 317
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
318
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
318
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
319 319
 	if ($aprs_full) $aprs_filter = '';
320 320
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
321 321
 	else $aprs_pass = '-1';
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
 sleep(1);
330 330
 if ($globalDebug) echo "SCAN MODE \n\n";
331 331
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
332
-$endtime = time()+$globalCronEnd;
332
+$endtime = time() + $globalCronEnd;
333 333
 $i = 1;
334 334
 $tt = array();
335 335
 // Delete all ATC
336 336
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
337
-	$ATC=new ATC($Connection->db);
337
+	$ATC = new ATC($Connection->db);
338 338
 }
339 339
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
340 340
 	$ATC->deleteAll();
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 
343 343
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
344 344
 while ($i > 0) {
345
-    if (!$globalDaemon) $i = $endtime-time();
345
+    if (!$globalDaemon) $i = $endtime - time();
346 346
     // Delete old ATC
347 347
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348 348
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 	}
358 358
 	if ($max != $globalMinFetch) {
359 359
 	    if ($globalDebug) echo 'Sleeping...'."\n";
360
-	    sleep($globalMinFetch-$max+2);
360
+	    sleep($globalMinFetch - $max + 2);
361 361
 	}
362 362
     }
363 363
 
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
 	    //$buffer = $Common->getData($hosts[$id]);
371 371
 	    $buffer = $Common->getData($value['host']);
372 372
 	    if ($buffer != '') $reset = 0;
373
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
374
-	    $buffer = explode('\n',$buffer);
373
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
374
+	    $buffer = explode('\n', $buffer);
375 375
 	    foreach ($buffer as $line) {
376 376
     		if ($line != '' && count($line) > 7) {
377 377
     		    $line = explode(',', $line);
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
     	    $last_exec[$id]['last'] = time();
400 400
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
401 401
 	    date_default_timezone_set('CET');
402
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
402
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
403 403
 	    date_default_timezone_set('UTC');
404 404
 	    if ($buffer != '') $reset = 0;
405
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
406
-	    $buffer = explode('\n',$buffer);
405
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
406
+	    $buffer = explode('\n', $buffer);
407 407
 	    foreach ($buffer as $line) {
408 408
 		if ($line != '') {
409 409
 		    echo "'".$line."'\n";
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
422 422
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
423 423
 		    if (isset($ais_data['timestamp'])) {
424
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
424
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
425 425
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
426 426
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
427 427
 			    $add = true;
@@ -445,12 +445,12 @@  discard block
 block discarded – undo
445 445
 	    $w = $e = null;
446 446
 	    
447 447
 	    if (isset($arr[$id])) {
448
-		$nn = stream_select($arr,$w,$e,$timeout);
448
+		$nn = stream_select($arr, $w, $e, $timeout);
449 449
 		if ($nn > 0) {
450 450
 		    foreach ($httpfeeds as $feed) {
451
-			$buffer = stream_get_line($feed,2000,"\n");
452
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
453
-			$buffer = explode('\n',$buffer);
451
+			$buffer = stream_get_line($feed, 2000, "\n");
452
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
453
+			$buffer = explode('\n', $buffer);
454 454
 			foreach ($buffer as $line) {
455 455
 			    if ($line != '') {
456 456
 				$ais_data = $AIS->parse_line(trim($line));
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
467 467
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
468 468
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
469
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
469
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
470 470
 				if (isset($ais_data['timestamp'])) {
471
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
471
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
472 472
 				} else {
473 473
 				    $data['datetime'] = date('Y-m-d H:i:s');
474 474
 				}
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
 		}
494 494
 	    }
495 495
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
496
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
496
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
497 497
 	    if ($buffer != '') {
498 498
 		//echo $buffer;
499
-		$all_data = json_decode($buffer,true);
499
+		$all_data = json_decode($buffer, true);
500 500
 		//print_r($all_data);
501 501
 		if (isset($all_data[0]['DATA'])) {
502 502
 		foreach ($all_data[0]['DATA'] as $line) {
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 			//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
512 512
 			$data['imo'] = $line['IMO'];
513 513
 			//$data['arrival_code'] = $ais_data['destination'];
514
-			$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
514
+			$data['datetime'] = date('Y-m-d H:i:s', $line['T']);
515 515
 			$data['format_source'] = 'myshiptracking';
516 516
 			$data['id_source'] = $id_source;
517 517
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -524,9 +524,9 @@  discard block
 block discarded – undo
524 524
 	    }
525 525
     	    $last_exec[$id]['last'] = time();
526 526
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
527
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
527
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
528 528
 	    if ($buffer != '') {
529
-		$all_data = json_decode($buffer,true);
529
+		$all_data = json_decode($buffer, true);
530 530
 		if (isset($all_data[0]['mmsi'])) {
531 531
 		    foreach ($all_data as $line) {
532 532
 			if ($line != '') {
@@ -554,27 +554,27 @@  discard block
 block discarded – undo
554 554
     	    $last_exec[$id]['last'] = time();
555 555
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
556 556
 	    echo 'download...';
557
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
557
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
558 558
 	    echo 'done !'."\n";
559 559
 	    if ($buffer != '') $reset = 0;
560
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
561
-	    $buffer = explode('\n',$buffer);
560
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
561
+	    $buffer = explode('\n', $buffer);
562 562
 	    foreach ($buffer as $line) {
563 563
 		if ($line != '') {
564 564
 		    $data = array();
565
-		    $data['mmsi'] = (int)substr($line,0,9);
566
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
565
+		    $data['mmsi'] = (int) substr($line, 0, 9);
566
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
567 567
 		    //$data['status'] = substr($line,21,2);
568 568
 		    //$data['type'] = substr($line,24,3);
569
-		    $data['latitude'] = substr($line,29,9);
570
-		    $data['longitude'] = substr($line,41,9);
571
-		    $data['speed'] = round(substr($line,51,5));
569
+		    $data['latitude'] = substr($line, 29, 9);
570
+		    $data['longitude'] = substr($line, 41, 9);
571
+		    $data['speed'] = round(substr($line, 51, 5));
572 572
 		    //$data['course'] = substr($line,57,5);
573
-		    $data['heading'] = round(substr($line,63,3));
573
+		    $data['heading'] = round(substr($line, 63, 3));
574 574
 		    //$data['draft'] = substr($line,67,4);
575 575
 		    //$data['length'] = substr($line,72,3);
576 576
 		    //$data['beam'] = substr($line,76,2);
577
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
577
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
578 578
 		    //$data['callsign'] = trim(substr($line,100,7);
579 579
 		    //$data['dest'] = substr($line,108,20);
580 580
 		    //$data['etaDate'] = substr($line,129,5);
@@ -593,8 +593,8 @@  discard block
 block discarded – undo
593 593
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
594 594
 	    //$buffer = $Common->getData($hosts[$id]);
595 595
 	    $buffer = $Common->getData($value['host']);
596
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
597
-	    $buffer = explode('\n',$buffer);
596
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
597
+	    $buffer = explode('\n', $buffer);
598 598
 	    $reset = 0;
599 599
 	    foreach ($buffer as $line) {
600 600
     		if ($line != '') {
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
606 606
 			$data['pilot_id'] = $line[1];
607 607
 			$data['pilot_name'] = $line[2];
608
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
608
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
609 609
 			$data['ident'] = $line[0]; // ident
610 610
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
611 611
 			$data['speed'] = $line[8]; // speed
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
622 622
 			//if (isset($line[37])) $data['last_update'] = $line[37];
623 623
 		        $data['departure_airport_icao'] = $line[11];
624
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
624
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
625 625
 		        $data['arrival_airport_icao'] = $line[13];
626 626
 			$data['frequency'] = $line[4];
627 627
 			$data['type'] = $line[18];
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
     			$data['id_source'] = $id_source;
631 631
 	    		//$data['arrival_airport_time'] = ;
632 632
 	    		if ($line[9] != '') {
633
-	    		    $aircraft_data = explode('/',$line[9]);
633
+	    		    $aircraft_data = explode('/', $line[9]);
634 634
 	    		    if (isset($aircraft_data[1])) {
635 635
 	    			$data['aircraft_icao'] = $aircraft_data[1];
636 636
 	    		    }
@@ -645,9 +645,9 @@  discard block
 block discarded – undo
645 645
     			if ($line[3] == 'PILOT') $SI->add($data);
646 646
 			elseif ($line[3] == 'ATC') {
647 647
 				//print_r($data);
648
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
649
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
650
-				$typec = substr($data['ident'],-3);
648
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
649
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
650
+				$typec = substr($data['ident'], -3);
651 651
 				if ($typec == 'APP') $data['type'] = 'Approach';
652 652
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
653 653
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
659 659
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
660 660
 				if (!isset($data['source_name'])) $data['source_name'] = '';
661
-				if (isset($ATC)) echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
661
+				if (isset($ATC)) echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
662 662
 			}
663 663
     			unset($data);
664 664
     		    }
@@ -669,9 +669,9 @@  discard block
 block discarded – undo
669 669
     	    $last_exec[$id]['last'] = time();
670 670
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
671 671
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
672
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
672
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
673 673
 	    if ($buffer != '') {
674
-	    $all_data = json_decode($buffer,true);
674
+	    $all_data = json_decode($buffer, true);
675 675
 	    if (isset($all_data['acList'])) {
676 676
 		$reset = 0;
677 677
 		foreach ($all_data['acList'] as $line) {
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
730 730
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
731 731
 	    $buffer = $Common->getData($value['host']);
732
-	    $all_data = json_decode($buffer,true);
732
+	    $all_data = json_decode($buffer, true);
733 733
 	    if (isset($all_data['planes'])) {
734 734
 		$reset = 0;
735 735
 		foreach ($all_data['planes'] as $key => $line) {
@@ -746,12 +746,12 @@  discard block
 block discarded – undo
746 746
 		    $data['emergency'] = ''; // emergency
747 747
 		    $data['registration'] = $line[2];
748 748
 		    $data['aircraft_icao'] = $line[0];
749
-		    $deparr = explode('-',$line[1]);
749
+		    $deparr = explode('-', $line[1]);
750 750
 		    if (count($deparr) == 2) {
751 751
 			$data['departure_airport_icao'] = $deparr[0];
752 752
 			$data['arrival_airport_icao'] = $deparr[1];
753 753
 		    }
754
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
754
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
755 755
 	    	    $data['format_source'] = 'planeupdatefaa';
756 756
     		    $data['id_source'] = $id_source;
757 757
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
     	    $last_exec[$id]['last'] = time();
765 765
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
766 766
 	    $buffer = $Common->getData($value['host']);
767
-	    $all_data = json_decode($buffer,true);
767
+	    $all_data = json_decode($buffer, true);
768 768
 	    if (isset($all_data['states'])) {
769 769
 		$reset = 0;
770 770
 		foreach ($all_data['states'] as $key => $line) {
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 		    //$data['emergency'] = ''; // emergency
782 782
 		    //$data['registration'] = $line[2];
783 783
 		    //$data['aircraft_icao'] = $line[0];
784
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
784
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
785 785
 	    	    $data['format_source'] = 'opensky';
786 786
     		    $data['id_source'] = $id_source;
787 787
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
796 796
 	    //$buffer = $Common->getData($hosts[$id]);
797 797
 	    $buffer = $Common->getData($value['host']);
798
-	    $all_data = json_decode($buffer,true);
798
+	    $all_data = json_decode($buffer, true);
799 799
 	    if (!empty($all_data)) $reset = 0;
800 800
 	    foreach ($all_data as $key => $line) {
801 801
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -828,11 +828,11 @@  discard block
 block discarded – undo
828 828
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
829 829
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
830 830
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
831
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
831
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
832 832
 	    //echo $buffer;
833
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
834
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
835
-	    $all_data = json_decode($buffer,true);
833
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
834
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
835
+	    $all_data = json_decode($buffer, true);
836 836
 	    if (json_last_error() != JSON_ERROR_NONE) {
837 837
 		die(json_last_error_msg());
838 838
 	    }
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 			//$data['departure_airport_iata'] = $line[11];
856 856
 			//$data['arrival_airport_iata'] = $line[12];
857 857
 	    		//$data['emergency'] = ''; // emergency
858
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
858
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
859 859
 	    		$data['format_source'] = 'radarvirtueljson';
860 860
     			$data['id_source'] = $id_source;
861 861
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -871,14 +871,14 @@  discard block
 block discarded – undo
871 871
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
872 872
 	    //$buffer = $Common->getData($hosts[$id]);
873 873
 	    $buffer = $Common->getData($value['host'].'?'.time());
874
-	    $all_data = json_decode(utf8_encode($buffer),true);
874
+	    $all_data = json_decode(utf8_encode($buffer), true);
875 875
 	    
876 876
 	    if (isset($all_data['pireps'])) {
877 877
 		$reset = 0;
878 878
 	        foreach ($all_data['pireps'] as $line) {
879 879
 		    $data = array();
880 880
 		    $data['id'] = $line['id'];
881
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
881
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
882 882
 		    $data['ident'] = $line['callsign']; // ident
883 883
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
884 884
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -908,9 +908,9 @@  discard block
 block discarded – undo
908 908
 			$SI->add($data);
909 909
 		    //    print_r($data);
910 910
     		    } elseif ($line['icon'] == 'ct') {
911
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
912
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
913
-			$typec = substr($data['ident'],-3);
911
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
912
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
913
+			$typec = substr($data['ident'], -3);
914 914
 			$data['type'] = '';
915 915
 			if ($typec == 'APP') $data['type'] = 'Approach';
916 916
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
922 922
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
923 923
 			else $data['type'] = 'Observer';
924
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
924
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
925 925
 		    }
926 926
 		    unset($data);
927 927
 		}
@@ -933,14 +933,14 @@  discard block
 block discarded – undo
933 933
 	    //$buffer = $Common->getData($hosts[$id]);
934 934
 	    if ($globalDebug) echo 'Get Data...'."\n";
935 935
 	    $buffer = $Common->getData($value['host']);
936
-	    $all_data = json_decode($buffer,true);
936
+	    $all_data = json_decode($buffer, true);
937 937
 	    if ($buffer != '' && is_array($all_data)) {
938 938
 		$reset = 0;
939 939
 		foreach ($all_data as $line) {
940 940
 	    	    $data = array();
941 941
 	    	    //$data['id'] = $line['id']; // id not usable
942 942
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
943
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
943
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
944 944
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
945 945
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
946 946
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -964,14 +964,14 @@  discard block
 block discarded – undo
964 964
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
965 965
 		    if (isset($line['aircraftname'])) {
966 966
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
967
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
968
-	    		$aircraft_data = explode('-',$line['aircraftname']);
967
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
968
+	    		$aircraft_data = explode('-', $line['aircraftname']);
969 969
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
970 970
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
971 971
 	    		else {
972
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
973
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
974
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
972
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
973
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
974
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
975 975
 	    		}
976 976
 	    	    }
977 977
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -991,14 +991,14 @@  discard block
 block discarded – undo
991 991
 	    //$buffer = $Common->getData($hosts[$id]);
992 992
 	    if ($globalDebug) echo 'Get Data...'."\n";
993 993
 	    $buffer = $Common->getData($value['host']);
994
-	    $all_data = json_decode($buffer,true);
994
+	    $all_data = json_decode($buffer, true);
995 995
 	    if ($buffer != '' && is_array($all_data)) {
996 996
 		$reset = 0;
997 997
 		foreach ($all_data as $line) {
998 998
 	    	    $data = array();
999 999
 	    	    //$data['id'] = $line['id']; // id not usable
1000 1000
 	    	    $data['id'] = trim($line['flight_id']);
1001
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1001
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1002 1002
 	    	    $data['pilot_name'] = $line['pilot_name'];
1003 1003
 	    	    $data['pilot_id'] = $line['pilot_id'];
1004 1004
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1050,11 +1050,11 @@  discard block
 block discarded – undo
1050 1050
 		    //$value = $formats[$nb];
1051 1051
 		    $format = $globalSources[$nb]['format'];
1052 1052
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1053
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1053
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1054 1054
 		    } elseif ($format == 'vrstcp') {
1055 1055
 			$buffer = @socket_read($r, 6000);
1056 1056
 		    } else {
1057
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1057
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1058 1058
 		    }
1059 1059
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1060 1060
 		    //echo $buffer."\n";
@@ -1063,8 +1063,8 @@  discard block
 block discarded – undo
1063 1063
 		    $error = false;
1064 1064
 		    //$SI::del();
1065 1065
 		    if ($format == 'vrstcp') {
1066
-			$buffer = explode('},{',$buffer);
1067
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1066
+			$buffer = explode('},{', $buffer);
1067
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1068 1068
 		    // SBS format is CSV format
1069 1069
 		    if ($buffer !== FALSE && $buffer != '') {
1070 1070
 			$tt[$format] = 0;
@@ -1097,11 +1097,11 @@  discard block
 block discarded – undo
1097 1097
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1098 1098
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1099 1099
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1100
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1100
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1101 1101
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1102 1102
 
1103 1103
 			    if (isset($ais_data['timestamp'])) {
1104
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1104
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1105 1105
 			    } else {
1106 1106
 				$data['datetime'] = date('Y-m-d H:i:s');
1107 1107
 			    }
@@ -1112,10 +1112,10 @@  discard block
 block discarded – undo
1112 1112
                         } elseif ($format == 'flightgearsp') {
1113 1113
                     	    //echo $buffer."\n";
1114 1114
                     	    if (strlen($buffer) > 5) {
1115
-				$line = explode(',',$buffer);
1115
+				$line = explode(',', $buffer);
1116 1116
 				$data = array();
1117 1117
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1118
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1118
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1119 1119
 				$data['ident'] = $line[6];
1120 1120
 				$data['aircraft_name'] = $line[7];
1121 1121
 				$data['longitude'] = $line[1];
@@ -1127,21 +1127,21 @@  discard block
 block discarded – undo
1127 1127
 				$data['format_source'] = 'flightgearsp';
1128 1128
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1129 1129
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1130
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1130
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1131 1131
 			    }
1132 1132
                         } elseif ($format == 'acars') {
1133 1133
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1134 1134
 			    $ACARS->add(trim($buffer));
1135
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1135
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1136 1136
 			    $ACARS->deleteLiveAcarsData();
1137 1137
 			} elseif ($format == 'flightgearmp') {
1138
-			    if (substr($buffer,0,1) != '#') {
1138
+			    if (substr($buffer, 0, 1) != '#') {
1139 1139
 				$data = array();
1140 1140
 				//echo $buffer."\n";
1141
-				$line = explode(' ',$buffer);
1141
+				$line = explode(' ', $buffer);
1142 1142
 				if (count($line) == 11) {
1143
-				    $userserver = explode('@',$line[0]);
1144
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1143
+				    $userserver = explode('@', $line[0]);
1144
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1145 1145
 				    $data['ident'] = $userserver[0];
1146 1146
 				    $data['registration'] = $userserver[0];
1147 1147
 				    $data['latitude'] = $line[4];
@@ -1149,8 +1149,8 @@  discard block
 block discarded – undo
1149 1149
 				    $data['altitude'] = $line[6];
1150 1150
 				    $data['datetime'] = date('Y-m-d H:i:s');
1151 1151
 				    $aircraft_type = $line[10];
1152
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1153
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1152
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1153
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1154 1154
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1155 1155
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1156 1156
 				}
@@ -1159,8 +1159,8 @@  discard block
 block discarded – undo
1159 1159
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1160 1160
 			    die;
1161 1161
 			} elseif ($format == 'vrstcp') {
1162
-			    foreach($buffer as $all_data) {
1163
-				$line = json_decode('{'.$all_data.'}',true);
1162
+			    foreach ($buffer as $all_data) {
1163
+				$line = json_decode('{'.$all_data.'}', true);
1164 1164
 				$data = array();
1165 1165
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1166 1166
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1186,16 +1186,16 @@  discard block
 block discarded – undo
1186 1186
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1187 1187
 				unset($data);
1188 1188
 			    }
1189
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1189
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1190 1190
 			    $line = explode("\t", $buffer);
1191
-			    for($k = 0; $k < count($line); $k=$k+2) {
1191
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1192 1192
 				$key = $line[$k];
1193
-			        $lined[$key] = $line[$k+1];
1193
+			        $lined[$key] = $line[$k + 1];
1194 1194
 			    }
1195 1195
     			    if (count($lined) > 3) {
1196 1196
     				$data['hex'] = $lined['hexid'];
1197 1197
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1198
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1198
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1199 1199
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1200 1200
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1201 1201
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1214,22 +1214,22 @@  discard block
 block discarded – undo
1214 1214
     			    } else $error = true;
1215 1215
 			} elseif ($format == 'aprs' && $use_aprs) {
1216 1216
 			    if ($aprs_connect == 0) {
1217
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1217
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1218 1218
 				$aprs_connect = 1;
1219 1219
 			    }
1220 1220
 			    
1221
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1221
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1222 1222
 				$aprs_last_tx = time();
1223 1223
 				$data_aprs = "# Keep alive";
1224
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1224
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1225 1225
 			    }
1226 1226
 			    
1227 1227
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1228 1228
 			    //echo 'APRS data : '.$buffer."\n";
1229
-			    $buffer = str_replace('APRS <- ','',$buffer);
1230
-			    $buffer = str_replace('APRS -> ','',$buffer);
1229
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1230
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1231 1231
 			    //echo $buffer."\n";
1232
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1232
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1233 1233
 				$line = $APRS->parse($buffer);
1234 1234
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1235 1235
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 				    //print_r($line);
1239 1239
 				    if (isset($line['address'])) $data['hex'] = $line['address'];
1240 1240
 				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1241
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1241
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1242 1242
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1243 1243
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1244 1244
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 				    $currentdate = date('Y-m-d H:i:s');
1266 1266
 				    $aprsdate = strtotime($data['datetime']);
1267 1267
 				    // Accept data if time <= system time + 20s
1268
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1268
+				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate) + 20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1269 1269
 					$send = $SI->add($data);
1270 1270
 				    } elseif ($data['source_type'] == 'ais') {
1271 1271
 					echo 'add...'."\n";
@@ -1366,7 +1366,7 @@  discard block
 block discarded – undo
1366 1366
 				connect_all($sourceee);
1367 1367
 				$sourceee = array();
1368 1368
 				//connect_all($globalSources);
1369
-				$tt[$format]=0;
1369
+				$tt[$format] = 0;
1370 1370
 				break;
1371 1371
 			    }
1372 1372
 			}
@@ -1375,14 +1375,14 @@  discard block
 block discarded – undo
1375 1375
 	    } else {
1376 1376
 		$error = socket_strerror(socket_last_error());
1377 1377
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1378
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1378
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1379 1379
 			if (isset($globalDebug)) echo "Restarting...\n";
1380 1380
 			// Restart the script if possible
1381 1381
 			if (is_array($sockets)) {
1382 1382
 			    if ($globalDebug) echo "Shutdown all sockets...";
1383 1383
 			    
1384 1384
 			    foreach ($sockets as $sock) {
1385
-				@socket_shutdown($sock,2);
1385
+				@socket_shutdown($sock, 2);
1386 1386
 				@socket_close($sock);
1387 1387
 			    }
1388 1388
 			    
Please login to merge, or discard this patch.