Completed
Push — master ( 090b05...8fa80b )
by Yannick
07:04
created
require/class.Source.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		try {
16 16
 			$sth = $this->db->prepare($query);
17 17
 			$sth->execute($query_values);
18
-		} catch(PDOException $e) {
18
+		} catch (PDOException $e) {
19 19
 			return "error : ".$e->getMessage();
20 20
 		}
21 21
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 		try {
29 29
 			$sth = $this->db->prepare($query);
30 30
 			$sth->execute($query_values);
31
-		} catch(PDOException $e) {
31
+		} catch (PDOException $e) {
32 32
 			return "error : ".$e->getMessage();
33 33
 		}
34 34
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		try {
42 42
 			$sth = $this->db->prepare($query);
43 43
 			$sth->execute($query_values);
44
-		} catch(PDOException $e) {
44
+		} catch (PDOException $e) {
45 45
 			return "error : ".$e->getMessage();
46 46
 		}
47 47
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		try {
55 55
 			$sth = $this->db->prepare($query);
56 56
 			$sth->execute($query_values);
57
-		} catch(PDOException $e) {
57
+		} catch (PDOException $e) {
58 58
 			return "error : ".$e->getMessage();
59 59
 		}
60 60
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		try {
68 68
 			$sth = $this->db->prepare($query);
69 69
 			$sth->execute($query_values);
70
-		} catch(PDOException $e) {
70
+		} catch (PDOException $e) {
71 71
 			return "error : ".$e->getMessage();
72 72
 		}
73 73
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -80,56 +80,56 @@  discard block
 block discarded – undo
80 80
 		try {
81 81
 			$sth = $this->db->prepare($query);
82 82
 			$sth->execute($query_values);
83
-		} catch(PDOException $e) {
83
+		} catch (PDOException $e) {
84 84
 			return "error : ".$e->getMessage();
85 85
 		}
86 86
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
87 87
 		return $all;
88 88
 	}
89 89
 
90
-	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') {
90
+	public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
91 91
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
92 92
 		$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)";
93
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
93
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
94 94
 		try {
95 95
 			$sth = $this->db->prepare($query);
96 96
 			$sth->execute($query_values);
97
-		} catch(PDOException $e) {
97
+		} catch (PDOException $e) {
98 98
 			echo "error : ".$e->getMessage();
99 99
 		}
100 100
 	}
101 101
 
102
-	public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') {
102
+	public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
103 103
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
104 104
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source";
105
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
105
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
106 106
 		try {
107 107
 			$sth = $this->db->prepare($query);
108 108
 			$sth->execute($query_values);
109
-		} catch(PDOException $e) {
109
+		} catch (PDOException $e) {
110 110
 			return "error : ".$e->getMessage();
111 111
 		}
112 112
 	}
113 113
 
114
-	public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') {
114
+	public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') {
115 115
 		$query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source";
116
-		$query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description);
116
+		$query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description);
117 117
 		try {
118 118
 			$sth = $this->db->prepare($query);
119 119
 			$sth->execute($query_values);
120
-		} catch(PDOException $e) {
120
+		} catch (PDOException $e) {
121 121
 			return "error : ".$e->getMessage();
122 122
 		}
123 123
 	}
124 124
 
125
-	public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') {
125
+	public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') {
126 126
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
127 127
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id";
128
-		$query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
128
+		$query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
129 129
 		try {
130 130
 			$sth = $this->db->prepare($query);
131 131
 			$sth->execute($query_values);
132
-		} catch(PDOException $e) {
132
+		} catch (PDOException $e) {
133 133
 			echo "error : ".$e->getMessage();
134 134
 		}
135 135
 	}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		try {
141 141
 			$sth = $this->db->prepare($query);
142 142
 			$sth->execute($query_values);
143
-		} catch(PDOException $e) {
143
+		} catch (PDOException $e) {
144 144
 			return "error : ".$e->getMessage();
145 145
 		}
146 146
 	}
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 		try {
152 152
 			$sth = $this->db->prepare($query);
153 153
 			$sth->execute($query_values);
154
-		} catch(PDOException $e) {
154
+		} catch (PDOException $e) {
155 155
 			return "error : ".$e->getMessage();
156 156
 		}
157 157
 	}
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 		try {
162 162
 			$sth = $this->db->prepare($query);
163 163
 			$sth->execute();
164
-		} catch(PDOException $e) {
164
+		} catch (PDOException $e) {
165 165
 			return "error : ".$e->getMessage();
166 166
 		}
167 167
 	}
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		try {
177 177
 			$sth = $this->db->prepare($query);
178 178
 			$sth->execute(array(':type' => $type));
179
-		} catch(PDOException $e) {
179
+		} catch (PDOException $e) {
180 180
 			return "error";
181 181
 		}
182 182
 		return "success";
Please login to merge, or discard this patch.
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,41 +111,41 @@  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 = '', $real_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 = '', $real_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,real_altitude)
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,real_altitude)
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,:real_altitude)";
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,':real_altitude' => $real_altitude);
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, ':real_altitude' => $real_altitude);
144 144
 		try {
145 145
 			$sth = $this->db->prepare($query);
146 146
 			$sth->execute($query_values);
147 147
 			$sth->closeCursor();
148
-		} catch(PDOException $e) {
148
+		} catch (PDOException $e) {
149 149
 			return "error : ".$e->getMessage();
150 150
 		}
151 151
 		return "success";
@@ -165,9 +165,9 @@  discard block
 block discarded – undo
165 165
 
166 166
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
167 167
                 //$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";
168
-                $query  = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
168
+                $query = "SELECT spotter_archive.* FROM spotter_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
169 169
 
170
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident));
170
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident));
171 171
 
172 172
                 return $spotter_array;
173 173
         }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
187 187
                 //$query  = SpotterArchive->$global_query." WHERE spotter_archive.flightaware_id = :id";
188 188
                 //$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";
189
-                $query  = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
189
+                $query = "SELECT * FROM spotter_archive WHERE flightaware_id = :id ORDER BY date DESC LIMIT 1";
190 190
 
191 191
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
192 192
                   /*
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
                 }
200 200
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
201 201
                 */
202
-                $spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id));
202
+                $spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id));
203 203
 
204 204
                 return $spotter_array;
205 205
         }
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
 	{
215 215
                 date_default_timezone_set('UTC');
216 216
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
217
-                $query  = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
217
+                $query = $this->global_query." WHERE spotter_archive.flightaware_id = :id ORDER BY date";
218 218
 
219 219
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
220 220
 
221 221
                 try {
222 222
                         $sth = $this->db->prepare($query);
223 223
                         $sth->execute(array(':id' => $id));
224
-                } catch(PDOException $e) {
224
+                } catch (PDOException $e) {
225 225
                         echo $e->getMessage();
226 226
                         die;
227 227
                 }
@@ -240,14 +240,14 @@  discard block
 block discarded – undo
240 240
         {
241 241
                 date_default_timezone_set('UTC');
242 242
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
243
-                $query  = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
243
+                $query = "SELECT spotter_archive.latitude, spotter_archive.longitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id";
244 244
 
245 245
 //              $spotter_array = Spotter->getDataFromDB($query,array(':id' => $id));
246 246
 
247 247
                 try {
248 248
                         $sth = $this->db->prepare($query);
249 249
                         $sth->execute(array(':id' => $id));
250
-                } catch(PDOException $e) {
250
+                } catch (PDOException $e) {
251 251
                         echo $e->getMessage();
252 252
                         die;
253 253
                 }
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
                 date_default_timezone_set('UTC');
270 270
 
271 271
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
272
-                $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
+                $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";
273 273
 
274 274
                 try {
275 275
                         $sth = $this->db->prepare($query);
276 276
                         $sth->execute(array(':ident' => $ident));
277
-                } catch(PDOException $e) {
277
+                } catch (PDOException $e) {
278 278
                         echo $e->getMessage();
279 279
                         die;
280 280
                 }
@@ -295,12 +295,12 @@  discard block
 block discarded – undo
295 295
                 date_default_timezone_set('UTC');
296 296
 
297 297
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
298
-                $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
+                $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";
299 299
 
300 300
                 try {
301 301
                         $sth = $this->db->prepare($query);
302 302
                         $sth->execute(array(':id' => $id));
303
-                } catch(PDOException $e) {
303
+                } catch (PDOException $e) {
304 304
                         echo $e->getMessage();
305 305
                         die;
306 306
                 }
@@ -321,12 +321,12 @@  discard block
 block discarded – undo
321 321
                 date_default_timezone_set('UTC');
322 322
 
323 323
                 $id = filter_var($id, FILTER_SANITIZE_STRING);
324
-                $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
+                $query = "SELECT spotter_archive.altitude, spotter_archive.ground_speed, spotter_archive.date FROM spotter_archive WHERE spotter_archive.flightaware_id = :id ORDER BY date";
325 325
 
326 326
                 try {
327 327
                         $sth = $this->db->prepare($query);
328 328
                         $sth->execute(array(':id' => $id));
329
-                } catch(PDOException $e) {
329
+                } catch (PDOException $e) {
330 330
                         echo $e->getMessage();
331 331
                         die;
332 332
                 }
@@ -348,13 +348,13 @@  discard block
 block discarded – undo
348 348
                 date_default_timezone_set('UTC');
349 349
 
350 350
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
351
-                $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
+                $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";
352 352
 //                $query  = "SELECT spotter_archive.altitude, spotter_archive.date FROM spotter_archive WHERE spotter_archive.ident = :ident";
353 353
 
354 354
                 try {
355 355
                         $sth = $this->db->prepare($query);
356 356
                         $sth->execute(array(':ident' => $ident));
357
-                } catch(PDOException $e) {
357
+                } catch (PDOException $e) {
358 358
                         echo $e->getMessage();
359 359
                         die;
360 360
                 }
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
         * @return Array the spotter information
372 372
         *
373 373
         */
374
-        public function getSpotterArchiveData($ident,$flightaware_id,$date)
374
+        public function getSpotterArchiveData($ident, $flightaware_id, $date)
375 375
         {
376 376
     		$Spotter = new Spotter($this->db);
377 377
                 $ident = filter_var($ident, FILTER_SANITIZE_STRING);
378
-                $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
+                $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";
379 379
 
380
-                $spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':flightaware_id' => $flightaware_id,':date' => $date.'%'));
380
+                $spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':flightaware_id' => $flightaware_id, ':date' => $date.'%'));
381 381
 
382 382
                 return $spotter_array;
383 383
         }
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
                 try {
391 391
                         $sth = $this->db->prepare($query);
392 392
                         $sth->execute();
393
-                } catch(PDOException $e) {
393
+                } catch (PDOException $e) {
394 394
                         echo $e->getMessage();
395 395
                         die;
396 396
                 }
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
         * @return Array the spotter information
403 403
         *
404 404
         */
405
-        public function getMinLiveSpotterData($begindate,$enddate,$filter = array())
405
+        public function getMinLiveSpotterData($begindate, $enddate, $filter = array())
406 406
         {
407 407
                 global $globalDBdriver, $globalLiveInterval;
408 408
                 date_default_timezone_set('UTC');
409 409
 
410 410
                 $filter_query = '';
411 411
                 if (isset($filter['source']) && !empty($filter['source'])) {
412
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
412
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
413 413
                 }
414 414
                 // Use spotter_output also ?
415 415
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
416
-                        $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
+                        $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 ";
417 417
                 }
418 418
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
419 419
                         $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 ";
420 420
                 }
421 421
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
422
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
422
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
423 423
                 }
424 424
 
425 425
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -438,14 +438,14 @@  discard block
 block discarded – undo
438 438
 						GROUP BY l.flightaware_id) s on spotter_archive.flightaware_id = s.flightaware_id 
439 439
 				    AND spotter_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive.aircraft_icao = a.icao';
440 440
 */
441
-			$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
+			$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 
442 442
 				    FROM spotter_archive 
443 443
 				    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
444 444
 				    WHERE spotter_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
445 445
                         	    '.$filter_query.' ORDER BY flightaware_id';
446 446
                 } else {
447 447
                         //$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';
448
-                        $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
+                        $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 
449 449
                         	    FROM spotter_archive 
450 450
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive.aircraft_icao = a.icao
451 451
                         	    WHERE spotter_archive.date >= '."'".$begindate."'".' AND spotter_archive.date <= '."'".$enddate."'".'
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                 try {
456 456
                         $sth = $this->db->prepare($query);
457 457
                         $sth->execute();
458
-                } catch(PDOException $e) {
458
+                } catch (PDOException $e) {
459 459
                         echo $e->getMessage();
460 460
                         die;
461 461
                 }
@@ -470,24 +470,24 @@  discard block
 block discarded – undo
470 470
         * @return Array the spotter information
471 471
         *
472 472
         */
473
-        public function getMinLiveSpotterDataPlayback($begindate,$enddate,$filter = array())
473
+        public function getMinLiveSpotterDataPlayback($begindate, $enddate, $filter = array())
474 474
         {
475 475
                 global $globalDBdriver, $globalLiveInterval;
476 476
                 date_default_timezone_set('UTC');
477 477
 
478 478
                 $filter_query = '';
479 479
                 if (isset($filter['source']) && !empty($filter['source'])) {
480
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
480
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
481 481
                 }
482 482
                 // Should use spotter_output also ?
483 483
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
484
-                        $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
+                        $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 ";
485 485
                 }
486 486
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
487 487
                         $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 ";
488 488
                 }
489 489
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
490
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
490
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
491 491
                 }
492 492
 
493 493
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
                     		    FROM spotter_archive 
498 498
                     		    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';
499 499
 			*/
500
-			$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
+			$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 
501 501
 				    FROM spotter_archive_output 
502 502
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON spotter_archive_output.aircraft_icao = a.icao 
503 503
 				    WHERE (spotter_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
513 513
                         	    '.$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';
514 514
                         */
515
-                        $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
+                        $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
516 516
                         	    FROM spotter_archive_output 
517 517
                         	    INNER JOIN (SELECT * FROM aircraft) a on spotter_archive_output.aircraft_icao = a.icao
518 518
                         	    WHERE spotter_archive_output.date >= '."'".$begindate."'".' AND spotter_archive_output.date <= '."'".$enddate."'".'
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
                 try {
525 525
                         $sth = $this->db->prepare($query);
526 526
                         $sth->execute();
527
-                } catch(PDOException $e) {
527
+                } catch (PDOException $e) {
528 528
                         echo $e->getMessage();
529 529
                         die;
530 530
                 }
@@ -539,23 +539,23 @@  discard block
 block discarded – undo
539 539
         * @return Array the spotter information
540 540
         *
541 541
         */
542
-        public function getLiveSpotterCount($begindate,$enddate,$filter = array())
542
+        public function getLiveSpotterCount($begindate, $enddate, $filter = array())
543 543
         {
544 544
                 global $globalDBdriver, $globalLiveInterval;
545 545
                 date_default_timezone_set('UTC');
546 546
 
547 547
                 $filter_query = '';
548 548
                 if (isset($filter['source']) && !empty($filter['source'])) {
549
-                        $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
549
+                        $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
550 550
                 }
551 551
                 if (isset($filter['airlines']) && !empty($filter['airlines'])) {
552
-                        $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
+                        $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 ";
553 553
                 }
554 554
                 if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
555 555
                         $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 ";
556 556
                 }
557 557
                 if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
558
-                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
558
+                        $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
559 559
                 }
560 560
 
561 561
                 //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
                 try {
571 571
                         $sth = $this->db->prepare($query);
572 572
                         $sth->execute();
573
-                } catch(PDOException $e) {
573
+                } catch (PDOException $e) {
574 574
                         echo $e->getMessage();
575 575
                         die;
576 576
                 }
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
     * @return Array the spotter information
591 591
     *
592 592
     */
593
-    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
+    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())
594 594
     {
595 595
 	global $globalTimezone, $globalDBdriver;
596 596
 	require_once(dirname(__FILE__).'/class.Translation.php');
@@ -612,7 +612,7 @@  discard block
 block discarded – undo
612 612
 	        
613 613
 		$q_array = explode(" ", $q);
614 614
 		
615
-		foreach ($q_array as $q_item){
615
+		foreach ($q_array as $q_item) {
616 616
 		    $additional_query .= " AND (";
617 617
 		    $additional_query .= "(spotter_archive_output.spotter_id like '%".$q_item."%') OR ";
618 618
 		    $additional_query .= "(spotter_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
 	
645 645
 	if ($registration != "")
646 646
 	{
647
-	    $registration = filter_var($registration,FILTER_SANITIZE_STRING);
647
+	    $registration = filter_var($registration, FILTER_SANITIZE_STRING);
648 648
 	    if (!is_string($registration))
649 649
 	    {
650 650
 		return false;
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	
656 656
 	if ($aircraft_icao != "")
657 657
 	{
658
-	    $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
658
+	    $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
659 659
 	    if (!is_string($aircraft_icao))
660 660
 	    {
661 661
 		return false;
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	
667 667
 	if ($aircraft_manufacturer != "")
668 668
 	{
669
-	    $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
669
+	    $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
670 670
 	    if (!is_string($aircraft_manufacturer))
671 671
 	    {
672 672
 		return false;
@@ -687,7 +687,7 @@  discard block
 block discarded – undo
687 687
 	
688 688
 	if ($airline_icao != "")
689 689
 	{
690
-	    $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
690
+	    $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
691 691
 	    if (!is_string($airline_icao))
692 692
 	    {
693 693
 		return false;
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
 	
699 699
 	if ($airline_country != "")
700 700
 	{
701
-	    $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
701
+	    $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
702 702
 	    if (!is_string($airline_country))
703 703
 	    {
704 704
 		return false;
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 	
710 710
 	if ($airline_type != "")
711 711
 	{
712
-	    $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
712
+	    $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
713 713
 	    if (!is_string($airline_type))
714 714
 	    {
715 715
 		return false;
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
 	
732 732
 	if ($airport != "")
733 733
 	{
734
-	    $airport = filter_var($airport,FILTER_SANITIZE_STRING);
734
+	    $airport = filter_var($airport, FILTER_SANITIZE_STRING);
735 735
 	    if (!is_string($airport))
736 736
 	    {
737 737
 		return false;
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 	
743 743
 	if ($airport_country != "")
744 744
 	{
745
-	    $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
745
+	    $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
746 746
 	    if (!is_string($airport_country))
747 747
 	    {
748 748
 		return false;
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
     
754 754
 	if ($callsign != "")
755 755
 	{
756
-	    $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
756
+	    $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
757 757
 	    if (!is_string($callsign))
758 758
 	    {
759 759
 		return false;
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
 		$translate = $Translation->ident2icao($callsign);
762 762
 		if ($translate != $callsign) {
763 763
 			$additional_query .= " AND (spotter_archive_output.ident = :callsign OR spotter_archive_output.ident = :translate)";
764
-			$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
764
+			$query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
765 765
 		} else {
766 766
 			$additional_query .= " AND (spotter_archive_output.ident = '".$callsign."')";
767 767
 		}
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 
771 771
 	if ($owner != "")
772 772
 	{
773
-	    $owner = filter_var($owner,FILTER_SANITIZE_STRING);
773
+	    $owner = filter_var($owner, FILTER_SANITIZE_STRING);
774 774
 	    if (!is_string($owner))
775 775
 	    {
776 776
 		return false;
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 
782 782
 	if ($pilot_name != "")
783 783
 	{
784
-	    $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
784
+	    $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
785 785
 	    if (!is_string($pilot_name))
786 786
 	    {
787 787
 		return false;
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
 	
793 793
 	if ($pilot_id != "")
794 794
 	{
795
-	    $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
795
+	    $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
796 796
 	    if (!is_string($pilot_id))
797 797
 	    {
798 798
 		return false;
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 	
804 804
 	if ($departure_airport_route != "")
805 805
 	{
806
-	    $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
806
+	    $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
807 807
 	    if (!is_string($departure_airport_route))
808 808
 	    {
809 809
 		return false;
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 	
815 815
 	if ($arrival_airport_route != "")
816 816
 	{
817
-	    $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
817
+	    $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
818 818
 	    if (!is_string($arrival_airport_route))
819 819
 	    {
820 820
 		return false;
@@ -827,8 +827,8 @@  discard block
 block discarded – undo
827 827
 	{
828 828
 	    $altitude_array = explode(",", $altitude);
829 829
 	    
830
-	    $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
831
-	    $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
830
+	    $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
831
+	    $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
832 832
 	    
833 833
 
834 834
 	    if ($altitude_array[1] != "")
@@ -846,8 +846,8 @@  discard block
 block discarded – undo
846 846
 	{
847 847
 	    $date_array = explode(",", $date_posted);
848 848
 	    
849
-	    $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
850
-	    $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
849
+	    $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
850
+	    $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
851 851
 	    
852 852
 	    if ($globalTimezone != '') {
853 853
 		date_default_timezone_set($globalTimezone);
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 	{
880 880
 	    $limit_array = explode(",", $limit);
881 881
 	    
882
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
883
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
882
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
883
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
884 884
 	    
885 885
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
886 886
 	    {
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	
892 892
 
893 893
 	if ($origLat != "" && $origLon != "" && $dist != "") {
894
-		$dist = number_format($dist*0.621371,2,'.','');
895
-		$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 
894
+		$dist = number_format($dist*0.621371, 2, '.', '');
895
+		$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 
896 896
                           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)) 
897 897
                           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";
898 898
 	} else {
@@ -909,12 +909,12 @@  discard block
 block discarded – undo
909 909
 			$additional_query .= " AND (spotter_archive_output.waypoints <> '')";
910 910
 		}
911 911
 
912
-		$query  = "SELECT spotter_archive_output.* FROM spotter_archive_output 
912
+		$query = "SELECT spotter_archive_output.* FROM spotter_archive_output 
913 913
 		    WHERE spotter_archive_output.ident <> '' 
914 914
 		    ".$additional_query."
915 915
 		    ".$filter_query.$orderby_query;
916 916
 	}
917
-	$spotter_array = $Spotter->getDataFromDB($query, $query_values,$limit_query);
917
+	$spotter_array = $Spotter->getDataFromDB($query, $query_values, $limit_query);
918 918
 
919 919
 	return $spotter_array;
920 920
     }
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
                 try {
932 932
                         $sth = $this->db->prepare($query);
933 933
                         $sth->execute();
934
-                } catch(PDOException $e) {
934
+                } catch (PDOException $e) {
935 935
                         return "error";
936 936
                 }
937 937
 	}
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 	{
969 969
 	    $limit_array = explode(",", $limit);
970 970
 	    
971
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
972
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
971
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
972
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
973 973
 	    
974 974
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
975 975
 	    {
@@ -1010,7 +1010,7 @@  discard block
 block discarded – undo
1010 1010
 	$query_values = array();
1011 1011
 	$limit_query = '';
1012 1012
 	$additional_query = '';
1013
-	$filter_query = $this->getFilter($filter,true,true);
1013
+	$filter_query = $this->getFilter($filter, true, true);
1014 1014
 	
1015 1015
 	if ($owner != "")
1016 1016
 	{
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	{
1028 1028
 	    $limit_array = explode(",", $limit);
1029 1029
 	    
1030
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1031
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1030
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1031
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1032 1032
 	    
1033 1033
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1034 1034
 	    {
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 	$query_values = array();
1069 1069
 	$limit_query = '';
1070 1070
 	$additional_query = '';
1071
-	$filter_query = $this->getFilter($filter,true,true);
1071
+	$filter_query = $this->getFilter($filter, true, true);
1072 1072
 	
1073 1073
 	if ($pilot != "")
1074 1074
 	{
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
 	{
1081 1081
 	    $limit_array = explode(",", $limit);
1082 1082
 	    
1083
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1084
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1083
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1084
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1085 1085
 	    
1086 1086
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1087 1087
 	    {
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
     * @return Array the airline country list
1112 1112
     *
1113 1113
     */
1114
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1114
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1115 1115
     {
1116 1116
 	global $globalDBdriver;
1117 1117
 	/*
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 	$flight_array = array();
1141 1141
 	$temp_array = array();
1142 1142
         
1143
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1143
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1144 1144
 	{
1145 1145
 	    $temp_array['flight_count'] = $row['nb'];
1146 1146
 	    $temp_array['flight_country'] = $row['name'];
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
     * @return Array the airline country list
1158 1158
     *
1159 1159
     */
1160
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1160
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1161 1161
     {
1162 1162
 	global $globalDBdriver;
1163 1163
 	/*
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	$flight_array = array();
1187 1187
 	$temp_array = array();
1188 1188
         
1189
-	while($row = $sth->fetch(PDO::FETCH_ASSOC))
1189
+	while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1190 1190
 	{
1191 1191
 	    $temp_array['airline_icao'] = $row['airline_icao'];
1192 1192
 	    $temp_array['flight_count'] = $row['nb'];
@@ -1204,14 +1204,14 @@  discard block
 block discarded – undo
1204 1204
     * @return Array the spotter information
1205 1205
     *
1206 1206
     */
1207
-    public function getDateArchiveSpotterDataById($id,$date)
1207
+    public function getDateArchiveSpotterDataById($id, $date)
1208 1208
     {
1209 1209
 	$Spotter = new Spotter($this->db);
1210 1210
 	date_default_timezone_set('UTC');
1211 1211
 	$id = filter_var($id, FILTER_SANITIZE_STRING);
1212
-	$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';
1213
-	$date = date('c',$date);
1214
-	$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date));
1212
+	$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';
1213
+	$date = date('c', $date);
1214
+	$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1215 1215
 	return $spotter_array;
1216 1216
     }
1217 1217
 
@@ -1221,14 +1221,14 @@  discard block
 block discarded – undo
1221 1221
     * @return Array the spotter information
1222 1222
     *
1223 1223
     */
1224
-    public function getDateArchiveSpotterDataByIdent($ident,$date)
1224
+    public function getDateArchiveSpotterDataByIdent($ident, $date)
1225 1225
     {
1226 1226
 	$Spotter = new Spotter($this->db);
1227 1227
 	date_default_timezone_set('UTC');
1228 1228
 	$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1229
-	$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';
1230
-	$date = date('c',$date);
1231
-	$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1229
+	$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';
1230
+	$date = date('c', $date);
1231
+	$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1232 1232
 	return $spotter_array;
1233 1233
     }
1234 1234
 
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
     * @return Array the spotter information
1239 1239
     *
1240 1240
     */
1241
-    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1241
+    public function getSpotterDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1242 1242
     {
1243 1243
 	global $global_query;
1244 1244
 	$Spotter = new Spotter();
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 	$query_values = array();
1247 1247
 	$limit_query = '';
1248 1248
 	$additional_query = '';
1249
-	$filter_query = $this->getFilter($filters,true,true);
1249
+	$filter_query = $this->getFilter($filters, true, true);
1250 1250
 	
1251 1251
 	if ($airport != "")
1252 1252
 	{
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 	{
1264 1264
 	    $limit_array = explode(",", $limit);
1265 1265
 	    
1266
-	    $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1267
-	    $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1266
+	    $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1267
+	    $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1268 1268
 	    
1269 1269
 	    if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1270 1270
 	    {
Please login to merge, or discard this patch.
location-geojson.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 if (!isset($globalDemo)) {
14 14
 	if (isset($_GET['coord'])) 
15 15
 	{
16
-		$coords = explode(',',$_GET['coord']);
16
+		$coords = explode(',', $_GET['coord']);
17 17
 //		$spotter_array = Source::getAllLocationInfobyCoord($coords);
18 18
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
19 19
 		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 $output = '{"type": "FeatureCollection","features": [';
35 35
 if (!empty($spotter_array) && count($spotter_array) > 0)
36 36
 {
37
-	foreach($spotter_array as $spotter_item)
37
+	foreach ($spotter_array as $spotter_item)
38 38
 	{
39 39
 		date_default_timezone_set('UTC');
40 40
 		//waypoint plotting
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		    $output .= '}';
63 63
 		$output .= '},';
64 64
 	}
65
-	$output  = substr($output, 0, -1);
65
+	$output = substr($output, 0, -1);
66 66
 }
67 67
 $output .= ']}';
68 68
 
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once('../require/settings.php');
3 3
 require_once('../require/class.Language.php'); 
4 4
 
5
-setcookie("MapFormat",'2d');
5
+setcookie("MapFormat", '2d');
6 6
 
7 7
 if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = '';
8 8
 // Compressed GeoJson is used if true
@@ -20,10 +20,10 @@  discard block
 block discarded – undo
20 20
 	$lastupd = $_GET['archivespeed']*$archiveupdatetime;
21 21
 	if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate'];
22 22
 	else $enddate = time();
23
-	setcookie("archive_begin",$begindate);
24
-	setcookie("archive_end",$enddate);
25
-	setcookie("archive_update",$lastupd);
26
-	setcookie("archive_speed",$archivespeed);
23
+	setcookie("archive_begin", $begindate);
24
+	setcookie("archive_end", $enddate);
25
+	setcookie("archive_update", $lastupd);
26
+	setcookie("archive_speed", $archivespeed);
27 27
 ?>
28 28
 document.cookie =  'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
29 29
 document.cookie =  'archive_end=<?php print $enddate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/';
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 <?php
75 75
 	}
76 76
 	if (isset($_GET['ident'])) {
77
-		$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
77
+		$ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING);
78 78
 	}
79 79
 	if (isset($_GET['flightaware_id'])) {
80
-		$flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
80
+		$flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING);
81 81
 	}
82 82
 	if (isset($_GET['latitude'])) {
83
-		$latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING);
83
+		$latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING);
84 84
 	}
85 85
 	if (isset($_GET['longitude'])) {
86
-		$longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING);
86
+		$longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING);
87 87
 	}
88 88
 ?>
89 89
 
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	     || navigator.userAgent.match(/BlackBerry/i)
120 120
 	     || navigator.userAgent.match(/Windows Phone/i))
121 121
 	{
122
-		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom-1; else print '8'; ?>;
122
+		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom - 1; else print '8'; ?>;
123 123
 	} else {
124 124
 		var zoom = <?php if (isset($globalLiveZoom)) print $globalLiveZoom; else print '9'; ?>;
125 125
 	}
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
 	map.addLayer(yandexLayer);
214 214
 <?php
215 215
 	} elseif ($MapType == 'Bing-Aerial') {
216
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
216
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
217 217
 ?>
218 218
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'});
219 219
 	map.addLayer(bingLayer);
220 220
 <?php
221 221
 	} elseif ($MapType == 'Bing-Hybrid') {
222
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
222
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
223 223
 ?>
224 224
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'});
225 225
 	map.addLayer(bingLayer);
226 226
 <?php
227 227
 	} elseif ($MapType == 'Bing-Road') {
228
-		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap');
228
+		if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap');
229 229
 ?>
230 230
 	var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'});
231 231
 	map.addLayer(bingLayer);
Please login to merge, or discard this patch.
install/class.update_db.php 1 patch
Spacing   +306 added lines, -306 removed lines patch added patch discarded remove patch
@@ -25,20 +25,20 @@  discard block
 block discarded – undo
25 25
 		fclose($fp);
26 26
 	}
27 27
 
28
-	public static function gunzip($in_file,$out_file_name = '') {
28
+	public static function gunzip($in_file, $out_file_name = '') {
29 29
 		//echo $in_file.' -> '.$out_file_name."\n";
30 30
 		$buffer_size = 4096; // read 4kb at a time
31 31
 		if ($out_file_name == '') $out_file_name = str_replace('.gz', '', $in_file); 
32 32
 		if ($in_file != '' && file_exists($in_file)) {
33 33
 			// PHP version of Ubuntu use gzopen64 instead of gzopen
34
-			if (function_exists('gzopen')) $file = gzopen($in_file,'rb');
35
-			elseif (function_exists('gzopen64')) $file = gzopen64($in_file,'rb');
34
+			if (function_exists('gzopen')) $file = gzopen($in_file, 'rb');
35
+			elseif (function_exists('gzopen64')) $file = gzopen64($in_file, 'rb');
36 36
 			else {
37 37
 				echo 'gzopen not available';
38 38
 				die;
39 39
 			}
40 40
 			$out_file = fopen($out_file_name, 'wb'); 
41
-			while(!gzeof($file)) {
41
+			while (!gzeof($file)) {
42 42
 				fwrite($out_file, gzread($file, $buffer_size));
43 43
 			}  
44 44
 			fclose($out_file);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			self::$db_sqlite = new PDO('sqlite:'.$database);
64 64
 			self::$db_sqlite->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 	}
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 			//$Connection = new Connection();
78 78
 			$sth = $Connection->db->prepare($query);
79 79
                         $sth->execute(array(':source' => $database_file));
80
-                } catch(PDOException $e) {
80
+                } catch (PDOException $e) {
81 81
                         return "error : ".$e->getMessage();
82 82
                 }
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 		try {
89 89
                         $sth = update_db::$db_sqlite->prepare($query);
90 90
                         $sth->execute();
91
-                } catch(PDOException $e) {
91
+                } catch (PDOException $e) {
92 92
                         return "error : ".$e->getMessage();
93 93
                 }
94 94
 		//$query_dest = 'INSERT INTO routes (`RouteID`,`CallSign`,`Operator_ICAO`,`FromAirport_ICAO`,`ToAirport_ICAO`,`RouteStop`,`Source`) VALUES (:RouteID, :CallSign, :Operator_ICAO, :FromAirport_ICAO, :ToAirport_ICAO, :routestop, :source)';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 			if ($globalTransaction) $Connection->db->beginTransaction();
100 100
             		while ($values = $sth->fetch(PDO::FETCH_ASSOC)) {
101 101
 				//$query_dest_values = array(':RouteID' => $values['RouteId'],':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
-				$query_dest_values = array(':CallSign' => $values['Callsign'],':Operator_ICAO' => $values['operator_icao'],':FromAirport_ICAO' => $values['FromAirportIcao'],':ToAirport_ICAO' => $values['ToAirportIcao'],':routestop' => $values['AllStop'],':source' => $database_file);
102
+				$query_dest_values = array(':CallSign' => $values['Callsign'], ':Operator_ICAO' => $values['operator_icao'], ':FromAirport_ICAO' => $values['FromAirportIcao'], ':ToAirport_ICAO' => $values['ToAirportIcao'], ':routestop' => $values['AllStop'], ':source' => $database_file);
103 103
 				$sth_dest->execute($query_dest_values);
104 104
             		}
105 105
 			if ($globalTransaction) $Connection->db->commit();
106
-		} catch(PDOException $e) {
106
+		} catch (PDOException $e) {
107 107
 			if ($globalTransaction) $Connection->db->rollBack(); 
108 108
 			return "error : ".$e->getMessage();
109 109
 		}
@@ -119,26 +119,26 @@  discard block
 block discarded – undo
119 119
 			//$Connection = new Connection();
120 120
 			$sth = $Connection->db->prepare($query);
121 121
                         $sth->execute(array(':source' => 'oneworld'));
122
-                } catch(PDOException $e) {
122
+                } catch (PDOException $e) {
123 123
                         return "error : ".$e->getMessage();
124 124
                 }
125 125
 
126 126
     		if ($globalDebug) echo " - Add routes to DB -";
127 127
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
128 128
 		$Spotter = new Spotter();
129
-		if ($fh = fopen($database_file,"r")) {
129
+		if ($fh = fopen($database_file, "r")) {
130 130
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
131 131
 			$Connection = new Connection();
132 132
 			$sth_dest = $Connection->db->prepare($query_dest);
133 133
 			if ($globalTransaction) $Connection->db->beginTransaction();
134 134
 			while (!feof($fh)) {
135
-				$line = fgetcsv($fh,9999,',');
135
+				$line = fgetcsv($fh, 9999, ',');
136 136
 				if ($line[0] != '') {
137 137
 					if (($line[2] == '-' || ($line[2] != '-' && (strtotime($line[2]) > time()))) && ($line[3] == '-' || ($line[3] != '-' && (strtotime($line[3]) < time())))) {
138 138
 						try {
139
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[7]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[5],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[6],':routestop' => '',':source' => 'oneworld');
139
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[7]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[5], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[6], ':routestop' => '', ':source' => 'oneworld');
140 140
 							$sth_dest->execute($query_dest_values);
141
-						} catch(PDOException $e) {
141
+						} catch (PDOException $e) {
142 142
 							if ($globalTransaction) $Connection->db->rollBack(); 
143 143
 							return "error : ".$e->getMessage();
144 144
 						}
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			//$Connection = new Connection();
161 161
 			$sth = $Connection->db->prepare($query);
162 162
                         $sth->execute(array(':source' => 'skyteam'));
163
-                } catch(PDOException $e) {
163
+                } catch (PDOException $e) {
164 164
                         return "error : ".$e->getMessage();
165 165
                 }
166 166
 
@@ -168,24 +168,24 @@  discard block
 block discarded – undo
168 168
 
169 169
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
170 170
 		$Spotter = new Spotter();
171
-		if ($fh = fopen($database_file,"r")) {
171
+		if ($fh = fopen($database_file, "r")) {
172 172
 			$query_dest = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign, :Operator_ICAO, :FromAirport_ICAO,:FromAirport_Time, :ToAirport_ICAO, :ToAirport_Time,:routestop, :source)';
173 173
 			$Connection = new Connection();
174 174
 			$sth_dest = $Connection->db->prepare($query_dest);
175 175
 			try {
176 176
 				if ($globalTransaction) $Connection->db->beginTransaction();
177 177
 				while (!feof($fh)) {
178
-					$line = fgetcsv($fh,9999,',');
178
+					$line = fgetcsv($fh, 9999, ',');
179 179
 					if ($line[0] != '') {
180
-						$datebe = explode('  -  ',$line[2]);
180
+						$datebe = explode('  -  ', $line[2]);
181 181
 						if (strtotime($datebe[0]) > time() && strtotime($datebe[1]) < time()) {
182
-							$query_dest_values = array(':CallSign' => str_replace('*','',$line[6]),':Operator_ICAO' => '',':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]),':FromAirport_Time' => $line[4],':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]),':ToAirport_Time' => $line[5],':routestop' => '',':source' => 'skyteam');
182
+							$query_dest_values = array(':CallSign' => str_replace('*', '', $line[6]), ':Operator_ICAO' => '', ':FromAirport_ICAO' => $Spotter->getAirportICAO($line[0]), ':FromAirport_Time' => $line[4], ':ToAirport_ICAO' => $Spotter->getAirportICAO($line[1]), ':ToAirport_Time' => $line[5], ':routestop' => '', ':source' => 'skyteam');
183 183
 							$sth_dest->execute($query_dest_values);
184 184
 						}
185 185
 					}
186 186
 				}
187 187
 				if ($globalTransaction) $Connection->db->commit();
188
-			} catch(PDOException $e) {
188
+			} catch (PDOException $e) {
189 189
 				if ($globalTransaction) $Connection->db->rollBack(); 
190 190
 				return "error : ".$e->getMessage();
191 191
 			}
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$Connection = new Connection();
201 201
 			$sth = $Connection->db->prepare($query);
202 202
                         $sth->execute(array(':source' => $database_file));
203
-                } catch(PDOException $e) {
203
+                } catch (PDOException $e) {
204 204
                         return "error : ".$e->getMessage();
205 205
                 }
206 206
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source";
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$Connection = new Connection();
209 209
 			$sth = $Connection->db->prepare($query);
210 210
                         $sth->execute(array(':source' => $database_file));
211
-                } catch(PDOException $e) {
211
+                } catch (PDOException $e) {
212 212
                         return "error : ".$e->getMessage();
213 213
                 }
214 214
 
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
 		try {
218 218
                         $sth = update_db::$db_sqlite->prepare($query);
219 219
                         $sth->execute();
220
-                } catch(PDOException $e) {
220
+                } catch (PDOException $e) {
221 221
                         return "error : ".$e->getMessage();
222 222
                 }
223 223
 		//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
@@ -234,15 +234,15 @@  discard block
 block discarded – undo
234 234
 			//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
235 235
 				if ($values['UserString4'] == 'M') $type = 'military';
236 236
 				else $type = null;
237
-				$query_dest_values = array(':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':type' => $type);
237
+				$query_dest_values = array(':LastModified' => $values['LastModified'], ':ModeS' => $values['ModeS'], ':ModeSCountry' => $values['ModeSCountry'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':type' => $type);
238 238
 				$sth_dest->execute($query_dest_values);
239 239
 				if ($values['RegisteredOwners'] != '' && $values['RegisteredOwners'] != NULL && $values['RegisteredOwners'] != 'Private') {
240
-				    $query_dest_owner_values = array(':registration' => $values['Registration'],':source' => $database_file,':owner' => $values['RegisteredOwners']);
240
+				    $query_dest_owner_values = array(':registration' => $values['Registration'], ':source' => $database_file, ':owner' => $values['RegisteredOwners']);
241 241
 				    $sth_dest_owner->execute($query_dest_owner_values);
242 242
 				}
243 243
             		}
244 244
 			if ($globalTransaction) $Connection->db->commit();
245
-		} catch(PDOException $e) {
245
+		} catch (PDOException $e) {
246 246
 			return "error : ".$e->getMessage();
247 247
 		}
248 248
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 			$Connection = new Connection();
253 253
 			$sth = $Connection->db->prepare($query);
254 254
                         $sth->execute(array(':source' => $database_file));
255
-                } catch(PDOException $e) {
255
+                } catch (PDOException $e) {
256 256
                         return "error : ".$e->getMessage();
257 257
                 }
258 258
 		return '';
@@ -267,11 +267,11 @@  discard block
 block discarded – undo
267 267
 			$Connection = new Connection();
268 268
 			$sth = $Connection->db->prepare($query);
269 269
                         $sth->execute(array(':source' => $database_file));
270
-                } catch(PDOException $e) {
270
+                } catch (PDOException $e) {
271 271
                         return "error : ".$e->getMessage();
272 272
                 }
273 273
 		
274
-		if ($fh = fopen($database_file,"r")) {
274
+		if ($fh = fopen($database_file, "r")) {
275 275
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
276 276
 			$query_dest = 'INSERT INTO aircraft_modes (ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
277 277
 		
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
 				if ($globalTransaction) $Connection->db->beginTransaction();
282 282
             			while (!feof($fh)) {
283 283
             				$values = array();
284
-            				$line = $Common->hex2str(fgets($fh,9999));
284
+            				$line = $Common->hex2str(fgets($fh, 9999));
285 285
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
286
-            				$values['ModeS'] = substr($line,0,6);
287
-            				$values['Registration'] = trim(substr($line,69,6));
288
-            				$aircraft_name = trim(substr($line,48,6));
286
+            				$values['ModeS'] = substr($line, 0, 6);
287
+            				$values['Registration'] = trim(substr($line, 69, 6));
288
+            				$aircraft_name = trim(substr($line, 48, 6));
289 289
             				// Check if we can find ICAO, else set it to GLID
290
-            				$aircraft_name_split = explode(' ',$aircraft_name);
290
+            				$aircraft_name_split = explode(' ', $aircraft_name);
291 291
             				$search_more = '';
292 292
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
293 293
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -299,20 +299,20 @@  discard block
 block discarded – undo
299 299
 	            				if (isset($result['icao']) && $result['icao'] != '') {
300 300
 	            				    $values['ICAOTypeCode'] = $result['icao'];
301 301
 	            				} 
302
-					} catch(PDOException $e) {
302
+					} catch (PDOException $e) {
303 303
 						return "error : ".$e->getMessage();
304 304
 					}
305 305
 					if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
306 306
 					// Add data to db
307 307
 					if ($values['Registration'] != '' && $values['Registration'] != '0000') {
308 308
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
309
-						$query_dest_values = array(':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
309
+						$query_dest_values = array(':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
310 310
 						//print_r($query_dest_values);
311 311
 						$sth_dest->execute($query_dest_values);
312 312
 					}
313 313
 				}
314 314
 				if ($globalTransaction) $Connection->db->commit();
315
-			} catch(PDOException $e) {
315
+			} catch (PDOException $e) {
316 316
 				return "error : ".$e->getMessage();
317 317
 			}
318 318
 		}
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 			$Connection = new Connection();
323 323
 			$sth = $Connection->db->prepare($query);
324 324
                         $sth->execute(array(':source' => $database_file));
325
-                } catch(PDOException $e) {
325
+                } catch (PDOException $e) {
326 326
                         return "error : ".$e->getMessage();
327 327
                 }
328 328
 		return '';
@@ -336,11 +336,11 @@  discard block
 block discarded – undo
336 336
 			$Connection = new Connection();
337 337
 			$sth = $Connection->db->prepare($query);
338 338
                         $sth->execute(array(':source' => $database_file));
339
-                } catch(PDOException $e) {
339
+                } catch (PDOException $e) {
340 340
                         return "error : ".$e->getMessage();
341 341
                 }
342 342
 		
343
-		if ($fh = fopen($database_file,"r")) {
343
+		if ($fh = fopen($database_file, "r")) {
344 344
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
345 345
 			$query_dest = 'INSERT INTO aircraft_modes (LastModified,ModeS,Registration,ICAOTypeCode,Source,source_type) VALUES (:lastmodified,:ModeS,:Registration,:ICAOTypeCode,:source,:source_type)';
346 346
 		
@@ -348,9 +348,9 @@  discard block
 block discarded – undo
348 348
 			$sth_dest = $Connection->db->prepare($query_dest);
349 349
 			try {
350 350
 				if ($globalTransaction) $Connection->db->beginTransaction();
351
-				$tmp = fgetcsv($fh,9999,',',"'");
351
+				$tmp = fgetcsv($fh, 9999, ',', "'");
352 352
             			while (!feof($fh)) {
353
-            				$line = fgetcsv($fh,9999,',',"'");
353
+            				$line = fgetcsv($fh, 9999, ',', "'");
354 354
             				
355 355
 					//FFFFFF                     RIDEAU VALLEY SOARINGASW-20               C-FBKN MZ 123.400
356 356
 					//print_r($line);
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
             				$values['ICAOTypeCode'] = '';
360 360
             				$aircraft_name = $line[2];
361 361
             				// Check if we can find ICAO, else set it to GLID
362
-            				$aircraft_name_split = explode(' ',$aircraft_name);
362
+            				$aircraft_name_split = explode(' ', $aircraft_name);
363 363
             				$search_more = '';
364 364
             				if (count($aircraft_name) > 1 && strlen($aircraft_name_split[1]) > 3) $search_more .= " AND LIKE '%".$aircraft_name_split[0]."%'";
365 365
             				$query_search = "SELECT * FROM aircraft WHERE type LIKE '%".$aircraft_name."%'".$search_more;
@@ -368,20 +368,20 @@  discard block
 block discarded – undo
368 368
                                     		$sth_search->execute();
369 369
 	            				$result = $sth_search->fetch(PDO::FETCH_ASSOC);
370 370
 	            				if (isset($result['icao']) && $result['icao'] != '') $values['ICAOTypeCode'] = $result['icao'];
371
-					} catch(PDOException $e) {
371
+					} catch (PDOException $e) {
372 372
 						return "error : ".$e->getMessage();
373 373
 					}
374 374
 					//if (!isset($values['ICAOTypeCode'])) $values['ICAOTypeCode'] = 'GLID';
375 375
 					// Add data to db
376 376
 					if ($values['Registration'] != '' && $values['Registration'] != '0000' && $values['ICAOTypeCode'] != '') {
377 377
 						//$query_dest_values = array(':AircraftID' => $values['AircraftID'],':FirstCreated' => $values['FirstCreated'],':LastModified' => $values['LastModified'],':ModeS' => $values['ModeS'],':ModeSCountry' => $values['ModeSCountry'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':SerialNo' => $values['SerialNo'], ':OperatorFlagCode' => $values['OperatorFlagCode'], ':Manufacturer' => $values['Manufacturer'], ':Type' => $values['Type'], ':FirstRegDate' => $values['FirstRegDate'], ':CurrentRegDate' => $values['CurrentRegDate'], ':Country' => $values['Country'], ':PreviousID' => $values['PreviousID'], ':DeRegDate' => $values['DeRegDate'], ':Status' => $values['Status'], ':PopularName' => $values['PopularName'],':GenericName' => $values['GenericName'],':AircraftClass' => $values['AircraftClass'], ':Engines' => $values['Engines'], ':OwnershipStatus' => $values['OwnershipStatus'],':RegisteredOwners' => $values['RegisteredOwners'],':MTOW' => $values['MTOW'], ':TotalHours' => $values['TotalHours'],':YearBuilt' => $values['YearBuilt'], ':CofACategory' => $values['CofACategory'], ':CofAExpiry' => $values['CofAExpiry'], ':UserNotes' => $values['UserNotes'], ':Interested' => $values['Interested'], ':UserTag' => $values['UserTag'], ':InfoUrl' => $values['InfoURL'], ':PictureUrl1' => $values['PictureURL1'], ':PictureUrl2' => $values['PictureURL2'], ':PictureUrl3' => $values['PictureURL3'], ':UserBool1' => $values['UserBool1'], ':UserBool2' => $values['UserBool2'], ':UserBool3' => $values['UserBool3'], ':UserBool4' => $values['UserBool4'], ':UserBool5' => $values['UserBool5'], ':UserString1' => $values['UserString1'], ':UserString2' => $values['UserString2'], ':UserString3' => $values['UserString3'], ':UserString4' => $values['UserString4'], ':UserString5' => $values['UserString5'], ':UserInt1' => $values['UserInt1'], ':UserInt2' => $values['UserInt2'], ':UserInt3' => $values['UserInt3'], ':UserInt4' => $values['UserInt4'], ':UserInt5' => $values['UserInt5']);
378
-						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'),':ModeS' => $values['ModeS'],':Registration' => $values['Registration'],':ICAOTypeCode' => $values['ICAOTypeCode'],':source' => $database_file,':source_type' => 'flarm');
378
+						$query_dest_values = array(':lastmodified' => date('Y-m-d H:m:s'), ':ModeS' => $values['ModeS'], ':Registration' => $values['Registration'], ':ICAOTypeCode' => $values['ICAOTypeCode'], ':source' => $database_file, ':source_type' => 'flarm');
379 379
 						//print_r($query_dest_values);
380 380
 						$sth_dest->execute($query_dest_values);
381 381
 					}
382 382
 				}
383 383
 				if ($globalTransaction) $Connection->db->commit();
384
-			} catch(PDOException $e) {
384
+			} catch (PDOException $e) {
385 385
 				return "error : ".$e->getMessage();
386 386
 			}
387 387
 		}
@@ -391,13 +391,13 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
                         $sth->execute(array(':source' => $database_file));
394
-                } catch(PDOException $e) {
394
+                } catch (PDOException $e) {
395 395
                         return "error : ".$e->getMessage();
396 396
                 }
397 397
 		return '';
398 398
 	}
399 399
 
400
-	public static function retrieve_owner($database_file,$country = 'F') {
400
+	public static function retrieve_owner($database_file, $country = 'F') {
401 401
 		global $globalTransaction, $globalMasterSource;
402 402
 		//$query = 'TRUNCATE TABLE aircraft_modes';
403 403
 		$query = "DELETE FROM aircraft_owner WHERE Source = '' OR Source IS NULL OR Source = :source; DELETE FROM aircraft_modes WHERE Source = :source;";
@@ -405,12 +405,12 @@  discard block
 block discarded – undo
405 405
 			$Connection = new Connection();
406 406
 			$sth = $Connection->db->prepare($query);
407 407
                         $sth->execute(array(':source' => $database_file));
408
-                } catch(PDOException $e) {
408
+                } catch (PDOException $e) {
409 409
                         return "error : ".$e->getMessage();
410 410
                 }
411 411
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
412 412
 		$Spotter = new Spotter();
413
-		if ($fh = fopen($database_file,"r")) {
413
+		if ($fh = fopen($database_file, "r")) {
414 414
 			//$query_dest = 'INSERT INTO aircraft_modes (`AircraftID`,`FirstCreated`,`LastModified`, `ModeS`,`ModeSCountry`,`Registration`,`ICAOTypeCode`,`SerialNo`, `OperatorFlagCode`, `Manufacturer`, `Type`, `FirstRegDate`, `CurrentRegDate`, `Country`, `PreviousID`, `DeRegDate`, `Status`, `PopularName`,`GenericName`,`AircraftClass`, `Engines`, `OwnershipStatus`,`RegisteredOwners`,`MTOW`, `TotalHours`, `YearBuilt`, `CofACategory`, `CofAExpiry`, `UserNotes`, `Interested`, `UserTag`, `InfoUrl`, `PictureUrl1`, `PictureUrl2`, `PictureUrl3`, `UserBool1`, `UserBool2`, `UserBool3`, `UserBool4`, `UserBool5`, `UserString1`, `UserString2`, `UserString3`, `UserString4`, `UserString5`, `UserInt1`, `UserInt2`, `UserInt3`, `UserInt4`, `UserInt5`) VALUES (:AircraftID,:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:SerialNo, :OperatorFlagCode, :Manufacturer, :Type, :FirstRegDate, :CurrentRegDate, :Country, :PreviousID, :DeRegDate, :Status, :PopularName,:GenericName,:AircraftClass, :Engines, :OwnershipStatus,:RegisteredOwners,:MTOW, :TotalHours,:YearBuilt, :CofACategory, :CofAExpiry, :UserNotes, :Interested, :UserTag, :InfoUrl, :PictureUrl1, :PictureUrl2, :PictureUrl3, :UserBool1, :UserBool2, :UserBool3, :UserBool4, :UserBool5, :UserString1, :UserString2, :UserString3, :UserString4, :UserString5, :UserInt1, :UserInt2, :UserInt3, :UserInt4, :UserInt5)';
415 415
 			$query_dest = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
416 416
 		        $query_modes = 'INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:modes,:modescountry,:registration,:icaotypecode,:source)';
@@ -420,9 +420,9 @@  discard block
 block discarded – undo
420 420
 			$sth_modes = $Connection->db->prepare($query_modes);
421 421
 			try {
422 422
 				if ($globalTransaction) $Connection->db->beginTransaction();
423
-				$tmp = fgetcsv($fh,9999,',','"');
423
+				$tmp = fgetcsv($fh, 9999, ',', '"');
424 424
             			while (!feof($fh)) {
425
-            				$line = fgetcsv($fh,9999,',','"');
425
+            				$line = fgetcsv($fh, 9999, ',', '"');
426 426
             				$values = array();
427 427
             				//print_r($line);
428 428
             				if ($country == 'F') {
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
             				    $values['base'] = $line[4];
431 431
             				    $values['owner'] = $line[5];
432 432
             				    if ($line[6] == '') $values['date_first_reg'] = null;
433
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
433
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
434 434
 					    $values['cancel'] = $line[7];
435 435
 					} elseif ($country == 'EI') {
436 436
 					    // TODO : add modeS & reg to aircraft_modes
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
             				    $values['base'] = $line[3];
439 439
             				    $values['owner'] = $line[2];
440 440
             				    if ($line[1] == '') $values['date_first_reg'] = null;
441
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[1]));
441
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[1]));
442 442
 					    $values['cancel'] = '';
443 443
 					    $values['modes'] = $line[7];
444 444
 					    $values['icao'] = $line[8];
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
             				    $values['base'] = null;
459 459
             				    $values['owner'] = $line[5];
460 460
             				    if ($line[18] == '') $values['date_first_reg'] = null;
461
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[18]));
461
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[18]));
462 462
 					    $values['cancel'] = '';
463 463
 					} elseif ($country == 'VH') {
464 464
 					    // TODO : add modeS & reg to aircraft_modes
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
             				    $values['base'] = null;
467 467
             				    $values['owner'] = $line[12];
468 468
             				    if ($line[28] == '') $values['date_first_reg'] = null;
469
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[28]));
469
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[28]));
470 470
 
471 471
 					    $values['cancel'] = $line[39];
472 472
 					} elseif ($country == 'OE' || $country == '9A' || $country == 'VP' || $country == 'LX' || $country == 'P2' || $country == 'HC') {
@@ -486,28 +486,28 @@  discard block
 block discarded – undo
486 486
             				    $values['base'] = null;
487 487
             				    $values['owner'] = $line[8];
488 488
             				    if ($line[7] == '') $values['date_first_reg'] = null;
489
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
489
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
490 490
 					    $values['cancel'] = '';
491 491
 					} elseif ($country == 'PP') {
492 492
             				    $values['registration'] = $line[0];
493 493
             				    $values['base'] = null;
494 494
             				    $values['owner'] = $line[4];
495 495
             				    if ($line[6] == '') $values['date_first_reg'] = null;
496
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[6]));
496
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[6]));
497 497
 					    $values['cancel'] = $line[7];
498 498
 					} elseif ($country == 'E7') {
499 499
             				    $values['registration'] = $line[0];
500 500
             				    $values['base'] = null;
501 501
             				    $values['owner'] = $line[4];
502 502
             				    if ($line[5] == '') $values['date_first_reg'] = null;
503
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
503
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
504 504
 					    $values['cancel'] = '';
505 505
 					} elseif ($country == '8Q') {
506 506
             				    $values['registration'] = $line[0];
507 507
             				    $values['base'] = null;
508 508
             				    $values['owner'] = $line[3];
509 509
             				    if ($line[7] == '') $values['date_first_reg'] = null;
510
-					    else $values['date_first_reg'] = date("Y-m-d",strtotime($line[7]));
510
+					    else $values['date_first_reg'] = date("Y-m-d", strtotime($line[7]));
511 511
 					    $values['cancel'] = '';
512 512
 					} elseif ($country == 'ZK') {
513 513
             				    $values['registration'] = $line[0];
@@ -521,18 +521,18 @@  discard block
 block discarded – undo
521 521
             				    $values['registration'] = $line[0];
522 522
             				    $values['base'] = null;
523 523
             				    $values['owner'] = $line[6];
524
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[5]));
525
-					    $values['cancel'] = date("Y-m-d",strtotime($line[8]));
524
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[5]));
525
+					    $values['cancel'] = date("Y-m-d", strtotime($line[8]));
526 526
 					    $values['modes'] = $line[4];
527 527
 					    $values['icao'] = $line[10];
528 528
 					} elseif ($country == 'OY') {
529 529
             				    $values['registration'] = $line[0];
530
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[4]));
530
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[4]));
531 531
 					    $values['modes'] = $line[5];
532 532
 					    $values['icao'] = $line[6];
533 533
 					} elseif ($country == 'PH') {
534 534
             				    $values['registration'] = $line[0];
535
-            				    $values['date_first_reg'] = date("Y-m-d",strtotime($line[3]));
535
+            				    $values['date_first_reg'] = date("Y-m-d", strtotime($line[3]));
536 536
 					    $values['modes'] = $line[4];
537 537
 					    $values['icao'] = $line[5];
538 538
 					} elseif ($country == 'OM' || $country == 'TF') {
@@ -543,17 +543,17 @@  discard block
 block discarded – undo
543 543
 					    $values['cancel'] = '';
544 544
 					}
545 545
 					if (isset($values['cancel']) && $values['cancel'] == '' && $values['registration'] != null && isset($values['owner'])) {
546
-						$query_dest_values = array(':registration' => $values['registration'],':base' => $values['base'],':date_first_reg' => $values['date_first_reg'],':owner' => $values['owner'],':source' => $database_file);
546
+						$query_dest_values = array(':registration' => $values['registration'], ':base' => $values['base'], ':date_first_reg' => $values['date_first_reg'], ':owner' => $values['owner'], ':source' => $database_file);
547 547
 						$sth_dest->execute($query_dest_values);
548 548
 					}
549 549
 					if ($globalMasterSource && $values['registration'] != null && isset($values['modes']) && $values['modes'] != '') {
550 550
 						$modescountry = $Spotter->countryFromAircraftRegistration($values['registration']);
551
-						$query_modes_values = array(':registration' => $values['registration'],':modes' => $values['modes'],':modescountry' => $modescountry,':icaotypecode' => $values['icao'],':source' => $database_file);
551
+						$query_modes_values = array(':registration' => $values['registration'], ':modes' => $values['modes'], ':modescountry' => $modescountry, ':icaotypecode' => $values['icao'], ':source' => $database_file);
552 552
 						$sth_modes->execute($query_modes_values);
553 553
 					}
554 554
 				}
555 555
 				if ($globalTransaction) $Connection->db->commit();
556
-			} catch(PDOException $e) {
556
+			} catch (PDOException $e) {
557 557
 				return "error : ".$e->getMessage();
558 558
 			}
559 559
 		}
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
 			$Connection = new Connection();
669 669
 			$sth = $Connection->db->prepare($query);
670 670
                         $sth->execute();
671
-                } catch(PDOException $e) {
671
+                } catch (PDOException $e) {
672 672
                         return "error : ".$e->getMessage();
673 673
                 }
674 674
 
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 			$Connection = new Connection();
679 679
 			$sth = $Connection->db->prepare($query);
680 680
                         $sth->execute();
681
-                } catch(PDOException $e) {
681
+                } catch (PDOException $e) {
682 682
                         return "error : ".$e->getMessage();
683 683
                 }
684 684
 
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 		if ($globalTransaction) $Connection->db->beginTransaction();
690 690
   
691 691
 		$i = 0;
692
-		while($row = sparql_fetch_array($result))
692
+		while ($row = sparql_fetch_array($result))
693 693
 		{
694 694
 			if ($i >= 1) {
695 695
 			//print_r($row);
@@ -709,31 +709,31 @@  discard block
 block discarded – undo
709 709
 				$row['image'] = '';
710 710
 				$row['image_thumb'] = '';
711 711
 			} else {
712
-				$image = str_replace(' ','_',$row['image']);
712
+				$image = str_replace(' ', '_', $row['image']);
713 713
 				$digest = md5($image);
714
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image . '/220px-' . $image;
715
-				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/' . $folder;
716
-				$folder = $digest[0] . '/' . $digest[0] . $digest[1] . '/' . $image;
717
-				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/' . $folder;
714
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image.'/220px-'.$image;
715
+				$row['image_thumb'] = 'http://upload.wikimedia.org/wikipedia/commons/thumb/'.$folder;
716
+				$folder = $digest[0].'/'.$digest[0].$digest[1].'/'.$image;
717
+				$row['image'] = 'http://upload.wikimedia.org/wikipedia/commons/'.$folder;
718 718
 			}
719 719
 			
720
-			$country = explode('-',$row['country']);
720
+			$country = explode('-', $row['country']);
721 721
 			$row['country'] = $country[0];
722 722
 			
723 723
 			$row['type'] = trim($row['type']);
724
-			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i',$row['name'])) {
724
+			if ($row['type'] == 'Military: Naval Auxiliary Air Station' || $row['type'] == 'http://dbpedia.org/resource/Naval_air_station' || $row['type'] == 'Military: Naval Air Station' || $row['type'] == 'Military Northern Fleet' || $row['type'] == 'Military and industrial' || $row['type'] == 'Military: Royal Air Force station' || $row['type'] == 'http://dbpedia.org/resource/Military_airbase' || $row['type'] == 'Military: Naval air station' || preg_match('/air base/i', $row['name'])) {
725 725
 				$row['type'] = 'Military';
726 726
 			} elseif ($row['type'] == 'http://dbpedia.org/resource/Airport' || $row['type'] == 'Civil' || $row['type'] == 'Public use' || $row['type'] == 'Public' || $row['type'] == 'http://dbpedia.org/resource/Civilian' || $row['type'] == 'Public, Civilian' || $row['type'] == 'Public / Military' || $row['type'] == 'Private & Civilian' || $row['type'] == 'Civilian and Military' || $row['type'] == 'Public/military' || $row['type'] == 'Active With Few Facilities' || $row['type'] == '?ivilian' || $row['type'] == 'Civil/Military' || $row['type'] == 'NA' || $row['type'] == 'Public/Military') {
727 727
 				$row['type'] = 'small_airport';
728 728
 			}
729 729
 			
730
-			$row['city'] = urldecode(str_replace('_',' ',str_replace('http://dbpedia.org/resource/','',$row['city'])));
731
-			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'],':iata' => $row['iata'],':icao' => $row['icao'],':latitude' => $row['latitude'],':longitude' => $row['longitude'],':altitude' => $row['altitude'],':type' => $row['type'],':city' => $row['city'],':country' => $row['country'],':home_link' => $row['homepage'],':wikipedia_link' => $row['wikipedia_page'],':image' => $row['image'],':image_thumb' => $row['image_thumb']);
730
+			$row['city'] = urldecode(str_replace('_', ' ', str_replace('http://dbpedia.org/resource/', '', $row['city'])));
731
+			$query_dest_values = array(':airport_id' => $i, ':name' => $row['name'], ':iata' => $row['iata'], ':icao' => $row['icao'], ':latitude' => $row['latitude'], ':longitude' => $row['longitude'], ':altitude' => $row['altitude'], ':type' => $row['type'], ':city' => $row['city'], ':country' => $row['country'], ':home_link' => $row['homepage'], ':wikipedia_link' => $row['wikipedia_page'], ':image' => $row['image'], ':image_thumb' => $row['image_thumb']);
732 732
 			//print_r($query_dest_values);
733 733
 			
734 734
 			try {
735 735
 				$sth_dest->execute($query_dest_values);
736
-			} catch(PDOException $e) {
736
+			} catch (PDOException $e) {
737 737
 				return "error : ".$e->getMessage();
738 738
 			}
739 739
 			}
@@ -747,7 +747,7 @@  discard block
 block discarded – undo
747 747
 			$Connection = new Connection();
748 748
 			$sth = $Connection->db->prepare($query);
749 749
                         $sth->execute();
750
-                } catch(PDOException $e) {
750
+                } catch (PDOException $e) {
751 751
                         return "error : ".$e->getMessage();
752 752
                 }
753 753
 
@@ -755,12 +755,12 @@  discard block
 block discarded – undo
755 755
 		if ($globalDebug) echo "Insert Not available Airport...\n";
756 756
 		$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`,`image`,`image_thumb`)
757 757
 		    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link, :image, :image_thumb)";
758
-		$query_values = array(':airport_id' => $i, ':name' => 'Not available',':iata' => 'NA',':icao' => 'NA',':latitude' => '0',':longitude' => '0',':altitude' => '0',':type' => 'NA',':city' => 'N/A',':country' => 'N/A',':home_link' => '',':wikipedia_link' => '',':image' => '',':image_thumb' => '');
758
+		$query_values = array(':airport_id' => $i, ':name' => 'Not available', ':iata' => 'NA', ':icao' => 'NA', ':latitude' => '0', ':longitude' => '0', ':altitude' => '0', ':type' => 'NA', ':city' => 'N/A', ':country' => 'N/A', ':home_link' => '', ':wikipedia_link' => '', ':image' => '', ':image_thumb' => '');
759 759
 		try {
760 760
 			$Connection = new Connection();
761 761
 			$sth = $Connection->db->prepare($query);
762 762
                         $sth->execute($query_values);
763
-                } catch(PDOException $e) {
763
+                } catch (PDOException $e) {
764 764
                         return "error : ".$e->getMessage();
765 765
                 }
766 766
 		$i++;
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		echo "Download data from ourairports.com...\n";
779 779
 		$delimiter = ',';
780 780
 		$out_file = $tmp_dir.'airports.csv';
781
-		update_db::download('http://ourairports.com/data/airports.csv',$out_file);
781
+		update_db::download('http://ourairports.com/data/airports.csv', $out_file);
782 782
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
783 783
 		echo "Add data from ourairports.com...\n";
784 784
 
@@ -789,32 +789,32 @@  discard block
 block discarded – undo
789 789
 			//$Connection->db->beginTransaction();
790 790
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
791 791
 			{
792
-				if(!$header) $header = $row;
792
+				if (!$header) $header = $row;
793 793
 				else {
794 794
 					$data = array();
795 795
 					$data = array_combine($header, $row);
796 796
 					try {
797 797
 						$sth = $Connection->db->prepare('SELECT COUNT(*) FROM airport WHERE `icao` = :icao');
798 798
 						$sth->execute(array(':icao' => $data['gps_code']));
799
-					} catch(PDOException $e) {
799
+					} catch (PDOException $e) {
800 800
 						return "error : ".$e->getMessage();
801 801
 					}
802 802
 					if ($sth->fetchColumn() > 0) {
803 803
 						$query = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
804 804
 						try {
805 805
 							$sth = $Connection->db->prepare($query);
806
-							$sth->execute(array(':icao' => $data['gps_code'],':type' => $data['type']));
807
-						} catch(PDOException $e) {
806
+							$sth->execute(array(':icao' => $data['gps_code'], ':type' => $data['type']));
807
+						} catch (PDOException $e) {
808 808
 							return "error : ".$e->getMessage();
809 809
 						}
810 810
 					} else {
811 811
 						$query = "INSERT INTO airport (`airport_id`,`name`,`city`,`country`,`iata`,`icao`,`latitude`,`longitude`,`altitude`,`type`,`home_link`,`wikipedia_link`)
812 812
 						    VALUES (:airport_id, :name, :city, :country, :iata, :icao, :latitude, :longitude, :altitude, :type, :home_link, :wikipedia_link)";
813
-						$query_values = array(':airport_id' => $i, ':name' => $data['name'],':iata' => $data['iata_code'],':icao' => $data['gps_code'],':latitude' => $data['latitude_deg'],':longitude' => $data['longitude_deg'],':altitude' => $data['elevation_ft'],':type' => $data['type'],':city' => $data['municipality'],':country' => $data['iso_country'],':home_link' => $data['home_link'],':wikipedia_link' => $data['wikipedia_link']);
813
+						$query_values = array(':airport_id' => $i, ':name' => $data['name'], ':iata' => $data['iata_code'], ':icao' => $data['gps_code'], ':latitude' => $data['latitude_deg'], ':longitude' => $data['longitude_deg'], ':altitude' => $data['elevation_ft'], ':type' => $data['type'], ':city' => $data['municipality'], ':country' => $data['iso_country'], ':home_link' => $data['home_link'], ':wikipedia_link' => $data['wikipedia_link']);
814 814
 						try {
815 815
 							$sth = $Connection->db->prepare($query);
816 816
 							$sth->execute($query_values);
817
-						} catch(PDOException $e) {
817
+						} catch (PDOException $e) {
818 818
 							return "error : ".$e->getMessage();
819 819
 						}
820 820
 						$i++;
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 
828 828
 		echo "Download data from another free database...\n";
829 829
 		$out_file = $tmp_dir.'GlobalAirportDatabase.zip';
830
-		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip',$out_file);
830
+		update_db::download('http://www.partow.net/downloads/GlobalAirportDatabase.zip', $out_file);
831 831
 		if (!file_exists($out_file) || !is_readable($out_file)) return FALSE;
832 832
 		update_db::unzip($out_file);
833 833
 		$header = NULL;
@@ -839,15 +839,15 @@  discard block
 block discarded – undo
839 839
 			//$Connection->db->beginTransaction();
840 840
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
841 841
 			{
842
-				if(!$header) $header = $row;
842
+				if (!$header) $header = $row;
843 843
 				else {
844 844
 					$data = $row;
845 845
 
846 846
 					$query = 'UPDATE airport SET `city` = :city, `country` = :country WHERE icao = :icao';
847 847
 					try {
848 848
 						$sth = $Connection->db->prepare($query);
849
-						$sth->execute(array(':icao' => $data[0],':city' => ucwords(strtolower($data[3])),':country' => ucwords(strtolower($data[4]))));
850
-					} catch(PDOException $e) {
849
+						$sth->execute(array(':icao' => $data[0], ':city' => ucwords(strtolower($data[3])), ':country' => ucwords(strtolower($data[4]))));
850
+					} catch (PDOException $e) {
851 851
 						return "error : ".$e->getMessage();
852 852
 					}
853 853
 				}
@@ -861,15 +861,15 @@  discard block
 block discarded – undo
861 861
 		try {
862 862
 			$sth = $Connection->db->prepare("SELECT icao FROM airport WHERE `name` LIKE '%Air Base%'");
863 863
 			$sth->execute();
864
-		} catch(PDOException $e) {
864
+		} catch (PDOException $e) {
865 865
 			return "error : ".$e->getMessage();
866 866
 		}
867 867
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
868 868
 			$query2 = 'UPDATE airport SET `type` = :type WHERE icao = :icao';
869 869
 			try {
870 870
 				$sth2 = $Connection->db->prepare($query2);
871
-				$sth2->execute(array(':icao' => $row['icao'],':type' => 'military'));
872
-			} catch(PDOException $e) {
871
+				$sth2->execute(array(':icao' => $row['icao'], ':type' => 'military'));
872
+			} catch (PDOException $e) {
873 873
 				return "error : ".$e->getMessage();
874 874
 			}
875 875
 		}
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 			$Connection = new Connection();
894 894
 			$sth = $Connection->db->prepare($query);
895 895
                         $sth->execute(array(':source' => 'translation.csv'));
896
-                } catch(PDOException $e) {
896
+                } catch (PDOException $e) {
897 897
                         return "error : ".$e->getMessage();
898 898
                 }
899 899
 
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
911 911
 			{
912 912
 				$i++;
913
-				if($i > 12) {
913
+				if ($i > 12) {
914 914
 					$data = $row;
915 915
 					$operator = $data[2];
916 916
 					if ($operator != '' && is_numeric(substr(substr($operator, 0, 3), -1, 1))) {
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
                                                 //echo substr($operator, 0, 2)."\n";;
919 919
                                                 if (count($airline_array) > 0) {
920 920
 							//print_r($airline_array);
921
-							$operator = $airline_array[0]['icao'].substr($operator,2);
921
+							$operator = $airline_array[0]['icao'].substr($operator, 2);
922 922
                                                 }
923 923
                                         }
924 924
 					
@@ -926,14 +926,14 @@  discard block
 block discarded – undo
926 926
 					if ($operator_correct != '' && is_numeric(substr(substr($operator_correct, 0, 3), -1, 1))) {
927 927
                                                 $airline_array = $Spotter->getAllAirlineInfo(substr($operator_correct, 0, 2));
928 928
                                                 if (count($airline_array) > 0) {
929
-                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct,2);
929
+                                            		$operator_correct = $airline_array[0]['icao'].substr($operator_correct, 2);
930 930
                                             	}
931 931
                                         }
932 932
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
933 933
 					try {
934 934
 						$sth = $Connection->db->prepare($query);
935
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $operator,':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
936
-					} catch(PDOException $e) {
935
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $operator, ':Operator_correct' => $operator_correct, ':source' => 'translation.csv'));
936
+					} catch (PDOException $e) {
937 937
 						return "error : ".$e->getMessage();
938 938
 					}
939 939
 				}
@@ -953,7 +953,7 @@  discard block
 block discarded – undo
953 953
 			$Connection = new Connection();
954 954
 			$sth = $Connection->db->prepare($query);
955 955
                         $sth->execute(array(':source' => 'website_fam'));
956
-                } catch(PDOException $e) {
956
+                } catch (PDOException $e) {
957 957
                         return "error : ".$e->getMessage();
958 958
                 }
959 959
 
@@ -973,8 +973,8 @@  discard block
 block discarded – undo
973 973
 					$query = 'INSERT INTO translation (Reg,Reg_correct,Operator,Operator_correct,Source) VALUES (:Reg, :Reg_correct, :Operator, :Operator_correct, :source)';
974 974
 					try {
975 975
 						$sth = $Connection->db->prepare($query);
976
-						$sth->execute(array(':Reg' => $data[0],':Reg_correct' => $data[1],':Operator' => $data[2],':Operator_correct' => $data[3], ':source' => 'website_fam'));
977
-					} catch(PDOException $e) {
976
+						$sth->execute(array(':Reg' => $data[0], ':Reg_correct' => $data[1], ':Operator' => $data[2], ':Operator_correct' => $data[3], ':source' => 'website_fam'));
977
+					} catch (PDOException $e) {
978 978
 						return "error : ".$e->getMessage();
979 979
 					}
980 980
 				}
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 			$Connection = new Connection();
998 998
 			$sth = $Connection->db->prepare($query);
999 999
                         $sth->execute(array(':source' => 'website_faa'));
1000
-                } catch(PDOException $e) {
1000
+                } catch (PDOException $e) {
1001 1001
                         return "error : ".$e->getMessage();
1002 1002
                 }
1003 1003
 
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 			$Connection = new Connection();
1007 1007
 			$sth = $Connection->db->prepare($query);
1008 1008
                         $sth->execute(array(':source' => 'website_faa'));
1009
-                } catch(PDOException $e) {
1009
+                } catch (PDOException $e) {
1010 1010
                         return "error : ".$e->getMessage();
1011 1011
                 }
1012 1012
 
@@ -1023,8 +1023,8 @@  discard block
 block discarded – undo
1023 1023
 					$query_search = 'SELECT icaotypecode FROM aircraft_modes WHERE registration = :registration AND Source <> :source LIMIT 1';
1024 1024
 					try {
1025 1025
 						$sths = $Connection->db->prepare($query_search);
1026
-						$sths->execute(array(':registration' => 'N'.$data[0],':source' => 'website_faa'));
1027
-					} catch(PDOException $e) {
1026
+						$sths->execute(array(':registration' => 'N'.$data[0], ':source' => 'website_faa'));
1027
+					} catch (PDOException $e) {
1028 1028
 						return "error s : ".$e->getMessage();
1029 1029
 					}
1030 1030
 					$result_search = $sths->fetchAll(PDO::FETCH_ASSOC);
@@ -1037,8 +1037,8 @@  discard block
 block discarded – undo
1037 1037
 							//}
1038 1038
 						try {
1039 1039
 							$sthi = $Connection->db->prepare($queryi);
1040
-							$sthi->execute(array(':mfr' => $data[2],':icao' => $result_search[0]['icaotypecode']));
1041
-						} catch(PDOException $e) {
1040
+							$sthi->execute(array(':mfr' => $data[2], ':icao' => $result_search[0]['icaotypecode']));
1041
+						} catch (PDOException $e) {
1042 1042
 							return "error u : ".$e->getMessage();
1043 1043
 						}
1044 1044
 					} else {
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 						try {
1047 1047
 							$sthsm = $Connection->db->prepare($query_search_mfr);
1048 1048
 							$sthsm->execute(array(':mfr' => $data[2]));
1049
-						} catch(PDOException $e) {
1049
+						} catch (PDOException $e) {
1050 1050
 							return "error mfr : ".$e->getMessage();
1051 1051
 						}
1052 1052
 						$result_search_mfr = $sthsm->fetchAll(PDO::FETCH_ASSOC);
@@ -1056,8 +1056,8 @@  discard block
 block discarded – undo
1056 1056
 							$queryf = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:source)';
1057 1057
 							try {
1058 1058
 								$sthf = $Connection->db->prepare($queryf);
1059
-								$sthf->execute(array(':FirstCreated' => $data[16],':LastModified' => $data[15],':ModeS' => $data[33],':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0],':ICAOTypeCode' => $result_search_mfr[0]['icao'],':source' => 'website_faa'));
1060
-							} catch(PDOException $e) {
1059
+								$sthf->execute(array(':FirstCreated' => $data[16], ':LastModified' => $data[15], ':ModeS' => $data[33], ':ModeSCountry' => $data[14], ':Registration' => 'N'.$data[0], ':ICAOTypeCode' => $result_search_mfr[0]['icao'], ':source' => 'website_faa'));
1060
+							} catch (PDOException $e) {
1061 1061
 								return "error f : ".$e->getMessage();
1062 1062
 							}
1063 1063
 						}
@@ -1067,13 +1067,13 @@  discard block
 block discarded – undo
1067 1067
 						$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,:date_first_reg,:source)';
1068 1068
 						try {
1069 1069
 							$sth = $Connection->db->prepare($query);
1070
-							$sth->execute(array(':registration' => 'N'.$data[0],':base' => $data[9],':owner' => ucwords(strtolower($data[6])),':date_first_reg' => date('Y-m-d',strtotime($data[23])), ':source' => 'website_faa'));
1071
-						} catch(PDOException $e) {
1070
+							$sth->execute(array(':registration' => 'N'.$data[0], ':base' => $data[9], ':owner' => ucwords(strtolower($data[6])), ':date_first_reg' => date('Y-m-d', strtotime($data[23])), ':source' => 'website_faa'));
1071
+						} catch (PDOException $e) {
1072 1072
 							return "error i : ".$e->getMessage();
1073 1073
 						}
1074 1074
 					}
1075 1075
 				}
1076
-				if ($i % 90 == 0) {
1076
+				if ($i%90 == 0) {
1077 1077
 					if ($globalTransaction) $Connection->db->commit();
1078 1078
 					if ($globalTransaction) $Connection->db->beginTransaction();
1079 1079
 				}
@@ -1092,7 +1092,7 @@  discard block
 block discarded – undo
1092 1092
 			$Connection = new Connection();
1093 1093
 			$sth = $Connection->db->prepare($query);
1094 1094
                         $sth->execute(array(':source' => 'website_fam'));
1095
-                } catch(PDOException $e) {
1095
+                } catch (PDOException $e) {
1096 1096
                         return "error : ".$e->getMessage();
1097 1097
                 }
1098 1098
 
@@ -1113,8 +1113,8 @@  discard block
 block discarded – undo
1113 1113
 					$query = 'INSERT INTO aircraft_modes (FirstCreated,LastModified,ModeS,ModeSCountry,Registration,ICAOTypeCode,type_flight,Source) VALUES (:FirstCreated,:LastModified,:ModeS,:ModeSCountry,:Registration,:ICAOTypeCode,:type_flight,:source)';
1114 1114
 					try {
1115 1115
 						$sth = $Connection->db->prepare($query);
1116
-						$sth->execute(array(':FirstCreated' => $data[0],':LastModified' => $data[1],':ModeS' => $data[2],':ModeSCountry' => $data[3], ':Registration' => $data[4],':ICAOTypeCode' => $data[5],':type_flight' => $data[6],':source' => 'website_fam'));
1117
-					} catch(PDOException $e) {
1116
+						$sth->execute(array(':FirstCreated' => $data[0], ':LastModified' => $data[1], ':ModeS' => $data[2], ':ModeSCountry' => $data[3], ':Registration' => $data[4], ':ICAOTypeCode' => $data[5], ':type_flight' => $data[6], ':source' => 'website_fam'));
1117
+					} catch (PDOException $e) {
1118 1118
 						return "error : ".$e->getMessage();
1119 1119
 					}
1120 1120
 				}
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 			$Connection = new Connection();
1134 1134
 			$sth = $Connection->db->prepare($query);
1135 1135
                         $sth->execute(array(':source' => 'website_fam'));
1136
-                } catch(PDOException $e) {
1136
+                } catch (PDOException $e) {
1137 1137
                         return "error : ".$e->getMessage();
1138 1138
                 }
1139 1139
 
@@ -1149,8 +1149,8 @@  discard block
 block discarded – undo
1149 1149
 					$query = 'INSERT INTO aircraft_owner (registration,base,owner,date_first_reg,Source) VALUES (:registration,:base,:owner,NULL,:source)';
1150 1150
 					try {
1151 1151
 						$sth = $Connection->db->prepare($query);
1152
-						$sth->execute(array(':registration' => $data[0],':base' => $data[1],':owner' => $data[2], ':source' => 'website_fam'));
1153
-					} catch(PDOException $e) {
1152
+						$sth->execute(array(':registration' => $data[0], ':base' => $data[1], ':owner' => $data[2], ':source' => 'website_fam'));
1153
+					} catch (PDOException $e) {
1154 1154
 						print_r($data);
1155 1155
 						return "error : ".$e->getMessage();
1156 1156
 					}
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 			$Connection = new Connection();
1171 1171
 			$sth = $Connection->db->prepare($query);
1172 1172
                         $sth->execute(array(':source' => 'website_fam'));
1173
-                } catch(PDOException $e) {
1173
+                } catch (PDOException $e) {
1174 1174
                         return "error : ".$e->getMessage();
1175 1175
                 }
1176 1176
 
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 					$query = 'INSERT INTO routes (CallSign,Operator_ICAO,FromAirport_ICAO,FromAirport_Time,ToAirport_ICAO,ToAirport_Time,RouteStop,Source) VALUES (:CallSign,:Operator_ICAO,:FromAirport_ICAO,:FromAirport_Time,:ToAirport_ICAO,:ToAirport_Time,:RouteStop,:source)';
1191 1191
 					try {
1192 1192
 						$sth = $Connection->db->prepare($query);
1193
-						$sth->execute(array(':CallSign' => $data[0],':Operator_ICAO' => $data[1],':FromAirport_ICAO' => $data[2],':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4],':ToAirport_Time' => $data[5],':RouteStop' => $data[6],':source' => 'website_fam'));
1194
-					} catch(PDOException $e) {
1193
+						$sth->execute(array(':CallSign' => $data[0], ':Operator_ICAO' => $data[1], ':FromAirport_ICAO' => $data[2], ':FromAirport_Time' => $data[3], ':ToAirport_ICAO' => $data[4], ':ToAirport_Time' => $data[5], ':RouteStop' => $data[6], ':source' => 'website_fam'));
1194
+					} catch (PDOException $e) {
1195 1195
 						return "error : ".$e->getMessage();
1196 1196
 					}
1197 1197
 				}
@@ -1210,7 +1210,7 @@  discard block
 block discarded – undo
1210 1210
 			$Connection = new Connection();
1211 1211
 			$sth = $Connection->db->prepare($query);
1212 1212
                         $sth->execute();
1213
-                } catch(PDOException $e) {
1213
+                } catch (PDOException $e) {
1214 1214
                         return "error : ".$e->getMessage();
1215 1215
                 }
1216 1216
 
@@ -1231,8 +1231,8 @@  discard block
 block discarded – undo
1231 1231
 					$query = 'INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,length,gross_tonnage,dead_weight,width,country,engine_power,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:length,:gross_tonnage,:dead_weight,:width,:country,:engine_power,:type)';
1232 1232
 					try {
1233 1233
 						$sth = $Connection->db->prepare($query);
1234
-						$sth->execute(array(':mmsi' => $data[0],':imo' => $data[1],':call_sign' => $data[2],':ship_name' => $data[3], ':length' => $data[4],':gross_tonnage' => $data[5],':dead_weight' => $data[6],':width' => $data[7],':country' => $data[8],':engine_power' => $data[9],':type' => $data[10]));
1235
-					} catch(PDOException $e) {
1234
+						$sth->execute(array(':mmsi' => $data[0], ':imo' => $data[1], ':call_sign' => $data[2], ':ship_name' => $data[3], ':length' => $data[4], ':gross_tonnage' => $data[5], ':dead_weight' => $data[6], ':width' => $data[7], ':country' => $data[8], ':engine_power' => $data[9], ':type' => $data[10]));
1235
+					} catch (PDOException $e) {
1236 1236
 						return "error : ".$e->getMessage();
1237 1237
 					}
1238 1238
 				}
@@ -1251,7 +1251,7 @@  discard block
 block discarded – undo
1251 1251
 			$Connection = new Connection();
1252 1252
 			$sth = $Connection->db->prepare($query);
1253 1253
 			$sth->execute();
1254
-		} catch(PDOException $e) {
1254
+		} catch (PDOException $e) {
1255 1255
 			return "error : ".$e->getMessage();
1256 1256
 		}
1257 1257
 
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 					try {
1268 1268
 						$sth = $Connection->db->prepare($query);
1269 1269
 						$sth->execute(array(':icao' => $icao));
1270
-					} catch(PDOException $e) {
1270
+					} catch (PDOException $e) {
1271 1271
 						return "error : ".$e->getMessage();
1272 1272
 					}
1273 1273
 				}
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 		return '';
1279 1279
         }
1280 1280
 
1281
-	public static function tle($filename,$tletype) {
1281
+	public static function tle($filename, $tletype) {
1282 1282
 		require_once(dirname(__FILE__).'/../require/class.Spotter.php');
1283 1283
 		global $tmp_dir, $globalTransaction;
1284 1284
 		//$Spotter = new Spotter();
@@ -1288,7 +1288,7 @@  discard block
 block discarded – undo
1288 1288
 			$Connection = new Connection();
1289 1289
 			$sth = $Connection->db->prepare($query);
1290 1290
                         $sth->execute(array(':source' => $filename));
1291
-                } catch(PDOException $e) {
1291
+                } catch (PDOException $e) {
1292 1292
                         return "error : ".$e->getMessage();
1293 1293
                 }
1294 1294
 		
@@ -1313,8 +1313,8 @@  discard block
 block discarded – undo
1313 1313
 					$query = 'INSERT INTO tle (tle_name,tle_tle1,tle_tle2,tle_type,tle_source) VALUES (:name, :tle1, :tle2, :type, :source)';
1314 1314
 					try {
1315 1315
 						$sth = $Connection->db->prepare($query);
1316
-						$sth->execute(array(':name' => $dbdata['name'],':tle1' => $dbdata['tle1'],':tle2' => $dbdata['tle2'], ':type' => $tletype,':source' => $filename));
1317
-					} catch(PDOException $e) {
1316
+						$sth->execute(array(':name' => $dbdata['name'], ':tle1' => $dbdata['tle1'], ':tle2' => $dbdata['tle2'], ':type' => $tletype, ':source' => $filename));
1317
+					} catch (PDOException $e) {
1318 1318
 						return "error : ".$e->getMessage();
1319 1319
 					}
1320 1320
 
@@ -1334,28 +1334,28 @@  discard block
 block discarded – undo
1334 1334
         */
1335 1335
         private static function table2array($data) {
1336 1336
                 $html = str_get_html($data);
1337
-                $tabledata=array();
1338
-                foreach($html->find('tr') as $element)
1337
+                $tabledata = array();
1338
+                foreach ($html->find('tr') as $element)
1339 1339
                 {
1340 1340
                         $td = array();
1341
-                        foreach( $element->find('th') as $row)
1341
+                        foreach ($element->find('th') as $row)
1342 1342
                         {
1343 1343
                                 $td [] = trim($row->plaintext);
1344 1344
                         }
1345
-                        $td=array_filter($td);
1345
+                        $td = array_filter($td);
1346 1346
                         $tabledata[] = $td;
1347 1347
 
1348 1348
                         $td = array();
1349 1349
                         $tdi = array();
1350
-                        foreach( $element->find('td') as $row)
1350
+                        foreach ($element->find('td') as $row)
1351 1351
                         {
1352 1352
                                 $td [] = trim($row->plaintext);
1353 1353
                                 $tdi [] = trim($row->innertext);
1354 1354
                         }
1355
-                        $td=array_filter($td);
1356
-                        $tdi=array_filter($tdi);
1355
+                        $td = array_filter($td);
1356
+                        $tdi = array_filter($tdi);
1357 1357
                     //    $tabledata[]=array_merge($td,$tdi);
1358
-                        $tabledata[]=$td;
1358
+                        $tabledata[] = $td;
1359 1359
                 }
1360 1360
                 return(array_filter($tabledata));
1361 1361
         }
@@ -1428,13 +1428,13 @@  discard block
 block discarded – undo
1428 1428
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1429 1429
 			{
1430 1430
 				$i++;
1431
-				if($i > 3 && count($row) > 2) {
1431
+				if ($i > 3 && count($row) > 2) {
1432 1432
 					$data = array_values(array_filter($row));
1433 1433
 					$cntdata = count($data);
1434 1434
 					if ($cntdata > 10) {
1435 1435
 						$value = $data[9];
1436 1436
 						
1437
-						for ($i =10;$i < $cntdata;$i++) {
1437
+						for ($i = 10; $i < $cntdata; $i++) {
1438 1438
 							$value .= ' '.$data[$i];
1439 1439
 						}
1440 1440
 						$data[9] = $value;
@@ -1444,8 +1444,8 @@  discard block
 block discarded – undo
1444 1444
 						$query = 'INSERT INTO waypoints (name_begin,latitude_begin,longitude_begin,name_end,latitude_end,longitude_end,high,base,top,segment_name) VALUES (:name_begin, :latitude_begin, :longitude_begin, :name_end, :latitude_end, :longitude_end, :high, :base, :top, :segment_name)';
1445 1445
 						try {
1446 1446
 							$sth = $Connection->db->prepare($query);
1447
-							$sth->execute(array(':name_begin' => $data[0],':latitude_begin' => $data[1],':longitude_begin' => $data[2],':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1448
-						} catch(PDOException $e) {
1447
+							$sth->execute(array(':name_begin' => $data[0], ':latitude_begin' => $data[1], ':longitude_begin' => $data[2], ':name_end' => $data[3], ':latitude_end' => $data[4], ':longitude_end' => $data[5], ':high' => $data[6], ':base' => $data[7], ':top' => $data[8], ':segment_name' => $data[9]));
1448
+						} catch (PDOException $e) {
1449 1449
 							return "error : ".$e->getMessage();
1450 1450
 						}
1451 1451
 					}
@@ -1466,7 +1466,7 @@  discard block
 block discarded – undo
1466 1466
 			$Connection = new Connection();
1467 1467
 			$sth = $Connection->db->prepare($query);
1468 1468
                         $sth->execute();
1469
-                } catch(PDOException $e) {
1469
+                } catch (PDOException $e) {
1470 1470
                         return "error : ".$e->getMessage();
1471 1471
                 }
1472 1472
 
@@ -1478,12 +1478,12 @@  discard block
 block discarded – undo
1478 1478
 			if ($globalTransaction) $Connection->db->beginTransaction();
1479 1479
 			while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
1480 1480
 			{
1481
-				if(count($row) > 1) {
1481
+				if (count($row) > 1) {
1482 1482
 					$query = "INSERT INTO airlines (name,icao,active,forsource) VALUES (:name, :icao, 'Y','ivao')";
1483 1483
 					try {
1484 1484
 						$sth = $Connection->db->prepare($query);
1485
-						$sth->execute(array(':name' => $row[1],':icao' => $row[0]));
1486
-					} catch(PDOException $e) {
1485
+						$sth->execute(array(':name' => $row[1], ':icao' => $row[0]));
1486
+					} catch (PDOException $e) {
1487 1487
 						return "error : ".$e->getMessage();
1488 1488
 					}
1489 1489
 				}
@@ -1503,21 +1503,21 @@  discard block
 block discarded – undo
1503 1503
 			try {
1504 1504
 				$sth = $Connection->db->prepare($query);
1505 1505
                     		$sth->execute();
1506
-	                } catch(PDOException $e) {
1506
+	                } catch (PDOException $e) {
1507 1507
 				return "error : ".$e->getMessage();
1508 1508
 	                }
1509 1509
 	        }
1510 1510
 
1511 1511
 
1512
-		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz',$tmp_dir.'airspace.sql');
1512
+		if ($globalDBdriver == 'mysql') update_db::gunzip('../db/airspace.sql.gz', $tmp_dir.'airspace.sql');
1513 1513
 		else {
1514
-			update_db::gunzip('../db/pgsql/airspace.sql.gz',$tmp_dir.'airspace.sql');
1514
+			update_db::gunzip('../db/pgsql/airspace.sql.gz', $tmp_dir.'airspace.sql');
1515 1515
 			$query = "CREATE EXTENSION postgis";
1516
-			$Connection = new Connection(null,null,$_SESSION['database_root'],$_SESSION['database_rootpass']);
1516
+			$Connection = new Connection(null, null, $_SESSION['database_root'], $_SESSION['database_rootpass']);
1517 1517
 			try {
1518 1518
 				$sth = $Connection->db->prepare($query);
1519 1519
 				$sth->execute();
1520
-			} catch(PDOException $e) {
1520
+			} catch (PDOException $e) {
1521 1521
 				return "error : ".$e->getMessage();
1522 1522
 			}
1523 1523
 		}
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 		include_once('class.create_db.php');
1531 1531
 		require_once(dirname(__FILE__).'/../require/class.NOTAM.php');
1532 1532
 		if ($globalDebug) echo "NOTAM from FlightAirMap website : Download...";
1533
-		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz',$tmp_dir.'notam.txt.gz');
1533
+		update_db::download('http://data.flightairmap.fr/data/notam.txt.gz', $tmp_dir.'notam.txt.gz');
1534 1534
 		$error = '';
1535 1535
 		if (file_exists($tmp_dir.'notam.txt.gz')) {
1536 1536
 			if ($globalDebug) echo "Gunzip...";
@@ -1562,14 +1562,14 @@  discard block
 block discarded – undo
1562 1562
 			try {
1563 1563
 				$sth = $Connection->db->prepare($query);
1564 1564
             	        	$sth->execute();
1565
-	                } catch(PDOException $e) {
1565
+	                } catch (PDOException $e) {
1566 1566
     	                	echo "error : ".$e->getMessage();
1567 1567
 	                }
1568 1568
 		}
1569 1569
 		if ($globalDBdriver == 'mysql') {
1570
-			update_db::gunzip('../db/countries.sql.gz',$tmp_dir.'countries.sql');
1570
+			update_db::gunzip('../db/countries.sql.gz', $tmp_dir.'countries.sql');
1571 1571
 		} else {
1572
-			update_db::gunzip('../db/pgsql/countries.sql.gz',$tmp_dir.'countries.sql');
1572
+			update_db::gunzip('../db/pgsql/countries.sql.gz', $tmp_dir.'countries.sql');
1573 1573
 		}
1574 1574
 		$error = create_db::import_file($tmp_dir.'countries.sql');
1575 1575
 		return $error;
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 //		update_db::unzip($tmp_dir.'AptNav.zip');
1583 1583
 //		update_db::download('https://gitorious.org/fg/fgdata/raw/e81f8a15424a175a7b715f8f7eb8f4147b802a27:Navaids/awy.dat.gz',$tmp_dir.'awy.dat.gz');
1584 1584
 //		update_db::download('http://sourceforge.net/p/flightgear/fgdata/ci/next/tree/Navaids/awy.dat.gz?format=raw',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1585
-		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz',$tmp_dir.'awy.dat.gz','http://sourceforge.net');
1585
+		update_db::download('http://pkgs.fedoraproject.org/repo/extras/FlightGear-Atlas/awy.dat.gz/f530c9d1c4b31a288ba88dcc8224268b/awy.dat.gz', $tmp_dir.'awy.dat.gz', 'http://sourceforge.net');
1586 1586
 		update_db::gunzip($tmp_dir.'awy.dat.gz');
1587 1587
 		$error = update_db::waypoints($tmp_dir.'awy.dat');
1588 1588
 		return $error;
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
 			update_db::ivao_airlines($tmp_dir.'data/airlines.dat');
1603 1603
 			if ($globalDebug) echo "Copy airlines logos to airlines images directory...";
1604 1604
 			if (is_writable(dirname(__FILE__).'/../images/airlines')) {
1605
-				if (!$Common->xcopy($tmp_dir.'logos/',dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1605
+				if (!$Common->xcopy($tmp_dir.'logos/', dirname(__FILE__).'/../images/airlines/')) $error = "Failed to copy airlines logo.";
1606 1606
 			} else $error = "The directory ".dirname(__FILE__).'/../images/airlines'." must be writable";
1607 1607
 		} else $error = "File ".$tmp_dir.'ivao.zip'." doesn't exist. Download failed.";
1608 1608
 		if ($error != '') {
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
 		global $tmp_dir, $globalDebug;
1616 1616
 		$error = '';
1617 1617
 		if ($globalDebug) echo "Routes : Download...";
1618
-		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz',$tmp_dir.'StandingData.sqb.gz');
1618
+		update_db::download('http://www.virtualradarserver.co.uk/Files/StandingData.sqb.gz', $tmp_dir.'StandingData.sqb.gz');
1619 1619
 		if (file_exists($tmp_dir.'StandingData.sqb.gz')) {
1620 1620
 			if ($globalDebug) echo "Gunzip...";
1621 1621
 			update_db::gunzip($tmp_dir.'StandingData.sqb.gz');
@@ -1631,7 +1631,7 @@  discard block
 block discarded – undo
1631 1631
 		global $tmp_dir, $globalDebug;
1632 1632
 		$error = '';
1633 1633
 		if ($globalDebug) echo "Schedules Oneworld : Download...";
1634
-		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz',$tmp_dir.'oneworld.csv.gz');
1634
+		update_db::download('http://data.flightairmap.fr/data/schedules/oneworld.csv.gz', $tmp_dir.'oneworld.csv.gz');
1635 1635
 		if (file_exists($tmp_dir.'oneworld.csv.gz')) {
1636 1636
 			if ($globalDebug) echo "Gunzip...";
1637 1637
 			update_db::gunzip($tmp_dir.'oneworld.csv.gz');
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 		global $tmp_dir, $globalDebug;
1648 1648
 		$error = '';
1649 1649
 		if ($globalDebug) echo "Schedules Skyteam : Download...";
1650
-		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz',$tmp_dir.'skyteam.csv.gz');
1650
+		update_db::download('http://data.flightairmap.fr/data/schedules/skyteam.csv.gz', $tmp_dir.'skyteam.csv.gz');
1651 1651
 		if (file_exists($tmp_dir.'skyteam.csv.gz')) {
1652 1652
 			if ($globalDebug) echo "Gunzip...";
1653 1653
 			update_db::gunzip($tmp_dir.'skyteam.csv.gz');
@@ -1675,7 +1675,7 @@  discard block
 block discarded – undo
1675 1675
 */
1676 1676
 		if ($globalDebug) echo "Modes : Download...";
1677 1677
 //		update_db::download('http://planebase.biz/sqb.php?f=basestationall.zip',$tmp_dir.'basestation_latest.zip','http://planebase.biz/bstnsqb');
1678
-		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz',$tmp_dir.'BaseStation.sqb.gz');
1678
+		update_db::download('http://data.flightairmap.fr/data/BaseStation.sqb.gz', $tmp_dir.'BaseStation.sqb.gz');
1679 1679
 
1680 1680
 //		if (file_exists($tmp_dir.'basestation_latest.zip')) {
1681 1681
 		if (file_exists($tmp_dir.'BaseStation.sqb.gz')) {
@@ -1695,7 +1695,7 @@  discard block
 block discarded – undo
1695 1695
 	public static function update_ModeS_faa() {
1696 1696
 		global $tmp_dir, $globalDebug;
1697 1697
 		if ($globalDebug) echo "Modes FAA: Download...";
1698
-		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip',$tmp_dir.'ReleasableAircraft.zip');
1698
+		update_db::download('http://registry.faa.gov/database/ReleasableAircraft.zip', $tmp_dir.'ReleasableAircraft.zip');
1699 1699
 		if (file_exists($tmp_dir.'ReleasableAircraft.zip')) {
1700 1700
 			if ($globalDebug) echo "Unzip...";
1701 1701
 			update_db::unzip($tmp_dir.'ReleasableAircraft.zip');
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 	public static function update_ModeS_flarm() {
1712 1712
 		global $tmp_dir, $globalDebug;
1713 1713
 		if ($globalDebug) echo "Modes Flarmnet: Download...";
1714
-		update_db::download('http://flarmnet.org/files/data.fln',$tmp_dir.'data.fln');
1714
+		update_db::download('http://flarmnet.org/files/data.fln', $tmp_dir.'data.fln');
1715 1715
 		if (file_exists($tmp_dir.'data.fln')) {
1716 1716
 			if ($globalDebug) echo "Add to DB...";
1717 1717
 			$error = update_db::retrieve_modes_flarmnet($tmp_dir.'data.fln');
@@ -1725,7 +1725,7 @@  discard block
 block discarded – undo
1725 1725
 	public static function update_ModeS_ogn() {
1726 1726
 		global $tmp_dir, $globalDebug;
1727 1727
 		if ($globalDebug) echo "Modes OGN: Download...";
1728
-		update_db::download('http://ddb.glidernet.org/download/',$tmp_dir.'ogn.csv');
1728
+		update_db::download('http://ddb.glidernet.org/download/', $tmp_dir.'ogn.csv');
1729 1729
 		if (file_exists($tmp_dir.'ogn.csv')) {
1730 1730
 			if ($globalDebug) echo "Add to DB...";
1731 1731
 			$error = update_db::retrieve_modes_ogn($tmp_dir.'ogn.csv');
@@ -1740,201 +1740,201 @@  discard block
 block discarded – undo
1740 1740
 		global $tmp_dir, $globalDebug, $globalMasterSource;
1741 1741
 		
1742 1742
 		if ($globalDebug) echo "Owner France: Download...";
1743
-		update_db::download('http://antonakis.co.uk/registers/France.txt',$tmp_dir.'owner_f.csv');
1743
+		update_db::download('http://antonakis.co.uk/registers/France.txt', $tmp_dir.'owner_f.csv');
1744 1744
 		if (file_exists($tmp_dir.'owner_f.csv')) {
1745 1745
 			if ($globalDebug) echo "Add to DB...";
1746
-			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv','F');
1746
+			$error = update_db::retrieve_owner($tmp_dir.'owner_f.csv', 'F');
1747 1747
 		} else $error = "File ".$tmp_dir.'owner_f.csv'." doesn't exist. Download failed.";
1748 1748
 		if ($error != '') {
1749 1749
 			return $error;
1750 1750
 		} elseif ($globalDebug) echo "Done\n";
1751 1751
 		
1752 1752
 		if ($globalDebug) echo "Owner Ireland: Download...";
1753
-		update_db::download('http://antonakis.co.uk/registers/Ireland.txt',$tmp_dir.'owner_ei.csv');
1753
+		update_db::download('http://antonakis.co.uk/registers/Ireland.txt', $tmp_dir.'owner_ei.csv');
1754 1754
 		if (file_exists($tmp_dir.'owner_ei.csv')) {
1755 1755
 			if ($globalDebug) echo "Add to DB...";
1756
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv','EI');
1756
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ei.csv', 'EI');
1757 1757
 		} else $error = "File ".$tmp_dir.'owner_ei.csv'." doesn't exist. Download failed.";
1758 1758
 		if ($error != '') {
1759 1759
 			return $error;
1760 1760
 		} elseif ($globalDebug) echo "Done\n";
1761 1761
 		if ($globalDebug) echo "Owner Switzerland: Download...";
1762
-		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt',$tmp_dir.'owner_hb.csv');
1762
+		update_db::download('http://antonakis.co.uk/registers/Switzerland.txt', $tmp_dir.'owner_hb.csv');
1763 1763
 		if (file_exists($tmp_dir.'owner_hb.csv')) {
1764 1764
 			if ($globalDebug) echo "Add to DB...";
1765
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv','HB');
1765
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hb.csv', 'HB');
1766 1766
 		} else $error = "File ".$tmp_dir.'owner_hb.csv'." doesn't exist. Download failed.";
1767 1767
 		if ($error != '') {
1768 1768
 			return $error;
1769 1769
 		} elseif ($globalDebug) echo "Done\n";
1770 1770
 		if ($globalDebug) echo "Owner Czech Republic: Download...";
1771
-		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt',$tmp_dir.'owner_ok.csv');
1771
+		update_db::download('http://antonakis.co.uk/registers/CzechRepublic.txt', $tmp_dir.'owner_ok.csv');
1772 1772
 		if (file_exists($tmp_dir.'owner_ok.csv')) {
1773 1773
 			if ($globalDebug) echo "Add to DB...";
1774
-			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv','OK');
1774
+			$error = update_db::retrieve_owner($tmp_dir.'owner_ok.csv', 'OK');
1775 1775
 		} else $error = "File ".$tmp_dir.'owner_ok.csv'." doesn't exist. Download failed.";
1776 1776
 		if ($error != '') {
1777 1777
 			return $error;
1778 1778
 		} elseif ($globalDebug) echo "Done\n";
1779 1779
 		if ($globalDebug) echo "Owner Australia: Download...";
1780
-		update_db::download('http://antonakis.co.uk/registers/Australia.txt',$tmp_dir.'owner_vh.csv');
1780
+		update_db::download('http://antonakis.co.uk/registers/Australia.txt', $tmp_dir.'owner_vh.csv');
1781 1781
 		if (file_exists($tmp_dir.'owner_vh.csv')) {
1782 1782
 			if ($globalDebug) echo "Add to DB...";
1783
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv','VH');
1783
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vh.csv', 'VH');
1784 1784
 		} else $error = "File ".$tmp_dir.'owner_vh.csv'." doesn't exist. Download failed.";
1785 1785
 		if ($error != '') {
1786 1786
 			return $error;
1787 1787
 		} elseif ($globalDebug) echo "Done\n";
1788 1788
 		if ($globalDebug) echo "Owner Austria: Download...";
1789
-		update_db::download('http://antonakis.co.uk/registers/Austria.txt',$tmp_dir.'owner_oe.csv');
1789
+		update_db::download('http://antonakis.co.uk/registers/Austria.txt', $tmp_dir.'owner_oe.csv');
1790 1790
 		if (file_exists($tmp_dir.'owner_oe.csv')) {
1791 1791
 			if ($globalDebug) echo "Add to DB...";
1792
-			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv','OE');
1792
+			$error = update_db::retrieve_owner($tmp_dir.'owner_oe.csv', 'OE');
1793 1793
 		} else $error = "File ".$tmp_dir.'owner_oe.csv'." doesn't exist. Download failed.";
1794 1794
 		if ($error != '') {
1795 1795
 			return $error;
1796 1796
 		} elseif ($globalDebug) echo "Done\n";
1797 1797
 		if ($globalDebug) echo "Owner Chile: Download...";
1798
-		update_db::download('http://antonakis.co.uk/registers/Chile.txt',$tmp_dir.'owner_cc.csv');
1798
+		update_db::download('http://antonakis.co.uk/registers/Chile.txt', $tmp_dir.'owner_cc.csv');
1799 1799
 		if (file_exists($tmp_dir.'owner_cc.csv')) {
1800 1800
 			if ($globalDebug) echo "Add to DB...";
1801
-			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv','CC');
1801
+			$error = update_db::retrieve_owner($tmp_dir.'owner_cc.csv', 'CC');
1802 1802
 		} else $error = "File ".$tmp_dir.'owner_cc.csv'." doesn't exist. Download failed.";
1803 1803
 		if ($error != '') {
1804 1804
 			return $error;
1805 1805
 		} elseif ($globalDebug) echo "Done\n";
1806 1806
 		if ($globalDebug) echo "Owner Colombia: Download...";
1807
-		update_db::download('http://antonakis.co.uk/registers/Colombia.txt',$tmp_dir.'owner_hj.csv');
1807
+		update_db::download('http://antonakis.co.uk/registers/Colombia.txt', $tmp_dir.'owner_hj.csv');
1808 1808
 		if (file_exists($tmp_dir.'owner_hj.csv')) {
1809 1809
 			if ($globalDebug) echo "Add to DB...";
1810
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv','HJ');
1810
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hj.csv', 'HJ');
1811 1811
 		} else $error = "File ".$tmp_dir.'owner_hj.csv'." doesn't exist. Download failed.";
1812 1812
 		if ($error != '') {
1813 1813
 			return $error;
1814 1814
 		} elseif ($globalDebug) echo "Done\n";
1815 1815
 		if ($globalDebug) echo "Owner Bosnia Herzegobina: Download...";
1816
-		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt',$tmp_dir.'owner_e7.csv');
1816
+		update_db::download('http://antonakis.co.uk/registers/BosniaHerzegovina.txt', $tmp_dir.'owner_e7.csv');
1817 1817
 		if (file_exists($tmp_dir.'owner_e7.csv')) {
1818 1818
 			if ($globalDebug) echo "Add to DB...";
1819
-			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv','E7');
1819
+			$error = update_db::retrieve_owner($tmp_dir.'owner_e7.csv', 'E7');
1820 1820
 		} else $error = "File ".$tmp_dir.'owner_e7.csv'." doesn't exist. Download failed.";
1821 1821
 		if ($error != '') {
1822 1822
 			return $error;
1823 1823
 		} elseif ($globalDebug) echo "Done\n";
1824 1824
 		if ($globalDebug) echo "Owner Brazil: Download...";
1825
-		update_db::download('http://antonakis.co.uk/registers/Brazil.txt',$tmp_dir.'owner_pp.csv');
1825
+		update_db::download('http://antonakis.co.uk/registers/Brazil.txt', $tmp_dir.'owner_pp.csv');
1826 1826
 		if (file_exists($tmp_dir.'owner_pp.csv')) {
1827 1827
 			if ($globalDebug) echo "Add to DB...";
1828
-			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv','PP');
1828
+			$error = update_db::retrieve_owner($tmp_dir.'owner_pp.csv', 'PP');
1829 1829
 		} else $error = "File ".$tmp_dir.'owner_pp.csv'." doesn't exist. Download failed.";
1830 1830
 		if ($error != '') {
1831 1831
 			return $error;
1832 1832
 		} elseif ($globalDebug) echo "Done\n";
1833 1833
 		if ($globalDebug) echo "Owner Cayman Islands: Download...";
1834
-		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt',$tmp_dir.'owner_vp.csv');
1834
+		update_db::download('http://antonakis.co.uk/registers/CaymanIslands.txt', $tmp_dir.'owner_vp.csv');
1835 1835
 		if (file_exists($tmp_dir.'owner_vp.csv')) {
1836 1836
 			if ($globalDebug) echo "Add to DB...";
1837
-			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv','VP');
1837
+			$error = update_db::retrieve_owner($tmp_dir.'owner_vp.csv', 'VP');
1838 1838
 		} else $error = "File ".$tmp_dir.'owner_vp.csv'." doesn't exist. Download failed.";
1839 1839
 		if ($error != '') {
1840 1840
 			return $error;
1841 1841
 		} elseif ($globalDebug) echo "Done\n";
1842 1842
 		if ($globalDebug) echo "Owner Croatia: Download...";
1843
-		update_db::download('http://antonakis.co.uk/registers/Croatia.txt',$tmp_dir.'owner_9a.csv');
1843
+		update_db::download('http://antonakis.co.uk/registers/Croatia.txt', $tmp_dir.'owner_9a.csv');
1844 1844
 		if (file_exists($tmp_dir.'owner_9a.csv')) {
1845 1845
 			if ($globalDebug) echo "Add to DB...";
1846
-			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv','9A');
1846
+			$error = update_db::retrieve_owner($tmp_dir.'owner_9a.csv', '9A');
1847 1847
 		} else $error = "File ".$tmp_dir.'owner_9a.csv'." doesn't exist. Download failed.";
1848 1848
 		if ($error != '') {
1849 1849
 			return $error;
1850 1850
 		} elseif ($globalDebug) echo "Done\n";
1851 1851
 		if ($globalDebug) echo "Owner Luxembourg: Download...";
1852
-		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt',$tmp_dir.'owner_lx.csv');
1852
+		update_db::download('http://antonakis.co.uk/registers/Luxembourg.txt', $tmp_dir.'owner_lx.csv');
1853 1853
 		if (file_exists($tmp_dir.'owner_lx.csv')) {
1854 1854
 			if ($globalDebug) echo "Add to DB...";
1855
-			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv','LX');
1855
+			$error = update_db::retrieve_owner($tmp_dir.'owner_lx.csv', 'LX');
1856 1856
 		} else $error = "File ".$tmp_dir.'owner_lx.csv'." doesn't exist. Download failed.";
1857 1857
 		if ($error != '') {
1858 1858
 			return $error;
1859 1859
 		} elseif ($globalDebug) echo "Done\n";
1860 1860
 		if ($globalDebug) echo "Owner Maldives: Download...";
1861
-		update_db::download('http://antonakis.co.uk/registers/Maldives.txt',$tmp_dir.'owner_8q.csv');
1861
+		update_db::download('http://antonakis.co.uk/registers/Maldives.txt', $tmp_dir.'owner_8q.csv');
1862 1862
 		if (file_exists($tmp_dir.'owner_8q.csv')) {
1863 1863
 			if ($globalDebug) echo "Add to DB...";
1864
-			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv','8Q');
1864
+			$error = update_db::retrieve_owner($tmp_dir.'owner_8q.csv', '8Q');
1865 1865
 		} else $error = "File ".$tmp_dir.'owner_8q.csv'." doesn't exist. Download failed.";
1866 1866
 		if ($error != '') {
1867 1867
 			return $error;
1868 1868
 		} elseif ($globalDebug) echo "Done\n";
1869 1869
 		if ($globalDebug) echo "Owner New Zealand: Download...";
1870
-		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt',$tmp_dir.'owner_zk.csv');
1870
+		update_db::download('http://antonakis.co.uk/registers/NewZealand.txt', $tmp_dir.'owner_zk.csv');
1871 1871
 		if (file_exists($tmp_dir.'owner_zk.csv')) {
1872 1872
 			if ($globalDebug) echo "Add to DB...";
1873
-			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv','ZK');
1873
+			$error = update_db::retrieve_owner($tmp_dir.'owner_zk.csv', 'ZK');
1874 1874
 		} else $error = "File ".$tmp_dir.'owner_zk.csv'." doesn't exist. Download failed.";
1875 1875
 		if ($error != '') {
1876 1876
 			return $error;
1877 1877
 		} elseif ($globalDebug) echo "Done\n";
1878 1878
 		if ($globalDebug) echo "Owner Papua New Guinea: Download...";
1879
-		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt',$tmp_dir.'owner_p2.csv');
1879
+		update_db::download('http://antonakis.co.uk/registers/PapuaNewGuinea.txt', $tmp_dir.'owner_p2.csv');
1880 1880
 		if (file_exists($tmp_dir.'owner_p2.csv')) {
1881 1881
 			if ($globalDebug) echo "Add to DB...";
1882
-			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv','P2');
1882
+			$error = update_db::retrieve_owner($tmp_dir.'owner_p2.csv', 'P2');
1883 1883
 		} else $error = "File ".$tmp_dir.'owner_p2.csv'." doesn't exist. Download failed.";
1884 1884
 		if ($error != '') {
1885 1885
 			return $error;
1886 1886
 		} elseif ($globalDebug) echo "Done\n";
1887 1887
 		if ($globalDebug) echo "Owner Slovakia: Download...";
1888
-		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt',$tmp_dir.'owner_om.csv');
1888
+		update_db::download('http://antonakis.co.uk/registers/Slovakia.txt', $tmp_dir.'owner_om.csv');
1889 1889
 		if (file_exists($tmp_dir.'owner_om.csv')) {
1890 1890
 			if ($globalDebug) echo "Add to DB...";
1891
-			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv','OM');
1891
+			$error = update_db::retrieve_owner($tmp_dir.'owner_om.csv', 'OM');
1892 1892
 		} else $error = "File ".$tmp_dir.'owner_om.csv'." doesn't exist. Download failed.";
1893 1893
 		if ($error != '') {
1894 1894
 			return $error;
1895 1895
 		} elseif ($globalDebug) echo "Done\n";
1896 1896
 		if ($globalDebug) echo "Owner Ecuador: Download...";
1897
-		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt',$tmp_dir.'owner_hc.csv');
1897
+		update_db::download('http://antonakis.co.uk/registers/Ecuador.txt', $tmp_dir.'owner_hc.csv');
1898 1898
 		if (file_exists($tmp_dir.'owner_hc.csv')) {
1899 1899
 			if ($globalDebug) echo "Add to DB...";
1900
-			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv','HC');
1900
+			$error = update_db::retrieve_owner($tmp_dir.'owner_hc.csv', 'HC');
1901 1901
 		} else $error = "File ".$tmp_dir.'owner_hc.csv'." doesn't exist. Download failed.";
1902 1902
 		if ($error != '') {
1903 1903
 			return $error;
1904 1904
 		} elseif ($globalDebug) echo "Done\n";
1905 1905
 		if ($globalDebug) echo "Owner Iceland: Download...";
1906
-		update_db::download('http://antonakis.co.uk/registers/Iceland.txt',$tmp_dir.'owner_tf.csv');
1906
+		update_db::download('http://antonakis.co.uk/registers/Iceland.txt', $tmp_dir.'owner_tf.csv');
1907 1907
 		if (file_exists($tmp_dir.'owner_tf.csv')) {
1908 1908
 			if ($globalDebug) echo "Add to DB...";
1909
-			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv','TF');
1909
+			$error = update_db::retrieve_owner($tmp_dir.'owner_tf.csv', 'TF');
1910 1910
 		} else $error = "File ".$tmp_dir.'owner_tf.csv'." doesn't exist. Download failed.";
1911 1911
 		if ($error != '') {
1912 1912
 			return $error;
1913 1913
 		} elseif ($globalDebug) echo "Done\n";
1914 1914
 		if ($globalDebug) echo "Owner Isle of Man: Download...";
1915
-		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt',$tmp_dir.'owner_m.csv');
1915
+		update_db::download('http://antonakis.co.uk/registers/IsleOfMan.txt', $tmp_dir.'owner_m.csv');
1916 1916
 		if (file_exists($tmp_dir.'owner_m.csv')) {
1917 1917
 			if ($globalDebug) echo "Add to DB...";
1918
-			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv','M');
1918
+			$error = update_db::retrieve_owner($tmp_dir.'owner_m.csv', 'M');
1919 1919
 		} else $error = "File ".$tmp_dir.'owner_m.csv'." doesn't exist. Download failed.";
1920 1920
 		if ($error != '') {
1921 1921
 			return $error;
1922 1922
 		} elseif ($globalDebug) echo "Done\n";
1923 1923
 		if ($globalMasterSource) {
1924 1924
 			if ($globalDebug) echo "ModeS Netherlands: Download...";
1925
-			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt',$tmp_dir.'owner_ph.csv');
1925
+			update_db::download('http://antonakis.co.uk/registers/Netherlands.txt', $tmp_dir.'owner_ph.csv');
1926 1926
 			if (file_exists($tmp_dir.'owner_ph.csv')) {
1927 1927
 				if ($globalDebug) echo "Add to DB...";
1928
-				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv','PH');
1928
+				$error = update_db::retrieve_owner($tmp_dir.'owner_ph.csv', 'PH');
1929 1929
 			} else $error = "File ".$tmp_dir.'owner_ph.csv'." doesn't exist. Download failed.";
1930 1930
 			if ($error != '') {
1931 1931
 				return $error;
1932 1932
 			} elseif ($globalDebug) echo "Done\n";
1933 1933
 			if ($globalDebug) echo "ModeS Denmark: Download...";
1934
-			update_db::download('http://antonakis.co.uk/registers/Denmark.txt',$tmp_dir.'owner_oy.csv');
1934
+			update_db::download('http://antonakis.co.uk/registers/Denmark.txt', $tmp_dir.'owner_oy.csv');
1935 1935
 			if (file_exists($tmp_dir.'owner_oy.csv')) {
1936 1936
 				if ($globalDebug) echo "Add to DB...";
1937
-				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv','OY');
1937
+				$error = update_db::retrieve_owner($tmp_dir.'owner_oy.csv', 'OY');
1938 1938
 			} else $error = "File ".$tmp_dir.'owner_oy.csv'." doesn't exist. Download failed.";
1939 1939
 			if ($error != '') {
1940 1940
 				return $error;
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
 		global $tmp_dir, $globalDebug;
1948 1948
 		$error = '';
1949 1949
 		if ($globalDebug) echo "Translation : Download...";
1950
-		update_db::download('http://www.acarsd.org/download/translation.php',$tmp_dir.'translation.zip');
1950
+		update_db::download('http://www.acarsd.org/download/translation.php', $tmp_dir.'translation.zip');
1951 1951
 		if (file_exists($tmp_dir.'translation.zip')) {
1952 1952
 			if ($globalDebug) echo "Unzip...";
1953 1953
 			update_db::unzip($tmp_dir.'translation.zip');
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
 	public static function update_translation_fam() {
1964 1964
 		global $tmp_dir, $globalDebug;
1965 1965
 		if ($globalDebug) echo "Translation from FlightAirMap website : Download...";
1966
-		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz',$tmp_dir.'translation.tsv.gz');
1966
+		update_db::download('http://data.flightairmap.fr/data/translation.tsv.gz', $tmp_dir.'translation.tsv.gz');
1967 1967
 		if (file_exists($tmp_dir.'translation.tsv.gz')) {
1968 1968
 			if ($globalDebug) echo "Gunzip...";
1969 1969
 			update_db::gunzip($tmp_dir.'translation.tsv.gz');
@@ -1978,7 +1978,7 @@  discard block
 block discarded – undo
1978 1978
 	public static function update_ModeS_fam() {
1979 1979
 		global $tmp_dir, $globalDebug;
1980 1980
 		if ($globalDebug) echo "ModeS from FlightAirMap website : Download...";
1981
-		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz',$tmp_dir.'modes.tsv.gz');
1981
+		update_db::download('http://data.flightairmap.fr/data/modes.tsv.gz', $tmp_dir.'modes.tsv.gz');
1982 1982
 		if (file_exists($tmp_dir.'modes.tsv.gz')) {
1983 1983
 			if ($globalDebug) echo "Gunzip...";
1984 1984
 			update_db::gunzip($tmp_dir.'modes.tsv.gz');
@@ -1994,9 +1994,9 @@  discard block
 block discarded – undo
1994 1994
 		global $tmp_dir, $globalDebug, $globalOwner;
1995 1995
 		if ($globalDebug) echo "owner from FlightAirMap website : Download...";
1996 1996
 		if ($globalOwner === TRUE) {
1997
-			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz',$tmp_dir.'owners.tsv.gz');
1997
+			update_db::download('http://data.flightairmap.fr/data/owners_all.tsv.gz', $tmp_dir.'owners.tsv.gz');
1998 1998
 		} else {
1999
-			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz',$tmp_dir.'owners.tsv.gz');
1999
+			update_db::download('http://data.flightairmap.fr/data/owners.tsv.gz', $tmp_dir.'owners.tsv.gz');
2000 2000
 		}
2001 2001
 		if (file_exists($tmp_dir.'owners.tsv.gz')) {
2002 2002
 			if ($globalDebug) echo "Gunzip...";
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 	public static function update_routes_fam() {
2013 2013
 		global $tmp_dir, $globalDebug;
2014 2014
 		if ($globalDebug) echo "Routes from FlightAirMap website : Download...";
2015
-		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz',$tmp_dir.'routes.tsv.gz');
2015
+		update_db::download('http://data.flightairmap.fr/data/routes.tsv.gz', $tmp_dir.'routes.tsv.gz');
2016 2016
 		if (file_exists($tmp_dir.'routes.tsv.gz')) {
2017 2017
 			if ($globalDebug) echo "Gunzip...";
2018 2018
 			update_db::gunzip($tmp_dir.'routes.tsv.gz');
@@ -2026,13 +2026,13 @@  discard block
 block discarded – undo
2026 2026
 	}
2027 2027
 	public static function update_marine_identity_fam() {
2028 2028
 		global $tmp_dir, $globalDebug;
2029
-		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5',$tmp_dir.'marine_identity.tsv.gz.md5');
2029
+		update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz.md5', $tmp_dir.'marine_identity.tsv.gz.md5');
2030 2030
 		if (file_exists($tmp_dir.'marine_identity.tsv.gz.md5')) {
2031
-			$marine_identity_md5_file = explode(' ',file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2031
+			$marine_identity_md5_file = explode(' ', file_get_contents($tmp_dir.'marine_identity.tsv.gz.md5'));
2032 2032
 			$marine_identity_md5 = $marine_identity_md5_file[0];
2033 2033
 			if (!update_db::check_marine_identity_version($marine_identity_md5)) {
2034 2034
 				if ($globalDebug) echo "Marine identity from FlightAirMap website : Download...";
2035
-				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz',$tmp_dir.'marine_identity.tsv.gz');
2035
+				update_db::download('http://data.flightairmap.fr/data/marine_identity.tsv.gz', $tmp_dir.'marine_identity.tsv.gz');
2036 2036
 				if (file_exists($tmp_dir.'marine_identity.tsv.gz')) {
2037 2037
 					if ($globalDebug) echo "Gunzip...";
2038 2038
 					update_db::gunzip($tmp_dir.'marine_identity.tsv.gz');
@@ -2052,7 +2052,7 @@  discard block
 block discarded – undo
2052 2052
 	public static function update_banned_fam() {
2053 2053
 		global $tmp_dir, $globalDebug;
2054 2054
 		if ($globalDebug) echo "Banned airlines in Europe from FlightAirMap website : Download...";
2055
-		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv',$tmp_dir.'ban_eu.csv');
2055
+		update_db::download('http://data.flightairmap.fr/data/ban-eu.csv', $tmp_dir.'ban_eu.csv');
2056 2056
 		if (file_exists($tmp_dir.'ban_eu.csv')) {
2057 2057
 			//if ($globalDebug) echo "Gunzip...";
2058 2058
 			//update_db::gunzip($tmp_dir.'ban_ue.csv');
@@ -2071,18 +2071,18 @@  discard block
 block discarded – undo
2071 2071
 		$error = '';
2072 2072
 		if ($globalDebug) echo "Airspace from FlightAirMap website : Download...";
2073 2073
 		if ($globalDBdriver == 'mysql') {
2074
-			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2074
+			update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2075 2075
 		} else {
2076
-			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5',$tmp_dir.'airspace.sql.gz.md5');
2076
+			update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz.md5', $tmp_dir.'airspace.sql.gz.md5');
2077 2077
 		}
2078 2078
 		if (file_exists($tmp_dir.'airspace.sql.gz.md5')) {
2079
-			$airspace_md5_file = explode(' ',file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2079
+			$airspace_md5_file = explode(' ', file_get_contents($tmp_dir.'airspace.sql.gz.md5'));
2080 2080
 			$airspace_md5 = $airspace_md5_file[0];
2081 2081
 			if (!update_db::check_airspace_version($airspace_md5)) {
2082 2082
 				if ($globalDBdriver == 'mysql') {
2083
-					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz',$tmp_dir.'airspace.sql.gz');
2083
+					update_db::download('http://data.flightairmap.fr/data/airspace_mysql.sql.gz', $tmp_dir.'airspace.sql.gz');
2084 2084
 				} else {
2085
-					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz',$tmp_dir.'airspace.sql.gz');
2085
+					update_db::download('http://data.flightairmap.fr/data/airspace_pgsql.sql.gz', $tmp_dir.'airspace.sql.gz');
2086 2086
 				}
2087 2087
 				if (file_exists($tmp_dir.'airspace.sql.gz')) {
2088 2088
 					if ($globalDebug) echo "Gunzip...";
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
 						try {
2095 2095
 							$sth = $Connection->db->prepare($query);
2096 2096
     	    	    					$sth->execute();
2097
-			            		} catch(PDOException $e) {
2097
+			            		} catch (PDOException $e) {
2098 2098
 							return "error : ".$e->getMessage();
2099 2099
 		            			}
2100 2100
 		    			}
@@ -2112,15 +2112,15 @@  discard block
 block discarded – undo
2112 2112
 	public static function update_tle() {
2113 2113
 		global $tmp_dir, $globalDebug;
2114 2114
 		if ($globalDebug) echo "Download TLE : Download...";
2115
-		$alltle = array('stations.txt','gps-ops.txt','glo-ops.txt','galileo.txt','weather.txt','noaa.txt','goes.txt','resource.txt','dmc.txt','tdrss.txt','geo.txt','intelsat.txt','gorizont.txt',
2116
-		'raduga.txt','molniya.txt','iridium.txt','orbcomm.txt','globalstar.txt','amateur.txt','x-comm.txt','other-comm.txt','sbas.txt','nnss.txt','musson.txt','science.txt','geodetic.txt',
2117
-		'engineering.txt','education.txt','military.txt','radar.txt','cubesat.txt','other.txt','tle-new.txt');
2115
+		$alltle = array('stations.txt', 'gps-ops.txt', 'glo-ops.txt', 'galileo.txt', 'weather.txt', 'noaa.txt', 'goes.txt', 'resource.txt', 'dmc.txt', 'tdrss.txt', 'geo.txt', 'intelsat.txt', 'gorizont.txt',
2116
+		'raduga.txt', 'molniya.txt', 'iridium.txt', 'orbcomm.txt', 'globalstar.txt', 'amateur.txt', 'x-comm.txt', 'other-comm.txt', 'sbas.txt', 'nnss.txt', 'musson.txt', 'science.txt', 'geodetic.txt',
2117
+		'engineering.txt', 'education.txt', 'military.txt', 'radar.txt', 'cubesat.txt', 'other.txt', 'tle-new.txt');
2118 2118
 		foreach ($alltle as $filename) {
2119 2119
 			if ($globalDebug) echo "downloading ".$filename.'...';
2120
-			update_db::download('http://celestrak.com/NORAD/elements/'.$filename,$tmp_dir.$filename);
2120
+			update_db::download('http://celestrak.com/NORAD/elements/'.$filename, $tmp_dir.$filename);
2121 2121
 			if (file_exists($tmp_dir.$filename)) {
2122 2122
 				if ($globalDebug) echo "Add to DB ".$filename."...";
2123
-				$error = update_db::tle($tmp_dir.$filename,str_replace('.txt','',$filename));
2123
+				$error = update_db::tle($tmp_dir.$filename, str_replace('.txt', '', $filename));
2124 2124
 			} else $error = "File ".$tmp_dir.$filename." doesn't exist. Download failed.";
2125 2125
 			if ($error != '') {
2126 2126
 				echo $error."\n";
@@ -2133,32 +2133,32 @@  discard block
 block discarded – undo
2133 2133
 		global $tmp_dir, $globalDebug;
2134 2134
 		$error = '';
2135 2135
 		if ($globalDebug) echo "Models from FlightAirMap website : Download...";
2136
-		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',$tmp_dir.'models.md5sum');
2136
+		update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', $tmp_dir.'models.md5sum');
2137 2137
 		if (file_exists($tmp_dir.'models.md5sum')) {
2138 2138
 			if ($globalDebug) echo "Check files...\n";
2139 2139
 			$newmodelsdb = array();
2140
-			if (($handle = fopen($tmp_dir.'models.md5sum','r')) !== FALSE) {
2141
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2140
+			if (($handle = fopen($tmp_dir.'models.md5sum', 'r')) !== FALSE) {
2141
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2142 2142
 					$model = trim($row[2]);
2143 2143
 					$newmodelsdb[$model] = trim($row[0]);
2144 2144
 				}
2145 2145
 			}
2146 2146
 			$modelsdb = array();
2147 2147
 			if (file_exists(dirname(__FILE__).'/../models/models.md5sum')) {
2148
-				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum','r')) !== FALSE) {
2149
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2148
+				if (($handle = fopen(dirname(__FILE__).'/../models/models.md5sum', 'r')) !== FALSE) {
2149
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2150 2150
 						$model = trim($row[2]);
2151 2151
 						$modelsdb[$model] = trim($row[0]);
2152 2152
 					}
2153 2153
 				}
2154 2154
 			}
2155
-			$diff = array_diff($newmodelsdb,$modelsdb);
2155
+			$diff = array_diff($newmodelsdb, $modelsdb);
2156 2156
 			foreach ($diff as $key => $value) {
2157 2157
 				if ($globalDebug) echo 'Downloading model '.$key.' ...'."\n";
2158
-				update_db::download('http://data.flightairmap.fr/data/models/'.$key,dirname(__FILE__).'/../models/'.$key);
2158
+				update_db::download('http://data.flightairmap.fr/data/models/'.$key, dirname(__FILE__).'/../models/'.$key);
2159 2159
 				
2160 2160
 			}
2161
-			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum',dirname(__FILE__).'/../models/models.md5sum');
2161
+			update_db::download('http://data.flightairmap.fr/data/models/models.md5sum', dirname(__FILE__).'/../models/models.md5sum');
2162 2162
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2163 2163
 		if ($error != '') {
2164 2164
 			return $error;
@@ -2170,32 +2170,32 @@  discard block
 block discarded – undo
2170 2170
 		global $tmp_dir, $globalDebug;
2171 2171
 		$error = '';
2172 2172
 		if ($globalDebug) echo "Space models from FlightAirMap website : Download...";
2173
-		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',$tmp_dir.'space_models.md5sum');
2173
+		update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', $tmp_dir.'space_models.md5sum');
2174 2174
 		if (file_exists($tmp_dir.'space_models.md5sum')) {
2175 2175
 			if ($globalDebug) echo "Check files...\n";
2176 2176
 			$newmodelsdb = array();
2177
-			if (($handle = fopen($tmp_dir.'space_models.md5sum','r')) !== FALSE) {
2178
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2177
+			if (($handle = fopen($tmp_dir.'space_models.md5sum', 'r')) !== FALSE) {
2178
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2179 2179
 					$model = trim($row[2]);
2180 2180
 					$newmodelsdb[$model] = trim($row[0]);
2181 2181
 				}
2182 2182
 			}
2183 2183
 			$modelsdb = array();
2184 2184
 			if (file_exists(dirname(__FILE__).'/../models/space/space_models.md5sum')) {
2185
-				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum','r')) !== FALSE) {
2186
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2185
+				if (($handle = fopen(dirname(__FILE__).'/../models/space/space_models.md5sum', 'r')) !== FALSE) {
2186
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2187 2187
 						$model = trim($row[2]);
2188 2188
 						$modelsdb[$model] = trim($row[0]);
2189 2189
 					}
2190 2190
 				}
2191 2191
 			}
2192
-			$diff = array_diff($newmodelsdb,$modelsdb);
2192
+			$diff = array_diff($newmodelsdb, $modelsdb);
2193 2193
 			foreach ($diff as $key => $value) {
2194 2194
 				if ($globalDebug) echo 'Downloading space model '.$key.' ...'."\n";
2195
-				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key,dirname(__FILE__).'/../models/space/'.$key);
2195
+				update_db::download('http://data.flightairmap.fr/data/models/space/'.$key, dirname(__FILE__).'/../models/space/'.$key);
2196 2196
 				
2197 2197
 			}
2198
-			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum',dirname(__FILE__).'/../models/space/space_models.md5sum');
2198
+			update_db::download('http://data.flightairmap.fr/data/models/space/space_models.md5sum', dirname(__FILE__).'/../models/space/space_models.md5sum');
2199 2199
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2200 2200
 		if ($error != '') {
2201 2201
 			return $error;
@@ -2207,32 +2207,32 @@  discard block
 block discarded – undo
2207 2207
 		global $tmp_dir, $globalDebug;
2208 2208
 		$error = '';
2209 2209
 		if ($globalDebug) echo "Vehicules models from FlightAirMap website : Download...";
2210
-		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',$tmp_dir.'vehicules_models.md5sum');
2210
+		update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', $tmp_dir.'vehicules_models.md5sum');
2211 2211
 		if (file_exists($tmp_dir.'vehicules_models.md5sum')) {
2212 2212
 			if ($globalDebug) echo "Check files...\n";
2213 2213
 			$newmodelsdb = array();
2214
-			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum','r')) !== FALSE) {
2215
-				while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2214
+			if (($handle = fopen($tmp_dir.'vehicules_models.md5sum', 'r')) !== FALSE) {
2215
+				while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2216 2216
 					$model = trim($row[2]);
2217 2217
 					$newmodelsdb[$model] = trim($row[0]);
2218 2218
 				}
2219 2219
 			}
2220 2220
 			$modelsdb = array();
2221 2221
 			if (file_exists(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum')) {
2222
-				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum','r')) !== FALSE) {
2223
-					while (($row = fgetcsv($handle,1000," ")) !== FALSE) {
2222
+				if (($handle = fopen(dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum', 'r')) !== FALSE) {
2223
+					while (($row = fgetcsv($handle, 1000, " ")) !== FALSE) {
2224 2224
 						$model = trim($row[2]);
2225 2225
 						$modelsdb[$model] = trim($row[0]);
2226 2226
 					}
2227 2227
 				}
2228 2228
 			}
2229
-			$diff = array_diff($newmodelsdb,$modelsdb);
2229
+			$diff = array_diff($newmodelsdb, $modelsdb);
2230 2230
 			foreach ($diff as $key => $value) {
2231 2231
 				if ($globalDebug) echo 'Downloading vehicules model '.$key.' ...'."\n";
2232
-				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key,dirname(__FILE__).'/../models/vehicules/'.$key);
2232
+				update_db::download('http://data.flightairmap.fr/data/models/vehicules/'.$key, dirname(__FILE__).'/../models/vehicules/'.$key);
2233 2233
 				
2234 2234
 			}
2235
-			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum',dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2235
+			update_db::download('http://data.flightairmap.fr/data/models/vehicules/vehicules_models.md5sum', dirname(__FILE__).'/../models/vehicules/vehicules_models.md5sum');
2236 2236
 		} else $error = "File ".$tmp_dir.'models.md5sum'." doesn't exist. Download failed.";
2237 2237
 		if ($error != '') {
2238 2238
 			return $error;
@@ -2255,8 +2255,8 @@  discard block
 block discarded – undo
2255 2255
 		*/
2256 2256
 		if (file_exists($tmp_dir.'aircrafts.html')) {
2257 2257
 		    //var_dump(file_get_html($tmp_dir.'aircrafts.html'));
2258
-		    $fh = fopen($tmp_dir.'aircrafts.html',"r");
2259
-		    $result = fread($fh,100000000);
2258
+		    $fh = fopen($tmp_dir.'aircrafts.html', "r");
2259
+		    $result = fread($fh, 100000000);
2260 2260
 		    //echo $result;
2261 2261
 		    //var_dump(str_get_html($result));
2262 2262
 		    //print_r(self::table2array($result));
@@ -2274,23 +2274,23 @@  discard block
 block discarded – undo
2274 2274
 			$Connection = new Connection();
2275 2275
 			$sth = $Connection->db->prepare($query);
2276 2276
                         $sth->execute();
2277
-                } catch(PDOException $e) {
2277
+                } catch (PDOException $e) {
2278 2278
                         return "error : ".$e->getMessage();
2279 2279
                 }
2280 2280
 
2281 2281
 		$error = '';
2282 2282
 		if ($globalDebug) echo "Notam : Download...";
2283
-		update_db::download($globalNOTAMSource,$tmp_dir.'notam.rss');
2283
+		update_db::download($globalNOTAMSource, $tmp_dir.'notam.rss');
2284 2284
 		if (file_exists($tmp_dir.'notam.rss')) {
2285
-			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')),true);
2285
+			$notams = json_decode(json_encode(simplexml_load_file($tmp_dir.'notam.rss')), true);
2286 2286
 			foreach ($notams['channel']['item'] as $notam) {
2287
-				$title = explode(':',$notam['title']);
2287
+				$title = explode(':', $notam['title']);
2288 2288
 				$data['ref'] = trim($title[0]);
2289 2289
 				unset($title[0]);
2290
-				$data['title'] = trim(implode(':',$title));
2291
-				$description = strip_tags($notam['description'],'<pre>');
2292
-				preg_match(':^(.*?)<pre>:',$description,$match);
2293
-				$q = explode('/',$match[1]);
2290
+				$data['title'] = trim(implode(':', $title));
2291
+				$description = strip_tags($notam['description'], '<pre>');
2292
+				preg_match(':^(.*?)<pre>:', $description, $match);
2293
+				$q = explode('/', $match[1]);
2294 2294
 				$data['fir'] = $q[0];
2295 2295
 				$data['code'] = $q[1];
2296 2296
 				$ifrvfr = $q[2];
@@ -2306,30 +2306,30 @@  discard block
 block discarded – undo
2306 2306
 				$data['lower_limit'] = $q[5];
2307 2307
 				$data['upper_limit'] = $q[6];
2308 2308
 				$latlonrad = $q[7];
2309
-				sscanf($latlonrad,'%4c%c%5c%c%3d',$las,$lac,$lns,$lnc,$radius);
2310
-				$latitude = $Common->convertDec($las,'latitude');
2311
-				$longitude = $Common->convertDec($lns,'longitude');
2309
+				sscanf($latlonrad, '%4c%c%5c%c%3d', $las, $lac, $lns, $lnc, $radius);
2310
+				$latitude = $Common->convertDec($las, 'latitude');
2311
+				$longitude = $Common->convertDec($lns, 'longitude');
2312 2312
 				if ($lac == 'S') $latitude = '-'.$latitude;
2313 2313
 				if ($lnc == 'W') $longitude = '-'.$longitude;
2314 2314
 				$data['center_latitude'] = $latitude;
2315 2315
 				$data['center_longitude'] = $longitude;
2316 2316
 				$data['radius'] = intval($radius);
2317 2317
 				
2318
-				preg_match(':<pre>(.*?)</pre>:',$description,$match);
2318
+				preg_match(':<pre>(.*?)</pre>:', $description, $match);
2319 2319
 				$data['text'] = $match[1];
2320
-				preg_match(':</pre>(.*?)$:',$description,$match);
2320
+				preg_match(':</pre>(.*?)$:', $description, $match);
2321 2321
 				$fromto = $match[1];
2322
-				preg_match('#FROM:(.*?)TO:#',$fromto,$match);
2322
+				preg_match('#FROM:(.*?)TO:#', $fromto, $match);
2323 2323
 				$fromall = trim($match[1]);
2324
-				preg_match('#^(.*?) \((.*?)\)$#',$fromall,$match);
2324
+				preg_match('#^(.*?) \((.*?)\)$#', $fromall, $match);
2325 2325
 				$from = trim($match[1]);
2326
-				$data['date_begin'] = date("Y-m-d H:i:s",strtotime($from));
2327
-				preg_match('#TO:(.*?)$#',$fromto,$match);
2326
+				$data['date_begin'] = date("Y-m-d H:i:s", strtotime($from));
2327
+				preg_match('#TO:(.*?)$#', $fromto, $match);
2328 2328
 				$toall = trim($match[1]);
2329
-				if (!preg_match(':Permanent:',$toall)) {
2330
-					preg_match('#^(.*?) \((.*?)\)#',$toall,$match);
2329
+				if (!preg_match(':Permanent:', $toall)) {
2330
+					preg_match('#^(.*?) \((.*?)\)#', $toall, $match);
2331 2331
 					$to = trim($match[1]);
2332
-					$data['date_end'] = date("Y-m-d H:i:s",strtotime($to));
2332
+					$data['date_end'] = date("Y-m-d H:i:s", strtotime($to));
2333 2333
 					$data['permanent'] = 0;
2334 2334
 				} else {
2335 2335
 				    $data['date_end'] = NULL;
@@ -2337,7 +2337,7 @@  discard block
 block discarded – undo
2337 2337
 				}
2338 2338
 				$data['full_notam'] = $notam['title'].'<br>'.$notam['description'];
2339 2339
 				$NOTAM = new NOTAM();
2340
-				$NOTAM->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['center_latitude'],$data['center_longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
2340
+				$NOTAM->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['center_latitude'], $data['center_longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
2341 2341
 				unset($data);
2342 2342
 			} 
2343 2343
 		} else $error = "File ".$tmp_dir.'notam.rss'." doesn't exist. Download failed.";
@@ -2360,16 +2360,16 @@  discard block
 block discarded – undo
2360 2360
 				$Connection = new Connection();
2361 2361
 				$sth = $Connection->db->prepare($query);
2362 2362
 				$sth->execute();
2363
-			} catch(PDOException $e) {
2363
+			} catch (PDOException $e) {
2364 2364
 				return "error : ".$e->getMessage();
2365 2365
 			}
2366 2366
 		}
2367 2367
 		$Common = new Common();
2368 2368
 		$airspace_lst = $Common->getData('https://raw.githubusercontent.com/XCSoar/xcsoar-data-repository/master/data/airspace.json');
2369
-		$airspace_json = json_decode($airspace_lst,true);
2369
+		$airspace_json = json_decode($airspace_lst, true);
2370 2370
 		foreach ($airspace_json['records'] as $airspace) {
2371 2371
 			if ($globalDebug) echo $airspace['name']."...\n";
2372
-			update_db::download($airspace['uri'],$tmp_dir.$airspace['name']);
2372
+			update_db::download($airspace['uri'], $tmp_dir.$airspace['name']);
2373 2373
 			if (file_exists($tmp_dir.$airspace['name'])) {
2374 2374
 				file_put_contents($tmp_dir.$airspace['name'], utf8_encode(file_get_contents($tmp_dir.$airspace['name'])));
2375 2375
 				//system('recode l9..utf8 '.$tmp_dir.$airspace['name']);
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
 				$Connection = new Connection();
2392 2392
 				$sth = $Connection->db->prepare($query);
2393 2393
 				$sth->execute(array(':new' => $new, ':old' => $old));
2394
-			} catch(PDOException $e) {
2394
+			} catch (PDOException $e) {
2395 2395
 				return "error : ".$e->getMessage();
2396 2396
 			}
2397 2397
 		}
@@ -2408,7 +2408,7 @@  discard block
 block discarded – undo
2408 2408
 			$Connection = new Connection();
2409 2409
 			$sth = $Connection->db->prepare($query);
2410 2410
                         $sth->execute();
2411
-                } catch(PDOException $e) {
2411
+                } catch (PDOException $e) {
2412 2412
                         return "error : ".$e->getMessage();
2413 2413
                 }
2414 2414
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2423,7 +2423,7 @@  discard block
 block discarded – undo
2423 2423
 			$Connection = new Connection();
2424 2424
 			$sth = $Connection->db->prepare($query);
2425 2425
                         $sth->execute();
2426
-                } catch(PDOException $e) {
2426
+                } catch (PDOException $e) {
2427 2427
                         return "error : ".$e->getMessage();
2428 2428
                 }
2429 2429
 	}
@@ -2434,7 +2434,7 @@  discard block
 block discarded – undo
2434 2434
 			$Connection = new Connection();
2435 2435
 			$sth = $Connection->db->prepare($query);
2436 2436
                         $sth->execute(array(':version' => $version));
2437
-                } catch(PDOException $e) {
2437
+                } catch (PDOException $e) {
2438 2438
                         return "error : ".$e->getMessage();
2439 2439
                 }
2440 2440
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
 			$Connection = new Connection();
2449 2449
 			$sth = $Connection->db->prepare($query);
2450 2450
                         $sth->execute(array(':version' => $version));
2451
-                } catch(PDOException $e) {
2451
+                } catch (PDOException $e) {
2452 2452
                         return "error : ".$e->getMessage();
2453 2453
                 }
2454 2454
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2464,7 +2464,7 @@  discard block
 block discarded – undo
2464 2464
 			$Connection = new Connection();
2465 2465
 			$sth = $Connection->db->prepare($query);
2466 2466
                         $sth->execute(array(':version' => $version));
2467
-                } catch(PDOException $e) {
2467
+                } catch (PDOException $e) {
2468 2468
                         return "error : ".$e->getMessage();
2469 2469
                 }
2470 2470
 	}
@@ -2476,7 +2476,7 @@  discard block
 block discarded – undo
2476 2476
 			$Connection = new Connection();
2477 2477
 			$sth = $Connection->db->prepare($query);
2478 2478
                         $sth->execute(array(':version' => $version));
2479
-                } catch(PDOException $e) {
2479
+                } catch (PDOException $e) {
2480 2480
                         return "error : ".$e->getMessage();
2481 2481
                 }
2482 2482
 	}
@@ -2492,7 +2492,7 @@  discard block
 block discarded – undo
2492 2492
 			$Connection = new Connection();
2493 2493
 			$sth = $Connection->db->prepare($query);
2494 2494
                         $sth->execute();
2495
-                } catch(PDOException $e) {
2495
+                } catch (PDOException $e) {
2496 2496
                         return "error : ".$e->getMessage();
2497 2497
                 }
2498 2498
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2507,7 +2507,7 @@  discard block
 block discarded – undo
2507 2507
 			$Connection = new Connection();
2508 2508
 			$sth = $Connection->db->prepare($query);
2509 2509
                         $sth->execute();
2510
-                } catch(PDOException $e) {
2510
+                } catch (PDOException $e) {
2511 2511
                         return "error : ".$e->getMessage();
2512 2512
                 }
2513 2513
 	}
@@ -2522,7 +2522,7 @@  discard block
 block discarded – undo
2522 2522
 			$Connection = new Connection();
2523 2523
 			$sth = $Connection->db->prepare($query);
2524 2524
                         $sth->execute();
2525
-                } catch(PDOException $e) {
2525
+                } catch (PDOException $e) {
2526 2526
                         return "error : ".$e->getMessage();
2527 2527
                 }
2528 2528
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2537,7 +2537,7 @@  discard block
 block discarded – undo
2537 2537
 			$Connection = new Connection();
2538 2538
 			$sth = $Connection->db->prepare($query);
2539 2539
                         $sth->execute();
2540
-                } catch(PDOException $e) {
2540
+                } catch (PDOException $e) {
2541 2541
                         return "error : ".$e->getMessage();
2542 2542
                 }
2543 2543
 	}
@@ -2553,7 +2553,7 @@  discard block
 block discarded – undo
2553 2553
 			$Connection = new Connection();
2554 2554
 			$sth = $Connection->db->prepare($query);
2555 2555
                         $sth->execute();
2556
-                } catch(PDOException $e) {
2556
+                } catch (PDOException $e) {
2557 2557
                         return "error : ".$e->getMessage();
2558 2558
                 }
2559 2559
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2568,7 +2568,7 @@  discard block
 block discarded – undo
2568 2568
 			$Connection = new Connection();
2569 2569
 			$sth = $Connection->db->prepare($query);
2570 2570
                         $sth->execute();
2571
-                } catch(PDOException $e) {
2571
+                } catch (PDOException $e) {
2572 2572
                         return "error : ".$e->getMessage();
2573 2573
                 }
2574 2574
 	}
@@ -2583,7 +2583,7 @@  discard block
 block discarded – undo
2583 2583
 			$Connection = new Connection();
2584 2584
 			$sth = $Connection->db->prepare($query);
2585 2585
                         $sth->execute();
2586
-                } catch(PDOException $e) {
2586
+                } catch (PDOException $e) {
2587 2587
                         return "error : ".$e->getMessage();
2588 2588
                 }
2589 2589
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2598,7 +2598,7 @@  discard block
 block discarded – undo
2598 2598
 			$Connection = new Connection();
2599 2599
 			$sth = $Connection->db->prepare($query);
2600 2600
                         $sth->execute();
2601
-                } catch(PDOException $e) {
2601
+                } catch (PDOException $e) {
2602 2602
                         return "error : ".$e->getMessage();
2603 2603
                 }
2604 2604
 	}
@@ -2613,7 +2613,7 @@  discard block
 block discarded – undo
2613 2613
 			$Connection = new Connection();
2614 2614
 			$sth = $Connection->db->prepare($query);
2615 2615
                         $sth->execute();
2616
-                } catch(PDOException $e) {
2616
+                } catch (PDOException $e) {
2617 2617
                         return "error : ".$e->getMessage();
2618 2618
                 }
2619 2619
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2628,7 +2628,7 @@  discard block
 block discarded – undo
2628 2628
 			$Connection = new Connection();
2629 2629
 			$sth = $Connection->db->prepare($query);
2630 2630
                         $sth->execute();
2631
-                } catch(PDOException $e) {
2631
+                } catch (PDOException $e) {
2632 2632
                         return "error : ".$e->getMessage();
2633 2633
                 }
2634 2634
 	}
@@ -2643,7 +2643,7 @@  discard block
 block discarded – undo
2643 2643
 			$Connection = new Connection();
2644 2644
 			$sth = $Connection->db->prepare($query);
2645 2645
                         $sth->execute();
2646
-                } catch(PDOException $e) {
2646
+                } catch (PDOException $e) {
2647 2647
                         return "error : ".$e->getMessage();
2648 2648
                 }
2649 2649
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -2658,7 +2658,7 @@  discard block
 block discarded – undo
2658 2658
 			$Connection = new Connection();
2659 2659
 			$sth = $Connection->db->prepare($query);
2660 2660
                         $sth->execute();
2661
-                } catch(PDOException $e) {
2661
+                } catch (PDOException $e) {
2662 2662
                         return "error : ".$e->getMessage();
2663 2663
                 }
2664 2664
 	}
@@ -2673,7 +2673,7 @@  discard block
 block discarded – undo
2673 2673
 			$Connection = new Connection();
2674 2674
 			$sth = $Connection->db->prepare($query);
2675 2675
                         $sth->execute();
2676
-                } catch(PDOException $e) {
2676
+                } catch (PDOException $e) {
2677 2677
                         return "error : ".$e->getMessage();
2678 2678
                 }
2679 2679
 	}
@@ -2688,7 +2688,7 @@  discard block
 block discarded – undo
2688 2688
 			$Connection = new Connection();
2689 2689
 			$sth = $Connection->db->prepare($query);
2690 2690
                         $sth->execute();
2691
-                } catch(PDOException $e) {
2691
+                } catch (PDOException $e) {
2692 2692
                         return "error : ".$e->getMessage();
2693 2693
                 }
2694 2694
 	}
Please login to merge, or discard this patch.
require/class.NOTAM.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
 		try {
983 983
 			$sth = $this->db->prepare($query);
984 984
 			$sth->execute($query_values);
985
-		} catch(PDOException $e) {
985
+		} catch (PDOException $e) {
986 986
 			echo "error : ".$e->getMessage();
987 987
 		}
988 988
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1000,19 +1000,19 @@  discard block
 block discarded – undo
1000 1000
 		try {
1001 1001
 			$sth = $this->db->prepare($query);
1002 1002
 			$sth->execute($query_values);
1003
-		} catch(PDOException $e) {
1003
+		} catch (PDOException $e) {
1004 1004
 			echo "error : ".$e->getMessage();
1005 1005
 		}
1006 1006
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1007 1007
 		return $all;
1008 1008
 	}
1009 1009
 	public function getAllNOTAMtext() {
1010
-		$query  = 'SELECT full_notam FROM notam';
1010
+		$query = 'SELECT full_notam FROM notam';
1011 1011
 		$query_values = array();
1012 1012
 		try {
1013 1013
 			$sth = $this->db->prepare($query);
1014 1014
 			$sth->execute($query_values);
1015
-		} catch(PDOException $e) {
1015
+		} catch (PDOException $e) {
1016 1016
 			echo "error : ".$e->getMessage();
1017 1017
 		}
1018 1018
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1021,13 +1021,13 @@  discard block
 block discarded – undo
1021 1021
 	public function createNOTAMtextFile($filename) {
1022 1022
 		$allnotam_result = $this->getAllNOTAMtext();
1023 1023
 		$notamtext = '';
1024
-		foreach($allnotam_result as $notam) {
1024
+		foreach ($allnotam_result as $notam) {
1025 1025
 			$notamtext .= '%%'."\n";
1026 1026
 			$notamtext .= $notam['full_notam'];
1027 1027
 			$notamtext .= "\n".'%%'."\n";
1028 1028
 		}
1029 1029
 		//$allnotam = implode('\n%%%%\n',$allnotam_result);
1030
-		file_put_contents($filename,$notamtext);
1030
+		file_put_contents($filename, $notamtext);
1031 1031
 	}
1032 1032
 	public function parseNOTAMtextFile($filename) {
1033 1033
 		$data = file_get_contents($filename);
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
 		try {
1049 1049
 			$sth = $this->db->prepare($query);
1050 1050
 			$sth->execute($query_values);
1051
-		} catch(PDOException $e) {
1051
+		} catch (PDOException $e) {
1052 1052
 			echo "error : ".$e->getMessage();
1053 1053
 		}
1054 1054
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1057,10 +1057,10 @@  discard block
 block discarded – undo
1057 1057
 	public function getAllNOTAMbyCoord($coord) {
1058 1058
 		global $globalDBdriver;
1059 1059
 		if (is_array($coord)) {
1060
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1061
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1062
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1063
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1060
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1061
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1062
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1063
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1064 1064
 			if ($minlat > $maxlat) {
1065 1065
 				$tmplat = $minlat;
1066 1066
 				$minlat = $maxlat;
@@ -1082,19 +1082,19 @@  discard block
 block discarded – undo
1082 1082
 		try {
1083 1083
 			$sth = $this->db->prepare($query);
1084 1084
 			$sth->execute($query_values);
1085
-		} catch(PDOException $e) {
1085
+		} catch (PDOException $e) {
1086 1086
 			echo "error : ".$e->getMessage();
1087 1087
 		}
1088 1088
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
1089 1089
 		return $all;
1090 1090
 	}
1091
-	public function getAllNOTAMbyCoordScope($coord,$scope) {
1091
+	public function getAllNOTAMbyCoordScope($coord, $scope) {
1092 1092
 		global $globalDBdriver;
1093 1093
 		if (is_array($coord)) {
1094
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1095
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1096
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1097
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1094
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1095
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1096
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1097
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1098 1098
 		} else return array();
1099 1099
 		if ($globalDBdriver == 'mysql') {
1100 1100
 			$query  = 'SELECT * FROM notam WHERE center_latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND center_longitude BETWEEN '.$minlong.' AND '.$maxlong.' AND radius > 0 AND date_end > UTC_TIMESTAMP() AND date_begin < UTC_TIMESTAMP() AND scope = :scope';
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 		try {
1107 1107
 			$sth = $this->db->prepare($query);
1108 1108
 			$sth->execute($query_values);
1109
-		} catch(PDOException $e) {
1109
+		} catch (PDOException $e) {
1110 1110
 			echo "error : ".$e->getMessage();
1111 1111
 		}
1112 1112
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1118,7 +1118,7 @@  discard block
 block discarded – undo
1118 1118
 		try {
1119 1119
 			$sth = $this->db->prepare($query);
1120 1120
 			$sth->execute($query_values);
1121
-		} catch(PDOException $e) {
1121
+		} catch (PDOException $e) {
1122 1122
 			return "error : ".$e->getMessage();
1123 1123
 		}
1124 1124
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -1126,13 +1126,13 @@  discard block
 block discarded – undo
1126 1126
 		else return array();
1127 1127
 	}
1128 1128
 
1129
-	public function addNOTAM($ref,$title,$type,$fir,$code,$rules,$scope,$lower_limit,$upper_limit,$center_latitude,$center_longitude,$radius,$date_begin,$date_end,$permanent,$text,$full_notam) {
1129
+	public function addNOTAM($ref, $title, $type, $fir, $code, $rules, $scope, $lower_limit, $upper_limit, $center_latitude, $center_longitude, $radius, $date_begin, $date_end, $permanent, $text, $full_notam) {
1130 1130
 		$query = "INSERT INTO notam (ref,title,notam_type,fir,code,rules,scope,lower_limit,upper_limit,center_latitude,center_longitude,radius,date_begin,date_end,permanent,notam_text,full_notam) VALUES (:ref,:title,:type,:fir,:code,:rules,:scope,:lower_limit,:upper_limit,:center_latitude,:center_longitude,:radius,:date_begin,:date_end,:permanent,:text,:full_notam)";
1131
-		$query_values = array(':ref' => $ref,':title' => $title,':type' => $type,':fir' => $fir,':code' => $code,':rules' => $rules,':scope' => $scope,':lower_limit' => $lower_limit,':upper_limit' => $upper_limit,':center_latitude' => $center_latitude,':center_longitude' => $center_longitude,':radius' => $radius,':date_begin' => $date_begin,':date_end' => $date_end,':permanent' => $permanent,':text' => $text,':full_notam' => $full_notam);
1131
+		$query_values = array(':ref' => $ref, ':title' => $title, ':type' => $type, ':fir' => $fir, ':code' => $code, ':rules' => $rules, ':scope' => $scope, ':lower_limit' => $lower_limit, ':upper_limit' => $upper_limit, ':center_latitude' => $center_latitude, ':center_longitude' => $center_longitude, ':radius' => $radius, ':date_begin' => $date_begin, ':date_end' => $date_end, ':permanent' => $permanent, ':text' => $text, ':full_notam' => $full_notam);
1132 1132
 		try {
1133 1133
 			$sth = $this->db->prepare($query);
1134 1134
 			$sth->execute($query_values);
1135
-		} catch(PDOException $e) {
1135
+		} catch (PDOException $e) {
1136 1136
 			return "error : ".$e->getMessage();
1137 1137
 		}
1138 1138
 	}
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 		try {
1144 1144
 			$sth = $this->db->prepare($query);
1145 1145
 			$sth->execute($query_values);
1146
-		} catch(PDOException $e) {
1146
+		} catch (PDOException $e) {
1147 1147
 			return "error : ".$e->getMessage();
1148 1148
 		}
1149 1149
 	}
@@ -1158,7 +1158,7 @@  discard block
 block discarded – undo
1158 1158
 		try {
1159 1159
 			$sth = $this->db->prepare($query);
1160 1160
 			$sth->execute($query_values);
1161
-		} catch(PDOException $e) {
1161
+		} catch (PDOException $e) {
1162 1162
 			return "error : ".$e->getMessage();
1163 1163
 		}
1164 1164
 	}
@@ -1168,7 +1168,7 @@  discard block
 block discarded – undo
1168 1168
 		try {
1169 1169
 			$sth = $this->db->prepare($query);
1170 1170
 			$sth->execute($query_values);
1171
-		} catch(PDOException $e) {
1171
+		} catch (PDOException $e) {
1172 1172
 			return "error : ".$e->getMessage();
1173 1173
 		}
1174 1174
 	}
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
 		try {
1178 1178
 			$sth = $this->db->prepare($query);
1179 1179
 			$sth->execute();
1180
-		} catch(PDOException $e) {
1180
+		} catch (PDOException $e) {
1181 1181
 			return "error : ".$e->getMessage();
1182 1182
 		}
1183 1183
 	}
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		try {
1187 1187
 			$sth = $this->db->prepare($query);
1188 1188
 			$sth->execute();
1189
-		} catch(PDOException $e) {
1189
+		} catch (PDOException $e) {
1190 1190
 			return "error : ".$e->getMessage();
1191 1191
 		}
1192 1192
 	}
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 	public function updateNOTAM() {
1195 1195
 		global $globalNOTAMAirports;
1196 1196
 		if (isset($globalNOTAMAirports) && is_array($globalNOTAMAirports) && count($globalNOTAMAirports) > 0) {
1197
-			foreach (array_chunk($globalNOTAMAirports,10) as $airport) {
1198
-				$airport_icao = implode(',',$airport);
1197
+			foreach (array_chunk($globalNOTAMAirports, 10) as $airport) {
1198
+				$airport_icao = implode(',', $airport);
1199 1199
 				$alldata = $this->downloadNOTAM($airport_icao);
1200 1200
 				if (count($alldata) > 0) {
1201 1201
 					foreach ($alldata as $initial_data) {
1202 1202
 						$data = $this->parse($initial_data);
1203 1203
 						$notamref = $this->getNOTAMbyRef($data['ref']);
1204
-						if (count($notamref) == 0) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1204
+						if (count($notamref) == 0) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1205 1205
 					}
1206 1206
 				}
1207 1207
 			}
@@ -1214,7 +1214,7 @@  discard block
 block discarded – undo
1214 1214
 			foreach ($alldata as $initial_data) {
1215 1215
 				$data = $this->parse($initial_data);
1216 1216
 				$notamref = $this->getNOTAMbyRef($data['ref']);
1217
-				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'],$data['title'],'',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1217
+				if (!isset($notamref['notam_id'])) $this->addNOTAM($data['ref'], $data['title'], '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1218 1218
 			}
1219 1219
 		}
1220 1220
 	}
@@ -1223,12 +1223,12 @@  discard block
 block discarded – undo
1223 1223
 		global $globalTransaction;
1224 1224
 		$Spotter = new Spotter();
1225 1225
 		$allairports = $Spotter->getAllAirportInfo();
1226
-		foreach (array_chunk($allairports,20) as $airport) {
1226
+		foreach (array_chunk($allairports, 20) as $airport) {
1227 1227
 			$airports_icao = array();
1228
-			foreach($airport as $icao) {
1228
+			foreach ($airport as $icao) {
1229 1229
 				if (isset($icao['icao'])) $airports_icao[] = $icao['icao'];
1230 1230
 			}
1231
-			$airport_icao = implode(',',$airports_icao);
1231
+			$airport_icao = implode(',', $airports_icao);
1232 1232
 			$alldata = $this->downloadNOTAM($airport_icao);
1233 1233
 			if ($globalTransaction) $this->db->beginTransaction();
1234 1234
 			if (count($alldata) > 0) {
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 						if (count($notamref) == 0) {
1242 1242
 							if (isset($data['ref_replaced'])) $this->deleteNOTAMbyRef($data['ref_replaced']);
1243 1243
 							if (isset($data['ref_cancelled'])) $this->deleteNOTAMbyRef($data['ref_cancelled']);
1244
-							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'],'','',$data['fir'],$data['code'],'',$data['scope'],$data['lower_limit'],$data['upper_limit'],$data['latitude'],$data['longitude'],$data['radius'],$data['date_begin'],$data['date_end'],$data['permanent'],$data['text'],$data['full_notam']);
1244
+							elseif (isset($data['latitude']) && isset($data['scope']) && isset($data['text']) && isset($data['permanent'])) echo $this->addNOTAM($data['ref'], '', '', $data['fir'], $data['code'], '', $data['scope'], $data['lower_limit'], $data['upper_limit'], $data['latitude'], $data['longitude'], $data['radius'], $data['date_begin'], $data['date_end'], $data['permanent'], $data['text'], $data['full_notam']);
1245 1245
 						}
1246 1246
 					}
1247 1247
 				}
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 		date_default_timezone_set("UTC");
1256 1256
 		$Common = new Common();
1257 1257
 		//$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=DOMESTIC&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1258
-		$url = str_replace('{icao}',$icao,'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1258
+		$url = str_replace('{icao}', $icao, 'https://pilotweb.nas.faa.gov/PilotWeb/notamRetrievalByICAOAction.do?method=displayByICAOs&reportType=RAW&formatType=ICAO&retrieveLocId={icao}&actionType=notamRetrievalByICAOs');
1259 1259
 		$data = $Common->getData($url);
1260 1260
 		preg_match_all("/<pre>(.+?)<\/pre>/is", $data, $matches);
1261 1261
 		//print_r($matches);
@@ -1272,15 +1272,15 @@  discard block
 block discarded – undo
1272 1272
 		$result['permanent'] = '';
1273 1273
 		$result['date_begin'] = NULL;
1274 1274
 		$result['date_end'] = NULL;
1275
-		$data = str_ireplace(array("\r","\n",'\r','\n'),' ',$data);
1275
+		$data = str_ireplace(array("\r", "\n", '\r', '\n'), ' ', $data);
1276 1276
 		//echo $data."\n";
1277
-		$data = preg_split('#\s(?=([A-Z]\)\s))#',$data);
1277
+		$data = preg_split('#\s(?=([A-Z]\)\s))#', $data);
1278 1278
 		//print_r($data);
1279 1279
 		foreach ($data as $line) {
1280 1280
 			$line = trim($line);
1281
-			if (preg_match('#Q\) (.*)#',$line,$matches)) {
1282
-				$line = str_replace(' ','',$line);
1283
-				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#',$line,$matches)) {
1281
+			if (preg_match('#Q\) (.*)#', $line, $matches)) {
1282
+				$line = str_replace(' ', '', $line);
1283
+				if (preg_match('#Q\)([A-Z]{3,4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3}|)#', $line, $matches)) {
1284 1284
 				//if (preg_match('#Q\)([A-Z]{4})\/([A-Z]{5})\/(IV|I|V)\/([A-Z]{1,3})\/([A-Z]{1,2})\/([0-9]{3})\/([0-9]{3})\/([0-9]{4})(N|S)([0-9]{5})(E|W)([0-9]{3})#',$line,$matches)) {
1285 1285
 					//print_r($matches);
1286 1286
 					$result['fir'] = $matches[1];
@@ -1326,9 +1326,9 @@  discard block
 block discarded – undo
1326 1326
 					elseif ($matches[5] == 'AW') $result['scope'] = 'Airport/Navigation warning';
1327 1327
 					$result['lower_limit'] = $matches[6];
1328 1328
 					$result['upper_limit'] = $matches[7];
1329
-					$latitude = $Common->convertDec($matches[8],'latitude');
1329
+					$latitude = $Common->convertDec($matches[8], 'latitude');
1330 1330
 					if ($matches[9] == 'S') $latitude = -$latitude;
1331
-					$longitude = $Common->convertDec($matches[10],'longitude');
1331
+					$longitude = $Common->convertDec($matches[10], 'longitude');
1332 1332
 					if ($matches[11] == 'W') $longitude = -$longitude;
1333 1333
 					$result['latitude'] = $latitude;
1334 1334
 					$result['longitude'] = $longitude;
@@ -1339,21 +1339,21 @@  discard block
 block discarded – undo
1339 1339
 					echo "Can't parse : ".$line."\n";
1340 1340
 				}
1341 1341
 			}
1342
-			elseif (preg_match('#A\) (.*)#',$line,$matches)) {
1342
+			elseif (preg_match('#A\) (.*)#', $line, $matches)) {
1343 1343
 				$result['icao'] = $matches[1];
1344 1344
 			}
1345
-			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#',$line,$matches)) {
1345
+			elseif (preg_match('#B\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})#', $line, $matches)) {
1346 1346
 				if ($matches[1] > 50) $year = '19'.$matches[1];
1347 1347
 				else $year = '20'.$matches[1];
1348 1348
 				$result['date_begin'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
1349 1349
 			}
1350
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#',$line,$matches)) {
1350
+			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})$#', $line, $matches)) {
1351 1351
 				if ($matches[1] > 50) $year = '19'.$matches[1];
1352 1352
 				else $year = '20'.$matches[1];
1353 1353
 				$result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
1354 1354
 				$result['permanent'] = 0;
1355 1355
 			}
1356
-			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#',$line,$matches)) {
1356
+			elseif (preg_match('#C\) ([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2}) (EST|PERM)$#', $line, $matches)) {
1357 1357
 				if ($matches[1] > 50) $year = '19'.$matches[1];
1358 1358
 				else $year = '20'.$matches[1];
1359 1359
 				$result['date_end'] = $year.'/'.$matches[2].'/'.$matches[3].' '.$matches[4].':'.$matches[5];
@@ -1362,26 +1362,26 @@  discard block
 block discarded – undo
1362 1362
 				if ($matches[6] == 'PERM') $result['permanent'] = 1;
1363 1363
 				else $result['permanent'] = 0;
1364 1364
 			}
1365
-			elseif (preg_match('#C\) (EST|PERM)$#',$line,$matches)) {
1365
+			elseif (preg_match('#C\) (EST|PERM)$#', $line, $matches)) {
1366 1366
 				$result['date_end'] = '2030/12/20 12:00';
1367 1367
 				if ($matches[1] == 'EST') $result['estimated'] = 1;
1368 1368
 				else $result['estimated'] = 0;
1369 1369
 				if ($matches[1] == 'PERM') $result['permanent'] = 1;
1370 1370
 				else $result['permanent'] = 0;
1371 1371
 			}
1372
-			elseif (preg_match('#E\) (.*)#',$line,$matches)) {
1372
+			elseif (preg_match('#E\) (.*)#', $line, $matches)) {
1373 1373
 				$rtext = array();
1374
-				$text = explode(' ',$matches[1]);
1374
+				$text = explode(' ', $matches[1]);
1375 1375
 				foreach ($text as $word) {
1376 1376
 					if (isset($this->abbr[$word])) $rtext[] = strtoupper($this->abbr[$word]);
1377
-					elseif (ctype_digit(strval(substr($word,3))) && isset($this->abbr[substr($word,0,3)])) $rtext[] = strtoupper($this->abbr[substr($word,0,3)]).' '.substr($word,3);
1377
+					elseif (ctype_digit(strval(substr($word, 3))) && isset($this->abbr[substr($word, 0, 3)])) $rtext[] = strtoupper($this->abbr[substr($word, 0, 3)]).' '.substr($word, 3);
1378 1378
 					else $rtext[] = $word;
1379 1379
 				}
1380
-				$result['text'] = implode(' ',$rtext);
1380
+				$result['text'] = implode(' ', $rtext);
1381 1381
 			//} elseif (preg_match('#F\) (.*)#',$line,$matches)) {
1382 1382
 			//} elseif (preg_match('#G\) (.*)#',$line,$matches)) {
1383
-			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#',$line,$matches)) {
1384
-				$text = explode(' ',$line);
1383
+			} elseif (preg_match('#(NOTAMN|NOTAMR|NOTAMC)#', $line, $matches)) {
1384
+				$text = explode(' ', $line);
1385 1385
 				$result['ref'] = $text[0];
1386 1386
 				if ($matches[1] == 'NOTAMN') $result['type'] = 'new';
1387 1387
 				if ($matches[1] == 'NOTAMC') {
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 	* @param String $date get data for a date
30 30
 	* @return Array Return Accidents data in array
31 31
 	*/
32
-	public function getAccidentData($limit = '',$type = '',$date = '') {
32
+	public function getAccidentData($limit = '', $type = '', $date = '') {
33 33
 		global $globalURL, $globalDBdriver;
34 34
 		$Image = new Image($this->db);
35 35
 		$Spotter = new Spotter($this->db);
36 36
 		$Translation = new Translation($this->db);
37
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
37
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
38 38
 		date_default_timezone_set('UTC');
39 39
 		$result = array();
40 40
 		$limit_query = '';
41 41
 		if ($limit != "")
42 42
 		{
43 43
 			$limit_array = explode(",", $limit);
44
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
45
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
44
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
45
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
46 46
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
47 47
 			{
48 48
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
 
52 52
 		if ($type != '') {
53 53
 			if ($date != '') {
54
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
54
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
55 55
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
56 56
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
57
-					$query_values = array(':type' => $type,':date' => $date);
58
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
57
+					$query_values = array(':type' => $type, ':date' => $date);
58
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
59 59
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
60
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
61
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
60
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
61
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
62 62
 					if ($globalDBdriver == 'mysql') {
63 63
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
64 64
 					} else {
65 65
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
66 66
 					}
67
-					$query_values = array(':type' => $type,':date' => $date);
67
+					$query_values = array(':type' => $type, ':date' => $date);
68 68
 				} else {
69 69
 					$date = $date.'%';
70 70
 					if ($globalDBdriver == 'mysql') {
71 71
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
72
-						$query_values = array(':type' => $type,':date' => $date);
72
+						$query_values = array(':type' => $type, ':date' => $date);
73 73
 					} else {
74 74
 						$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
75 75
 						//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
76
-						$query_values = array(':type' => $type,':date' => $date);
76
+						$query_values = array(':type' => $type, ':date' => $date);
77 77
 					}
78 78
 				}
79 79
 			} else {
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 			}
84 84
 		} else {
85 85
 			if ($date != '') {
86
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
86
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
87 87
 					$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
88 88
 					//$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
89 89
 				} else {
@@ -102,19 +102,19 @@  discard block
 block discarded – undo
102 102
 		try {
103 103
 			$sth = $this->db->prepare($query);
104 104
 			$sth->execute($query_values);
105
-		} catch(PDOException $e) {
105
+		} catch (PDOException $e) {
106 106
 			echo "error : ".$e->getMessage();
107 107
 		}
108 108
 		$i = 0;
109 109
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
110 110
 			//print_r($row);
111 111
 			//echo $row['flightaware_id'];
112
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
112
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
113 113
 				$data = array();
114 114
 				if ($row['registration'] != '') {
115 115
 					$image_array = $Image->getSpotterImage($row['registration']);
116
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
117
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
116
+					if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
117
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
118 118
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
119 119
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
120 120
 					if (!empty($aircraft_info)) {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
123 123
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
124 124
 					} else {
125
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
125
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
126 126
 					}
127 127
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
128 128
 					if (!empty($owner_data)) {
@@ -130,18 +130,18 @@  discard block
 block discarded – undo
130 130
 						$data['aircraft_base'] = $owner_data['base'];
131 131
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
132 132
 					}
133
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
133
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
134 134
 				if ($row['registration'] == '') $row['registration'] = 'NA';
135 135
 				if ($row['ident'] == '') $row['ident'] = 'NA';
136
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
136
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
137 137
 				if (isset($identicao[0])) {
138
-					if (substr($row['ident'],0,2) == 'AF') {
139
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
140
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
141
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
142
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
138
+					if (substr($row['ident'], 0, 2) == 'AF') {
139
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
140
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
141
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
142
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
143 143
 				} else $icao = $row['ident'];
144
-				$icao = $Translation->checkTranslation($icao,false);
144
+				$icao = $Translation->checkTranslation($icao, false);
145 145
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
146 146
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
147 147
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 					if (!empty($airline_info)) {
151 151
 						//echo 'data found !'."\n";
152 152
 						//print_r($airline_info);
153
-						$data = array_merge($data,$airline_info);
153
+						$data = array_merge($data, $airline_info);
154 154
 					} 
155 155
 					//else echo 'No data...'."\n";
156 156
 				}
157
-				$data = array_merge($row,$data);
157
+				$data = array_merge($row, $data);
158 158
 				if ($data['ident'] == null) $data['ident'] = $icao;
159 159
 				if ($data['title'] == null) {
160 160
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		try {
191 191
 			$sth = $this->db->prepare($query);
192 192
 			$sth->execute();
193
-		} catch(PDOException $e) {
193
+		} catch (PDOException $e) {
194 194
 			echo "Error : ".$e->getMessage();
195 195
 		}
196 196
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 		try {
211 211
 			$sth = $this->db->prepare($query);
212 212
 			$sth->execute();
213
-		} catch(PDOException $e) {
213
+		} catch (PDOException $e) {
214 214
 			echo "Error : ".$e->getMessage();
215 215
 		}
216 216
 		return $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
 		if ($globalDebug) echo 'Import '.$file."\n";
226 226
 		$result = array();
227 227
 		if (file_exists($file)) {
228
-			if (($handle = fopen($file,'r')) !== FALSE) {
229
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
228
+			if (($handle = fopen($file, 'r')) !== FALSE) {
229
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
230 230
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
231
-						$result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam');
231
+						$result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam');
232 232
 					}
233 233
 				}
234 234
 				fclose($handle);
235 235
 			}
236
-			if (!empty($result)) $this->add($result,true);
236
+			if (!empty($result)) $this->add($result, true);
237 237
 			elseif ($globalDebug) echo 'Nothing to import';
238 238
 		}
239 239
 	}
@@ -249,8 +249,8 @@  discard block
 block discarded – undo
249 249
 		$all_md5_new = array();
250 250
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
251 251
 			if ($this->check_accidents_nb() > 0) {
252
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
253
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
252
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
253
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
254 254
 						if (isset($data[1])) {
255 255
 							$year = $data[0];
256 256
 							$all_md5[$year] = $data[1];
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 				}
261 261
 			}
262 262
 		}
263
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
263
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
264 264
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
265
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
266
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
265
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
266
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
267 267
 					if (isset($data[1])) {
268 268
 						$year = $data[0];
269 269
 						$all_md5_new[$year] = $data[1];
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 				fclose($handle);
273 273
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
274 274
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
275
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
275
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
276 276
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
277 277
 		foreach ($result as $file => $md5) {
278
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
278
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
279 279
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
280 280
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
281 281
 		}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	* Add data to DB
286 286
 	* @param Array $crash An array with accidents/incidents data
287 287
 	*/
288
-	public function add($crash,$new = false) {
288
+	public function add($crash, $new = false) {
289 289
 		global $globalTransaction, $globalDebug;
290 290
 		require_once('class.Connection.php');
291 291
 		require_once('class.Image.php');
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 			$sthd->execute(array(':source' => $crash[0]['source']));
302 302
 		}
303 303
 		if ($globalTransaction) $Connection->db->beginTransaction();
304
-		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
304
+		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null);
305 305
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
306 306
 		$sth_check = $Connection->db->prepare($query_check);
307 307
 		$query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)';
@@ -314,15 +314,15 @@  discard block
 block discarded – undo
314 314
 				$cr = array_map(function($value) {
315 315
 					return $value === "" ? NULL : $value;
316 316
 				}, $cr);
317
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
318
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
319
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
317
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
318
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
319
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
320 320
 					$sth_check->execute($query_check_values);
321 321
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
322 322
 					if ($result_check['nb'] == 0) {
323
-						$query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']);
323
+						$query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']);
324 324
 						$sth->execute($query_values);
325
-						if ($cr['date'] > time()-(30*86400)) {
325
+						if ($cr['date'] > time() - (30*86400)) {
326 326
 							if (empty($Image->getSpotterImage($cr['registration']))) {
327 327
 								if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
328 328
 								$Image->addSpotterImage($cr['registration']);
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 							// elseif ($globalDebug) echo 'Image already in DB'."\n";
332 332
 						}
333 333
 						if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
334
-						$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
334
+						$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
335 335
 					}
336 336
 				}
337
-				if ($globalTransaction && $j % 1000 == 0) {
337
+				if ($globalTransaction && $j%1000 == 0) {
338 338
 					$Connection->db->commit();
339 339
 					$Connection->db->beginTransaction();
340 340
 				}
341 341
 			}
342 342
 			if ($globalTransaction) $Connection->db->commit();
343
-		} catch(PDOException $e) {
343
+		} catch (PDOException $e) {
344 344
 			if ($globalTransaction) $Connection->db->rollBack();
345 345
 			echo $e->getMessage();
346 346
 		}
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
 			$Connection = new Connection();
359 359
 			$sth = $Connection->db->prepare($query);
360 360
 			$sth->execute();
361
-		} catch(PDOException $e) {
361
+		} catch (PDOException $e) {
362 362
 			return "error : ".$e->getMessage();
363 363
 		}
364 364
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 			$Connection = new Connection();
377 377
 			$sth = $Connection->db->prepare($query);
378 378
 			$sth->execute();
379
-		} catch(PDOException $e) {
379
+		} catch (PDOException $e) {
380 380
 			return "error : ".$e->getMessage();
381 381
 		}
382 382
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 			$Connection = new Connection();
392 392
 			$sth = $Connection->db->prepare($query);
393 393
 			$sth->execute();
394
-		} catch(PDOException $e) {
394
+		} catch (PDOException $e) {
395 395
 			return "error : ".$e->getMessage();
396 396
 		}
397 397
 	}
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Spacing   +127 added lines, -127 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];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		} else {
170 170
 			$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;
171 171
 		}
172
-		$spotter_array = $Spotter->getDataFromDB($query.$limit_query,array(),'',true);
172
+		$spotter_array = $Spotter->getDataFromDB($query.$limit_query, array(), '', true);
173 173
 
174 174
 		return $spotter_array;
175 175
 	}
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	{
185 185
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
186 186
 		date_default_timezone_set('UTC');
187
-		$filter_query = $this->getFilter($filter,true,true);
187
+		$filter_query = $this->getFilter($filter, true, true);
188 188
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
189 189
 		if ($globalDBdriver == 'mysql') {
190 190
 			if (isset($globalArchive) && $globalArchive === TRUE) {
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		try {
208 208
 			$sth = $this->db->prepare($query);
209 209
 			$sth->execute();
210
-		} catch(PDOException $e) {
210
+		} catch (PDOException $e) {
211 211
 			echo $e->getMessage();
212 212
 			die;
213 213
 		}
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
227 227
 		date_default_timezone_set('UTC');
228 228
 
229
-		$filter_query = $this->getFilter($filter,true,true);
229
+		$filter_query = $this->getFilter($filter, true, true);
230 230
 
231 231
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
232 232
 		if ($globalDBdriver == 'mysql') {
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
238 238
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
239 239
 				*/
240
-				$query  = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
240
+				$query = 'SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
241 241
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id 
242 242
 				UNION
243 243
 				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 
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 				WHERE latitude <> '0' AND longitude <> '0' 
246 246
 				ORDER BY flightaware_id, date";
247 247
 			} else {
248
-				$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 
248
+				$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 
249 249
 				FROM spotter_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= spotter_live.date 
250 250
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
251 251
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				WHERE spotter_archive.latitude <> '0' AND spotter_archive.longitude <> '0' 
259 259
 				ORDER BY spotter_archive.flightaware_id, spotter_archive.date";
260 260
                                */
261
-				$query  = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
261
+				$query = "SELECT * FROM (SELECT spotter_archive.ident, spotter_archive.flightaware_id, spotter_archive.aircraft_icao, spotter_archive.departure_airport_icao as departure_airport, spotter_archive.arrival_airport_icao as arrival_airport, spotter_archive.latitude, spotter_archive.longitude, spotter_archive.altitude, spotter_archive.heading, spotter_archive.ground_speed, spotter_archive.squawk, spotter_archive.date, spotter_archive.format_source 
262 262
 				FROM spotter_archive INNER JOIN (SELECT flightaware_id FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date) l ON l.flightaware_id = spotter_archive.flightaware_id 
263 263
 				UNION
264 264
 				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 
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 				ORDER BY flightaware_id, date";
269 269
 				//AND CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".round($globalLiveInterval*1000)." SECONDS' <= spotter_archive.date
270 270
 			} else {
271
-				$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 
271
+				$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 
272 272
 				FROM spotter_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date
273 273
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0' 
274 274
 				ORDER BY spotter_live.flightaware_id, spotter_live.date";
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
     		try {
278 278
 			$sth = $this->db->prepare($query);
279 279
 			$sth->execute();
280
-		} catch(PDOException $e) {
280
+		} catch (PDOException $e) {
281 281
 			echo $e->getMessage();
282 282
 			die;
283 283
 		}
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 	public function getLiveSpotterCount($filter = array())
295 295
 	{
296 296
 		global $globalDBdriver, $globalLiveInterval;
297
-		$filter_query = $this->getFilter($filter,true,true);
297
+		$filter_query = $this->getFilter($filter, true, true);
298 298
 
299 299
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
300 300
 		if ($globalDBdriver == 'mysql') {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 		try {
308 308
 			$sth = $this->db->prepare($query);
309 309
 			$sth->execute();
310
-		} catch(PDOException $e) {
310
+		} catch (PDOException $e) {
311 311
 			echo $e->getMessage();
312 312
 			die;
313 313
 		}
@@ -330,10 +330,10 @@  discard block
 block discarded – undo
330 330
 		$filter_query = $this->getFilter($filter);
331 331
 
332 332
 		if (is_array($coord)) {
333
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
334
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
335
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
336
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
333
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
334
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
335
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
336
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
337 337
 		} else return array();
338 338
 		if ($globalDBdriver == 'mysql') {
339 339
 			$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;
@@ -356,23 +356,23 @@  discard block
 block discarded – undo
356 356
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
357 357
 		$Spotter = new Spotter($this->db);
358 358
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
359
-		$filter_query = $this->getFilter($filter,true,true);
359
+		$filter_query = $this->getFilter($filter, true, true);
360 360
 
361 361
 		if (is_array($coord)) {
362
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
363
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
364
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
365
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
362
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
363
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
364
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
365
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
366 366
 		} else return array();
367 367
 		if ($globalDBdriver == 'mysql') {
368 368
 			if (isset($globalArchive) && $globalArchive === TRUE) {
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
 				'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= spotter_live.date 
372 372
 				AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.'
373 373
 				AND spotter_live.latitude <> 0 AND spotter_live.longitude <> 0';
374 374
 			} else {
375
-				$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 
375
+				$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 
376 376
 				FROM spotter_live 
377 377
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
378 378
 				    FROM spotter_live l 
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
 			}
385 385
 		} else {
386 386
 			if (isset($globalArchive) && $globalArchive === TRUE) {
387
-				$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 
387
+				$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 
388 388
 				FROM spotter_live 
389 389
 				".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= spotter_live.date 
390 390
 				AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." 
391 391
 				AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong." 
392 392
 				AND spotter_live.latitude <> '0' AND spotter_live.longitude <> '0'";
393 393
 			} else {
394
-				$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 
394
+				$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 
395 395
 				FROM spotter_live 
396 396
 				INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate 
397 397
 				    FROM spotter_live l 
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 		try {
407 407
 			$sth = $this->db->prepare($query);
408 408
 			$sth->execute();
409
-		} catch(PDOException $e) {
409
+		} catch (PDOException $e) {
410 410
 			echo $e->getMessage();
411 411
 			die;
412 412
 		}
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
                 if ($interval == '1m')
456 456
                 {
457 457
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
458
-                } else if ($interval == '15m'){
458
+                } else if ($interval == '15m') {
459 459
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
460 460
                 } 
461 461
             }
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
464 464
         }
465 465
 
466
-                $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 
466
+                $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 
467 467
                    WHERE spotter_live.latitude <> '' 
468 468
                                    AND spotter_live.longitude <> '' 
469 469
                    ".$additional_query."
470 470
                    HAVING distance < :radius  
471 471
                                    ORDER BY distance";
472 472
 
473
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
473
+                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
474 474
 
475 475
                 return $spotter_array;
476 476
         }
@@ -488,9 +488,9 @@  discard block
 block discarded – undo
488 488
 		date_default_timezone_set('UTC');
489 489
 
490 490
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
491
-                $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';
491
+                $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';
492 492
 
493
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
493
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident), '', true);
494 494
 
495 495
 		return $spotter_array;
496 496
 	}
@@ -501,16 +501,16 @@  discard block
 block discarded – undo
501 501
 	* @return Array the spotter information
502 502
 	*
503 503
 	*/
504
-	public function getDateLiveSpotterDataByIdent($ident,$date)
504
+	public function getDateLiveSpotterDataByIdent($ident, $date)
505 505
 	{
506 506
 		$Spotter = new Spotter($this->db);
507 507
 		date_default_timezone_set('UTC');
508 508
 
509 509
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
510
-                $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';
510
+                $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';
511 511
 
512
-                $date = date('c',$date);
513
-		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
512
+                $date = date('c', $date);
513
+		$spotter_array = $Spotter->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
514 514
 
515 515
 		return $spotter_array;
516 516
 	}
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
 		$Spotter = new Spotter($this->db);
527 527
 		date_default_timezone_set('UTC');
528 528
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
529
-		$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';
530
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id),'',true);
529
+		$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';
530
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id), '', true);
531 531
 		return $spotter_array;
532 532
 	}
533 533
 
@@ -537,15 +537,15 @@  discard block
 block discarded – undo
537 537
 	* @return Array the spotter information
538 538
 	*
539 539
 	*/
540
-	public function getDateLiveSpotterDataById($id,$date)
540
+	public function getDateLiveSpotterDataById($id, $date)
541 541
 	{
542 542
 		$Spotter = new Spotter($this->db);
543 543
 		date_default_timezone_set('UTC');
544 544
 
545 545
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
546
-		$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';
547
-		$date = date('c',$date);
548
-		$spotter_array = $Spotter->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
546
+		$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';
547
+		$date = date('c', $date);
548
+		$spotter_array = $Spotter->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
549 549
 		return $spotter_array;
550 550
 	}
551 551
 
@@ -561,13 +561,13 @@  discard block
 block discarded – undo
561 561
 		date_default_timezone_set('UTC');
562 562
 
563 563
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
564
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
564
+                $query = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
565 565
 
566 566
     		try {
567 567
 			
568 568
 			$sth = $this->db->prepare($query);
569 569
 			$sth->execute(array(':ident' => $ident));
570
-		} catch(PDOException $e) {
570
+		} catch (PDOException $e) {
571 571
 			echo $e->getMessage();
572 572
 			die;
573 573
 		}
@@ -582,7 +582,7 @@  discard block
 block discarded – undo
582 582
 	* @return Array the spotter information
583 583
 	*
584 584
 	*/
585
-	public function getAllLiveSpotterDataById($id,$liveinterval = false)
585
+	public function getAllLiveSpotterDataById($id, $liveinterval = false)
586 586
 	{
587 587
 		global $globalDBdriver, $globalLiveInterval;
588 588
 		date_default_timezone_set('UTC');
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		try {
602 602
 			$sth = $this->db->prepare($query);
603 603
 			$sth->execute(array(':id' => $id));
604
-		} catch(PDOException $e) {
604
+		} catch (PDOException $e) {
605 605
 			echo $e->getMessage();
606 606
 			die;
607 607
 		}
@@ -619,12 +619,12 @@  discard block
 block discarded – undo
619 619
 	{
620 620
 		date_default_timezone_set('UTC');
621 621
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
622
-		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
622
+		$query = self::$global_query.' WHERE spotter_live.ident = :ident';
623 623
     		try {
624 624
 			
625 625
 			$sth = $this->db->prepare($query);
626 626
 			$sth->execute(array(':ident' => $ident));
627
-		} catch(PDOException $e) {
627
+		} catch (PDOException $e) {
628 628
 			echo $e->getMessage();
629 629
 			die;
630 630
 		}
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			
655 655
 			$sth = $this->db->prepare($query);
656 656
 			$sth->execute();
657
-		} catch(PDOException $e) {
657
+		} catch (PDOException $e) {
658 658
 			return "error";
659 659
 		}
660 660
 
@@ -677,14 +677,14 @@  discard block
 block discarded – undo
677 677
 				
678 678
 				$sth = $this->db->prepare($query);
679 679
 				$sth->execute();
680
-			} catch(PDOException $e) {
680
+			} catch (PDOException $e) {
681 681
 				return "error";
682 682
 			}
683 683
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
684 684
                         $i = 0;
685
-                        $j =0;
685
+                        $j = 0;
686 686
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
687
-			foreach($all as $row)
687
+			foreach ($all as $row)
688 688
 			{
689 689
 				$i++;
690 690
 				$j++;
@@ -692,9 +692,9 @@  discard block
 block discarded – undo
692 692
 					if ($globalDebug) echo ".";
693 693
 				    	try {
694 694
 						
695
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
695
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
696 696
 						$sth->execute();
697
-					} catch(PDOException $e) {
697
+					} catch (PDOException $e) {
698 698
 						return "error";
699 699
 					}
700 700
                                 	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
 			if ($i > 0) {
706 706
     				try {
707 707
 					
708
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
708
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
709 709
 					$sth->execute();
710
-				} catch(PDOException $e) {
710
+				} catch (PDOException $e) {
711 711
 					return "error";
712 712
 				}
713 713
 			}
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				
721 721
 				$sth = $this->db->prepare($query);
722 722
 				$sth->execute();
723
-			} catch(PDOException $e) {
723
+			} catch (PDOException $e) {
724 724
 				return "error";
725 725
 			}
726 726
 /*			$query_delete = "DELETE FROM spotter_live WHERE flightaware_id IN (";
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
 	public function deleteLiveSpotterDataByIdent($ident)
769 769
 	{
770 770
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
771
-		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
771
+		$query = 'DELETE FROM spotter_live WHERE ident = :ident';
772 772
         
773 773
     		try {
774 774
 			
775 775
 			$sth = $this->db->prepare($query);
776 776
 			$sth->execute(array(':ident' => $ident));
777
-		} catch(PDOException $e) {
777
+		} catch (PDOException $e) {
778 778
 			return "error";
779 779
 		}
780 780
 
@@ -790,13 +790,13 @@  discard block
 block discarded – undo
790 790
 	public function deleteLiveSpotterDataById($id)
791 791
 	{
792 792
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
793
-		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
793
+		$query = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
794 794
         
795 795
     		try {
796 796
 			
797 797
 			$sth = $this->db->prepare($query);
798 798
 			$sth->execute(array(':id' => $id));
799
-		} catch(PDOException $e) {
799
+		} catch (PDOException $e) {
800 800
 			return "error";
801 801
 		}
802 802
 
@@ -814,13 +814,13 @@  discard block
 block discarded – undo
814 814
 	{
815 815
 		global $globalDBdriver, $globalTimezone;
816 816
 		if ($globalDBdriver == 'mysql') {
817
-			$query  = 'SELECT spotter_live.ident FROM spotter_live 
817
+			$query = 'SELECT spotter_live.ident FROM spotter_live 
818 818
 				WHERE spotter_live.ident = :ident 
819 819
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
820 820
 				AND spotter_live.date < UTC_TIMESTAMP()';
821 821
 			$query_data = array(':ident' => $ident);
822 822
 		} else {
823
-			$query  = "SELECT spotter_live.ident FROM spotter_live 
823
+			$query = "SELECT spotter_live.ident FROM spotter_live 
824 824
 				WHERE spotter_live.ident = :ident 
825 825
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
826 826
 				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -829,8 +829,8 @@  discard block
 block discarded – undo
829 829
 		
830 830
 		$sth = $this->db->prepare($query);
831 831
 		$sth->execute($query_data);
832
-		$ident_result='';
833
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
832
+		$ident_result = '';
833
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
834 834
 		{
835 835
 			$ident_result = $row['ident'];
836 836
 		}
@@ -847,13 +847,13 @@  discard block
 block discarded – undo
847 847
 	{
848 848
 		global $globalDBdriver, $globalTimezone;
849 849
 		if ($globalDBdriver == 'mysql') {
850
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
850
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
851 851
 				WHERE spotter_live.ident = :ident 
852 852
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
853 853
 //				AND spotter_live.date < UTC_TIMESTAMP()";
854 854
 			$query_data = array(':ident' => $ident);
855 855
 		} else {
856
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
856
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
857 857
 				WHERE spotter_live.ident = :ident 
858 858
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
859 859
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 		
863 863
 		$sth = $this->db->prepare($query);
864 864
 		$sth->execute($query_data);
865
-		$ident_result='';
866
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
865
+		$ident_result = '';
866
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
867 867
 		{
868 868
 			$ident_result = $row['flightaware_id'];
869 869
 		}
@@ -880,13 +880,13 @@  discard block
 block discarded – undo
880 880
 	{
881 881
 		global $globalDBdriver, $globalTimezone;
882 882
 		if ($globalDBdriver == 'mysql') {
883
-			$query  = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
883
+			$query = 'SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
884 884
 				WHERE spotter_live.flightaware_id = :id 
885 885
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
886 886
 //				AND spotter_live.date < UTC_TIMESTAMP()";
887 887
 			$query_data = array(':id' => $id);
888 888
 		} else {
889
-			$query  = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
889
+			$query = "SELECT spotter_live.ident, spotter_live.flightaware_id FROM spotter_live 
890 890
 				WHERE spotter_live.flightaware_id = :id 
891 891
 				AND spotter_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
892 892
 //				AND spotter_live.date < now() AT TIME ZONE 'UTC'";
@@ -895,8 +895,8 @@  discard block
 block discarded – undo
895 895
 		
896 896
 		$sth = $this->db->prepare($query);
897 897
 		$sth->execute($query_data);
898
-		$ident_result='';
899
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
898
+		$ident_result = '';
899
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
900 900
 		{
901 901
 			$ident_result = $row['flightaware_id'];
902 902
 		}
@@ -913,13 +913,13 @@  discard block
 block discarded – undo
913 913
 	{
914 914
 		global $globalDBdriver, $globalTimezone;
915 915
 		if ($globalDBdriver == 'mysql') {
916
-			$query  = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
916
+			$query = 'SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
917 917
 				WHERE spotter_live.ModeS = :modes 
918 918
 				AND spotter_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
919 919
 //				AND spotter_live.date < UTC_TIMESTAMP()";
920 920
 			$query_data = array(':modes' => $modes);
921 921
 		} else {
922
-			$query  = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
922
+			$query = "SELECT spotter_live.ModeS, spotter_live.flightaware_id FROM spotter_live 
923 923
 				WHERE spotter_live.ModeS = :modes 
924 924
 				AND spotter_live.date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '30 MINUTE'";
925 925
 //			//	AND spotter_live.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
@@ -928,8 +928,8 @@  discard block
 block discarded – undo
928 928
 		
929 929
 		$sth = $this->db->prepare($query);
930 930
 		$sth->execute($query_data);
931
-		$ident_result='';
932
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
931
+		$ident_result = '';
932
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
933 933
 		{
934 934
 			//$ident_result = $row['spotter_live_id'];
935 935
 			$ident_result = $row['flightaware_id'];
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
 	* @return String success or false
949 949
 	*
950 950
 	*/
951
-	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 = '')
951
+	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 = '')
952 952
 	{
953 953
 		global $globalURL, $globalArchive, $globalDebug;
954 954
 		$Common = new Common();
@@ -1048,27 +1048,27 @@  discard block
 block discarded – undo
1048 1048
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
1049 1049
 
1050 1050
         
1051
-		$flightaware_id = filter_var($flightaware_id,FILTER_SANITIZE_STRING);
1052
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1053
-		$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
1054
-		$departure_airport_icao = filter_var($departure_airport_icao,FILTER_SANITIZE_STRING);
1055
-		$arrival_airport_icao = filter_var($arrival_airport_icao,FILTER_SANITIZE_STRING);
1056
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1057
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1058
-		$waypoints = filter_var($waypoints,FILTER_SANITIZE_STRING);
1059
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1060
-		$altitude_real = filter_var($altitude_real,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1061
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
1062
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1063
-		$squawk = filter_var($squawk,FILTER_SANITIZE_NUMBER_INT);
1064
-		$route_stop = filter_var($route_stop,FILTER_SANITIZE_STRING);
1065
-		$ModeS = filter_var($ModeS,FILTER_SANITIZE_STRING);
1066
-		$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_STRING);
1067
-		$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
1068
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
1069
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
1070
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
1071
-		$verticalrate = filter_var($verticalrate,FILTER_SANITIZE_NUMBER_INT);
1051
+		$flightaware_id = filter_var($flightaware_id, FILTER_SANITIZE_STRING);
1052
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1053
+		$aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
1054
+		$departure_airport_icao = filter_var($departure_airport_icao, FILTER_SANITIZE_STRING);
1055
+		$arrival_airport_icao = filter_var($arrival_airport_icao, FILTER_SANITIZE_STRING);
1056
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1057
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1058
+		$waypoints = filter_var($waypoints, FILTER_SANITIZE_STRING);
1059
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1060
+		$altitude_real = filter_var($altitude_real, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1061
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
1062
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1063
+		$squawk = filter_var($squawk, FILTER_SANITIZE_NUMBER_INT);
1064
+		$route_stop = filter_var($route_stop, FILTER_SANITIZE_STRING);
1065
+		$ModeS = filter_var($ModeS, FILTER_SANITIZE_STRING);
1066
+		$pilot_id = filter_var($pilot_id, FILTER_SANITIZE_STRING);
1067
+		$pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
1068
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
1069
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
1070
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
1071
+		$verticalrate = filter_var($verticalrate, FILTER_SANITIZE_NUMBER_INT);
1072 1072
 
1073 1073
 		$airline_name = '';
1074 1074
 		$airline_icao = '';
@@ -1090,10 +1090,10 @@  discard block
 block discarded – undo
1090 1090
 		$arrival_airport_country = '';
1091 1091
 		
1092 1092
             	
1093
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1094
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1095
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1096
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1093
+            	if ($squawk == '' || $Common->isInteger($squawk) === false) $squawk = NULL;
1094
+            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false) $verticalrate = NULL;
1095
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
1096
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
1097 1097
 		
1098 1098
 		$query = '';
1099 1099
 		if ($globalArchive) {
@@ -1104,19 +1104,19 @@  discard block
 block discarded – undo
1104 1104
 		$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, real_altitude) 
1105 1105
 		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, :real_altitude)';
1106 1106
 
1107
-		$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,':real_altitude' => $altitude_real);
1107
+		$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, ':real_altitude' => $altitude_real);
1108 1108
 		try {
1109 1109
 			
1110 1110
 			$sth = $this->db->prepare($query);
1111 1111
 			$sth->execute($query_values);
1112 1112
 			$sth->closeCursor();
1113
-		} catch(PDOException $e) {
1113
+		} catch (PDOException $e) {
1114 1114
 			return "error : ".$e->getMessage();
1115 1115
 		}
1116 1116
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1117 1117
 		    if ($globalDebug) echo '(Add to SBS archive : ';
1118 1118
 		    $SpotterArchive = new SpotterArchive($this->db);
1119
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1119
+		    $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time, $arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name, $verticalrate, $format_source, $source_name, $over_country);
1120 1120
 		    if ($globalDebug) echo $result.')';
1121 1121
 		} elseif ($globalDebug && $putinarchive !== true) {
1122 1122
 			echo '(Not adding to archive)';
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 
1130 1130
 	public function getOrderBy()
1131 1131
 	{
1132
-		$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"));
1132
+		$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"));
1133 1133
 		return $orderby;
1134 1134
 	}
1135 1135
 
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		$currentdate = date('Y-m-d');
34 34
 		$sourcestat = $Stats->getStatsSource($currentdate);
35 35
 		if (!empty($sourcestat)) {
36
-		    foreach($sourcestat as $srcst) {
36
+		    foreach ($sourcestat as $srcst) {
37 37
 		    	$type = $srcst['stats_type'];
38 38
 			if ($type == 'polar' || $type == 'hist') {
39 39
 			    $source = $srcst['source_name'];
40 40
 			    $data = $srcst['source_data'];
41
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
41
+			    $this->stats[$currentdate][$source][$type] = json_decode($data, true);
42 42
 	    		}
43 43
 		    }
44 44
 		}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     }
52 52
 
53
-    public function get_Schedule($id,$ident) {
53
+    public function get_Schedule($id, $ident) {
54 54
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
55 55
 	// Get schedule here, so it's done only one time
56 56
 	
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 		$schedule = $Schedule->fetchSchedule($operator);
76 76
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
77 77
 		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
78
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
79
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
78
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $schedule['DepartureTime']));
79
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $schedule['ArrivalTime']));
80 80
 		    // Should also check if route schedule = route from DB
81 81
 		    if ($schedule['DepartureAirportIATA'] != '') {
82 82
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 			    }
97 97
 			}
98 98
 		    }
99
-		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
99
+		    $Schedule->addSchedule($operator, $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time'], $schedule['Source']);
100 100
 		}
101 101
 	    } else $scheduleexist = true;
102 102
 	} else $scheduleexist = true;
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
        if ($scheduleexist) {
105 105
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
106 106
     		$sch = $Schedule->getSchedule($operator);
107
-		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
107
+		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport' => $sch['arrival_airport_icao'], 'departure_airport' => $sch['departure_airport_icao'], 'departure_airport_time' => $sch['departure_airport_time'], 'arrival_airport_time' => $sch['arrival_airport_time']));
108 108
        }
109 109
 	$Spotter->db = null;
110 110
 	$Schedule->db = null;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
132 132
     		    $Spotter = new Spotter($this->db);
133 133
         	    $real_arrival = $this->arrival($key);
134
-        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
134
+        	    if (isset($this->all_flights[$key]['altitude'])) $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
135 135
         	}
136 136
 	    }
137 137
 	}
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
         $airport_time = '';
146 146
         if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
147 147
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
148
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
148
+	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $globalClosestMinDist);
149 149
     	    if (isset($closestAirports[0])) {
150 150
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
151 151
         	    $airport_icao = $closestAirports[0]['icao'];
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         		    break;
161 161
         		}
162 162
         	    }
163
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
163
+        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude'] + 5000))) {
164 164
         		$airport_icao = $closestAirports[0]['icao'];
165 165
         		$airport_time = $this->all_flights[$key]['datetime'];
166 166
         	} else {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         } else {
174 174
         	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
175 175
         }
176
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
176
+        return array('airport_icao' => $airport_icao, 'airport_time' => $airport_time);
177 177
     }
178 178
 
179 179
 
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
185 185
 	foreach ($this->all_flights as $key => $flight) {
186 186
 	    if (isset($flight['lastupdate'])) {
187
-		if ($flight['lastupdate'] < (time()-5900)) {
187
+		if ($flight['lastupdate'] < (time() - 5900)) {
188 188
 		    $this->delKey($key);
189 189
 		}
190 190
 	    }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
 			$real_arrival = $this->arrival($key);
201 201
 			$Spotter = new Spotter($this->db);
202 202
 			if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
203
-				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
203
+				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'], $this->all_flights[$key]['ident'], $this->all_flights[$key]['latitude'], $this->all_flights[$key]['longitude'], $this->all_flights[$key]['altitude'], $this->all_flights[$key]['ground'], $this->all_flights[$key]['speed'], $this->all_flights[$key]['datetime'], $real_arrival['airport_icao'], $real_arrival['airport_time']);
204 204
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
205 205
 			}
206 206
 		}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	$send = false;
234 234
 	
235 235
 	// SBS format is CSV format
236
-	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
236
+	if (is_array($line) && (isset($line['hex']) || isset($line['id']))) {
237 237
 	    //print_r($line);
238 238
 	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
239 239
   	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
@@ -269,25 +269,25 @@  discard block
 block discarded – undo
269 269
 		if (!isset($this->all_flights[$id])) {
270 270
 		    if ($globalDebug) echo 'New flight...'."\n";
271 271
 		    $this->all_flights[$id] = array();
272
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
273
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
274
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
272
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
273
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => '', 'departure_airport' => '', 'arrival_airport' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'altitude_real' => '', 'altitude_previous' => '', 'heading' => '', 'departure_airport_time' => '', 'arrival_airport_time' => '', 'squawk' => '', 'route_stop' => '', 'registration' => '', 'pilot_id' => '', 'pilot_name' => '', 'waypoints' => '', 'ground' => '0', 'format_source' => '', 'source_name' => '', 'over_country' => '', 'verticalrate' => '', 'noarchive' => false, 'putinarchive' => true, 'source_type' => ''));
274
+		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('lastupdate' => time()));
275 275
 		    if (!isset($line['id'])) {
276 276
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
277 277
 //			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
278 278
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
279
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
279
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
280 280
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
281
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
281
+		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
282 282
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
283 283
 		}
284 284
 		if (isset($line['source_type']) && $line['source_type'] != '') {
285
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
285
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_type' => $line['source_type']));
286 286
 		}
287 287
 		
288 288
 		//print_r($this->all_flights);
289 289
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
290
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
290
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => trim($line['hex'])));
291 291
 		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
292 292
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
293 293
 		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
@@ -296,27 +296,27 @@  discard block
 block discarded – undo
296 296
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
297 297
 			    $Spotter = new Spotter($this->db);
298 298
 			    if (isset($this->all_flights[$id]['source_type'])) {
299
-				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
299
+				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']), $this->all_flights[$id]['source_type']);
300 300
 			    } else {
301 301
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
302 302
 			    }
303 303
 			    $Spotter->db = null;
304
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
305
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
304
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
305
+			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
306 306
 			}
307 307
 		    }
308 308
 		    if ($globalAllFlights !== FALSE) $dataFound = true;
309 309
 		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
310 310
 		}
311 311
 	        if (isset($line['id']) && !isset($line['hex'])) {
312
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
312
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('hex' => ''));
313 313
 	        }
314 314
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
315 315
 			$icao = $line['aircraft_icao'];
316 316
 			$Spotter = new Spotter($this->db);
317 317
 			if (isset($Spotter->aircraft_correct_icaotype[$icao])) $icao = $Spotter->aircraft_correct_icaotype[$icao];
318 318
 			$Spotter->db = null;
319
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $icao));
319
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $icao));
320 320
 		}
321 321
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_name'])) {
322 322
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 				$Spotter = new Spotter($this->db);
325 325
 				$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
326 326
 				$Spotter->db = null;
327
-				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
327
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
328 328
 			}
329 329
 		}
330 330
 		if (!isset($this->all_flights[$id]['aircraft_icao']) && isset($line['aircraft_type'])) {
@@ -332,15 +332,15 @@  discard block
 block discarded – undo
332 332
 			elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
333 333
 			elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
334 334
 			elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
335
-			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
335
+			if (isset($aircraft_icao)) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => $aircraft_icao));
336 336
 		}
337 337
 		if (!isset($this->all_flights[$id]['aircraft_icao'])) {
338
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
338
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('aircraft_icao' => 'NA'));
339 339
 		}
340 340
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
341
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
341
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
342 342
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
343
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
343
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => $line['datetime']));
344 344
 		    } else {
345 345
 				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
346 346
 				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
@@ -351,32 +351,32 @@  discard block
 block discarded – undo
351 351
 				*/
352 352
 				return '';
353 353
 		    }
354
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
354
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
355 355
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n";
356 356
 			return '';
357
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
357
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
358 358
 			if ($globalDebug) echo "!!! Date is in the future ".$line['datetime']." for ".$this->all_flights[$id]['id']." - format : ".$line['format_source']."!!!\n
359 359
 			";
360 360
 			return '';
361 361
 		} elseif (!isset($line['datetime'])) {
362 362
 			date_default_timezone_set('UTC');
363
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
363
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('datetime' => date('Y-m-d H:i:s')));
364 364
 		} else {
365 365
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!";
366 366
 			return '';
367 367
 		}
368 368
 
369 369
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
370
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
370
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('registration' => $line['registration']));
371 371
 		}
372 372
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
373
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
373
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('waypoints' => $line['waypoints']));
374 374
 		}
375 375
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
376
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
376
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_id' => trim($line['pilot_id'])));
377 377
 		}
378 378
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
379
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
379
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('pilot_name' => trim($line['pilot_name'])));
380 380
 		}
381 381
  
382 382
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
@@ -384,13 +384,13 @@  discard block
 block discarded – undo
384 384
 		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
385 385
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
386 386
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
387
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
388
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
389
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
390
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
391
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
387
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
388
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
389
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
390
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
391
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
392 392
 			} else {
393
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
393
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
394 394
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
395 395
 				$timeelapsed = microtime(true);
396 396
             			$Spotter = new Spotter($this->db);
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
401 401
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
402 402
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
403
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
403
+            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $fromsource);
404 404
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
405 405
 				$Spotter->db = null;
406
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
406
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
407 407
 			    }
408 408
 			}
409
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
409
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ident' => trim($line['ident'])));
410 410
 		    
411 411
 /*
412 412
 		    if (!isset($line['id'])) {
@@ -416,25 +416,25 @@  discard block
 block discarded – undo
416 416
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
417 417
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
418 418
   */
419
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
419
+		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
420 420
 
421 421
 		    //$putinarchive = true;
422 422
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
423
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
423
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport_time' => $line['departure_airport_time']));
424 424
 		    }
425 425
 		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
426
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
426
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('arrival_airport_time' => $line['arrival_airport_time']));
427 427
 		    }
428 428
 		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
429
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
429
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
430 430
 		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
431 431
 			$timeelapsed = microtime(true);
432 432
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
433 433
 				$Spotter = new Spotter($this->db);
434 434
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
435 435
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
436
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
437
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
436
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $line['departure_airport_icao'], 'arrival_airport' => $line['arrival_airport_icao'], 'route_stop' => ''));
437
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
438 438
                         }
439 439
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
440 440
 			$timeelapsed = microtime(true);
@@ -448,35 +448,35 @@  discard block
 block discarded – undo
448 448
 				$Translation->db = null;
449 449
 			    }
450 450
 			    $Spotter->db = null;
451
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
451
+			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
452 452
                     	}
453 453
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
454 454
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
455 455
 			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
456 456
 				//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['FromAirport_ICAO'],'arrival_airport' => $route['ToAirport_ICAO'],'route_stop' => $route['RouteStop']));
457
-		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
457
+		    		$this->all_flights[$id] = array_merge($this->all_flights[$id], array('departure_airport' => $route['fromairport_icao'], 'arrival_airport' => $route['toairport_icao'], 'route_stop' => $route['routestop']));
458 458
 		    	    }
459 459
 			}
460 460
 			if (!isset($globalFork)) $globalFork = TRUE;
461 461
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
462
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
462
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id, trim($line['ident']));
463 463
 			}
464 464
 		    }
465 465
 		}
466 466
 
467 467
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
468 468
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
469
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
470
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
469
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($line['speed'])));
470
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed_fromsrc' => true));
471 471
 		    //$dataFound = true;
472 472
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
473
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
473
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm');
474 474
 		    if ($distance > 1000 && $distance < 10000) {
475 475
 		    // use datetime
476 476
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
477 477
 			$speed = $speed*3.6;
478 478
 			if ($speed < 1000) {
479
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
479
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('speed' => round($speed)));
480 480
 	  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
481 481
 	  		} else {
482 482
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
492 492
 	    	    	return false;
493 493
 	    	    }
494
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
494
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time() - $this->all_flights[$id]['time_last_coord']);
495 495
 	    	    else unset($timediff);
496
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
496
+	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time() - $this->all_flights[$id]['time_last_archive_coord']);
497 497
 	    	    else unset($timediff_archive);
498 498
 	    	    if ($this->tmd > 5
499 499
 	    	        || (isset($line['format_source']) 
@@ -517,14 +517,14 @@  discard block
 block discarded – undo
517 517
 	    	    	|| ($timediff > 30 
518 518
 	    	    	    && isset($this->all_flights[$id]['latitude']) 
519 519
 	    	    	    && isset($this->all_flights[$id]['longitude']) 
520
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
520
+	    	    	    && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm'))
521 521
 	    	    	    )
522 522
 	    	    	) {
523 523
 
524 524
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
525 525
 			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
526 526
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
527
-				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
527
+				|| !$Common->checkLine($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['livedb_latitude'], $this->all_flights[$id]['livedb_longitude'], $line['latitude'], $line['longitude'])) {
528 528
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
529 529
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
530 530
 				$this->all_flights[$id]['putinarchive'] = true;
@@ -534,11 +534,11 @@  discard block
 block discarded – undo
534 534
 				    $timeelapsed = microtime(true);
535 535
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
536 536
 					$Spotter = new Spotter($this->db);
537
-					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
537
+					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
538 538
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
539 539
 					else $this->all_flights[$id]['over_country'] = '';
540 540
 					$Spotter->db = null;
541
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
541
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
542 542
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
543 543
 				    }
544 544
 				}
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 					$this->all_flights[$id]['time_last_coord'] = time();
565 565
 				}
566 566
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
567
-				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
567
+				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude'] - $line['latitude']) > 0.0001)) {
568 568
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
569 569
 				    $dataFound = true;
570 570
 				    $this->all_flights[$id]['time_last_coord'] = time();
571 571
 				}
572 572
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
573
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
573
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('latitude' => $line['latitude']));
574 574
 				/*
575 575
 				if (abs($this->all_flights[$id]['archive_latitude']-$this->all_flights[$id]['latitude']) > 0.3) {
576 576
 				    $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -592,13 +592,13 @@  discard block
 block discarded – undo
592 592
 					$this->all_flights[$id]['time_last_coord'] = time();
593 593
 				}
594 594
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
595
-				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
595
+				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude'] - $line['longitude']) > 0.0001)) {
596 596
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
597 597
 				    $dataFound = true;
598 598
 				    $this->all_flights[$id]['time_last_coord'] = time();
599 599
 				}
600 600
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
601
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
601
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('longitude' => $line['longitude']));
602 602
 				/*
603 603
 				if (abs($this->all_flights[$id]['archive_longitude']-$this->all_flights[$id]['longitude']) > 0.3) {
604 604
 				    $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
@@ -616,46 +616,46 @@  discard block
 block discarded – undo
616 616
 		    } else if ($globalDebug && $timediff > 30) {
617 617
 			$this->tmd = $this->tmd + 1;
618 618
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
619
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
620
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
619
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')."m -";
620
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
621 621
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
622 622
 		    }
623 623
 		}
624 624
 		if (isset($line['last_update']) && $line['last_update'] != '') {
625 625
 		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
626
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
626
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('last_update' => $line['last_update']));
627 627
 		}
628 628
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
629
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
629
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('verticalrate' => $line['verticalrate']));
630 630
 		    //$dataFound = true;
631 631
 		}
632 632
 		if (isset($line['format_source']) && $line['format_source'] != '') {
633
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
633
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('format_source' => $line['format_source']));
634 634
 		}
635 635
 		if (isset($line['source_name']) && $line['source_name'] != '') {
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
636
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('source_name' => $line['source_name']));
637 637
 		}
638 638
 		if (isset($line['emergency']) && $line['emergency'] != '') {
639
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
639
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('emergency' => $line['emergency']));
640 640
 		    //$dataFound = true;
641 641
 		}
642 642
 		if (isset($line['ground']) && $line['ground'] != '') {
643 643
 		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
644 644
 			// Here we force archive of flight because after ground it's a new one (or should be)
645
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
646
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
647
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
648
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
649
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
645
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
646
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
647
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
648
+		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
649
+			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
650 650
 		    }
651 651
 		    if ($line['ground'] != 1) $line['ground'] = 0;
652
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
652
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('ground' => $line['ground']));
653 653
 		    //$dataFound = true;
654 654
 		}
655 655
 		if (isset($line['squawk']) && $line['squawk'] != '') {
656 656
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
657 657
 			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
658
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
658
+			    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
659 659
 			    $highlight = '';
660 660
 			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
661 661
 			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
@@ -664,59 +664,59 @@  discard block
 block discarded – undo
664 664
 				$timeelapsed = microtime(true);
665 665
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
666 666
 				    $Spotter = new Spotter($this->db);
667
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
667
+				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'], $highlight);
668 668
 				    $Spotter->db = null;
669
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
669
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
670 670
 				}
671 671
 				//$putinarchive = true;
672 672
 				//$highlight = '';
673 673
 			    }
674 674
 			    
675
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
675
+		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id], array('squawk' => $line['squawk']));
676 676
 		    //$dataFound = true;
677 677
 		}
678 678
 
679 679
 		if (isset($line['altitude']) && $line['altitude'] != '') {
680 680
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
681
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
682
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
683
-			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
681
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
682
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude' => round($line['altitude']/100)));
683
+			$this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_real' => $line['altitude']));
684 684
 			//$dataFound = true;
685 685
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
686 686
 		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
687 687
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
688 688
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
689
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
690
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
691
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
692
-				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
693
-				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
689
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('addedSpotter' => 0));
690
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 1));
691
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $id.'-'.date('YmdHi')));
692
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $line['id']));
693
+				elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
694 694
 			}
695 695
 		    }
696
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
696
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('altitude_previous' => $line['altitude']));
697 697
 		}
698 698
 
699 699
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
700
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
700
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('noarchive' => true));
701 701
 		}
702 702
 		
703 703
 		if (isset($line['heading']) && $line['heading'] != '') {
704
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
705
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
706
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
704
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading'] - round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
705
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($line['heading'])));
706
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading_fromsrc' => true));
707 707
 		    //$dataFound = true;
708 708
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
709
-  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
710
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
711
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
709
+  		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'], $this->all_flights[$id]['archive_longitude'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
710
+		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => round($heading)));
711
+		    if (abs($this->all_flights[$id]['heading'] - round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
712 712
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['id']." : ".$heading."\n";
713 713
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
714 714
   		    // If not enough messages and ACARS set heading to 0
715
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
715
+  		    $this->all_flights[$id] = array_merge($this->all_flights[$id], array('heading' => 0));
716 716
   		}
717
-		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
718
-		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
719
-		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
717
+		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
718
+		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
719
+		elseif ($globalDaemon === TRUE && isset($globalAircraftMinUpdate) && $globalAircraftMinUpdate != '' && isset($this->all_flights[$id]['lastupdate']) && time() - $this->all_flights[$id]['lastupdate'] < $globalMinupdate) $dataFound = false;
720 720
 
721 721
 //		print_r($this->all_flights[$id]);
722 722
 		//gets the callsign from the last hour
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
728 728
 		    $this->all_flights[$id]['lastupdate'] = time();
729 729
 		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
730
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
730
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == '' || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
731 731
 			    //print_r($this->all_flights);
732 732
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
733 733
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
@@ -738,61 +738,61 @@  discard block
 block discarded – undo
738 738
 				    $SpotterLive = new SpotterLive($this->db);
739 739
 				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
740 740
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
741
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
741
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
742 742
 				    } elseif (isset($line['id'])) {
743 743
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
744
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
744
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
745 745
 				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
746 746
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
747
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
747
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
748 748
 				    } else $recent_ident = '';
749
-				    $SpotterLive->db=null;
749
+				    $SpotterLive->db = null;
750 750
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
751 751
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
752 752
 				} else $recent_ident = '';
753 753
 			    } else {
754 754
 				$recent_ident = '';
755
-				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
755
+				$this->all_flights[$id] = array_merge($this->all_flights[$id], array('forcenew' => 0));
756 756
 			    }
757 757
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
758
-			    if($recent_ident == "")
758
+			    if ($recent_ident == "")
759 759
 			    {
760 760
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
761 761
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
762 762
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
763 763
 				//adds the spotter data for the archive
764 764
 				$ignoreImport = false;
765
-				foreach($globalAirportIgnore as $airportIgnore) {
765
+				foreach ($globalAirportIgnore as $airportIgnore) {
766 766
 				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
767 767
 					$ignoreImport = true;
768 768
 				    }
769 769
 				}
770 770
 				if (count($globalAirportAccept) > 0) {
771 771
 				    $ignoreImport = true;
772
-				    foreach($globalAirportIgnore as $airportIgnore) {
772
+				    foreach ($globalAirportIgnore as $airportIgnore) {
773 773
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
774 774
 					    $ignoreImport = false;
775 775
 					}
776 776
 				    }
777 777
 				}
778 778
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
779
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
780
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
779
+				    foreach ($globalAirlineIgnore as $airlineIgnore) {
780
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
781 781
 					    $ignoreImport = true;
782 782
 					}
783 783
 				    }
784 784
 				}
785 785
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
786 786
 				    $ignoreImport = true;
787
-				    foreach($globalAirlineAccept as $airlineAccept) {
788
-					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
787
+				    foreach ($globalAirlineAccept as $airlineAccept) {
788
+					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
789 789
 					    $ignoreImport = false;
790 790
 					}
791 791
 				    }
792 792
 				}
793 793
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
794 794
 				    $ignoreImport = true;
795
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
795
+				    foreach ($globalPilotIdAccept as $pilotIdAccept) {
796 796
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
797 797
 					    $ignoreImport = false;
798 798
 					}
@@ -804,32 +804,32 @@  discard block
 block discarded – undo
804 804
 				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
805 805
 				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
806 806
 				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
807
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
807
+				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
808 808
 				    $timeelapsed = microtime(true);
809 809
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
810 810
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
811 811
 					    $Spotter = new Spotter($this->db);
812
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
812
+					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $highlight, $this->all_flights[$id]['hex'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['source_type']);
813 813
 					    $Spotter->db = null;
814 814
 					    if ($globalDebug && isset($result)) echo $result."\n";
815 815
 					}
816 816
 				    }
817
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
817
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
818 818
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
819 819
 
820 820
 				    // Add source stat in DB
821 821
 				    $Stats = new Stats($this->db);
822 822
 				    if (!empty($this->stats)) {
823 823
 					if ($globalDebug) echo 'Add source stats : ';
824
-				        foreach($this->stats as $date => $data) {
825
-					    foreach($data as $source => $sourced) {
824
+				        foreach ($this->stats as $date => $data) {
825
+					    foreach ($data as $source => $sourced) {
826 826
 					        //print_r($sourced);
827
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
828
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
827
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar', $date);
828
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist', $date);
829 829
 				    		if (isset($sourced['msg'])) {
830 830
 				    		    if (time() - $sourced['msg']['date'] > 10) {
831 831
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
832
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
832
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg', $date);
833 833
 			    			        unset($this->stats[$date][$source]['msg']);
834 834
 			    			    }
835 835
 			    			}
@@ -867,14 +867,14 @@  discard block
 block discarded – undo
867 867
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
868 868
 					    $SpotterLive = new SpotterLive($this->db);
869 869
 					    $SpotterLive->deleteLiveSpotterData();
870
-					    $SpotterLive->db=null;
870
+					    $SpotterLive->db = null;
871 871
 					}
872 872
 				    }
873 873
 				    if ($globalDebug) echo " Done\n";
874 874
 				    $this->last_delete = time();
875 875
 				}
876 876
 			    } else {
877
-				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
877
+				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
878 878
 				    $this->all_flights[$id]['id'] = $recent_ident;
879 879
 				    $this->all_flights[$id]['addedSpotter'] = 1;
880 880
 				}
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
883 883
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
884 884
 					    $Spotter = new Spotter($this->db);
885
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
885
+					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['arrival_airport_time']);
886 886
 					    $Spotter->db = null;
887 887
 					}
888 888
 				    }
@@ -908,37 +908,37 @@  discard block
 block discarded – undo
908 908
 		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
909 909
 		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
910 910
 
911
-		    foreach($globalAirportIgnore as $airportIgnore) {
911
+		    foreach ($globalAirportIgnore as $airportIgnore) {
912 912
 		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
913 913
 			    $ignoreImport = true;
914 914
 			}
915 915
 		    }
916 916
 		    if (count($globalAirportAccept) > 0) {
917 917
 		        $ignoreImport = true;
918
-		        foreach($globalAirportIgnore as $airportIgnore) {
918
+		        foreach ($globalAirportIgnore as $airportIgnore) {
919 919
 			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
920 920
 				$ignoreImport = false;
921 921
 			    }
922 922
 			}
923 923
 		    }
924 924
 		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
925
-			foreach($globalAirlineIgnore as $airlineIgnore) {
926
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
925
+			foreach ($globalAirlineIgnore as $airlineIgnore) {
926
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineIgnore)) {
927 927
 				$ignoreImport = true;
928 928
 			    }
929 929
 			}
930 930
 		    }
931 931
 		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
932 932
 			$ignoreImport = true;
933
-			foreach($globalAirlineAccept as $airlineAccept) {
934
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
933
+			foreach ($globalAirlineAccept as $airlineAccept) {
934
+			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 4), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'], 0, 3), -1, 1)) && substr($this->all_flights[$id]['ident'], 0, 2) == $airlineAccept)) {
935 935
 				$ignoreImport = false;
936 936
 			    }
937 937
 			}
938 938
 		    }
939 939
 		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
940 940
 			$ignoreImport = true;
941
-			foreach($globalPilotIdAccept as $pilotIdAccept) {
941
+			foreach ($globalPilotIdAccept as $pilotIdAccept) {
942 942
 			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
943 943
 			        $ignoreImport = false;
944 944
 			    }
@@ -946,23 +946,23 @@  discard block
 block discarded – undo
946 946
 		    }
947 947
 
948 948
 		    if (!$ignoreImport) {
949
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
950
-				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
949
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
950
+				if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id], array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
951 951
 				$timeelapsed = microtime(true);
952 952
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
953 953
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
954 954
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
955 955
 					$SpotterLive = new SpotterLive($this->db);
956
-					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
956
+					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
957 957
 					$SpotterLive->db = null;
958 958
 					if ($globalDebug) echo $result."\n";
959 959
 				    }
960 960
 				}
961 961
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
962
-					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
962
+					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'], $this->all_flights[$id]['route_stop'], $this->all_flights[$id]['hex'], $this->all_flights[$id]['putinarchive'], $this->all_flights[$id]['registration'], $this->all_flights[$id]['pilot_id'], $this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'], $this->all_flights[$id]['format_source'], $this->all_flights[$id]['source_name'], $this->all_flights[$id]['over_country']);
963 963
 				}
964 964
 				$this->all_flights[$id]['putinarchive'] = false;
965
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
965
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
966 966
 
967 967
 				// Put statistics in $this->stats variable
968 968
 				//if ($line['format_source'] != 'aprs') {
@@ -981,19 +981,19 @@  discard block
 block discarded – undo
981 981
 							$latitude = $globalCenterLatitude;
982 982
 							$longitude = $globalCenterLongitude;
983 983
 						}
984
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
984
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
985 985
 					} else {
986 986
 						$latitude = $this->source_location[$source]['latitude'];
987 987
 						$longitude = $this->source_location[$source]['longitude'];
988 988
 					}
989
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
989
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
990 990
 					//$stats_heading = $stats_heading%22.5;
991 991
 					$stats_heading = round($stats_heading/22.5);
992
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
992
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude']);
993 993
 					$current_date = date('Y-m-d');
994 994
 					if ($stats_heading == 16) $stats_heading = 0;
995 995
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
996
-						for ($i=0;$i<=15;$i++) {
996
+						for ($i = 0; $i <= 15; $i++) {
997 997
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
998 998
 						}
999 999
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -1008,9 +1008,9 @@  discard block
 block discarded – undo
1008 1008
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1009 1009
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1010 1010
 						    end($this->stats[$current_date][$source]['hist']);
1011
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1011
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
1012 1012
 						} else $mini = 0;
1013
-						for ($i=$mini;$i<=$distance;$i+=10) {
1013
+						for ($i = $mini; $i <= $distance; $i += 10) {
1014 1014
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1015 1015
 						}
1016 1016
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -1023,7 +1023,7 @@  discard block
 block discarded – undo
1023 1023
 				$this->all_flights[$id]['lastupdate'] = time();
1024 1024
 				if ($this->all_flights[$id]['putinarchive']) $send = true;
1025 1025
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1026
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1026
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
1027 1027
 			//$this->del();
1028 1028
 			
1029 1029
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
Please login to merge, or discard this patch.