Completed
Push — master ( 14d49d...7c97e3 )
by Yannick
86:48 queued 56:08
created
require/class.Translation.php 4 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 
75 75
     /**
76 76
      * @param $ident
77
-     * @param $correct_ident
78
-     * @param $source
77
+     * @param string $correct_ident
78
+     * @param string $source
79 79
      * @return string
80 80
      */
81 81
     public function addOperator($ident, $correct_ident, $source) {
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 
92 92
     /**
93 93
      * @param $ident
94
-     * @param $correct_ident
95
-     * @param $source
94
+     * @param string $correct_ident
95
+     * @param string $source
96 96
      * @return string
97 97
      */
98 98
     public function updateOperator($ident, $correct_ident, $source) {
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 	}
26 26
 
27 27
 	/**
28
-	* Change IATA to ICAO value for ident
29
-	* 
30
-	* @param string $ident ident
31
-	* @return string the icao
32
-	*/
28
+	 * Change IATA to ICAO value for ident
29
+	 * 
30
+	 * @param string $ident ident
31
+	 * @return string the icao
32
+	 */
33 33
 	public function ident2icao($ident) {
34 34
 		$Spotter = new Spotter();
35 35
 		if (!is_numeric(substr($ident, 0, 3))) {
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 		return $icao;
53 53
 	}
54 54
 
55
-    /**
56
-     * @param $ident
57
-     * @return string
58
-     */
59
-    public function getOperator($ident) {
55
+	/**
56
+	 * @param $ident
57
+	 * @return string
58
+	 */
59
+	public function getOperator($ident) {
60 60
 		$query = "SELECT * FROM translation WHERE Operator = :ident LIMIT 1";
61 61
 		$query_values = array(':ident' => $ident);
62 62
 		try {
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
 		} else return $ident;
73 73
 	}
74 74
 
75
-    /**
76
-     * @param $ident
77
-     * @param $correct_ident
78
-     * @param $source
79
-     * @return string
80
-     */
81
-    public function addOperator($ident, $correct_ident, $source) {
75
+	/**
76
+	 * @param $ident
77
+	 * @param $correct_ident
78
+	 * @param $source
79
+	 * @return string
80
+	 */
81
+	public function addOperator($ident, $correct_ident, $source) {
82 82
 		$query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
83 83
 		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
84 84
 		try {
@@ -89,13 +89,13 @@  discard block
 block discarded – undo
89 89
 		}
90 90
 	}
91 91
 
92
-    /**
93
-     * @param $ident
94
-     * @param $correct_ident
95
-     * @param $source
96
-     * @return string
97
-     */
98
-    public function updateOperator($ident, $correct_ident, $source) {
92
+	/**
93
+	 * @param $ident
94
+	 * @param $correct_ident
95
+	 * @param $source
96
+	 * @return string
97
+	 */
98
+	public function updateOperator($ident, $correct_ident, $source) {
99 99
 		$query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
100 100
 		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
101 101
 		try {
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 		}
107 107
 	}
108 108
 
109
-    /**
110
-     * @param $ident
111
-     * @param bool $web
112
-     * @return string
113
-     */
114
-    public function checkTranslation($ident, $web = false) {
109
+	/**
110
+	 * @param $ident
111
+	 * @param bool $web
112
+	 * @return string
113
+	 */
114
+	public function checkTranslation($ident, $web = false) {
115 115
 		global $globalTranslationSources, $globalTranslationFetch;
116 116
 		//if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
117 117
 		$globalTranslationSources = array();
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
 			} else return $ident;
42 42
 		} else return $ident;
43 43
 		if ($airline_icao == 'AF') {
44
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
45
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
44
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
45
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
46 46
 		} else {
47 47
 			$identicao = $Spotter->getAllAirlineInfo($airline_icao);
48 48
 			if (isset($identicao[0])) {
49
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
49
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
50 50
 			} else $icao = $ident;
51 51
 		}
52 52
 		return $icao;
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		try {
63 63
 			$sth = $this->db->prepare($query);
64 64
 			$sth->execute($query_values);
65
-		} catch(PDOException $e) {
65
+		} catch (PDOException $e) {
66 66
 			return "error : ".$e->getMessage();
67 67
 		}
68 68
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function addOperator($ident, $correct_ident, $source) {
82 82
 		$query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
83
-		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
83
+		$query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source);
84 84
 		try {
85 85
 			$sth = $this->db->prepare($query);
86 86
 			$sth->execute($query_values);
87
-		} catch(PDOException $e) {
87
+		} catch (PDOException $e) {
88 88
 			return "error : ".$e->getMessage();
89 89
 		}
90 90
 	}
@@ -97,11 +97,11 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public function updateOperator($ident, $correct_ident, $source) {
99 99
 		$query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
100
-		$query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
100
+		$query_values = array(':ident' => $ident, ':correct_ident' => $correct_ident, ':source' => $source);
101 101
 		try {
102 102
 			$sth = $this->db->prepare($query);
103 103
 			$sth->execute($query_values);
104
-		} catch(PDOException $e) {
104
+		} catch (PDOException $e) {
105 105
 			return "error : ".$e->getMessage();
106 106
 		}
107 107
 	}
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -38,16 +38,25 @@  discard block
 block discarded – undo
38 38
 			} elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
39 39
 				//$airline_icao = substr($ident, 0, 3);
40 40
 				return $ident;
41
-			} else return $ident;
42
-		} else return $ident;
41
+			} else {
42
+				return $ident;
43
+			}
44
+		} else {
45
+			return $ident;
46
+		}
43 47
 		if ($airline_icao == 'AF') {
44
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
45
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
48
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
49
+				$icao = $ident;
50
+			} else {
51
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
52
+			}
46 53
 		} else {
47 54
 			$identicao = $Spotter->getAllAirlineInfo($airline_icao);
48 55
 			if (isset($identicao[0])) {
49 56
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
50
-			} else $icao = $ident;
57
+			} else {
58
+				$icao = $ident;
59
+			}
51 60
 		}
52 61
 		return $icao;
53 62
 	}
@@ -69,7 +78,9 @@  discard block
 block discarded – undo
69 78
 		$sth->closeCursor();
70 79
 		if (isset($row['operator_correct'])) {
71 80
 			return $row['operator_correct'];
72
-		} else return $ident;
81
+		} else {
82
+			return $ident;
83
+		}
73 84
 	}
74 85
 
75 86
     /**
@@ -115,7 +126,9 @@  discard block
 block discarded – undo
115 126
 		global $globalTranslationSources, $globalTranslationFetch;
116 127
 		//if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
117 128
 		$globalTranslationSources = array();
118
-		if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE;
129
+		if (!isset($globalTranslationFetch)) {
130
+			$globalTranslationFetch = TRUE;
131
+		}
119 132
 		//echo "Check Translation for ".$ident."...";
120 133
 		$correct = $this->getOperator($ident);
121 134
 		if ($correct != '' && $correct != $ident) {
Please login to merge, or discard this patch.
require/class.TrackerArchive.php 3 patches
Indentation   +1070 added lines, -1070 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 		if ($this->db === null) die('Error: No DB connection. (TrackerArchive)');
17 17
 	}
18 18
 
19
-    /**
20
-     * Get SQL query part for filter used
21
-     * @param array $filter the filter
22
-     * @param bool $where
23
-     * @param bool $and
24
-     * @return string the SQL part
25
-     */
19
+	/**
20
+	 * Get SQL query part for filter used
21
+	 * @param array $filter the filter
22
+	 * @param bool $where
23
+	 * @param bool $and
24
+	 * @return string the SQL part
25
+	 */
26 26
 	public function getFilter($filter = array(),$where = false,$and = false) {
27 27
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
28 28
 		$filters = array();
@@ -91,27 +91,27 @@  discard block
 block discarded – undo
91 91
 		return $filter_query;
92 92
 	}
93 93
 
94
-    /**
95
-     * Add to tracker_archive
96
-     *
97
-     * @param string $famtrackid
98
-     * @param string $ident
99
-     * @param string $latitude
100
-     * @param string $longitude
101
-     * @param string $altitude
102
-     * @param string $heading
103
-     * @param string $groundspeed
104
-     * @param string $date
105
-     * @param bool $putinarchive
106
-     * @param string $comment
107
-     * @param string $type
108
-     * @param bool $noarchive
109
-     * @param string $format_source
110
-     * @param string $source_name
111
-     * @param string $over_country
112
-     * @return string
113
-     */
114
-    public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
94
+	/**
95
+	 * Add to tracker_archive
96
+	 *
97
+	 * @param string $famtrackid
98
+	 * @param string $ident
99
+	 * @param string $latitude
100
+	 * @param string $longitude
101
+	 * @param string $altitude
102
+	 * @param string $heading
103
+	 * @param string $groundspeed
104
+	 * @param string $date
105
+	 * @param bool $putinarchive
106
+	 * @param string $comment
107
+	 * @param string $type
108
+	 * @param bool $noarchive
109
+	 * @param string $format_source
110
+	 * @param string $source_name
111
+	 * @param string $over_country
112
+	 * @return string
113
+	 */
114
+	public function addTrackerArchiveData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '') {
115 115
 		require_once(dirname(__FILE__).'/class.Tracker.php');
116 116
 		if ($over_country == '') {
117 117
 			$Tracker = new Tracker($this->db);
@@ -134,40 +134,40 @@  discard block
 block discarded – undo
134 134
 	}
135 135
 
136 136
 
137
-    /**
138
-     * Gets all the spotter information based on a particular callsign
139
-     *
140
-     * @param $ident
141
-     * @return array the spotter information
142
-     */
143
-    public function getLastArchiveTrackerDataByIdent($ident)
144
-    {
145
-        $Tracker = new Tracker($this->db);
146
-        date_default_timezone_set('UTC');
147
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
148
-        $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
149
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
150
-        return $spotter_array;
151
-    }
152
-
153
-
154
-    /**
155
-     * Gets last the spotter information based on a particular id
156
-     *
157
-     * @param $id
158
-     * @return array the spotter information
159
-     */
160
-    public function getLastArchiveTrackerDataById($id)
161
-    {
162
-        $Tracker = new Tracker($this->db);
163
-        date_default_timezone_set('UTC');
164
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
165
-        //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
166
-        //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
167
-        $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
137
+	/**
138
+	 * Gets all the spotter information based on a particular callsign
139
+	 *
140
+	 * @param $ident
141
+	 * @return array the spotter information
142
+	 */
143
+	public function getLastArchiveTrackerDataByIdent($ident)
144
+	{
145
+		$Tracker = new Tracker($this->db);
146
+		date_default_timezone_set('UTC');
147
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
148
+		$query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
149
+		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
150
+		return $spotter_array;
151
+	}
152
+
153
+
154
+	/**
155
+	 * Gets last the spotter information based on a particular id
156
+	 *
157
+	 * @param $id
158
+	 * @return array the spotter information
159
+	 */
160
+	public function getLastArchiveTrackerDataById($id)
161
+	{
162
+		$Tracker = new Tracker($this->db);
163
+		date_default_timezone_set('UTC');
164
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
165
+		//$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
166
+		//$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
167
+		$query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
168 168
 
169 169
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
170
-        /*
170
+		/*
171 171
                 try {
172 172
                         $Connection = new Connection();
173 173
                         $sth = Connection->$db->prepare($query);
@@ -177,245 +177,245 @@  discard block
 block discarded – undo
177 177
                 }
178 178
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
179 179
                 */
180
-        $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
181
-
182
-        return $spotter_array;
183
-    }
184
-
185
-    /**
186
-     * Gets all the spotter information based on a particular id
187
-     *
188
-     * @param $id
189
-     * @param string $date
190
-     * @return array the spotter information
191
-     */
192
-    public function getAllArchiveTrackerDataById($id,$date = '')
193
-    {
194
-        date_default_timezone_set('UTC');
195
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
196
-        if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
197
-        else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
180
+		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
181
+
182
+		return $spotter_array;
183
+	}
184
+
185
+	/**
186
+	 * Gets all the spotter information based on a particular id
187
+	 *
188
+	 * @param $id
189
+	 * @param string $date
190
+	 * @return array the spotter information
191
+	 */
192
+	public function getAllArchiveTrackerDataById($id,$date = '')
193
+	{
194
+		date_default_timezone_set('UTC');
195
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
196
+		if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
197
+		else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
198 198
 
199 199
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
200 200
 
201
-        try {
202
-            $sth = $this->db->prepare($query);
203
-            $sth->execute(array(':id' => $id));
204
-        } catch(PDOException $e) {
205
-            echo $e->getMessage();
206
-            die;
207
-        }
208
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
209
-
210
-        return $spotter_array;
211
-    }
212
-
213
-    /**
214
-     * Gets coordinate & time spotter information based on a particular id
215
-     *
216
-     * @param $id
217
-     * @return array the spotter information
218
-     */
219
-    public function getCoordArchiveTrackerDataById($id)
220
-    {
221
-        date_default_timezone_set('UTC');
222
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
223
-        $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
201
+		try {
202
+			$sth = $this->db->prepare($query);
203
+			$sth->execute(array(':id' => $id));
204
+		} catch(PDOException $e) {
205
+			echo $e->getMessage();
206
+			die;
207
+		}
208
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
209
+
210
+		return $spotter_array;
211
+	}
212
+
213
+	/**
214
+	 * Gets coordinate & time spotter information based on a particular id
215
+	 *
216
+	 * @param $id
217
+	 * @return array the spotter information
218
+	 */
219
+	public function getCoordArchiveTrackerDataById($id)
220
+	{
221
+		date_default_timezone_set('UTC');
222
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
223
+		$query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
224 224
 
225 225
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
226 226
 
227
-        try {
228
-            $sth = $this->db->prepare($query);
229
-            $sth->execute(array(':id' => $id));
230
-        } catch(PDOException $e) {
231
-            echo $e->getMessage();
232
-            die;
233
-        }
234
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
235
-
236
-        return $spotter_array;
237
-    }
238
-
239
-
240
-    /**
241
-     * Gets altitude information based on a particular callsign
242
-     *
243
-     * @param $ident
244
-     * @return array the spotter information
245
-     */
246
-    public function getAltitudeArchiveTrackerDataByIdent($ident)
247
-    {
248
-
249
-        date_default_timezone_set('UTC');
250
-
251
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
252
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
253
-
254
-        try {
255
-            $sth = $this->db->prepare($query);
256
-            $sth->execute(array(':ident' => $ident));
257
-        } catch(PDOException $e) {
258
-            echo $e->getMessage();
259
-            die;
260
-        }
261
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
262
-
263
-        return $spotter_array;
264
-    }
265
-
266
-    /**
267
-     * Gets altitude information based on a particular id
268
-     *
269
-     * @param $id
270
-     * @return array the spotter information
271
-     */
272
-    public function getAltitudeArchiveTrackerDataById($id)
273
-    {
274
-
275
-        date_default_timezone_set('UTC');
276
-
277
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
278
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
279
-
280
-        try {
281
-            $sth = $this->db->prepare($query);
282
-            $sth->execute(array(':id' => $id));
283
-        } catch(PDOException $e) {
284
-            echo $e->getMessage();
285
-            die;
286
-        }
287
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
288
-
289
-        return $spotter_array;
290
-    }
291
-
292
-    /**
293
-     * Gets altitude & speed information based on a particular id
294
-     *
295
-     * @param $id
296
-     * @return array the spotter information
297
-     */
298
-    public function getAltitudeSpeedArchiveTrackerDataById($id)
299
-    {
300
-
301
-        date_default_timezone_set('UTC');
302
-
303
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
304
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
305
-
306
-        try {
307
-            $sth = $this->db->prepare($query);
308
-            $sth->execute(array(':id' => $id));
309
-        } catch(PDOException $e) {
310
-            echo $e->getMessage();
311
-            die;
312
-        }
313
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
314
-
315
-        return $spotter_array;
316
-    }
317
-
318
-
319
-    /**
320
-     * Gets altitude information based on a particular callsign
321
-     *
322
-     * @param $ident
323
-     * @return array the spotter information
324
-     */
325
-    public function getLastAltitudeArchiveTrackerDataByIdent($ident)
326
-    {
327
-
328
-        date_default_timezone_set('UTC');
329
-
330
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
331
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
227
+		try {
228
+			$sth = $this->db->prepare($query);
229
+			$sth->execute(array(':id' => $id));
230
+		} catch(PDOException $e) {
231
+			echo $e->getMessage();
232
+			die;
233
+		}
234
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
235
+
236
+		return $spotter_array;
237
+	}
238
+
239
+
240
+	/**
241
+	 * Gets altitude information based on a particular callsign
242
+	 *
243
+	 * @param $ident
244
+	 * @return array the spotter information
245
+	 */
246
+	public function getAltitudeArchiveTrackerDataByIdent($ident)
247
+	{
248
+
249
+		date_default_timezone_set('UTC');
250
+
251
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
252
+		$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
253
+
254
+		try {
255
+			$sth = $this->db->prepare($query);
256
+			$sth->execute(array(':ident' => $ident));
257
+		} catch(PDOException $e) {
258
+			echo $e->getMessage();
259
+			die;
260
+		}
261
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
262
+
263
+		return $spotter_array;
264
+	}
265
+
266
+	/**
267
+	 * Gets altitude information based on a particular id
268
+	 *
269
+	 * @param $id
270
+	 * @return array the spotter information
271
+	 */
272
+	public function getAltitudeArchiveTrackerDataById($id)
273
+	{
274
+
275
+		date_default_timezone_set('UTC');
276
+
277
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
278
+		$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
279
+
280
+		try {
281
+			$sth = $this->db->prepare($query);
282
+			$sth->execute(array(':id' => $id));
283
+		} catch(PDOException $e) {
284
+			echo $e->getMessage();
285
+			die;
286
+		}
287
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
288
+
289
+		return $spotter_array;
290
+	}
291
+
292
+	/**
293
+	 * Gets altitude & speed information based on a particular id
294
+	 *
295
+	 * @param $id
296
+	 * @return array the spotter information
297
+	 */
298
+	public function getAltitudeSpeedArchiveTrackerDataById($id)
299
+	{
300
+
301
+		date_default_timezone_set('UTC');
302
+
303
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
304
+		$query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
305
+
306
+		try {
307
+			$sth = $this->db->prepare($query);
308
+			$sth->execute(array(':id' => $id));
309
+		} catch(PDOException $e) {
310
+			echo $e->getMessage();
311
+			die;
312
+		}
313
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
314
+
315
+		return $spotter_array;
316
+	}
317
+
318
+
319
+	/**
320
+	 * Gets altitude information based on a particular callsign
321
+	 *
322
+	 * @param $ident
323
+	 * @return array the spotter information
324
+	 */
325
+	public function getLastAltitudeArchiveTrackerDataByIdent($ident)
326
+	{
327
+
328
+		date_default_timezone_set('UTC');
329
+
330
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
331
+		$query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
332 332
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
333 333
 
334
-        try {
335
-            $sth = $this->db->prepare($query);
336
-            $sth->execute(array(':ident' => $ident));
337
-        } catch(PDOException $e) {
338
-            echo $e->getMessage();
339
-            die;
340
-        }
341
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
342
-
343
-        return $spotter_array;
344
-    }
345
-
346
-
347
-    /**
348
-     * Gets all the archive spotter information
349
-     *
350
-     * @param $ident
351
-     * @param $famtrackid
352
-     * @param $date
353
-     * @return array the spotter information
354
-     */
355
-    public function getTrackerArchiveData($ident,$famtrackid,$date)
356
-    {
357
-        $Tracker = new Tracker($this->db);
358
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
359
-        $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
360
-
361
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
362
-
363
-        return $spotter_array;
364
-    }
365
-
366
-    public function deleteTrackerArchiveTrackData()
367
-    {
368
-        global $globalArchiveKeepTrackMonths, $globalDBdriver;
369
-        if ($globalDBdriver == 'mysql') {
370
-            $query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
371
-        } else {
372
-            $query = "DELETE FROM tracker_archive WHERE tracker_archive_id IN (SELECT tracker_archive_id FROM tracker_archive WHERE tracker_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)";
373
-        }
374
-        try {
375
-            $sth = $this->db->prepare($query);
376
-            $sth->execute();
377
-        } catch(PDOException $e) {
378
-            echo $e->getMessage();
379
-            die;
380
-        }
381
-    }
382
-
383
-    /**
384
-     * Gets Minimal Live Tracker data
385
-     *
386
-     * @param $begindate
387
-     * @param $enddate
388
-     * @param array $filter
389
-     * @return array the spotter information
390
-     */
391
-    public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
392
-    {
393
-        global $globalDBdriver;
394
-        date_default_timezone_set('UTC');
395
-
396
-        $filter_query = '';
397
-        if (isset($filter['source']) && !empty($filter['source'])) {
398
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
399
-        }
400
-        // Use spotter_output also ?
401
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
402
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
403
-        }
404
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
405
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
406
-        }
407
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
408
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
409
-        }
410
-
411
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
412
-        if ($globalDBdriver == 'mysql') {
413
-            /*
334
+		try {
335
+			$sth = $this->db->prepare($query);
336
+			$sth->execute(array(':ident' => $ident));
337
+		} catch(PDOException $e) {
338
+			echo $e->getMessage();
339
+			die;
340
+		}
341
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
342
+
343
+		return $spotter_array;
344
+	}
345
+
346
+
347
+	/**
348
+	 * Gets all the archive spotter information
349
+	 *
350
+	 * @param $ident
351
+	 * @param $famtrackid
352
+	 * @param $date
353
+	 * @return array the spotter information
354
+	 */
355
+	public function getTrackerArchiveData($ident,$famtrackid,$date)
356
+	{
357
+		$Tracker = new Tracker($this->db);
358
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
359
+		$query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
360
+
361
+		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
362
+
363
+		return $spotter_array;
364
+	}
365
+
366
+	public function deleteTrackerArchiveTrackData()
367
+	{
368
+		global $globalArchiveKeepTrackMonths, $globalDBdriver;
369
+		if ($globalDBdriver == 'mysql') {
370
+			$query = 'DELETE FROM tracker_archive WHERE tracker_archive.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepTrackMonths.' MONTH)';
371
+		} else {
372
+			$query = "DELETE FROM tracker_archive WHERE tracker_archive_id IN (SELECT tracker_archive_id FROM tracker_archive WHERE tracker_archive.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepTrackMonths." MONTH' LIMIT 10000)";
373
+		}
374
+		try {
375
+			$sth = $this->db->prepare($query);
376
+			$sth->execute();
377
+		} catch(PDOException $e) {
378
+			echo $e->getMessage();
379
+			die;
380
+		}
381
+	}
382
+
383
+	/**
384
+	 * Gets Minimal Live Tracker data
385
+	 *
386
+	 * @param $begindate
387
+	 * @param $enddate
388
+	 * @param array $filter
389
+	 * @return array the spotter information
390
+	 */
391
+	public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
392
+	{
393
+		global $globalDBdriver;
394
+		date_default_timezone_set('UTC');
395
+
396
+		$filter_query = '';
397
+		if (isset($filter['source']) && !empty($filter['source'])) {
398
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
399
+		}
400
+		// Use spotter_output also ?
401
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
402
+			$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
403
+		}
404
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
405
+			$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
406
+		}
407
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
408
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
409
+		}
410
+
411
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
412
+		if ($globalDBdriver == 'mysql') {
413
+			/*
414 414
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
415 415
                     		    FROM tracker_archive 
416 416
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
417 417
 			*/
418
-            /*
418
+			/*
419 419
 			$query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
420 420
 				    FROM tracker_archive 
421 421
 				    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate 
@@ -424,900 +424,900 @@  discard block
 block discarded – undo
424 424
 						GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid 
425 425
 				    AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
426 426
 */
427
-            $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
427
+			$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
428 428
 				    FROM tracker_archive 
429 429
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
430 430
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
431 431
                         	    '.$filter_query.' ORDER BY famtrackid';
432
-        } else {
433
-            //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
434
-            $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
432
+		} else {
433
+			//$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
434
+			$query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
435 435
                         	    FROM tracker_archive 
436 436
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
437 437
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
438 438
                         	    '.$filter_query.' ORDER BY famtrackid';
439
-        }
440
-        //echo $query;
441
-        try {
442
-            $sth = $this->db->prepare($query);
443
-            $sth->execute();
444
-        } catch(PDOException $e) {
445
-            echo $e->getMessage();
446
-            die;
447
-        }
448
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
449
-
450
-        return $spotter_array;
451
-    }
452
-
453
-    /**
454
-     * Gets Minimal Live Tracker data
455
-     *
456
-     * @param $begindate
457
-     * @param $enddate
458
-     * @param array $filter
459
-     * @return array the spotter information
460
-     */
461
-    public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
462
-    {
463
-        global $globalDBdriver;
464
-        date_default_timezone_set('UTC');
465
-
466
-        $filter_query = '';
467
-        if (isset($filter['source']) && !empty($filter['source'])) {
468
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
469
-        }
470
-        // Should use spotter_output also ?
471
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
472
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
473
-        }
474
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
475
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
476
-        }
477
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
478
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
479
-        }
480
-
481
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
482
-        if ($globalDBdriver == 'mysql') {
483
-            /*
439
+		}
440
+		//echo $query;
441
+		try {
442
+			$sth = $this->db->prepare($query);
443
+			$sth->execute();
444
+		} catch(PDOException $e) {
445
+			echo $e->getMessage();
446
+			die;
447
+		}
448
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
449
+
450
+		return $spotter_array;
451
+	}
452
+
453
+	/**
454
+	 * Gets Minimal Live Tracker data
455
+	 *
456
+	 * @param $begindate
457
+	 * @param $enddate
458
+	 * @param array $filter
459
+	 * @return array the spotter information
460
+	 */
461
+	public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
462
+	{
463
+		global $globalDBdriver;
464
+		date_default_timezone_set('UTC');
465
+
466
+		$filter_query = '';
467
+		if (isset($filter['source']) && !empty($filter['source'])) {
468
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
469
+		}
470
+		// Should use spotter_output also ?
471
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
472
+			$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
473
+		}
474
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
475
+			$filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
476
+		}
477
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
478
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
479
+		}
480
+
481
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
482
+		if ($globalDBdriver == 'mysql') {
483
+			/*
484 484
                         $query  = 'SELECT a.aircraft_shadow, tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk 
485 485
                     		    FROM tracker_archive 
486 486
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
487 487
 			*/
488
-            $query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
488
+			$query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
489 489
 				    FROM tracker_archive_output 
490 490
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao 
491 491
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
492 492
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
493 493
 
494
-        } else {
495
-            //$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
496
-            /*
494
+		} else {
495
+			//$query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow FROM tracker_archive_output INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive_output l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive_output.famtrackid = s.famtrackid AND tracker_archive_output.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao';
496
+			/*
497 497
                         $query  = 'SELECT tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
498 498
                         	    FROM tracker_archive_output 
499 499
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
500 500
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
501 501
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
502 502
                         */
503
-            $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
503
+			$query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
504 504
                         	    FROM tracker_archive_output 
505 505
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
506 506
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
507 507
                         	    '.$filter_query.' LIMIT 200 OFFSET 0';
508 508
 //                        	    .' GROUP BY spotter_output.famtrackid, spotter_output.ident, spotter_output.aircraft_icao, spotter_output.departure_airport_icao, spotter_output.arrival_airport_icao, spotter_output.latitude, spotter_output.longitude, spotter_output.altitude, spotter_output.heading, spotter_output.ground_speed, spotter_output.squawk, a.aircraft_shadow';
509 509
                         	    
510
-        }
511
-        //echo $query;
512
-        try {
513
-            $sth = $this->db->prepare($query);
514
-            $sth->execute();
515
-        } catch(PDOException $e) {
516
-            echo $e->getMessage();
517
-            die;
518
-        }
519
-        $spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
520
-
521
-        return $spotter_array;
522
-    }
523
-
524
-    /**
525
-     * Gets count Live Tracker data
526
-     *
527
-     * @param $begindate
528
-     * @param $enddate
529
-     * @param array $filter
530
-     * @return array the spotter information
531
-     */
532
-    public function getLiveTrackerCount($begindate,$enddate,$filter = array())
533
-    {
534
-        global $globalDBdriver, $globalLiveInterval;
535
-        date_default_timezone_set('UTC');
536
-
537
-        $filter_query = '';
538
-        if (isset($filter['source']) && !empty($filter['source'])) {
539
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
540
-        }
541
-        if (isset($filter['airlines']) && !empty($filter['airlines'])) {
542
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
543
-        }
544
-        if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
545
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
546
-        }
547
-        if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
548
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
549
-        }
550
-
551
-        //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
552
-        if ($globalDBdriver == 'mysql') {
553
-            $query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
510
+		}
511
+		//echo $query;
512
+		try {
513
+			$sth = $this->db->prepare($query);
514
+			$sth->execute();
515
+		} catch(PDOException $e) {
516
+			echo $e->getMessage();
517
+			die;
518
+		}
519
+		$spotter_array = $sth->fetchAll(PDO::FETCH_ASSOC);
520
+
521
+		return $spotter_array;
522
+	}
523
+
524
+	/**
525
+	 * Gets count Live Tracker data
526
+	 *
527
+	 * @param $begindate
528
+	 * @param $enddate
529
+	 * @param array $filter
530
+	 * @return array the spotter information
531
+	 */
532
+	public function getLiveTrackerCount($begindate,$enddate,$filter = array())
533
+	{
534
+		global $globalDBdriver, $globalLiveInterval;
535
+		date_default_timezone_set('UTC');
536
+
537
+		$filter_query = '';
538
+		if (isset($filter['source']) && !empty($filter['source'])) {
539
+			$filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
540
+		}
541
+		if (isset($filter['airlines']) && !empty($filter['airlines'])) {
542
+			$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
543
+		}
544
+		if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
545
+			$filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
546
+		}
547
+		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
548
+			$filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
549
+		}
550
+
551
+		//if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
552
+		if ($globalDBdriver == 'mysql') {
553
+			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb 
554 554
 			FROM tracker_archive l 
555 555
 			WHERE (l.date BETWEEN DATE_SUB('."'".$begindate."'".',INTERVAL '.$globalLiveInterval.' SECOND) AND '."'".$begindate."'".')'.$filter_query;
556
-        } else {
557
-            $query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
558
-        }
559
-        //echo $query;
560
-        try {
561
-            $sth = $this->db->prepare($query);
562
-            $sth->execute();
563
-        } catch(PDOException $e) {
564
-            echo $e->getMessage();
565
-            die;
566
-        }
567
-        $result = $sth->fetch(PDO::FETCH_ASSOC);
568
-        $sth->closeCursor();
569
-        return $result['nb'];
570
-
571
-    }
572
-
573
-
574
-
575
-    // tracker_archive_output
576
-
577
-    /**
578
-     * Gets all the spotter information
579
-     *
580
-     * @param string $q
581
-     * @param string $registration
582
-     * @param string $aircraft_icao
583
-     * @param string $aircraft_manufacturer
584
-     * @param string $highlights
585
-     * @param string $airline_icao
586
-     * @param string $airline_country
587
-     * @param string $airline_type
588
-     * @param string $airport
589
-     * @param string $airport_country
590
-     * @param string $callsign
591
-     * @param string $departure_airport_route
592
-     * @param string $arrival_airport_route
593
-     * @param string $owner
594
-     * @param string $pilot_id
595
-     * @param string $pilot_name
596
-     * @param string $altitude
597
-     * @param string $date_posted
598
-     * @param string $limit
599
-     * @param string $sort
600
-     * @param string $includegeodata
601
-     * @param string $origLat
602
-     * @param string $origLon
603
-     * @param string $dist
604
-     * @param array $filters
605
-     * @return array the spotter information
606
-     */
607
-    public function searchTrackerData($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())
608
-    {
609
-        global $globalTimezone, $globalDBdriver;
610
-        require_once(dirname(__FILE__).'/class.Translation.php');
611
-        $Translation = new Translation($this->db);
612
-        $Tracker = new Tracker($this->db);
613
-
614
-        date_default_timezone_set('UTC');
556
+		} else {
557
+			$query = 'SELECT COUNT(DISTINCT famtrackid) as nb FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."' - INTERVAL '".$globalLiveInterval." SECONDS' AND "."'".$enddate."'".')'.$filter_query;
558
+		}
559
+		//echo $query;
560
+		try {
561
+			$sth = $this->db->prepare($query);
562
+			$sth->execute();
563
+		} catch(PDOException $e) {
564
+			echo $e->getMessage();
565
+			die;
566
+		}
567
+		$result = $sth->fetch(PDO::FETCH_ASSOC);
568
+		$sth->closeCursor();
569
+		return $result['nb'];
570
+
571
+	}
572
+
573
+
574
+
575
+	// tracker_archive_output
576
+
577
+	/**
578
+	 * Gets all the spotter information
579
+	 *
580
+	 * @param string $q
581
+	 * @param string $registration
582
+	 * @param string $aircraft_icao
583
+	 * @param string $aircraft_manufacturer
584
+	 * @param string $highlights
585
+	 * @param string $airline_icao
586
+	 * @param string $airline_country
587
+	 * @param string $airline_type
588
+	 * @param string $airport
589
+	 * @param string $airport_country
590
+	 * @param string $callsign
591
+	 * @param string $departure_airport_route
592
+	 * @param string $arrival_airport_route
593
+	 * @param string $owner
594
+	 * @param string $pilot_id
595
+	 * @param string $pilot_name
596
+	 * @param string $altitude
597
+	 * @param string $date_posted
598
+	 * @param string $limit
599
+	 * @param string $sort
600
+	 * @param string $includegeodata
601
+	 * @param string $origLat
602
+	 * @param string $origLon
603
+	 * @param string $dist
604
+	 * @param array $filters
605
+	 * @return array the spotter information
606
+	 */
607
+	public function searchTrackerData($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())
608
+	{
609
+		global $globalTimezone, $globalDBdriver;
610
+		require_once(dirname(__FILE__).'/class.Translation.php');
611
+		$Translation = new Translation($this->db);
612
+		$Tracker = new Tracker($this->db);
613
+
614
+		date_default_timezone_set('UTC');
615 615
 	
616
-        $query_values = array();
617
-        $additional_query = '';
618
-        $limit_query = '';
619
-        $filter_query = $this->getFilter($filters);
620
-        if ($q != "")
621
-        {
622
-            if (!is_string($q))
623
-            {
624
-                return array();
625
-            } else {
616
+		$query_values = array();
617
+		$additional_query = '';
618
+		$limit_query = '';
619
+		$filter_query = $this->getFilter($filters);
620
+		if ($q != "")
621
+		{
622
+			if (!is_string($q))
623
+			{
624
+				return array();
625
+			} else {
626 626
 	        
627
-                $q_array = explode(" ", $q);
627
+				$q_array = explode(" ", $q);
628 628
 		
629
-                foreach ($q_array as $q_item){
630
-                    $additional_query .= " AND (";
631
-                    $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
632
-                    $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
633
-                    $additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
634
-                    $additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
635
-                    $additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
636
-                    $additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
637
-                    $additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
638
-                    $additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
639
-                    $additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
640
-                    $additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
641
-                    $additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
642
-                    $additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
643
-                    $additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
644
-                    $additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
645
-                    $additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
646
-                    $additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
647
-                    $additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
648
-                    $additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
649
-                    $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
650
-                    $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
651
-                    $translate = $Translation->ident2icao($q_item);
652
-                    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
653
-                    $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
654
-                    $additional_query .= ")";
655
-                }
656
-            }
657
-        }
629
+				foreach ($q_array as $q_item){
630
+					$additional_query .= " AND (";
631
+					$additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
632
+					$additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
633
+					$additional_query .= "(tracker_archive_output.aircraft_name like '%".$q_item."%') OR ";
634
+					$additional_query .= "(tracker_archive_output.aircraft_manufacturer like '%".$q_item."%') OR ";
635
+					$additional_query .= "(tracker_archive_output.airline_icao like '%".$q_item."%') OR ";
636
+					$additional_query .= "(tracker_archive_output.airline_name like '%".$q_item."%') OR ";
637
+					$additional_query .= "(tracker_archive_output.airline_country like '%".$q_item."%') OR ";
638
+					$additional_query .= "(tracker_archive_output.departure_airport_icao like '%".$q_item."%') OR ";
639
+					$additional_query .= "(tracker_archive_output.departure_airport_name like '%".$q_item."%') OR ";
640
+					$additional_query .= "(tracker_archive_output.departure_airport_city like '%".$q_item."%') OR ";
641
+					$additional_query .= "(tracker_archive_output.departure_airport_country like '%".$q_item."%') OR ";
642
+					$additional_query .= "(tracker_archive_output.arrival_airport_icao like '%".$q_item."%') OR ";
643
+					$additional_query .= "(tracker_archive_output.arrival_airport_name like '%".$q_item."%') OR ";
644
+					$additional_query .= "(tracker_archive_output.arrival_airport_city like '%".$q_item."%') OR ";
645
+					$additional_query .= "(tracker_archive_output.arrival_airport_country like '%".$q_item."%') OR ";
646
+					$additional_query .= "(tracker_archive_output.registration like '%".$q_item."%') OR ";
647
+					$additional_query .= "(tracker_archive_output.owner_name like '%".$q_item."%') OR ";
648
+					$additional_query .= "(tracker_archive_output.pilot_id like '%".$q_item."%') OR ";
649
+					$additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
650
+					$additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
651
+					$translate = $Translation->ident2icao($q_item);
652
+					if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
653
+					$additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
654
+					$additional_query .= ")";
655
+				}
656
+			}
657
+		}
658 658
 	
659
-        if ($registration != "")
660
-        {
661
-            $registration = filter_var($registration,FILTER_SANITIZE_STRING);
662
-            if (!is_string($registration))
663
-            {
664
-                return array();
665
-            } else {
666
-                $additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
667
-            }
668
-        }
659
+		if ($registration != "")
660
+		{
661
+			$registration = filter_var($registration,FILTER_SANITIZE_STRING);
662
+			if (!is_string($registration))
663
+			{
664
+				return array();
665
+			} else {
666
+				$additional_query .= " AND (tracker_archive_output.registration = '".$registration."')";
667
+			}
668
+		}
669 669
 	
670
-        if ($aircraft_icao != "")
671
-        {
672
-            $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
673
-            if (!is_string($aircraft_icao))
674
-            {
675
-                return array();
676
-            } else {
677
-                $additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
678
-            }
679
-        }
670
+		if ($aircraft_icao != "")
671
+		{
672
+			$aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
673
+			if (!is_string($aircraft_icao))
674
+			{
675
+				return array();
676
+			} else {
677
+				$additional_query .= " AND (tracker_archive_output.aircraft_icao = '".$aircraft_icao."')";
678
+			}
679
+		}
680 680
 	
681
-        if ($aircraft_manufacturer != "")
682
-        {
683
-            $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
684
-            if (!is_string($aircraft_manufacturer))
685
-            {
686
-                return array();
687
-            } else {
688
-                $additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
689
-            }
690
-        }
681
+		if ($aircraft_manufacturer != "")
682
+		{
683
+			$aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
684
+			if (!is_string($aircraft_manufacturer))
685
+			{
686
+				return array();
687
+			} else {
688
+				$additional_query .= " AND (tracker_archive_output.aircraft_manufacturer = '".$aircraft_manufacturer."')";
689
+			}
690
+		}
691 691
 	
692
-        if ($highlights == "true")
693
-        {
694
-            if (!is_string($highlights))
695
-            {
696
-                return array();
697
-            } else {
698
-                $additional_query .= " AND (tracker_archive_output.highlight <> '')";
699
-            }
700
-        }
692
+		if ($highlights == "true")
693
+		{
694
+			if (!is_string($highlights))
695
+			{
696
+				return array();
697
+			} else {
698
+				$additional_query .= " AND (tracker_archive_output.highlight <> '')";
699
+			}
700
+		}
701 701
 	
702
-        if ($airline_icao != "")
703
-        {
704
-            $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
705
-            if (!is_string($airline_icao))
706
-            {
707
-                return array();
708
-            } else {
709
-                $additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
710
-            }
711
-        }
702
+		if ($airline_icao != "")
703
+		{
704
+			$airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
705
+			if (!is_string($airline_icao))
706
+			{
707
+				return array();
708
+			} else {
709
+				$additional_query .= " AND (tracker_archive_output.airline_icao = '".$airline_icao."')";
710
+			}
711
+		}
712 712
 	
713
-        if ($airline_country != "")
714
-        {
715
-            $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
716
-            if (!is_string($airline_country))
717
-            {
718
-                return array();
719
-            } else {
720
-                $additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
721
-            }
722
-        }
713
+		if ($airline_country != "")
714
+		{
715
+			$airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
716
+			if (!is_string($airline_country))
717
+			{
718
+				return array();
719
+			} else {
720
+				$additional_query .= " AND (tracker_archive_output.airline_country = '".$airline_country."')";
721
+			}
722
+		}
723 723
 	
724
-        if ($airline_type != "")
725
-        {
726
-            $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
727
-            if (!is_string($airline_type))
728
-            {
729
-                return array();
730
-            } else {
731
-                if ($airline_type == "passenger")
732
-                {
733
-                    $additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
734
-                }
735
-                if ($airline_type == "cargo")
736
-                {
737
-                    $additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
738
-                }
739
-                if ($airline_type == "military")
740
-                {
741
-                    $additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
742
-                }
743
-            }
744
-        }
724
+		if ($airline_type != "")
725
+		{
726
+			$airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
727
+			if (!is_string($airline_type))
728
+			{
729
+				return array();
730
+			} else {
731
+				if ($airline_type == "passenger")
732
+				{
733
+					$additional_query .= " AND (tracker_archive_output.airline_type = 'passenger')";
734
+				}
735
+				if ($airline_type == "cargo")
736
+				{
737
+					$additional_query .= " AND (tracker_archive_output.airline_type = 'cargo')";
738
+				}
739
+				if ($airline_type == "military")
740
+				{
741
+					$additional_query .= " AND (tracker_archive_output.airline_type = 'military')";
742
+				}
743
+			}
744
+		}
745 745
 	
746
-        if ($airport != "")
747
-        {
748
-            $airport = filter_var($airport,FILTER_SANITIZE_STRING);
749
-            if (!is_string($airport))
750
-            {
751
-                return array();
752
-            } else {
753
-                $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
754
-            }
755
-        }
746
+		if ($airport != "")
747
+		{
748
+			$airport = filter_var($airport,FILTER_SANITIZE_STRING);
749
+			if (!is_string($airport))
750
+			{
751
+				return array();
752
+			} else {
753
+				$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = '".$airport."') OR (tracker_archive_output.arrival_airport_icao = '".$airport."'))";
754
+			}
755
+		}
756 756
 	
757
-        if ($airport_country != "")
758
-        {
759
-            $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
760
-            if (!is_string($airport_country))
761
-            {
762
-                return array();
763
-            } else {
764
-                $additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
765
-            }
766
-        }
757
+		if ($airport_country != "")
758
+		{
759
+			$airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
760
+			if (!is_string($airport_country))
761
+			{
762
+				return array();
763
+			} else {
764
+				$additional_query .= " AND ((tracker_archive_output.departure_airport_country = '".$airport_country."') OR (tracker_archive_output.arrival_airport_country = '".$airport_country."'))";
765
+			}
766
+		}
767 767
     
768
-        if ($callsign != "")
769
-        {
770
-            $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
771
-            if (!is_string($callsign))
772
-            {
773
-                return array();
774
-            } else {
775
-                $translate = $Translation->ident2icao($callsign);
776
-                if ($translate != $callsign) {
777
-                    $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
778
-                    $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
779
-                } else {
780
-                    $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
781
-                }
782
-            }
783
-        }
784
-
785
-        if ($owner != "")
786
-        {
787
-            $owner = filter_var($owner,FILTER_SANITIZE_STRING);
788
-            if (!is_string($owner))
789
-            {
790
-                return array();
791
-            } else {
792
-                $additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
793
-            }
794
-        }
795
-
796
-        if ($pilot_name != "")
797
-        {
798
-            $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
799
-            if (!is_string($pilot_name))
800
-            {
801
-                return array();
802
-            } else {
803
-                $additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
804
-            }
805
-        }
768
+		if ($callsign != "")
769
+		{
770
+			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
771
+			if (!is_string($callsign))
772
+			{
773
+				return array();
774
+			} else {
775
+				$translate = $Translation->ident2icao($callsign);
776
+				if ($translate != $callsign) {
777
+					$additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
778
+					$query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
779
+				} else {
780
+					$additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
781
+				}
782
+			}
783
+		}
784
+
785
+		if ($owner != "")
786
+		{
787
+			$owner = filter_var($owner,FILTER_SANITIZE_STRING);
788
+			if (!is_string($owner))
789
+			{
790
+				return array();
791
+			} else {
792
+				$additional_query .= " AND (tracker_archive_output.owner_name = '".$owner."')";
793
+			}
794
+		}
795
+
796
+		if ($pilot_name != "")
797
+		{
798
+			$pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
799
+			if (!is_string($pilot_name))
800
+			{
801
+				return array();
802
+			} else {
803
+				$additional_query .= " AND (tracker_archive_output.pilot_name = '".$pilot_name."')";
804
+			}
805
+		}
806 806
 	
807
-        if ($pilot_id != "")
808
-        {
809
-            $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
810
-            if (!is_string($pilot_id))
811
-            {
812
-                return array();
813
-            } else {
814
-                $additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
815
-            }
816
-        }
807
+		if ($pilot_id != "")
808
+		{
809
+			$pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
810
+			if (!is_string($pilot_id))
811
+			{
812
+				return array();
813
+			} else {
814
+				$additional_query .= " AND (tracker_archive_output.pilot_id = '".$pilot_id."')";
815
+			}
816
+		}
817 817
 	
818
-        if ($departure_airport_route != "")
819
-        {
820
-            $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
821
-            if (!is_string($departure_airport_route))
822
-            {
823
-                return array();
824
-            } else {
825
-                $additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
826
-            }
827
-        }
818
+		if ($departure_airport_route != "")
819
+		{
820
+			$departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
821
+			if (!is_string($departure_airport_route))
822
+			{
823
+				return array();
824
+			} else {
825
+				$additional_query .= " AND (tracker_archive_output.departure_airport_icao = '".$departure_airport_route."')";
826
+			}
827
+		}
828 828
 	
829
-        if ($arrival_airport_route != "")
830
-        {
831
-            $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
832
-            if (!is_string($arrival_airport_route))
833
-            {
834
-                return array();
835
-            } else {
836
-                $additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
837
-            }
838
-        }
829
+		if ($arrival_airport_route != "")
830
+		{
831
+			$arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
832
+			if (!is_string($arrival_airport_route))
833
+			{
834
+				return array();
835
+			} else {
836
+				$additional_query .= " AND (tracker_archive_output.arrival_airport_icao = '".$arrival_airport_route."')";
837
+			}
838
+		}
839 839
 	
840
-        if ($altitude != "")
841
-        {
842
-            $altitude_array = explode(",", $altitude);
840
+		if ($altitude != "")
841
+		{
842
+			$altitude_array = explode(",", $altitude);
843 843
 	    
844
-            $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
845
-            $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
844
+			$altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
845
+			$altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
846 846
 	    
847 847
 
848
-            if ($altitude_array[1] != "")
849
-            {
850
-                $altitude_array[0] = substr($altitude_array[0], 0, -2);
851
-                $altitude_array[1] = substr($altitude_array[1], 0, -2);
852
-                $additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
853
-            } else {
854
-                $altitude_array[0] = substr($altitude_array[0], 0, -2);
855
-                $additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
856
-            }
857
-        }
848
+			if ($altitude_array[1] != "")
849
+			{
850
+				$altitude_array[0] = substr($altitude_array[0], 0, -2);
851
+				$altitude_array[1] = substr($altitude_array[1], 0, -2);
852
+				$additional_query .= " AND altitude BETWEEN '".$altitude_array[0]."' AND '".$altitude_array[1]."' ";
853
+			} else {
854
+				$altitude_array[0] = substr($altitude_array[0], 0, -2);
855
+				$additional_query .= " AND altitude <= '".$altitude_array[0]."' ";
856
+			}
857
+		}
858 858
 	
859
-        if ($date_posted != "")
860
-        {
861
-            $date_array = explode(",", $date_posted);
859
+		if ($date_posted != "")
860
+		{
861
+			$date_array = explode(",", $date_posted);
862 862
 	    
863
-            $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
864
-            $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
863
+			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
864
+			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
865 865
 	    
866
-            if ($globalTimezone != '') {
867
-                date_default_timezone_set($globalTimezone);
868
-                $datetime = new DateTime();
869
-                $offset = $datetime->format('P');
870
-            } else $offset = '+00:00';
871
-
872
-
873
-            if ($date_array[1] != "")
874
-            {
875
-                $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
876
-                $date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
877
-                if ($globalDBdriver == 'mysql') {
878
-                    $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
879
-                } else {
880
-                    $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
881
-                }
882
-            } else {
883
-                $date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
884
-                if ($globalDBdriver == 'mysql') {
885
-                    $additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
886
-                } else {
887
-                    $additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
888
-                }
889
-            }
890
-        }
866
+			if ($globalTimezone != '') {
867
+				date_default_timezone_set($globalTimezone);
868
+				$datetime = new DateTime();
869
+				$offset = $datetime->format('P');
870
+			} else $offset = '+00:00';
871
+
872
+
873
+			if ($date_array[1] != "")
874
+			{
875
+				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
876
+				$date_array[1] = date("Y-m-d H:i:s", strtotime($date_array[1]));
877
+				if ($globalDBdriver == 'mysql') {
878
+					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) <= '".$date_array[1]."' ";
879
+				} else {
880
+					$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." <= CAST('".$date_array[1]."' AS TIMESTAMP) ";
881
+				}
882
+			} else {
883
+				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
884
+				if ($globalDBdriver == 'mysql') {
885
+					$additional_query .= " AND TIMESTAMP(CONVERT_TZ(tracker_archive_output.date,'+00:00', '".$offset."')) >= '".$date_array[0]."' ";
886
+				} else {
887
+					$additional_query .= " AND tracker_archive_output.date::timestamp AT TIME ZONE INTERVAL ".$offset." >= CAST('".$date_array[0]."' AS TIMESTAMP) ";
888
+				}
889
+			}
890
+		}
891 891
 	
892
-        if ($limit != "")
893
-        {
894
-            $limit_array = explode(",", $limit);
892
+		if ($limit != "")
893
+		{
894
+			$limit_array = explode(",", $limit);
895 895
 	    
896
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
897
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
896
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
897
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
898 898
 	    
899
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
900
-            {
901
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
902
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
903
-            }
904
-        }
899
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
900
+			{
901
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
902
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
903
+			}
904
+		}
905 905
 	
906 906
 
907
-        if ($origLat != "" && $origLon != "" && $dist != "") {
908
-            $dist = number_format($dist*0.621371,2,'.','');
909
-            $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
907
+		if ($origLat != "" && $origLon != "" && $dist != "") {
908
+			$dist = number_format($dist*0.621371,2,'.','');
909
+			$query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
910 910
                           FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
911 911
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
912
-        } else {
913
-            if ($sort != "")
914
-            {
915
-                $search_orderby_array = $Tracker->getOrderBy();
916
-                $orderby_query = $search_orderby_array[$sort]['sql'];
917
-            } else {
918
-                $orderby_query = " ORDER BY tracker_archive_output.date DESC";
919
-            }
912
+		} else {
913
+			if ($sort != "")
914
+			{
915
+				$search_orderby_array = $Tracker->getOrderBy();
916
+				$orderby_query = $search_orderby_array[$sort]['sql'];
917
+			} else {
918
+				$orderby_query = " ORDER BY tracker_archive_output.date DESC";
919
+			}
920 920
 	
921
-            if ($includegeodata == "true")
922
-            {
923
-                $additional_query .= " AND (tracker_archive_output.waypoints <> '')";
924
-            }
921
+			if ($includegeodata == "true")
922
+			{
923
+				$additional_query .= " AND (tracker_archive_output.waypoints <> '')";
924
+			}
925 925
 
926
-            $query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
926
+			$query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
927 927
 		    WHERE tracker_archive_output.ident <> '' 
928 928
 		    ".$additional_query."
929 929
 		    ".$filter_query.$orderby_query;
930
-        }
931
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
932
-
933
-        return $spotter_array;
934
-    }
935
-
936
-    public function deleteTrackerArchiveData()
937
-    {
938
-        global $globalArchiveKeepMonths, $globalDBdriver;
939
-        date_default_timezone_set('UTC');
940
-        if ($globalDBdriver == 'mysql') {
941
-            $query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
942
-        } else {
943
-            $query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
944
-        }
945
-        try {
946
-            $sth = $this->db->prepare($query);
947
-            $sth->execute();
948
-        } catch(PDOException $e) {
949
-            return "error";
950
-        }
951
-        return '';
952
-    }
953
-
954
-    /**
955
-     * Gets all the spotter information based on the callsign
956
-     *
957
-     * @param string $ident
958
-     * @param string $limit
959
-     * @param string $sort
960
-     * @return array the spotter information
961
-     */
962
-    public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
963
-    {
964
-        $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
930
+		}
931
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
932
+
933
+		return $spotter_array;
934
+	}
935
+
936
+	public function deleteTrackerArchiveData()
937
+	{
938
+		global $globalArchiveKeepMonths, $globalDBdriver;
939
+		date_default_timezone_set('UTC');
940
+		if ($globalDBdriver == 'mysql') {
941
+			$query = 'DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < DATE_SUB(UTC_TIMESTAMP(), INTERVAL '.$globalArchiveKeepMonths.' MONTH)';
942
+		} else {
943
+			$query = "DELETE FROM tracker_archive_output WHERE tracker_archive_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalArchiveKeepMonths." MONTH'";
944
+		}
945
+		try {
946
+			$sth = $this->db->prepare($query);
947
+			$sth->execute();
948
+		} catch(PDOException $e) {
949
+			return "error";
950
+		}
951
+		return '';
952
+	}
953
+
954
+	/**
955
+	 * Gets all the spotter information based on the callsign
956
+	 *
957
+	 * @param string $ident
958
+	 * @param string $limit
959
+	 * @param string $sort
960
+	 * @return array the spotter information
961
+	 */
962
+	public function getTrackerDataByIdent($ident = '', $limit = '', $sort = '')
963
+	{
964
+		$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
965 965
 	
966
-        date_default_timezone_set('UTC');
967
-        $Tracker = new Tracker($this->db);
966
+		date_default_timezone_set('UTC');
967
+		$Tracker = new Tracker($this->db);
968 968
 	
969
-        $query_values = array();
970
-        $limit_query = '';
971
-        $additional_query = '';
969
+		$query_values = array();
970
+		$limit_query = '';
971
+		$additional_query = '';
972 972
 	
973
-        if ($ident != "")
974
-        {
975
-            if (!is_string($ident))
976
-            {
977
-                return array();
978
-            } else {
979
-                $additional_query = " AND (tracker_archive_output.ident = :ident)";
980
-                $query_values = array(':ident' => $ident);
981
-            }
982
-        }
973
+		if ($ident != "")
974
+		{
975
+			if (!is_string($ident))
976
+			{
977
+				return array();
978
+			} else {
979
+				$additional_query = " AND (tracker_archive_output.ident = :ident)";
980
+				$query_values = array(':ident' => $ident);
981
+			}
982
+		}
983 983
 	
984
-        if ($limit != "")
985
-        {
986
-            $limit_array = explode(",", $limit);
984
+		if ($limit != "")
985
+		{
986
+			$limit_array = explode(",", $limit);
987 987
 	    
988
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
-            {
993
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
-            }
996
-        }
997
-
998
-        if ($sort != "")
999
-        {
1000
-            $search_orderby_array = $Tracker->getOrderBy();
1001
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1002
-        } else {
1003
-            $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1004
-        }
1005
-
1006
-        $query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
1007
-
1008
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1009
-
1010
-        return $spotter_array;
1011
-    }
1012
-
1013
-
1014
-    /**
1015
-     * Gets all the spotter information based on the owner
1016
-     *
1017
-     * @param string $owner
1018
-     * @param string $limit
1019
-     * @param string $sort
1020
-     * @param array $filter
1021
-     * @return array the spotter information
1022
-     */
1023
-    public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1024
-    {
1025
-        $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
991
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992
+			{
993
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
994
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
995
+			}
996
+		}
997
+
998
+		if ($sort != "")
999
+		{
1000
+			$search_orderby_array = $Tracker->getOrderBy();
1001
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1002
+		} else {
1003
+			$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1004
+		}
1005
+
1006
+		$query = $global_query." WHERE tracker_archive_output.ident <> '' ".$additional_query." ".$orderby_query;
1007
+
1008
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1009
+
1010
+		return $spotter_array;
1011
+	}
1012
+
1013
+
1014
+	/**
1015
+	 * Gets all the spotter information based on the owner
1016
+	 *
1017
+	 * @param string $owner
1018
+	 * @param string $limit
1019
+	 * @param string $sort
1020
+	 * @param array $filter
1021
+	 * @return array the spotter information
1022
+	 */
1023
+	public function getTrackerDataByOwner($owner = '', $limit = '', $sort = '', $filter = array())
1024
+	{
1025
+		$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1026 1026
 	
1027
-        date_default_timezone_set('UTC');
1028
-        $Tracker = new Tracker($this->db);
1027
+		date_default_timezone_set('UTC');
1028
+		$Tracker = new Tracker($this->db);
1029 1029
 	
1030
-        $query_values = array();
1031
-        $limit_query = '';
1032
-        $additional_query = '';
1033
-        $filter_query = $this->getFilter($filter,true,true);
1030
+		$query_values = array();
1031
+		$limit_query = '';
1032
+		$additional_query = '';
1033
+		$filter_query = $this->getFilter($filter,true,true);
1034 1034
 	
1035
-        if ($owner != "")
1036
-        {
1037
-            if (!is_string($owner))
1038
-            {
1039
-                return array();
1040
-            } else {
1041
-                $additional_query = " AND (tracker_archive_output.owner_name = :owner)";
1042
-                $query_values = array(':owner' => $owner);
1043
-            }
1044
-        }
1035
+		if ($owner != "")
1036
+		{
1037
+			if (!is_string($owner))
1038
+			{
1039
+				return array();
1040
+			} else {
1041
+				$additional_query = " AND (tracker_archive_output.owner_name = :owner)";
1042
+				$query_values = array(':owner' => $owner);
1043
+			}
1044
+		}
1045 1045
 	
1046
-        if ($limit != "")
1047
-        {
1048
-            $limit_array = explode(",", $limit);
1046
+		if ($limit != "")
1047
+		{
1048
+			$limit_array = explode(",", $limit);
1049 1049
 	    
1050
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1051
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1050
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1051
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1052 1052
 	    
1053
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1054
-            {
1055
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1056
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1057
-            }
1058
-        }
1059
-
1060
-        if ($sort != "")
1061
-        {
1062
-            $search_orderby_array = $Tracker->getOrderBy();
1063
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1064
-        } else {
1065
-            $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1066
-        }
1067
-
1068
-        $query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
1069
-
1070
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1071
-
1072
-        return $spotter_array;
1073
-    }
1074
-
1075
-    /**
1076
-     * Gets all the spotter information based on the pilot
1077
-     *
1078
-     * @param string $pilot
1079
-     * @param string $limit
1080
-     * @param string $sort
1081
-     * @param array $filter
1082
-     * @return array the spotter information
1083
-     */
1084
-    public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1085
-    {
1086
-        $global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1053
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1054
+			{
1055
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1056
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1057
+			}
1058
+		}
1059
+
1060
+		if ($sort != "")
1061
+		{
1062
+			$search_orderby_array = $Tracker->getOrderBy();
1063
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1064
+		} else {
1065
+			$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1066
+		}
1067
+
1068
+		$query = $global_query.$filter_query." tracker_archive_output.owner_name <> '' ".$additional_query." ".$orderby_query;
1069
+
1070
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1071
+
1072
+		return $spotter_array;
1073
+	}
1074
+
1075
+	/**
1076
+	 * Gets all the spotter information based on the pilot
1077
+	 *
1078
+	 * @param string $pilot
1079
+	 * @param string $limit
1080
+	 * @param string $sort
1081
+	 * @param array $filter
1082
+	 * @return array the spotter information
1083
+	 */
1084
+	public function getTrackerDataByPilot($pilot = '', $limit = '', $sort = '', $filter = array())
1085
+	{
1086
+		$global_query = "SELECT tracker_archive_output.* FROM tracker_archive_output";
1087 1087
 	
1088
-        date_default_timezone_set('UTC');
1089
-        $Tracker = new Tracker($this->db);
1088
+		date_default_timezone_set('UTC');
1089
+		$Tracker = new Tracker($this->db);
1090 1090
 	
1091
-        $query_values = array();
1092
-        $limit_query = '';
1093
-        $additional_query = '';
1094
-        $filter_query = $this->getFilter($filter,true,true);
1091
+		$query_values = array();
1092
+		$limit_query = '';
1093
+		$additional_query = '';
1094
+		$filter_query = $this->getFilter($filter,true,true);
1095 1095
 	
1096
-        if ($pilot != "")
1097
-        {
1098
-            $additional_query = " AND (tracker_archive_output.pilot_id = :pilot OR tracker_archive_output.pilot_name = :pilot)";
1099
-            $query_values = array(':pilot' => $pilot);
1100
-        }
1096
+		if ($pilot != "")
1097
+		{
1098
+			$additional_query = " AND (tracker_archive_output.pilot_id = :pilot OR tracker_archive_output.pilot_name = :pilot)";
1099
+			$query_values = array(':pilot' => $pilot);
1100
+		}
1101 1101
 	
1102
-        if ($limit != "")
1103
-        {
1104
-            $limit_array = explode(",", $limit);
1102
+		if ($limit != "")
1103
+		{
1104
+			$limit_array = explode(",", $limit);
1105 1105
 	    
1106
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1107
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1106
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1107
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1108 1108
 	    
1109
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1110
-            {
1111
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1112
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1113
-            }
1114
-        }
1115
-
1116
-        if ($sort != "")
1117
-        {
1118
-            $search_orderby_array = $Tracker->getOrderBy();
1119
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1120
-        } else {
1121
-            $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1122
-        }
1123
-
1124
-        $query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
1125
-
1126
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1127
-
1128
-        return $spotter_array;
1129
-    }
1130
-
1131
-    /**
1132
-     * Gets all number of flight over countries
1133
-     *
1134
-     * @param bool $limit
1135
-     * @param int $olderthanmonths
1136
-     * @param string $sincedate
1137
-     * @return array the airline country list
1138
-     */
1139
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1140
-    {
1141
-        global $globalDBdriver;
1142
-        /*
1109
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1110
+			{
1111
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1112
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1113
+			}
1114
+		}
1115
+
1116
+		if ($sort != "")
1117
+		{
1118
+			$search_orderby_array = $Tracker->getOrderBy();
1119
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1120
+		} else {
1121
+			$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1122
+		}
1123
+
1124
+		$query = $global_query.$filter_query." tracker_archive_output.pilot_name <> '' ".$additional_query." ".$orderby_query;
1125
+
1126
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1127
+
1128
+		return $spotter_array;
1129
+	}
1130
+
1131
+	/**
1132
+	 * Gets all number of flight over countries
1133
+	 *
1134
+	 * @param bool $limit
1135
+	 * @param int $olderthanmonths
1136
+	 * @param string $sincedate
1137
+	 * @return array the airline country list
1138
+	 */
1139
+	public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1140
+	{
1141
+		global $globalDBdriver;
1142
+		/*
1143 1143
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
1144 1144
 		    FROM countries c, tracker_archive s
1145 1145
 		    WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) ";
1146 1146
 	*/
1147
-        $query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1147
+		$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb
1148 1148
 		    FROM countries c, tracker_archive s
1149 1149
 		    WHERE c.iso2 = s.over_country ";
1150
-        if ($olderthanmonths > 0) {
1151
-            if ($globalDBdriver == 'mysql') {
1152
-                $query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1153
-            } else {
1154
-                $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1155
-            }
1156
-        }
1157
-        if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1158
-        $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1159
-        if ($limit) $query .= " LIMIT 0,10";
1150
+		if ($olderthanmonths > 0) {
1151
+			if ($globalDBdriver == 'mysql') {
1152
+				$query .= 'AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1153
+			} else {
1154
+				$query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1155
+			}
1156
+		}
1157
+		if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1158
+		$query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1159
+		if ($limit) $query .= " LIMIT 0,10";
1160 1160
       
1161 1161
 	
1162
-        $sth = $this->db->prepare($query);
1163
-        $sth->execute();
1162
+		$sth = $this->db->prepare($query);
1163
+		$sth->execute();
1164 1164
  
1165
-        $flight_array = array();
1166
-        $temp_array = array();
1165
+		$flight_array = array();
1166
+		$temp_array = array();
1167 1167
         
1168
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
1169
-        {
1170
-            $temp_array['flight_count'] = $row['nb'];
1171
-            $temp_array['flight_country'] = $row['name'];
1172
-            $temp_array['flight_country_iso3'] = $row['iso3'];
1173
-            $temp_array['flight_country_iso2'] = $row['iso2'];
1174
-            $flight_array[] = $temp_array;
1175
-        }
1176
-        return $flight_array;
1177
-    }
1178
-
1179
-    /**
1180
-     * Gets all number of flight over countries
1181
-     *
1182
-     * @param bool $limit
1183
-     * @param int $olderthanmonths
1184
-     * @param string $sincedate
1185
-     * @return array the airline country list
1186
-     */
1187
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1188
-    {
1189
-        global $globalDBdriver;
1190
-        /*
1168
+		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1169
+		{
1170
+			$temp_array['flight_count'] = $row['nb'];
1171
+			$temp_array['flight_country'] = $row['name'];
1172
+			$temp_array['flight_country_iso3'] = $row['iso3'];
1173
+			$temp_array['flight_country_iso2'] = $row['iso2'];
1174
+			$flight_array[] = $temp_array;
1175
+		}
1176
+		return $flight_array;
1177
+	}
1178
+
1179
+	/**
1180
+	 * Gets all number of flight over countries
1181
+	 *
1182
+	 * @param bool $limit
1183
+	 * @param int $olderthanmonths
1184
+	 * @param string $sincedate
1185
+	 * @return array the airline country list
1186
+	 */
1187
+	public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1188
+	{
1189
+		global $globalDBdriver;
1190
+		/*
1191 1191
 	$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb 
1192 1192
 		    FROM countries c, tracker_archive s
1193 1193
 		    WHERE Within(GeomFromText(CONCAT('POINT(',s.longitude,' ',s.latitude,')')), ogc_geom) ";
1194 1194
 	*/
1195
-        $query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1195
+		$query = "SELECT o.airline_icao,c.name, c.iso3, c.iso2, count(c.name) as nb
1196 1196
 		    FROM countries c, tracker_archive s, spotter_output o
1197 1197
 		    WHERE c.iso2 = s.over_country AND o.airline_icao <> '' AND o.famtrackid = s.famtrackid ";
1198
-        if ($olderthanmonths > 0) {
1199
-            if ($globalDBdriver == 'mysql') {
1200
-                $query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1201
-            } else {
1202
-                $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1203
-            }
1204
-        }
1205
-        if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1206
-        $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1207
-        if ($limit) $query .= " LIMIT 0,10";
1198
+		if ($olderthanmonths > 0) {
1199
+			if ($globalDBdriver == 'mysql') {
1200
+				$query .= 'AND s.date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH) ';
1201
+			} else {
1202
+				$query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1203
+			}
1204
+		}
1205
+		if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1206
+		$query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1207
+		if ($limit) $query .= " LIMIT 0,10";
1208 1208
       
1209 1209
 	
1210
-        $sth = $this->db->prepare($query);
1211
-        $sth->execute();
1210
+		$sth = $this->db->prepare($query);
1211
+		$sth->execute();
1212 1212
  
1213
-        $flight_array = array();
1214
-        $temp_array = array();
1213
+		$flight_array = array();
1214
+		$temp_array = array();
1215 1215
         
1216
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
1217
-        {
1218
-            $temp_array['airline_icao'] = $row['airline_icao'];
1219
-            $temp_array['flight_count'] = $row['nb'];
1220
-            $temp_array['flight_country'] = $row['name'];
1221
-            $temp_array['flight_country_iso3'] = $row['iso3'];
1222
-            $temp_array['flight_country_iso2'] = $row['iso2'];
1223
-            $flight_array[] = $temp_array;
1224
-        }
1225
-        return $flight_array;
1226
-    }
1227
-
1228
-    /**
1229
-     * Gets last spotter information based on a particular callsign
1230
-     *
1231
-     * @param $id
1232
-     * @param $date
1233
-     * @return array the spotter information
1234
-     */
1235
-    public function getDateArchiveTrackerDataById($id,$date)
1236
-    {
1237
-        $Tracker = new Tracker($this->db);
1238
-        date_default_timezone_set('UTC');
1239
-        $id = filter_var($id, FILTER_SANITIZE_STRING);
1240
-        $query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1241
-        $date = date('c',$date);
1242
-        $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1243
-        return $spotter_array;
1244
-    }
1245
-
1246
-    /**
1247
-     * Gets all the spotter information based on a particular callsign
1248
-     *
1249
-     * @param $ident
1250
-     * @param $date
1251
-     * @return array the spotter information
1252
-     */
1253
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1254
-    {
1255
-        $Tracker = new Tracker($this->db);
1256
-        date_default_timezone_set('UTC');
1257
-        $ident = filter_var($ident, FILTER_SANITIZE_STRING);
1258
-        $query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1259
-        $date = date('c',$date);
1260
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1261
-        return $spotter_array;
1262
-    }
1263
-
1264
-    /**
1265
-     * Gets all the spotter information based on the airport
1266
-     *
1267
-     * @param string $airport
1268
-     * @param string $limit
1269
-     * @param string $sort
1270
-     * @param array $filters
1271
-     * @return array the spotter information
1272
-     */
1273
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1274
-    {
1275
-        global $global_query;
1276
-        $Tracker = new Tracker($this->db);
1277
-        date_default_timezone_set('UTC');
1278
-        $query_values = array();
1279
-        $limit_query = '';
1280
-        $additional_query = '';
1281
-        $filter_query = $this->getFilter($filters,true,true);
1216
+		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1217
+		{
1218
+			$temp_array['airline_icao'] = $row['airline_icao'];
1219
+			$temp_array['flight_count'] = $row['nb'];
1220
+			$temp_array['flight_country'] = $row['name'];
1221
+			$temp_array['flight_country_iso3'] = $row['iso3'];
1222
+			$temp_array['flight_country_iso2'] = $row['iso2'];
1223
+			$flight_array[] = $temp_array;
1224
+		}
1225
+		return $flight_array;
1226
+	}
1227
+
1228
+	/**
1229
+	 * Gets last spotter information based on a particular callsign
1230
+	 *
1231
+	 * @param $id
1232
+	 * @param $date
1233
+	 * @return array the spotter information
1234
+	 */
1235
+	public function getDateArchiveTrackerDataById($id,$date)
1236
+	{
1237
+		$Tracker = new Tracker($this->db);
1238
+		date_default_timezone_set('UTC');
1239
+		$id = filter_var($id, FILTER_SANITIZE_STRING);
1240
+		$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1241
+		$date = date('c',$date);
1242
+		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1243
+		return $spotter_array;
1244
+	}
1245
+
1246
+	/**
1247
+	 * Gets all the spotter information based on a particular callsign
1248
+	 *
1249
+	 * @param $ident
1250
+	 * @param $date
1251
+	 * @return array the spotter information
1252
+	 */
1253
+	public function getDateArchiveTrackerDataByIdent($ident,$date)
1254
+	{
1255
+		$Tracker = new Tracker($this->db);
1256
+		date_default_timezone_set('UTC');
1257
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1258
+		$query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1259
+		$date = date('c',$date);
1260
+		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1261
+		return $spotter_array;
1262
+	}
1263
+
1264
+	/**
1265
+	 * Gets all the spotter information based on the airport
1266
+	 *
1267
+	 * @param string $airport
1268
+	 * @param string $limit
1269
+	 * @param string $sort
1270
+	 * @param array $filters
1271
+	 * @return array the spotter information
1272
+	 */
1273
+	public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1274
+	{
1275
+		global $global_query;
1276
+		$Tracker = new Tracker($this->db);
1277
+		date_default_timezone_set('UTC');
1278
+		$query_values = array();
1279
+		$limit_query = '';
1280
+		$additional_query = '';
1281
+		$filter_query = $this->getFilter($filters,true,true);
1282 1282
 	
1283
-        if ($airport != "")
1284
-        {
1285
-            if (!is_string($airport))
1286
-            {
1287
-                return array();
1288
-            } else {
1289
-                $additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1290
-                $query_values = array(':airport' => $airport);
1291
-            }
1292
-        }
1283
+		if ($airport != "")
1284
+		{
1285
+			if (!is_string($airport))
1286
+			{
1287
+				return array();
1288
+			} else {
1289
+				$additional_query .= " AND ((tracker_archive_output.departure_airport_icao = :airport) OR (tracker_archive_output.arrival_airport_icao = :airport))";
1290
+				$query_values = array(':airport' => $airport);
1291
+			}
1292
+		}
1293 1293
 	
1294
-        if ($limit != "")
1295
-        {
1296
-            $limit_array = explode(",", $limit);
1294
+		if ($limit != "")
1295
+		{
1296
+			$limit_array = explode(",", $limit);
1297 1297
 	    
1298
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1299
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1298
+			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1299
+			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1300 1300
 	    
1301
-            if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1302
-            {
1303
-                //$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1304
-                $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1305
-            }
1306
-        }
1301
+			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1302
+			{
1303
+				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
1304
+				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
1305
+			}
1306
+		}
1307 1307
 	
1308
-        if ($sort != "")
1309
-        {
1310
-            $search_orderby_array = $Tracker->getOrderBy();
1311
-            $orderby_query = $search_orderby_array[$sort]['sql'];
1312
-        } else {
1313
-            $orderby_query = " ORDER BY tracker_archive_output.date DESC";
1314
-        }
1308
+		if ($sort != "")
1309
+		{
1310
+			$search_orderby_array = $Tracker->getOrderBy();
1311
+			$orderby_query = $search_orderby_array[$sort]['sql'];
1312
+		} else {
1313
+			$orderby_query = " ORDER BY tracker_archive_output.date DESC";
1314
+		}
1315 1315
 
1316
-        $query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
1316
+		$query = $global_query.$filter_query." tracker_archive_output.ident <> '' ".$additional_query." AND ((tracker_archive_output.departure_airport_icao <> 'NA') AND (tracker_archive_output.arrival_airport_icao <> 'NA')) ".$orderby_query;
1317 1317
 
1318
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1318
+		$spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
1319 1319
 
1320
-        return $spotter_array;
1321
-    }
1320
+		return $spotter_array;
1321
+	}
1322 1322
 }
1323 1323
 ?>
1324 1324
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -23,33 +23,33 @@  discard block
 block discarded – undo
23 23
      * @param bool $and
24 24
      * @return string the SQL part
25 25
      */
26
-	public function getFilter($filter = array(),$where = false,$and = false) {
26
+	public function getFilter($filter = array(), $where = false, $and = false) {
27 27
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
28 28
 		$filters = array();
29 29
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
30 30
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
31 31
 				$filters = $globalStatsFilters[$globalFilterName];
32 32
 			} else {
33
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
33
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
34 34
 			}
35 35
 		}
36 36
 		if (isset($filter[0]['source'])) {
37
-			$filters = array_merge($filters,$filter);
37
+			$filters = array_merge($filters, $filter);
38 38
 		}
39
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
39
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
40 40
 		$filter_query_join = '';
41 41
 		$filter_query_where = '';
42
-		foreach($filters as $flt) {
42
+		foreach ($filters as $flt) {
43 43
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
44 44
 				if (isset($flt['source'])) {
45
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
45
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_archive_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
46 46
 				} else {
47
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
47
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_archive.famtrackid";
48 48
 				}
49 49
 			}
50 50
 		}
51 51
 		if (isset($filter['source']) && !empty($filter['source'])) {
52
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
52
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
53 53
 		}
54 54
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
55 55
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_archive_output.date) = '".$filter['day']."'";
78 78
 				}
79 79
 			}
80
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
80
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_archive.famtrackid";
81 81
 		}
82 82
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
83
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
83
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
84 84
 		}
85 85
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
86 86
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
87 87
 		if ($filter_query_where != '') {
88
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
88
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
89 89
 		}
90 90
 		$filter_query = $filter_query_join.$filter_query_where;
91 91
 		return $filter_query;
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
 		require_once(dirname(__FILE__).'/class.Tracker.php');
116 116
 		if ($over_country == '') {
117 117
 			$Tracker = new Tracker($this->db);
118
-			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
118
+			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude, $longitude);
119 119
 			if (!empty($data_country)) $country = $data_country['iso2'];
120 120
 			else $country = '';
121 121
 		} else $country = $over_country;
122 122
 		// Route is not added in tracker_archive
123
-		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
123
+		$query = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
124 124
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
125
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country,':comment' => $comment,':type' => $type);
125
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $country, ':comment' => $comment, ':type' => $type);
126 126
 		try {
127 127
 			$sth = $this->db->prepare($query);
128 128
 			$sth->execute($query_values);
129 129
 			$sth->closeCursor();
130
-		} catch(PDOException $e) {
130
+		} catch (PDOException $e) {
131 131
 			return "error : ".$e->getMessage();
132 132
 		}
133 133
 		return "success";
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
         $Tracker = new Tracker($this->db);
146 146
         date_default_timezone_set('UTC');
147 147
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
148
-        $query  = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
149
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident));
148
+        $query = "SELECT tracker_archive.* FROM tracker_archive WHERE ident = :ident ORDER BY date DESC LIMIT 1";
149
+        $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident));
150 150
         return $spotter_array;
151 151
     }
152 152
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         $id = filter_var($id, FILTER_SANITIZE_STRING);
165 165
         //$query  = TrackerArchive->$global_query." WHERE tracker_archive.famtrackid = :id";
166 166
         //$query  = "SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
167
-        $query  = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
167
+        $query = "SELECT * FROM tracker_archive WHERE famtrackid = :id ORDER BY date DESC LIMIT 1";
168 168
 
169 169
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
170 170
         /*
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                 }
178 178
                 $spotter_array = $sth->fetchAll(PDO->FETCH_ASSOC);
179 179
                 */
180
-        $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id));
180
+        $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id));
181 181
 
182 182
         return $spotter_array;
183 183
     }
@@ -189,19 +189,19 @@  discard block
 block discarded – undo
189 189
      * @param string $date
190 190
      * @return array the spotter information
191 191
      */
192
-    public function getAllArchiveTrackerDataById($id,$date = '')
192
+    public function getAllArchiveTrackerDataById($id, $date = '')
193 193
     {
194 194
         date_default_timezone_set('UTC');
195 195
         $id = filter_var($id, FILTER_SANITIZE_STRING);
196
-        if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
197
-        else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
196
+        if ($date == '') $query = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
197
+        else $query = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c', $date)."' ORDER BY date";
198 198
 
199 199
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
200 200
 
201 201
         try {
202 202
             $sth = $this->db->prepare($query);
203 203
             $sth->execute(array(':id' => $id));
204
-        } catch(PDOException $e) {
204
+        } catch (PDOException $e) {
205 205
             echo $e->getMessage();
206 206
             die;
207 207
         }
@@ -220,14 +220,14 @@  discard block
 block discarded – undo
220 220
     {
221 221
         date_default_timezone_set('UTC');
222 222
         $id = filter_var($id, FILTER_SANITIZE_STRING);
223
-        $query  = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
223
+        $query = "SELECT tracker_archive.latitude, tracker_archive.longitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id";
224 224
 
225 225
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
226 226
 
227 227
         try {
228 228
             $sth = $this->db->prepare($query);
229 229
             $sth->execute(array(':id' => $id));
230
-        } catch(PDOException $e) {
230
+        } catch (PDOException $e) {
231 231
             echo $e->getMessage();
232 232
             die;
233 233
         }
@@ -249,12 +249,12 @@  discard block
 block discarded – undo
249 249
         date_default_timezone_set('UTC');
250 250
 
251 251
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
252
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
252
+        $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
253 253
 
254 254
         try {
255 255
             $sth = $this->db->prepare($query);
256 256
             $sth->execute(array(':ident' => $ident));
257
-        } catch(PDOException $e) {
257
+        } catch (PDOException $e) {
258 258
             echo $e->getMessage();
259 259
             die;
260 260
         }
@@ -275,12 +275,12 @@  discard block
 block discarded – undo
275 275
         date_default_timezone_set('UTC');
276 276
 
277 277
         $id = filter_var($id, FILTER_SANITIZE_STRING);
278
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
278
+        $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id AND tracker_archive.latitude <> 0 AND tracker_archive.longitude <> 0 ORDER BY date";
279 279
 
280 280
         try {
281 281
             $sth = $this->db->prepare($query);
282 282
             $sth->execute(array(':id' => $id));
283
-        } catch(PDOException $e) {
283
+        } catch (PDOException $e) {
284 284
             echo $e->getMessage();
285 285
             die;
286 286
         }
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
         date_default_timezone_set('UTC');
302 302
 
303 303
         $id = filter_var($id, FILTER_SANITIZE_STRING);
304
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
304
+        $query = "SELECT tracker_archive.altitude, tracker_archive.ground_speed, tracker_archive.date FROM tracker_archive WHERE tracker_archive.famtrackid = :id ORDER BY date";
305 305
 
306 306
         try {
307 307
             $sth = $this->db->prepare($query);
308 308
             $sth->execute(array(':id' => $id));
309
-        } catch(PDOException $e) {
309
+        } catch (PDOException $e) {
310 310
             echo $e->getMessage();
311 311
             die;
312 312
         }
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
         date_default_timezone_set('UTC');
329 329
 
330 330
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
331
-        $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
331
+        $query = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate LIMIT 1";
332 332
 //                $query  = "SELECT tracker_archive.altitude, tracker_archive.date FROM tracker_archive WHERE tracker_archive.ident = :ident";
333 333
 
334 334
         try {
335 335
             $sth = $this->db->prepare($query);
336 336
             $sth->execute(array(':ident' => $ident));
337
-        } catch(PDOException $e) {
337
+        } catch (PDOException $e) {
338 338
             echo $e->getMessage();
339 339
             die;
340 340
         }
@@ -352,13 +352,13 @@  discard block
 block discarded – undo
352 352
      * @param $date
353 353
      * @return array the spotter information
354 354
      */
355
-    public function getTrackerArchiveData($ident,$famtrackid,$date)
355
+    public function getTrackerArchiveData($ident, $famtrackid, $date)
356 356
     {
357 357
         $Tracker = new Tracker($this->db);
358 358
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
359
-        $query  = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
359
+        $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.famtrackid = :famtrackid AND l.date LIKE :date GROUP BY l.famtrackid) s on spotter_live.famtrackid = s.famtrackid AND spotter_live.date = s.maxdate";
360 360
 
361
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':famtrackid' => $famtrackid,':date' => $date.'%'));
361
+        $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':famtrackid' => $famtrackid, ':date' => $date.'%'));
362 362
 
363 363
         return $spotter_array;
364 364
     }
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
         try {
375 375
             $sth = $this->db->prepare($query);
376 376
             $sth->execute();
377
-        } catch(PDOException $e) {
377
+        } catch (PDOException $e) {
378 378
             echo $e->getMessage();
379 379
             die;
380 380
         }
@@ -388,24 +388,24 @@  discard block
 block discarded – undo
388 388
      * @param array $filter
389 389
      * @return array the spotter information
390 390
      */
391
-    public function getMinLiveTrackerData($begindate,$enddate,$filter = array())
391
+    public function getMinLiveTrackerData($begindate, $enddate, $filter = array())
392 392
     {
393 393
         global $globalDBdriver;
394 394
         date_default_timezone_set('UTC');
395 395
 
396 396
         $filter_query = '';
397 397
         if (isset($filter['source']) && !empty($filter['source'])) {
398
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
398
+            $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
399 399
         }
400 400
         // Use spotter_output also ?
401 401
         if (isset($filter['airlines']) && !empty($filter['airlines'])) {
402
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
402
+            $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
403 403
         }
404 404
         if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
405 405
             $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
406 406
         }
407 407
         if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
408
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
408
+            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
409 409
         }
410 410
 
411 411
         //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -424,14 +424,14 @@  discard block
 block discarded – undo
424 424
 						GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid 
425 425
 				    AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
426 426
 */
427
-            $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
427
+            $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
428 428
 				    FROM tracker_archive 
429 429
 				    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
430 430
 				    WHERE tracker_archive.date BETWEEN '."'".$begindate."'".' AND '."'".$begindate."'".' 
431 431
                         	    '.$filter_query.' ORDER BY famtrackid';
432 432
         } else {
433 433
             //$query  = 'SELECT tracker_archive.ident, tracker_archive.famtrackid, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao';
434
-            $query  = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
434
+            $query = 'SELECT tracker_archive.date,tracker_archive.famtrackid, tracker_archive.ident, tracker_archive.aircraft_icao, tracker_archive.departure_airport_icao as departure_airport, tracker_archive.arrival_airport_icao as arrival_airport, tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.squawk, a.aircraft_shadow,a.engine_type, a.engine_count, a.wake_category 
435 435
                         	    FROM tracker_archive 
436 436
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive.aircraft_icao = a.icao
437 437
                         	    WHERE tracker_archive.date >= '."'".$begindate."'".' AND tracker_archive.date <= '."'".$enddate."'".'
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
         try {
442 442
             $sth = $this->db->prepare($query);
443 443
             $sth->execute();
444
-        } catch(PDOException $e) {
444
+        } catch (PDOException $e) {
445 445
             echo $e->getMessage();
446 446
             die;
447 447
         }
@@ -458,24 +458,24 @@  discard block
 block discarded – undo
458 458
      * @param array $filter
459 459
      * @return array the spotter information
460 460
      */
461
-    public function getMinLiveTrackerDataPlayback($begindate,$enddate,$filter = array())
461
+    public function getMinLiveTrackerDataPlayback($begindate, $enddate, $filter = array())
462 462
     {
463 463
         global $globalDBdriver;
464 464
         date_default_timezone_set('UTC');
465 465
 
466 466
         $filter_query = '';
467 467
         if (isset($filter['source']) && !empty($filter['source'])) {
468
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
468
+            $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
469 469
         }
470 470
         // Should use spotter_output also ?
471 471
         if (isset($filter['airlines']) && !empty($filter['airlines'])) {
472
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
472
+            $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
473 473
         }
474 474
         if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
475 475
             $filter_query .= " INNER JOIN (SELECT famtrackid FROM tracker_archive_output WHERE tracker_archive_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
476 476
         }
477 477
         if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
478
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
478
+            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
479 479
         }
480 480
 
481 481
         //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
                     		    FROM tracker_archive 
486 486
                     		    INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE (l.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate '.$filter_query.'LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive.aircraft_icao = a.icao';
487 487
 			*/
488
-            $query  = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
488
+            $query = 'SELECT a.aircraft_shadow, tracker_archive_output.ident, tracker_archive_output.famtrackid, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk 
489 489
 				    FROM tracker_archive_output 
490 490
 				    LEFT JOIN (SELECT aircraft_shadow,icao FROM aircraft) a ON tracker_archive_output.aircraft_icao = a.icao 
491 491
 				    WHERE (tracker_archive_output.date BETWEEN '."'".$begindate."'".' AND '."'".$enddate."'".') 
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
501 501
                         	    '.$filter_query.' GROUP BY tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao, tracker_archive_output.arrival_airport_icao, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow';
502 502
                         */
503
-            $query  = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
503
+            $query = 'SELECT DISTINCT tracker_archive_output.famtrackid, tracker_archive_output.ident, tracker_archive_output.aircraft_icao, tracker_archive_output.departure_airport_icao as departure_airport, tracker_archive_output.arrival_airport_icao as arrival_airport, tracker_archive_output.latitude, tracker_archive_output.longitude, tracker_archive_output.altitude, tracker_archive_output.heading, tracker_archive_output.ground_speed, tracker_archive_output.squawk, a.aircraft_shadow
504 504
                         	    FROM tracker_archive_output 
505 505
                         	    INNER JOIN (SELECT * FROM aircraft) a on tracker_archive_output.aircraft_icao = a.icao
506 506
                         	    WHERE tracker_archive_output.date >= '."'".$begindate."'".' AND tracker_archive_output.date <= '."'".$enddate."'".'
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         try {
513 513
             $sth = $this->db->prepare($query);
514 514
             $sth->execute();
515
-        } catch(PDOException $e) {
515
+        } catch (PDOException $e) {
516 516
             echo $e->getMessage();
517 517
             die;
518 518
         }
@@ -529,23 +529,23 @@  discard block
 block discarded – undo
529 529
      * @param array $filter
530 530
      * @return array the spotter information
531 531
      */
532
-    public function getLiveTrackerCount($begindate,$enddate,$filter = array())
532
+    public function getLiveTrackerCount($begindate, $enddate, $filter = array())
533 533
     {
534 534
         global $globalDBdriver, $globalLiveInterval;
535 535
         date_default_timezone_set('UTC');
536 536
 
537 537
         $filter_query = '';
538 538
         if (isset($filter['source']) && !empty($filter['source'])) {
539
-            $filter_query .= " AND format_source IN ('".implode("','",$filter['source'])."') ";
539
+            $filter_query .= " AND format_source IN ('".implode("','", $filter['source'])."') ";
540 540
         }
541 541
         if (isset($filter['airlines']) && !empty($filter['airlines'])) {
542
-            $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','",$filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
542
+            $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_icao IN ('".implode("','", $filter['airlines'])."')) so ON so.famtrackid = tracker_archive.famtrackid ";
543 543
         }
544 544
         if (isset($filter['airlinestype']) && !empty($filter['airlinestype'])) {
545 545
             $filter_query .= " INNER JOIN (SELECT famtrackid FROM spotter_output WHERE spotter_output.airline_type = '".$filter['airlinestype']."') sa ON sa.famtrackid = tracker_archive.famtrackid ";
546 546
         }
547 547
         if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
548
-            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
548
+            $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
549 549
         }
550 550
 
551 551
         //if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
         try {
561 561
             $sth = $this->db->prepare($query);
562 562
             $sth->execute();
563
-        } catch(PDOException $e) {
563
+        } catch (PDOException $e) {
564 564
             echo $e->getMessage();
565 565
             die;
566 566
         }
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
      * @param array $filters
605 605
      * @return array the spotter information
606 606
      */
607
-    public function searchTrackerData($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())
607
+    public function searchTrackerData($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())
608 608
     {
609 609
         global $globalTimezone, $globalDBdriver;
610 610
         require_once(dirname(__FILE__).'/class.Translation.php');
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
 	        
627 627
                 $q_array = explode(" ", $q);
628 628
 		
629
-                foreach ($q_array as $q_item){
629
+                foreach ($q_array as $q_item) {
630 630
                     $additional_query .= " AND (";
631 631
                     $additional_query .= "(tracker_archive_output.spotter_id like '%".$q_item."%') OR ";
632 632
                     $additional_query .= "(tracker_archive_output.aircraft_icao like '%".$q_item."%') OR ";
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
 	
659 659
         if ($registration != "")
660 660
         {
661
-            $registration = filter_var($registration,FILTER_SANITIZE_STRING);
661
+            $registration = filter_var($registration, FILTER_SANITIZE_STRING);
662 662
             if (!is_string($registration))
663 663
             {
664 664
                 return array();
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 	
670 670
         if ($aircraft_icao != "")
671 671
         {
672
-            $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING);
672
+            $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING);
673 673
             if (!is_string($aircraft_icao))
674 674
             {
675 675
                 return array();
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 	
681 681
         if ($aircraft_manufacturer != "")
682 682
         {
683
-            $aircraft_manufacturer = filter_var($aircraft_manufacturer,FILTER_SANITIZE_STRING);
683
+            $aircraft_manufacturer = filter_var($aircraft_manufacturer, FILTER_SANITIZE_STRING);
684 684
             if (!is_string($aircraft_manufacturer))
685 685
             {
686 686
                 return array();
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 	
702 702
         if ($airline_icao != "")
703 703
         {
704
-            $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING);
704
+            $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING);
705 705
             if (!is_string($airline_icao))
706 706
             {
707 707
                 return array();
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 	
713 713
         if ($airline_country != "")
714 714
         {
715
-            $airline_country = filter_var($airline_country,FILTER_SANITIZE_STRING);
715
+            $airline_country = filter_var($airline_country, FILTER_SANITIZE_STRING);
716 716
             if (!is_string($airline_country))
717 717
             {
718 718
                 return array();
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	
724 724
         if ($airline_type != "")
725 725
         {
726
-            $airline_type = filter_var($airline_type,FILTER_SANITIZE_STRING);
726
+            $airline_type = filter_var($airline_type, FILTER_SANITIZE_STRING);
727 727
             if (!is_string($airline_type))
728 728
             {
729 729
                 return array();
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	
746 746
         if ($airport != "")
747 747
         {
748
-            $airport = filter_var($airport,FILTER_SANITIZE_STRING);
748
+            $airport = filter_var($airport, FILTER_SANITIZE_STRING);
749 749
             if (!is_string($airport))
750 750
             {
751 751
                 return array();
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 	
757 757
         if ($airport_country != "")
758 758
         {
759
-            $airport_country = filter_var($airport_country,FILTER_SANITIZE_STRING);
759
+            $airport_country = filter_var($airport_country, FILTER_SANITIZE_STRING);
760 760
             if (!is_string($airport_country))
761 761
             {
762 762
                 return array();
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
     
768 768
         if ($callsign != "")
769 769
         {
770
-            $callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
770
+            $callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
771 771
             if (!is_string($callsign))
772 772
             {
773 773
                 return array();
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
                 $translate = $Translation->ident2icao($callsign);
776 776
                 if ($translate != $callsign) {
777 777
                     $additional_query .= " AND (tracker_archive_output.ident = :callsign OR tracker_archive_output.ident = :translate)";
778
-                    $query_values = array_merge($query_values,array(':callsign' => $callsign,':translate' => $translate));
778
+                    $query_values = array_merge($query_values, array(':callsign' => $callsign, ':translate' => $translate));
779 779
                 } else {
780 780
                     $additional_query .= " AND (tracker_archive_output.ident = '".$callsign."')";
781 781
                 }
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
 
785 785
         if ($owner != "")
786 786
         {
787
-            $owner = filter_var($owner,FILTER_SANITIZE_STRING);
787
+            $owner = filter_var($owner, FILTER_SANITIZE_STRING);
788 788
             if (!is_string($owner))
789 789
             {
790 790
                 return array();
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 
796 796
         if ($pilot_name != "")
797 797
         {
798
-            $pilot_name = filter_var($pilot_name,FILTER_SANITIZE_STRING);
798
+            $pilot_name = filter_var($pilot_name, FILTER_SANITIZE_STRING);
799 799
             if (!is_string($pilot_name))
800 800
             {
801 801
                 return array();
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 	
807 807
         if ($pilot_id != "")
808 808
         {
809
-            $pilot_id = filter_var($pilot_id,FILTER_SANITIZE_NUMBER_INT);
809
+            $pilot_id = filter_var($pilot_id, FILTER_SANITIZE_NUMBER_INT);
810 810
             if (!is_string($pilot_id))
811 811
             {
812 812
                 return array();
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
 	
818 818
         if ($departure_airport_route != "")
819 819
         {
820
-            $departure_airport_route = filter_var($departure_airport_route,FILTER_SANITIZE_STRING);
820
+            $departure_airport_route = filter_var($departure_airport_route, FILTER_SANITIZE_STRING);
821 821
             if (!is_string($departure_airport_route))
822 822
             {
823 823
                 return array();
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 	
829 829
         if ($arrival_airport_route != "")
830 830
         {
831
-            $arrival_airport_route = filter_var($arrival_airport_route,FILTER_SANITIZE_STRING);
831
+            $arrival_airport_route = filter_var($arrival_airport_route, FILTER_SANITIZE_STRING);
832 832
             if (!is_string($arrival_airport_route))
833 833
             {
834 834
                 return array();
@@ -841,8 +841,8 @@  discard block
 block discarded – undo
841 841
         {
842 842
             $altitude_array = explode(",", $altitude);
843 843
 	    
844
-            $altitude_array[0] = filter_var($altitude_array[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
845
-            $altitude_array[1] = filter_var($altitude_array[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
844
+            $altitude_array[0] = filter_var($altitude_array[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
845
+            $altitude_array[1] = filter_var($altitude_array[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
846 846
 	    
847 847
 
848 848
             if ($altitude_array[1] != "")
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
         {
861 861
             $date_array = explode(",", $date_posted);
862 862
 	    
863
-            $date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
864
-            $date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
863
+            $date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
864
+            $date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
865 865
 	    
866 866
             if ($globalTimezone != '') {
867 867
                 date_default_timezone_set($globalTimezone);
@@ -893,8 +893,8 @@  discard block
 block discarded – undo
893 893
         {
894 894
             $limit_array = explode(",", $limit);
895 895
 	    
896
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
897
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
896
+            $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
897
+            $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
898 898
 	    
899 899
             if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
900 900
             {
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	
906 906
 
907 907
         if ($origLat != "" && $origLon != "" && $dist != "") {
908
-            $dist = number_format($dist*0.621371,2,'.','');
909
-            $query="SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
908
+            $dist = number_format($dist*0.621371, 2, '.', '');
909
+            $query = "SELECT tracker_archive_output.*, 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2))) as distance 
910 910
                           FROM tracker_archive_output, tracker_archive WHERE spotter_output_archive.famtrackid = tracker_archive.famtrackid AND spotter_output.ident <> '' ".$additional_query."AND CAST(tracker_archive.longitude as double precision) between ($origLon-$dist/ABS(cos(radians($origLat))*69)) and ($origLon+$dist/ABS(cos(radians($origLat))*69)) and CAST(tracker_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
911 911
                           AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - ABS(CAST(tracker_archive.latitude as double precision)))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(ABS(CAST(tracker_archive.latitude as double precision))*pi()/180)*POWER(SIN(($origLon-CAST(tracker_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query." ORDER BY distance";
912 912
         } else {
@@ -923,12 +923,12 @@  discard block
 block discarded – undo
923 923
                 $additional_query .= " AND (tracker_archive_output.waypoints <> '')";
924 924
             }
925 925
 
926
-            $query  = "SELECT tracker_archive_output.* FROM tracker_archive_output 
926
+            $query = "SELECT tracker_archive_output.* FROM tracker_archive_output 
927 927
 		    WHERE tracker_archive_output.ident <> '' 
928 928
 		    ".$additional_query."
929 929
 		    ".$filter_query.$orderby_query;
930 930
         }
931
-        $spotter_array = $Tracker->getDataFromDB($query, $query_values,$limit_query);
931
+        $spotter_array = $Tracker->getDataFromDB($query, $query_values, $limit_query);
932 932
 
933 933
         return $spotter_array;
934 934
     }
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
         try {
946 946
             $sth = $this->db->prepare($query);
947 947
             $sth->execute();
948
-        } catch(PDOException $e) {
948
+        } catch (PDOException $e) {
949 949
             return "error";
950 950
         }
951 951
         return '';
@@ -985,8 +985,8 @@  discard block
 block discarded – undo
985 985
         {
986 986
             $limit_array = explode(",", $limit);
987 987
 	    
988
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
989
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
988
+            $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
989
+            $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
990 990
 	    
991 991
             if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
992 992
             {
@@ -1030,7 +1030,7 @@  discard block
 block discarded – undo
1030 1030
         $query_values = array();
1031 1031
         $limit_query = '';
1032 1032
         $additional_query = '';
1033
-        $filter_query = $this->getFilter($filter,true,true);
1033
+        $filter_query = $this->getFilter($filter, true, true);
1034 1034
 	
1035 1035
         if ($owner != "")
1036 1036
         {
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
         {
1048 1048
             $limit_array = explode(",", $limit);
1049 1049
 	    
1050
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1051
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1050
+            $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1051
+            $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1052 1052
 	    
1053 1053
             if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1054 1054
             {
@@ -1091,7 +1091,7 @@  discard block
 block discarded – undo
1091 1091
         $query_values = array();
1092 1092
         $limit_query = '';
1093 1093
         $additional_query = '';
1094
-        $filter_query = $this->getFilter($filter,true,true);
1094
+        $filter_query = $this->getFilter($filter, true, true);
1095 1095
 	
1096 1096
         if ($pilot != "")
1097 1097
         {
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
         {
1104 1104
             $limit_array = explode(",", $limit);
1105 1105
 	    
1106
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1107
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1106
+            $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1107
+            $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1108 1108
 	    
1109 1109
             if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1110 1110
             {
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
      * @param string $sincedate
1137 1137
      * @return array the airline country list
1138 1138
      */
1139
-    public function countAllFlightOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '')
1139
+    public function countAllFlightOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '')
1140 1140
     {
1141 1141
         global $globalDBdriver;
1142 1142
         /*
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
         $flight_array = array();
1166 1166
         $temp_array = array();
1167 1167
         
1168
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
1168
+        while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1169 1169
         {
1170 1170
             $temp_array['flight_count'] = $row['nb'];
1171 1171
             $temp_array['flight_country'] = $row['name'];
@@ -1184,7 +1184,7 @@  discard block
 block discarded – undo
1184 1184
      * @param string $sincedate
1185 1185
      * @return array the airline country list
1186 1186
      */
1187
-    public function countAllFlightOverCountriesByAirlines($limit = true,$olderthanmonths = 0,$sincedate = '')
1187
+    public function countAllFlightOverCountriesByAirlines($limit = true, $olderthanmonths = 0, $sincedate = '')
1188 1188
     {
1189 1189
         global $globalDBdriver;
1190 1190
         /*
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
         $flight_array = array();
1214 1214
         $temp_array = array();
1215 1215
         
1216
-        while($row = $sth->fetch(PDO::FETCH_ASSOC))
1216
+        while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1217 1217
         {
1218 1218
             $temp_array['airline_icao'] = $row['airline_icao'];
1219 1219
             $temp_array['flight_count'] = $row['nb'];
@@ -1232,14 +1232,14 @@  discard block
 block discarded – undo
1232 1232
      * @param $date
1233 1233
      * @return array the spotter information
1234 1234
      */
1235
-    public function getDateArchiveTrackerDataById($id,$date)
1235
+    public function getDateArchiveTrackerDataById($id, $date)
1236 1236
     {
1237 1237
         $Tracker = new Tracker($this->db);
1238 1238
         date_default_timezone_set('UTC');
1239 1239
         $id = filter_var($id, FILTER_SANITIZE_STRING);
1240
-        $query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1241
-        $date = date('c',$date);
1242
-        $spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date));
1240
+        $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1241
+        $date = date('c', $date);
1242
+        $spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date));
1243 1243
         return $spotter_array;
1244 1244
     }
1245 1245
 
@@ -1250,14 +1250,14 @@  discard block
 block discarded – undo
1250 1250
      * @param $date
1251 1251
      * @return array the spotter information
1252 1252
      */
1253
-    public function getDateArchiveTrackerDataByIdent($ident,$date)
1253
+    public function getDateArchiveTrackerDataByIdent($ident, $date)
1254 1254
     {
1255 1255
         $Tracker = new Tracker($this->db);
1256 1256
         date_default_timezone_set('UTC');
1257 1257
         $ident = filter_var($ident, FILTER_SANITIZE_STRING);
1258
-        $query  = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1259
-        $date = date('c',$date);
1260
-        $spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
1258
+        $query = 'SELECT tracker_archive.* FROM tracker_archive INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_archive l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_archive.famtrackid = s.famtrackid AND tracker_archive.date = s.maxdate ORDER BY tracker_archive.date DESC';
1259
+        $date = date('c', $date);
1260
+        $spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
1261 1261
         return $spotter_array;
1262 1262
     }
1263 1263
 
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
      * @param array $filters
1271 1271
      * @return array the spotter information
1272 1272
      */
1273
-    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '',$filters = array())
1273
+    public function getTrackerDataByAirport($airport = '', $limit = '', $sort = '', $filters = array())
1274 1274
     {
1275 1275
         global $global_query;
1276 1276
         $Tracker = new Tracker($this->db);
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
         $query_values = array();
1279 1279
         $limit_query = '';
1280 1280
         $additional_query = '';
1281
-        $filter_query = $this->getFilter($filters,true,true);
1281
+        $filter_query = $this->getFilter($filters, true, true);
1282 1282
 	
1283 1283
         if ($airport != "")
1284 1284
         {
@@ -1295,8 +1295,8 @@  discard block
 block discarded – undo
1295 1295
         {
1296 1296
             $limit_array = explode(",", $limit);
1297 1297
 	    
1298
-            $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1299
-            $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1298
+            $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1299
+            $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1300 1300
 	    
1301 1301
             if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1302 1302
             {
Please login to merge, or discard this patch.
Braces   +42 added lines, -15 removed lines patch added patch discarded remove patch
@@ -13,7 +13,9 @@  discard block
 block discarded – undo
13 13
 	public function __construct($dbc = null) {
14 14
 		$Connection = new Connection($dbc);
15 15
 		$this->db = $Connection->db;
16
-		if ($this->db === null) die('Error: No DB connection. (TrackerArchive)');
16
+		if ($this->db === null) {
17
+			die('Error: No DB connection. (TrackerArchive)');
18
+		}
17 19
 	}
18 20
 
19 21
     /**
@@ -36,7 +38,9 @@  discard block
 block discarded – undo
36 38
 		if (isset($filter[0]['source'])) {
37 39
 			$filters = array_merge($filters,$filter);
38 40
 		}
39
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
41
+		if (is_array($globalFilter)) {
42
+			$filter = array_merge($filter,$globalFilter);
43
+		}
40 44
 		$filter_query_join = '';
41 45
 		$filter_query_where = '';
42 46
 		foreach($filters as $flt) {
@@ -82,8 +86,11 @@  discard block
 block discarded – undo
82 86
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
83 87
 			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
84 88
 		}
85
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
86
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
89
+		if ($filter_query_where == '' && $where) {
90
+			$filter_query_where = ' WHERE';
91
+		} elseif ($filter_query_where != '' && $and) {
92
+			$filter_query_where .= ' AND';
93
+		}
87 94
 		if ($filter_query_where != '') {
88 95
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
89 96
 		}
@@ -116,9 +123,14 @@  discard block
 block discarded – undo
116 123
 		if ($over_country == '') {
117 124
 			$Tracker = new Tracker($this->db);
118 125
 			$data_country = $Tracker->getCountryFromLatitudeLongitude($latitude,$longitude);
119
-			if (!empty($data_country)) $country = $data_country['iso2'];
120
-			else $country = '';
121
-		} else $country = $over_country;
126
+			if (!empty($data_country)) {
127
+				$country = $data_country['iso2'];
128
+			} else {
129
+				$country = '';
130
+			}
131
+		} else {
132
+			$country = $over_country;
133
+		}
122 134
 		// Route is not added in tracker_archive
123 135
 		$query  = 'INSERT INTO tracker_archive (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
124 136
 		    VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
@@ -193,8 +205,11 @@  discard block
 block discarded – undo
193 205
     {
194 206
         date_default_timezone_set('UTC');
195 207
         $id = filter_var($id, FILTER_SANITIZE_STRING);
196
-        if ($date == '') $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
197
-        else $query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
208
+        if ($date == '') {
209
+        	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id ORDER BY date";
210
+        } else {
211
+        	$query  = $this->global_query." WHERE tracker_archive.famtrackid = :id AND date < '".date('c',$date)."' ORDER BY date";
212
+        }
198 213
 
199 214
 //              $spotter_array = Tracker->getDataFromDB($query,array(':id' => $id));
200 215
 
@@ -649,7 +664,9 @@  discard block
 block discarded – undo
649 664
                     $additional_query .= "(tracker_archive_output.pilot_name like '%".$q_item."%') OR ";
650 665
                     $additional_query .= "(tracker_archive_output.ident like '%".$q_item."%') OR ";
651 666
                     $translate = $Translation->ident2icao($q_item);
652
-                    if ($translate != $q_item) $additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
667
+                    if ($translate != $q_item) {
668
+                    	$additional_query .= "(tracker_archive_output.ident like '%".$translate."%') OR ";
669
+                    }
653 670
                     $additional_query .= "(tracker_archive_output.highlight like '%".$q_item."%')";
654 671
                     $additional_query .= ")";
655 672
                 }
@@ -867,7 +884,9 @@  discard block
 block discarded – undo
867 884
                 date_default_timezone_set($globalTimezone);
868 885
                 $datetime = new DateTime();
869 886
                 $offset = $datetime->format('P');
870
-            } else $offset = '+00:00';
887
+            } else {
888
+            	$offset = '+00:00';
889
+            }
871 890
 
872 891
 
873 892
             if ($date_array[1] != "")
@@ -1154,9 +1173,13 @@  discard block
 block discarded – undo
1154 1173
                 $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1155 1174
             }
1156 1175
         }
1157
-        if ($sincedate != '') $query .= "AND date > '".$sincedate."' ";
1176
+        if ($sincedate != '') {
1177
+        	$query .= "AND date > '".$sincedate."' ";
1178
+        }
1158 1179
         $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1159
-        if ($limit) $query .= " LIMIT 0,10";
1180
+        if ($limit) {
1181
+        	$query .= " LIMIT 0,10";
1182
+        }
1160 1183
       
1161 1184
 	
1162 1185
         $sth = $this->db->prepare($query);
@@ -1202,9 +1225,13 @@  discard block
 block discarded – undo
1202 1225
                 $query .= "AND s.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1203 1226
             }
1204 1227
         }
1205
-        if ($sincedate != '') $query .= "AND s.date > '".$sincedate."' ";
1228
+        if ($sincedate != '') {
1229
+        	$query .= "AND s.date > '".$sincedate."' ";
1230
+        }
1206 1231
         $query .= "GROUP BY o.airline_icao,c.name, c.iso3, c.iso2 ORDER BY nb DESC";
1207
-        if ($limit) $query .= " LIMIT 0,10";
1232
+        if ($limit) {
1233
+        	$query .= " LIMIT 0,10";
1234
+        }
1208 1235
       
1209 1236
 	
1210 1237
         $sth = $this->db->prepare($query);
Please login to merge, or discard this patch.
require/class.Scheduler.php 3 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 		if ($this->db === null) die('Error: No DB connection.');
28 28
 	}
29 29
 
30
-    /**
31
-     * Add schedule data to database
32
-     * @param String $ident aircraft ident
33
-     * @param String $departure_airport_icao departure airport icao
34
-     * @param String $departure_airport_time departure airport time
35
-     * @param String $arrival_airport_icao arrival airport icao
36
-     * @param String $arrival_airport_time arrival airport time
37
-     * @param String $source source of data
38
-     * @return string
39
-     */
30
+	/**
31
+	 * Add schedule data to database
32
+	 * @param String $ident aircraft ident
33
+	 * @param String $departure_airport_icao departure airport icao
34
+	 * @param String $departure_airport_time departure airport time
35
+	 * @param String $arrival_airport_icao arrival airport icao
36
+	 * @param String $arrival_airport_time arrival airport time
37
+	 * @param String $source source of data
38
+	 * @return string
39
+	 */
40 40
 	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
41 41
 		date_default_timezone_set('UTC');
42 42
 		$date = date("Y-m-d H:i:s",time());
@@ -52,18 +52,18 @@  discard block
 block discarded – undo
52 52
 		}
53 53
 		if ($sth->fetchColumn() > 0) {
54 54
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
55
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
55
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
57 57
 			} elseif ($arrival_airport_time == '') {
58
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
58
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
60 60
 			} elseif ($departure_airport_time == '') {
61
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
61
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
63 63
 			} else {
64
-			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65
-			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
64
+				//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65
+				$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
+				$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
67 67
 			}
68 68
 			try {
69 69
 				$sth = $this->db->prepare($query);
@@ -151,15 +151,15 @@  discard block
 block discarded – undo
151 151
 	*/
152 152
 	public function checkSchedule($ident) {
153 153
 		global $globalDBdriver;
154
-	        //$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
155
-	        if ($globalDBdriver == 'mysql') {
154
+			//$query = "SELECT COUNT(*) as nb FROM schedule WHERE ident = :ident AND date_added > DATE_SUB(CURDATE(), INTERVAL 8 DAY) - 8 LIMIT 1";
155
+			if ($globalDBdriver == 'mysql') {
156 156
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident AND ((date_added BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 1 MONTH)) AND DATE(NOW()) and date_modified IS NULL) OR (date_modified BETWEEN DATE(DATE_SUB(CURDATE(), INTERVAL 15 DAY)) AND DATE(NOW()))) LIMIT 1";
157 157
 		} else {
158 158
 			$query = "SELECT COUNT(*) as nb FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident 
159 159
 			AND ((date_added::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) and date_modified::timestamp IS NULL)
160 160
 			     OR (date_modified::timestamp BETWEEN CURRENT_TIMESTAMP - INTERVAL '1 MONTH' AND CURRENT_TIMESTAMP) LIMIT 1";
161 161
 		}
162
-	        $query_values = array(':ident' => $ident);
162
+			$query_values = array(':ident' => $ident);
163 163
 		 try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute($query_values);
@@ -171,13 +171,13 @@  discard block
 block discarded – undo
171 171
 		return $row['nb'];
172 172
 	}
173 173
 
174
-    /**
175
-     * Get flight info from Air France
176
-     * @param String $callsign The callsign
177
-     * @param String $date date we want flight number info
178
-     * @param String $carrier IATA code
179
-     * @return array departure and arrival airports and time
180
-     */
174
+	/**
175
+	 * Get flight info from Air France
176
+	 * @param String $callsign The callsign
177
+	 * @param String $date date we want flight number info
178
+	 * @param String $carrier IATA code
179
+	 * @return array departure and arrival airports and time
180
+	 */
181 181
 	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
182 182
 		$Common = new Common();
183 183
 		$check_date = new Datetime($date);
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
 		} else return array();
213 213
 	}
214 214
 
215
-    /**
216
-     * Get flight info from EasyJet
217
-     * @param String $callsign The callsign
218
-     * @param String $date date we want flight number info
219
-     * @return array departure and arrival airports and time
220
-     */
215
+	/**
216
+	 * Get flight info from EasyJet
217
+	 * @param String $callsign The callsign
218
+	 * @param String $date date we want flight number info
219
+	 * @return array departure and arrival airports and time
220
+	 */
221 221
 	private function getEasyJet($callsign, $date = 'NOW') {
222 222
 		global $globalTimezone;
223 223
 		$Common = new Common();
@@ -240,11 +240,11 @@  discard block
 block discarded – undo
240 240
 		} else return array();
241 241
 	}
242 242
 
243
-    /**
244
-     * Get flight info from Ryanair
245
-     * @param String $callsign The callsign
246
-     * @return array Flight departure and arrival airports and time
247
-     */
243
+	/**
244
+	 * Get flight info from Ryanair
245
+	 * @param String $callsign The callsign
246
+	 * @return array Flight departure and arrival airports and time
247
+	 */
248 248
 	private function getRyanair($callsign) {
249 249
 		$Common = new Common();
250 250
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 	}
268 268
 
269 269
 	/**
270
-	* Get flight info from Swiss
271
-	* @param string $callsign The callsign
272
-	* @return array Flight departure and arrival airports and time
273
-	*/
270
+	 * Get flight info from Swiss
271
+	 * @param string $callsign The callsign
272
+	 * @return array Flight departure and arrival airports and time
273
+	 */
274 274
 	private function getSwiss($callsign) {
275 275
 		$Common = new Common();
276 276
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 	
301 301
 	/**
302
-	* Get flight info from British Airways API
303
-	* @param String $callsign The callsign
304
-	* @param String $date date we want flight number info
305
-	* @return array Flight departure and arrival airports and time
306
-	*/
302
+	 * Get flight info from British Airways API
303
+	 * @param String $callsign The callsign
304
+	 * @param String $date date we want flight number info
305
+	 * @return array Flight departure and arrival airports and time
306
+	 */
307 307
 	public function getBritishAirways($callsign, $date = 'NOW') {
308 308
 		global $globalBritishAirwaysKey;
309 309
 		$Common = new Common();
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
 	}
328 328
 
329 329
 	/**
330
-	* Get flight info from Lutfhansa API
331
-	* @param String $callsign The callsign
332
-	* @param String $date date we want flight number info
333
-	* @return array Flight departure and arrival airports and time
334
-	*/
330
+	 * Get flight info from Lutfhansa API
331
+	 * @param String $callsign The callsign
332
+	 * @param String $date date we want flight number info
333
+	 * @return array Flight departure and arrival airports and time
334
+	 */
335 335
 	public function getLufthansa($callsign, $date = 'NOW') {
336 336
 		global $globalLufthansaKey;
337 337
 		$Common = new Common();
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	}
362 362
 
363 363
 	/**
364
-	* Get flight info from Transavia API
365
-	* @param string $callsign The callsign
366
-	* @param string $date date we want flight number info
367
-	* @return array Flight departure and arrival airports and time
368
-	*/
364
+	 * Get flight info from Transavia API
365
+	 * @param string $callsign The callsign
366
+	 * @param string $date date we want flight number info
367
+	 * @return array Flight departure and arrival airports and time
368
+	 */
369 369
 	public function getTransavia($callsign, $date = 'NOW') {
370 370
 		global $globalTransaviaKey;
371 371
 		$Common = new Common();
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 	}
392 392
 
393 393
 	/**
394
-	* Get flight info from Tunisair
395
-	* @param string $callsign The callsign
396
-	* @return array Flight departure and arrival airports and time
397
-	*/
394
+	 * Get flight info from Tunisair
395
+	 * @param string $callsign The callsign
396
+	 * @return array Flight departure and arrival airports and time
397
+	 */
398 398
 	public function getTunisair($callsign) {
399 399
 		$Common = new Common();
400 400
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -410,12 +410,12 @@  discard block
 block discarded – undo
410 410
 		return array();
411 411
 	}
412 412
 
413
-    /**
414
-     * Get flight info from Vueling
415
-     * @param String $callsign The callsign
416
-     * @param string $date
417
-     * @return array Flight departure and arrival airports and time
418
-     */
413
+	/**
414
+	 * Get flight info from Vueling
415
+	 * @param String $callsign The callsign
416
+	 * @param string $date
417
+	 * @return array Flight departure and arrival airports and time
418
+	 */
419 419
 	public function getVueling($callsign,$date = 'NOW') {
420 420
 		$Common = new Common();
421 421
 		$check_date = new Datetime($date);
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 	}
438 438
 
439 439
 	/**
440
-	* Get flight info from Iberia
441
-	* @param String $callsign The callsign
442
-	* @param String $date date we want flight number info
443
-	* @return array Flight departure and arrival airports and time
444
-	*/
440
+	 * Get flight info from Iberia
441
+	 * @param String $callsign The callsign
442
+	 * @param String $date date we want flight number info
443
+	 * @return array Flight departure and arrival airports and time
444
+	 */
445 445
 	public function getIberia($callsign, $date = 'NOW') {
446 446
 		$Common = new Common();
447 447
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -470,13 +470,13 @@  discard block
 block discarded – undo
470 470
 		return array();
471 471
 	}
472 472
 
473
-    /**
474
-     * Get flight info from Star Alliance
475
-     * @param String $callsign The callsign
476
-     * @param String $date date we want flight number info
477
-     * @param string $carrier
478
-     * @return array Flight departure and arrival airports and time
479
-     */
473
+	/**
474
+	 * Get flight info from Star Alliance
475
+	 * @param String $callsign The callsign
476
+	 * @param String $date date we want flight number info
477
+	 * @param string $carrier
478
+	 * @return array Flight departure and arrival airports and time
479
+	 */
480 480
 
481 481
 	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
482 482
 		$Common = new Common();
@@ -508,11 +508,11 @@  discard block
 block discarded – undo
508 508
 
509 509
 
510 510
 	/**
511
-	* Get flight info from Alitalia
512
-	* @param String $callsign The callsign
513
-	* @param String $date date we want flight number info
514
-	* @return array Flight departure and arrival airports and time
515
-	*/
511
+	 * Get flight info from Alitalia
512
+	 * @param String $callsign The callsign
513
+	 * @param String $date date we want flight number info
514
+	 * @return array Flight departure and arrival airports and time
515
+	 */
516 516
 	private function getAlitalia($callsign, $date = 'NOW') {
517 517
 		$Common = new Common();
518 518
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -532,11 +532,11 @@  discard block
 block discarded – undo
532 532
 	}
533 533
 
534 534
 	/**
535
-	* Get flight info from Brussels airlines
536
-	* @param String $callsign The callsign
537
-	* @param String $date date we want flight number info
538
-	* @return array Flight departure and arrival airports and time
539
-	*/
535
+	 * Get flight info from Brussels airlines
536
+	 * @param String $callsign The callsign
537
+	 * @param String $date date we want flight number info
538
+	 * @return array Flight departure and arrival airports and time
539
+	 */
540 540
 	private function getBrussels($callsign, $date = 'NOW') {
541 541
 		$Common = new Common();
542 542
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -546,25 +546,25 @@  discard block
 block discarded – undo
546 546
 		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
547 547
 		$data = $Common->getData($url);
548 548
 		if ($data != '') {
549
-		    //echo $data;
550
-		    $parsed_json = json_decode($data,true);
551
-		    if (isset($parsed_json[0]['FromAirportCode'])) {
549
+			//echo $data;
550
+			$parsed_json = json_decode($data,true);
551
+			if (isset($parsed_json[0]['FromAirportCode'])) {
552 552
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
553 553
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
554 554
 			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
555 555
 			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
556 556
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
557
-		    }
557
+			}
558 558
 		}
559 559
 		return array();
560 560
 	}
561 561
 
562 562
 	/**
563
-	* Get flight info from FlightRadar24
564
-	* @param String $callsign The callsign
565
-	* @param String $date date we want flight number info
566
-	* @return array Flight departure and arrival airports and time
567
-	*/
563
+	 * Get flight info from FlightRadar24
564
+	 * @param String $callsign The callsign
565
+	 * @param String $date date we want flight number info
566
+	 * @return array Flight departure and arrival airports and time
567
+	 */
568 568
 /*
569 569
 	public function getFlightRadar24($callsign, $date = 'NOW') {
570 570
 		$Common = new Common();
@@ -593,11 +593,11 @@  discard block
 block discarded – undo
593 593
 	}
594 594
   */
595 595
 	/**
596
-	* Get flight info from Lufthansa
597
-	* @param String $callsign The callsign
598
-	* @param String $date date we want flight number info
599
-	* @return array Flight departure and arrival airports and time
600
-	*/
596
+	 * Get flight info from Lufthansa
597
+	 * @param String $callsign The callsign
598
+	 * @param String $date date we want flight number info
599
+	 * @return array Flight departure and arrival airports and time
600
+	 */
601 601
 
602 602
 /*	private function getLufthansa($callsign, $date = 'NOW') {
603 603
 		$Common = new Common();
@@ -625,10 +625,10 @@  discard block
 block discarded – undo
625 625
 	}
626 626
   */
627 627
 	/**
628
-	* Get flight info from flytap
629
-	* @param String $callsign The callsign
630
-	* @return array Flight departure and arrival airports and time
631
-	*/
628
+	 * Get flight info from flytap
629
+	 * @param String $callsign The callsign
630
+	 * @return array Flight departure and arrival airports and time
631
+	 */
632 632
 	private function getFlyTap($callsign) {
633 633
 		$Common = new Common();
634 634
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -651,10 +651,10 @@  discard block
 block discarded – undo
651 651
 	}
652 652
 
653 653
 	/**
654
-	* Get flight info from flightmapper
655
-	* @param String $callsign The callsign
656
-	* @return array Flight departure and arrival airports and time
657
-	*/
654
+	 * Get flight info from flightmapper
655
+	 * @param String $callsign The callsign
656
+	 * @return array Flight departure and arrival airports and time
657
+	 */
658 658
 	public function getFlightMapper($callsign) {
659 659
 		$Common = new Common();
660 660
 		$airline_icao = '';
@@ -682,11 +682,11 @@  discard block
 block discarded – undo
682 682
 				$aarr = '';
683 683
 				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
684 684
 				if ($n == 7) {
685
-				    $departureTime = $dhour;
686
-				    $arrivalTime = $ahour;
687
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
685
+					$departureTime = $dhour;
686
+					$arrivalTime = $ahour;
687
+					$DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
+					$ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
+					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
690 690
 				}
691 691
 			}
692 692
 		}
@@ -694,10 +694,10 @@  discard block
 block discarded – undo
694 694
 	}
695 695
 
696 696
 	/**
697
-	* Get flight info from flightaware
698
-	* @param String $callsign The callsign
699
-	* @return array Flight departure and arrival airports and time
700
-	*/
697
+	 * Get flight info from flightaware
698
+	 * @param String $callsign The callsign
699
+	 * @return array Flight departure and arrival airports and time
700
+	 */
701 701
 	public function getFlightAware($callsign) {
702 702
 		global $globalFlightAwareUsername, $globalFlightAwarePassword;
703 703
 		date_default_timezone_set('UTC');
@@ -722,11 +722,11 @@  discard block
 block discarded – undo
722 722
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
723 723
 				if (isset($flight['origin'])) {
724 724
 					return array(
725
-					    'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
726
-					    'DepartureTime' => $flight['filed_departure_time']['time'],
727
-					    'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
728
-					    'ArrivalTime' => $flight['filed_arrival_time']['time'],
729
-					    'Source' => 'website_flightaware');
725
+						'DepartureAirportIATA' => $flight['origin']['alternate_ident'],
726
+						'DepartureTime' => $flight['filed_departure_time']['time'],
727
+						'ArrivalAirportIATA' => $flight['destination']['alternate_ident'],
728
+						'ArrivalTime' => $flight['filed_arrival_time']['time'],
729
+						'Source' => 'website_flightaware');
730 730
 				}
731 731
 			}
732 732
 		}
@@ -739,21 +739,21 @@  discard block
 block discarded – undo
739 739
 			$flight = reset($flights['flights']);
740 740
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
741 741
 				return array(
742
-				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744
-				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746
-				    'Source' => 'website_flightaware');
742
+					'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
+					'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744
+					'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
+					'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746
+					'Source' => 'website_flightaware');
747 747
 			}
748 748
 		}
749 749
 		return array();
750 750
 	}
751 751
 
752 752
 	/**
753
-	* Get flight info from CostToTravel
754
-	* @param String $callsign The callsign
755
-	* @return array Flight departure and arrival airports and time
756
-	*/
753
+	 * Get flight info from CostToTravel
754
+	 * @param String $callsign The callsign
755
+	 * @return array Flight departure and arrival airports and time
756
+	 */
757 757
 	public function getCostToTravel($callsign) {
758 758
 		$Common = new Common();
759 759
 		$url= "http://www.costtotravel.com/flight-number/".$callsign;
@@ -776,11 +776,11 @@  discard block
 block discarded – undo
776 776
 	}
777 777
 
778 778
 	/**
779
-	* Get flight info from Air Canada
780
-	* @param string $callsign The callsign
781
-	* @param string $date date we want flight number info
782
-	* @return array Flight departure and arrival airports and time
783
-	*/
779
+	 * Get flight info from Air Canada
780
+	 * @param string $callsign The callsign
781
+	 * @param string $date date we want flight number info
782
+	 * @return array Flight departure and arrival airports and time
783
+	 */
784 784
 	private function getAirCanada($callsign,$date = 'NOW') {
785 785
 		$Common = new Common();
786 786
 		if (class_exists("DomDocument") === FALSE) return array();
@@ -805,11 +805,11 @@  discard block
 block discarded – undo
805 805
 	}
806 806
 
807 807
 	/**
808
-	* Get flight info from Vietnam Airlines
809
-	* @param String $callsign The callsign
810
-	* @param String $date date we want flight number info
811
-	* @return array Flight departure and arrival airports and time
812
-	*/
808
+	 * Get flight info from Vietnam Airlines
809
+	 * @param String $callsign The callsign
810
+	 * @param String $date date we want flight number info
811
+	 * @return array Flight departure and arrival airports and time
812
+	 */
813 813
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
814 814
 		$Common = new Common();
815 815
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
@@ -832,12 +832,12 @@  discard block
 block discarded – undo
832 832
 	}
833 833
 
834 834
 	/**
835
-	* Get flight info from Air Berlin
836
-	* @param String $callsign The callsign
837
-	* @param String $date date we want flight number info
838
-	* @param String $carrier airline code
839
-	* @return array Flight departure and arrival airports and time
840
-	*/
835
+	 * Get flight info from Air Berlin
836
+	 * @param String $callsign The callsign
837
+	 * @param String $date date we want flight number info
838
+	 * @param String $carrier airline code
839
+	 * @return array Flight departure and arrival airports and time
840
+	 */
841 841
 	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
842 842
 		$Common = new Common();
843 843
 		date_default_timezone_set('UTC');
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 			$table = $Common->table2array($data);
867 867
 			$flight = $table;
868 868
 			if (isset($flight[5][4])) {
869
-			    $arrivalTime = $flight[5][4];
870
-			    $arrivalAirport = $flight[5][3];
869
+				$arrivalTime = $flight[5][4];
870
+				$arrivalAirport = $flight[5][3];
871 871
 			} else {
872
-			    $arrivalTime = '';
873
-			    $arrivalAirport = '';
872
+				$arrivalTime = '';
873
+				$arrivalAirport = '';
874 874
 			}
875 875
 		} else return array();
876 876
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
Please login to merge, or discard this patch.
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
      * @param String $source source of data
38 38
      * @return string
39 39
      */
40
-	public function addSchedule($ident,$departure_airport_icao,$departure_airport_time,$arrival_airport_icao,$arrival_airport_time,$source = 'website') {
40
+	public function addSchedule($ident, $departure_airport_icao, $departure_airport_time, $arrival_airport_icao, $arrival_airport_time, $source = 'website') {
41 41
 		date_default_timezone_set('UTC');
42
-		$date = date("Y-m-d H:i:s",time());
42
+		$date = date("Y-m-d H:i:s", time());
43 43
 		//if ($departure_airport_time == '' && $arrival_airport_time == '') exit;
44 44
 		//$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident";
45 45
 		$query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident";
@@ -47,69 +47,69 @@  discard block
 block discarded – undo
47 47
 		 try {
48 48
 			$sth = $this->db->prepare($query);
49 49
 			$sth->execute($query_values);
50
-		} catch(PDOException $e) {
50
+		} catch (PDOException $e) {
51 51
 			return "error : ".$e->getMessage();
52 52
 		}
53 53
 		if ($sth->fetchColumn() > 0) {
54 54
 			if ($departure_airport_time == '' && $arrival_airport_time == '') {
55 55
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao";
56
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao);
56
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao);
57 57
 			} elseif ($arrival_airport_time == '') {
58 58
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao";
59
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao);
59
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao);
60 60
 			} elseif ($departure_airport_time == '') {
61 61
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
62
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
62
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
63 63
 			} else {
64 64
 			    //$query = "SELECT COUNT(*) FROM schedule WHERE ident = :ident AND departure_airport_icao = :departure_airport_icao AND departure_airport_time = :departure_airport_time AND arrival_airport_icao = :arrival_airport_icao AND arrival_airport_time = :arrival_airport_time";
65 65
 			    $query = "SELECT COUNT(*) FROM routes WHERE CallSign = :ident AND FromAirport_ICAO = :departure_airport_icao AND FromAirport_Time = :departure_airport_time AND ToAirport_ICAO = :arrival_airport_icao AND ToAirport_Time = :arrival_airport_time";
66
-			    $query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time);
66
+			    $query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time);
67 67
 			}
68 68
 			try {
69 69
 				$sth = $this->db->prepare($query);
70 70
 				$sth->execute($query_values);
71
-			} catch(PDOException $e) {
71
+			} catch (PDOException $e) {
72 72
 				return "error : ".$e->getMessage();
73 73
 			}
74 74
 			if ($sth->fetchColumn() == 0) {
75 75
 				//$query = 'UPDATE schedule SET departure_airport_icao = :departure_airport_icao, departure_airport_time = :departure_airport_time, arrival_airport_icao = :arrival_airport_icao, arrival_airport_time = :arrival_airport_time, date_modified = :date, source = :source WHERE ident = :ident';
76 76
 				if ($departure_airport_time == '' && $arrival_airport_time == '') {
77 77
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
78
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
78
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
79 79
 				} elseif ($arrival_airport_time == '') {
80 80
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, date_modified = :date, Source = :source WHERE CallSign = :ident';
81
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
81
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':date' => $date, ':source' => $source);
82 82
 				} elseif ($departure_airport_time == '') {
83 83
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
84
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
84
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
85 85
 				} else {
86 86
 					$query = 'UPDATE routes SET FromAirport_ICAO = :departure_airport_icao, FromAiport_Time = :departure_airport_time, ToAirport_ICAO = :arrival_airport_icao, ToAirport_Time = :arrival_airport_time, date_modified = :date, Source = :source WHERE CallSign = :ident';
87
-					$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
87
+					$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
88 88
 				}
89 89
 				try {
90 90
 					$sth = $this->db->prepare($query);
91 91
 					$sth->execute($query_values);
92
-				} catch(PDOException $e) {
92
+				} catch (PDOException $e) {
93 93
 					return "error : ".$e->getMessage();
94 94
 				}
95 95
 			} else {
96 96
 				//$query = 'UPDATE schedule SET date_lastseen = :date WHERE ident = :ident';
97 97
 				$query = 'UPDATE routes SET date_lastseen = :date WHERE CallSign = :ident';
98
-				$query_values = array(':ident' => $ident,':date' => $date);
98
+				$query_values = array(':ident' => $ident, ':date' => $date);
99 99
 				try {
100 100
 					$sth = $this->db->prepare($query);
101 101
 					$sth->execute($query_values);
102
-				} catch(PDOException $e) {
102
+				} catch (PDOException $e) {
103 103
 					return "error : ".$e->getMessage();
104 104
 				}
105 105
 			}
106 106
 		} else {
107 107
 			$query = 'INSERT INTO  routes (CallSign,FromAirport_ICAO, FromAirport_Time, ToAirport_ICAO, ToAirport_Time,date_added,source)  VALUES (:ident,:departure_airport_icao,:departure_airport_time,:arrival_airport_icao,:arrival_airport_time,:date,:source)';
108
-			$query_values = array(':ident' => $ident,':departure_airport_icao' => $departure_airport_icao,':departure_airport_time' => $departure_airport_time,':arrival_airport_icao' => $arrival_airport_icao,':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
108
+			$query_values = array(':ident' => $ident, ':departure_airport_icao' => $departure_airport_icao, ':departure_airport_time' => $departure_airport_time, ':arrival_airport_icao' => $arrival_airport_icao, ':arrival_airport_time' => $arrival_airport_time, ':date' => $date, ':source' => $source);
109 109
 			 try {
110 110
 				$sth = $this->db->prepare($query);
111 111
 				$sth->execute($query_values);
112
-			} catch(PDOException $e) {
112
+			} catch (PDOException $e) {
113 113
 				return "error : ".$e->getMessage();
114 114
 			}
115 115
 		}
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
 	*/
124 124
 	public function getSchedule($ident) {
125 125
 		$Translation = new Translation($this->db);
126
-		$operator = $Translation->checkTranslation($ident,false);
126
+		$operator = $Translation->checkTranslation($ident, false);
127 127
 		if ($ident != $operator) {
128 128
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :operator OR CallSign = :ident LIMIT 1";
129
-			$query_values = array(':ident' => $ident,'operator' => $operator);
129
+			$query_values = array(':ident' => $ident, 'operator' => $operator);
130 130
 		} else {
131 131
 			$query = "SELECT FromAirport_ICAO as departure_airport_icao, ToAirport_ICAO as arrival_airport_icao, FromAirport_Time as departure_airport_time, ToAirport_Time as arrival_airport_time FROM routes WHERE FromAirport_ICAO <> '' AND ToAirport_ICAO <> '' AND CallSign = :ident LIMIT 1";
132 132
 			$query_values = array(':ident' => $ident);
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		 try {
135 135
 			$sth = $this->db->prepare($query);
136 136
 			$sth->execute($query_values);
137
-		} catch(PDOException $e) {
137
+		} catch (PDOException $e) {
138 138
 			return "error : ".$e->getMessage();
139 139
 		}
140 140
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 		 try {
164 164
 			$sth = $this->db->prepare($query);
165 165
 			$sth->execute($query_values);
166
-		} catch(PDOException $e) {
166
+		} catch (PDOException $e) {
167 167
 			return "error : ".$e->getMessage();
168 168
 		}
169 169
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -178,16 +178,16 @@  discard block
 block discarded – undo
178 178
      * @param String $carrier IATA code
179 179
      * @return array departure and arrival airports and time
180 180
      */
181
-	public function getAirFrance($callsign, $date = 'NOW',$carrier = 'AF') {
181
+	public function getAirFrance($callsign, $date = 'NOW', $carrier = 'AF') {
182 182
 		$Common = new Common();
183 183
 		$check_date = new Datetime($date);
184
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
185
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
184
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
185
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
186 186
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
187 187
 		$json = $Common->getData($url);
188 188
 		var_dump($json);
189 189
 		$parsed_json = json_decode($json);
190
-		if (property_exists($parsed_json,'errors') === false) {
190
+		if (property_exists($parsed_json, 'errors') === false) {
191 191
 			//$originLong = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originLong'};
192 192
 			$originShort = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'originShort'};
193 193
 			//$departureDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'departureDateMedium'};
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 			//$arrivalDateMedium = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalDateMedium'};
198 198
 			$arrivalTime = $parsed_json->{'flightsList'}[0]->{'segmentsList'}[0]->{'arrivalTime'};
199 199
 
200
-			preg_match('/\((.*?)\)/',$originShort,$originiata);
200
+			preg_match('/\((.*?)\)/', $originShort, $originiata);
201 201
 			$DepartureAirportIata = $originiata[1];
202
-			preg_match('/\((.*?)\)/',$destinationShort,$destinationiata);
202
+			preg_match('/\((.*?)\)/', $destinationShort, $destinationiata);
203 203
 			$ArrivalAirportIata = $destinationiata[1];
204 204
 
205 205
 			/*
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 			$arrivalTime = gmdate('H:i',strtotime($arrivalTime));
209 209
 			*/
210 210
 		
211
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
211
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airfrance');
212 212
 		} else return array();
213 213
 	}
214 214
 
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 		$Common = new Common();
224 224
 		date_default_timezone_set($globalTimezone);
225 225
 		$check_date = new Datetime($date);
226
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
227
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
226
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
227
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
228 228
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
229 229
 		$json = $Common->getData($url);
230 230
 		$parsed_json = json_decode($json);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 			$departureTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fstd'};
237 237
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
238 238
 
239
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
239
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_easyjet');
240 240
 		} else return array();
241 241
 	}
242 242
 
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
      */
248 248
 	private function getRyanair($callsign) {
249 249
 		$Common = new Common();
250
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
251
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
250
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
251
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
252 252
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
253 253
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
254
-		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
255
-		$json = $Common->getData($url,'post',$post,$headers);
254
+		$headers = array('Content-Type: application/json', 'Content-Length: '.strlen($post));
255
+		$json = $Common->getData($url, 'post', $post, $headers);
256 256
 		$parsed_json = json_decode($json);
257 257
 		if (isset($parsed_json->{'flightInfo'})) {
258 258
 			$flights = $parsed_json->{'flightInfo'};
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 				$ArrivalAirportIata = $parsed_json->{'flightInfo'}[0]->{'arrivalAirport'}->{'iata'}; //name
262 262
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
263 263
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
264
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
264
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
265 265
 			} else return array();
266 266
 		} else return array();
267 267
 	}
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 	*/
274 274
 	private function getSwiss($callsign) {
275 275
 		$Common = new Common();
276
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
277
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
276
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
277
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
278 278
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
279 279
 		$json = $Common->getData($url);
280 280
 		$parsed_json = json_decode($json);
@@ -288,12 +288,12 @@  discard block
 block discarded – undo
288 288
 				if ($flight->{'no'} == "Vol LX ".$numvol) {
289 289
 					$DepartureAirportIata = $flight->{'from'}->{'code'}; //city
290 290
 					$ArrivalAirportIata = $flight->{'to'}->{'code'}; //city
291
-					$departureTime = substr($flight->{'from'}->{'hour'},0,5);
292
-					$arrivalTime = substr($flight->{'to'}->{'hour'},0,5);
291
+					$departureTime = substr($flight->{'from'}->{'hour'},0, 5);
292
+					$arrivalTime = substr($flight->{'to'}->{'hour'},0, 5);
293 293
 				}
294 294
 			}
295 295
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
296
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
296
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_swiss');
297 297
 			} else return array();
298 298
 		} else return array();
299 299
 	}
@@ -308,21 +308,21 @@  discard block
 block discarded – undo
308 308
 		global $globalBritishAirwaysKey;
309 309
 		$Common = new Common();
310 310
 		$check_date = new Datetime($date);
311
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
312
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
311
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
312
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
313 313
 		if ($globalBritishAirwaysKey == '') return array();
314 314
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
315 315
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
316
-		$json = $Common->getData($url,'get','',$headers);
316
+		$json = $Common->getData($url, 'get', '', $headers);
317 317
 		if ($json == '') return array();
318 318
 		$parsed_json = json_decode($json);
319 319
 		$flights = $parsed_json->{'FlightsResponse'};
320 320
 		if (count($flights) > 0) {
321 321
 			$DepartureAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'DepartureAirport'};
322 322
 			$ArrivalAirportIata = $parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ArrivalAirport'};
323
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
323
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_britishairways');
326 326
 		} else return array();
327 327
 	}
328 328
 
@@ -336,27 +336,27 @@  discard block
 block discarded – undo
336 336
 		global $globalLufthansaKey;
337 337
 		$Common = new Common();
338 338
 		$check_date = new Datetime($date);
339
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
340
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
339
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
340
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
341 341
 		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
342 342
 		$url = "https://api.lufthansa.com/v1/oauth/token";
343
-		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
344
-		$data = $Common->getData($url,'post',$post);
343
+		$post = array('client_id' => $globalLufthansaKey['key'], 'client_secret' => $globalLufthansaKey['secret'], 'grant_type' => 'client_credentials');
344
+		$data = $Common->getData($url, 'post', $post);
345 345
 		$parsed_data = json_decode($data);
346 346
 		if (!isset($parsed_data->{'access_token'})) return array();
347 347
 		$token = $parsed_data->{'access_token'};
348 348
 		
349 349
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
350
-		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
351
-		$json = $Common->getData($url,'get','',$headers);
350
+		$headers = array('Authorization: Bearer '.$token, 'Accept: application/json');
351
+		$json = $Common->getData($url, 'get', '', $headers);
352 352
 		if ($json == '') return array();
353 353
 		$parsed_json = json_decode($json);
354 354
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
355 355
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
356
-			$departureTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
356
+			$departureTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'ScheduledTimeLocal'}->{'DateTime'}));
357 357
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
358
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
358
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_lufthansa');
360 360
 		} else return array();
361 361
 	}
362 362
 
@@ -370,23 +370,23 @@  discard block
 block discarded – undo
370 370
 		global $globalTransaviaKey;
371 371
 		$Common = new Common();
372 372
 		$check_date = new Datetime($date);
373
-		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
374
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
373
+		$numvol = sprintf('%04d', preg_replace('/^[A-Z]*/', '', $callsign));
374
+		if (!filter_var(preg_replace('/^[A-Z]*/', '', $callsign), FILTER_VALIDATE_INT)) return array();
375 375
 		if ($globalTransaviaKey == '') return array();
376 376
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
377 377
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
378 378
 		$headers = array('apikey: '.$globalTransaviaKey);
379
-		$json = $Common->getData($url,'get','',$headers);
379
+		$json = $Common->getData($url, 'get', '', $headers);
380 380
 		//echo 'result : '.$json;
381 381
 		if ($json == '') return array();
382 382
 		$parsed_json = json_decode($json);
383 383
 		
384 384
 		if (isset($parsed_json->{'data'}[0])) {
385 385
 			$DepartureAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'departureAirport'}->{'locationCode'};
386
-			$departureTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
386
+			$departureTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'departureDateTime'}));
387 387
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
388
-			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
388
+			$arrivalTime = date('H:i', strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_transavia');
390 390
 		} else return array();
391 391
 	}
392 392
 
@@ -397,14 +397,14 @@  discard block
 block discarded – undo
397 397
 	*/
398 398
 	public function getTunisair($callsign) {
399 399
 		$Common = new Common();
400
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
401
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
400
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
401
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
402 402
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
403 403
 		$data = $Common->getData($url);
404 404
 		$table = $Common->table2array($data);
405 405
 		foreach ($table as $flight) {
406
-			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d',$numvol)) {
407
-				return array('DepartureAirportIATA' => $flight[2],'DepartureTime' => str_replace('.',':',$flight[5]),'ArrivalAirportIATA' => $flight[3],'ArrivalTime' => str_replace('.',':',$flight[6]),'Source' => 'website_tunisair');
406
+			if (isset($flight[1]) && $flight[1] == "TU ".sprintf('%04d', $numvol)) {
407
+				return array('DepartureAirportIATA' => $flight[2], 'DepartureTime' => str_replace('.', ':', $flight[5]), 'ArrivalAirportIATA' => $flight[3], 'ArrivalTime' => str_replace('.', ':', $flight[6]), 'Source' => 'website_tunisair');
408 408
 			}
409 409
 		}
410 410
 		return array();
@@ -416,21 +416,21 @@  discard block
 block discarded – undo
416 416
      * @param string $date
417 417
      * @return array Flight departure and arrival airports and time
418 418
      */
419
-	public function getVueling($callsign,$date = 'NOW') {
419
+	public function getVueling($callsign, $date = 'NOW') {
420 420
 		$Common = new Common();
421 421
 		$check_date = new Datetime($date);
422
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
424
-		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
422
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
423
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
424
+		$final_date = str_replace('/', '%2F', $check_date->format('d/m/Y'));
425 425
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
426 426
 		$data = $Common->getData($url);
427
-		$data=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$data));
427
+		$data = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $data));
428 428
 		if ($data != '') {
429
-			preg_match('/flightOri=[A-Z]{3}/',$data,$result);
430
-			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
431
-			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
432
-			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
433
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
429
+			preg_match('/flightOri=[A-Z]{3}/', $data, $result);
430
+			$DepartureAirportIata = str_replace('flightOri=', '', $result[0]);
431
+			preg_match('/flightDest=[A-Z]{3}/', $data, $result);
432
+			$ArrivalAirportIata = str_replace('flightDest=', '', $result[0]);
433
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'Source' => 'website_vueling');
434 434
 			else return array();
435 435
 		}
436 436
 		return array();
@@ -444,27 +444,27 @@  discard block
 block discarded – undo
444 444
 	*/
445 445
 	public function getIberia($callsign, $date = 'NOW') {
446 446
 		$Common = new Common();
447
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
447
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
448 448
 		$check_date = new Datetime($date);
449
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
449
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
450 450
 		$url = "https://www.iberia.com/web/flightDetail.do";
451
-		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
452
-		$data = $Common->getData($url,'post',$post);
451
+		$post = array('numvuelo' => $numvol, 'fecha' => $check_date->format('Ymd'), 'airlineID' => 'IB');
452
+		$data = $Common->getData($url, 'post', $post);
453 453
 		if ($data != '') {
454 454
 			$table = $Common->table2array($data);
455 455
 			//print_r($table);
456 456
 			if (count($table) > 0) {
457 457
 				$flight = $table;
458
-				preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
459
-				preg_match('/([A-Z]{3})/',$flight[5][0],$ArrivalAirportIataMatch);
458
+				preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
459
+				preg_match('/([A-Z]{3})/', $flight[5][0], $ArrivalAirportIataMatch);
460 460
 				$DepartureAirportIata = $DepartureAirportIataMatch[0];
461 461
 				$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
462
-				$departureTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[3][2]))),0,5);
463
-				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
462
+				$departureTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[3][2]))), 0, 5);
463
+				$arrivalTime = trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][1])));
464 464
 				if ($arrivalTime == 'Hora estimada de llegada') {
465
-					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
466
-				} else $arrivalTime = substr($arrivalTime,0,5);
467
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
465
+					$arrivalTime = substr(trim(str_replace(' lunes', '', str_replace('&nbsp;', '', $flight[5][2]))), 0, 5);
466
+				} else $arrivalTime = substr($arrivalTime, 0, 5);
467
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_iberia');
468 468
 			}
469 469
 		}
470 470
 		return array();
@@ -478,11 +478,11 @@  discard block
 block discarded – undo
478 478
      * @return array Flight departure and arrival airports and time
479 479
      */
480 480
 
481
-	private function getStarAlliance($callsign, $date = 'NOW',$carrier = '') {
481
+	private function getStarAlliance($callsign, $date = 'NOW', $carrier = '') {
482 482
 		$Common = new Common();
483
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
483
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
484 484
 		$check_date = new Datetime($date);
485
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
485
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
486 486
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
487 487
 		$data = $Common->getData($url);
488 488
 		if ($data != '') {
@@ -491,13 +491,13 @@  discard block
 block discarded – undo
491 491
 				$flight = $table;
492 492
 				//print_r($table);
493 493
 				if (isset($flight[25]) && isset($flight[29])) {
494
-					preg_match('/([A-Z]{3})/',$flight[25][1],$DepartureAirportIataMatch);
495
-					preg_match('/([A-Z]{3})/',$flight[25][3],$ArrivalAirportIataMatch);
494
+					preg_match('/([A-Z]{3})/', $flight[25][1], $DepartureAirportIataMatch);
495
+					preg_match('/([A-Z]{3})/', $flight[25][3], $ArrivalAirportIataMatch);
496 496
 					$DepartureAirportIata = $DepartureAirportIataMatch[0];
497 497
 					$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
498
-					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
499
-					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
500
-					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
498
+					$departureTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][0])), 0, 5);
499
+					$arrivalTime = substr(trim(str_replace('Scheduled: ', '', $flight[29][1])), 0, 5);
500
+					return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_staralliance');
501 501
 				} else return array();
502 502
 			}
503 503
 			
@@ -515,10 +515,10 @@  discard block
 block discarded – undo
515 515
 	*/
516 516
 	private function getAlitalia($callsign, $date = 'NOW') {
517 517
 		$Common = new Common();
518
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
518
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
519 519
 		$check_date = new Datetime($date);
520
-		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
520
+		$url = "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
522 522
 		$data = $Common->getData($url);
523 523
 		if ($data != '') {
524 524
 			$table = $Common->text2array($data);
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 			$ArrivalAirportIata = '';
527 527
 			$departureTime = $table[4];
528 528
 			$arrivalTime = $table[5];
529
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_alitalia');
529
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_alitalia');
530 530
 		}
531 531
 		return array();
532 532
 	}
@@ -539,21 +539,21 @@  discard block
 block discarded – undo
539 539
 	*/
540 540
 	private function getBrussels($callsign, $date = 'NOW') {
541 541
 		$Common = new Common();
542
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
542
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
543 543
 		$check_date = new Datetime($date);
544
-		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
544
+		$url = "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
545 545
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
546
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
546
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
547 547
 		$data = $Common->getData($url);
548 548
 		if ($data != '') {
549 549
 		    //echo $data;
550
-		    $parsed_json = json_decode($data,true);
550
+		    $parsed_json = json_decode($data, true);
551 551
 		    if (isset($parsed_json[0]['FromAirportCode'])) {
552 552
 			$DepartureAirportIata = $parsed_json[0]['FromAirportCode'];
553 553
 			$ArrivalAirportIata = $parsed_json[0]['ToAirportCode'];
554
-			$departureTime = date('H:i',strtotime($parsed_json[0]['ScheduledDepatureDate']));
555
-			$arrivalTime = date('H:i',strtotime($parsed_json[0]['ScheduledArrivalDate']));
556
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_brussels');
554
+			$departureTime = date('H:i', strtotime($parsed_json[0]['ScheduledDepatureDate']));
555
+			$arrivalTime = date('H:i', strtotime($parsed_json[0]['ScheduledArrivalDate']));
556
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_brussels');
557 557
 		    }
558 558
 		}
559 559
 		return array();
@@ -631,21 +631,21 @@  discard block
 block discarded – undo
631 631
 	*/
632 632
 	private function getFlyTap($callsign) {
633 633
 		$Common = new Common();
634
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
635
-		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
634
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
635
+		$url = "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
636 636
 		//$check_date = new Datetime($date);
637
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
638
-		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
639
-		$data = $Common->getData($url,'post',$post);
637
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
638
+		$post = array('arrivalsdepartures_content' => 'number', 'arrivalsdepartures_tp' => $numvol, 'arrivalsdepartures_trk' => 'ARR', 'arrivalsdepartures_date_trk' => '1', 'aptCode' => '', 'arrivalsdepartures' => 'DEP', 'arrivalsdepartures_date' => '1', 'aptCodeFrom' => '', 'aptCodeTo' => '', 'arrivalsdepartures2' => 'DEP', 'arrivalsdepartures_date2' => '1');
639
+		$data = $Common->getData($url, 'post', $post);
640 640
 		if ($data != '') {
641 641
 			$table = $Common->table2array($data);
642
-			$departureTime = trim(substr($table[15][0],0,5));
643
-			$arrivalTime = trim(substr($table[35][0],0,5));
644
-			preg_match('/([A-Z]{3})/',$table[11][0],$DepartureAirportIataMatch);
645
-			preg_match('/([A-Z]{3})/',$table[31][0],$ArrivalAirportIataMatch);
642
+			$departureTime = trim(substr($table[15][0], 0, 5));
643
+			$arrivalTime = trim(substr($table[35][0], 0, 5));
644
+			preg_match('/([A-Z]{3})/', $table[11][0], $DepartureAirportIataMatch);
645
+			preg_match('/([A-Z]{3})/', $table[31][0], $ArrivalAirportIataMatch);
646 646
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
647 647
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
648
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flytap');
648
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flytap');
649 649
 		}
650 650
 		return array();
651 651
 	}
@@ -667,10 +667,10 @@  discard block
 block discarded – undo
667 667
 			} 
668 668
 		}
669 669
 		if ($airline_icao == '') return array();
670
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
671
-		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
670
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
671
+		$url = "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
672 672
 		//$check_date = new Datetime($date);
673
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
673
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
674 674
 		$data = $Common->getData($url);
675 675
 		if ($data != '') {
676 676
 			$table = $Common->table2array($data);
@@ -680,13 +680,13 @@  discard block
 block discarded – undo
680 680
 				$darr = '';
681 681
 				$ahour = '';
682 682
 				$aarr = '';
683
-				$n = sscanf($sched,'%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])',$dhour,$darr,$ahour,$aarr);
683
+				$n = sscanf($sched, '%*s %5[0-9:] %*[^()] (%3[A-Z]) %5[0-9:] %*[^()] (%3[A-Z])', $dhour, $darr, $ahour, $aarr);
684 684
 				if ($n == 7) {
685 685
 				    $departureTime = $dhour;
686 686
 				    $arrivalTime = $ahour;
687
-				    $DepartureAirportIata = str_replace(array('(',')'),'',$darr);
688
-				    $ArrivalAirportIata = str_replace(array('(',')'),'',$aarr);
689
-				    return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_flightmapper');
687
+				    $DepartureAirportIata = str_replace(array('(', ')'), '', $darr);
688
+				    $ArrivalAirportIata = str_replace(array('(', ')'), '', $aarr);
689
+				    return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_flightmapper');
690 690
 				}
691 691
 			}
692 692
 		}
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 			$url = 'http://'.$globalFlightAwareUsername.':'.$globalFlightAwarePassword.'@flightxml.flightaware.com/json/FlightXML3/FlightInfoStatus?ident='.$callsign;
719 719
 			$data = $Common->getData($url);
720 720
 			if ($data != '') {
721
-				$result = json_decode($data,true);
721
+				$result = json_decode($data, true);
722 722
 				$flight = $result['FlightInfoStatusResult']['flights'][0];
723 723
 				if (isset($flight['origin'])) {
724 724
 					return array(
@@ -731,18 +731,18 @@  discard block
 block discarded – undo
731 731
 			}
732 732
 		}
733 733
 		
734
-		$url= "http://flightaware.com/live/flight/".$callsign;
734
+		$url = "http://flightaware.com/live/flight/".$callsign;
735 735
 		$data = $Common->getData($url);
736 736
 		if ($data != '') {
737
-			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:',$data,$result);
738
-			$flights = json_decode($result[1],true);
737
+			preg_match(':<script>var trackpollBootstrap = (.*?);</script>:', $data, $result);
738
+			$flights = json_decode($result[1], true);
739 739
 			$flight = reset($flights['flights']);
740 740
 			if (isset($flight['activityLog']['flights'][0]['origin'])) {
741 741
 				return array(
742 742
 				    'DepartureAirportIATA' => $flight['activityLog']['flights'][0]['origin']['iata'],
743
-				    'DepartureTime' => date('H:i',$flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
743
+				    'DepartureTime' => date('H:i', $flight['activityLog']['flights'][0]['takeoffTimes']['scheduled']),
744 744
 				    'ArrivalAirportIATA' => $flight['activityLog']['flights'][0]['destination']['iata'],
745
-				    'ArrivalTime' => date('H:i',$flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
745
+				    'ArrivalTime' => date('H:i', $flight['activityLog']['flights'][0]['landingTimes']['scheduled']),
746 746
 				    'Source' => 'website_flightaware');
747 747
 			}
748 748
 		}
@@ -756,20 +756,20 @@  discard block
 block discarded – undo
756 756
 	*/
757 757
 	public function getCostToTravel($callsign) {
758 758
 		$Common = new Common();
759
-		$url= "http://www.costtotravel.com/flight-number/".$callsign;
759
+		$url = "http://www.costtotravel.com/flight-number/".$callsign;
760 760
 		//$check_date = new Datetime($date);
761 761
 		//if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
762 762
 		$data = $Common->getData($url);
763 763
 		if ($data != '') {
764 764
 			$table = $Common->table2array($data);
765 765
 			if (isset($table[11][1])) {
766
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
766
+				if (is_numeric(substr($table[11][1], 0, 1))) $departureTime = substr($table[11][1], 0, 5);
767 767
 				else $departureTime = '';
768
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
768
+				if (is_numeric(substr($table[17][1], 0, 1))) $arrivalTime = substr($table[17][1], 0, 5);
769 769
 				else $arrivalTime = '';
770
-				$DepartureAirportIata = substr($table[13][1],0,3);
771
-				$ArrivalAirportIata = substr($table[15][1],0,3);
772
-				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
770
+				$DepartureAirportIata = substr($table[13][1], 0, 3);
771
+				$ArrivalAirportIata = substr($table[15][1], 0, 3);
772
+				return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_costtotravel');
773 773
 			}
774 774
 		}
775 775
 		return array();
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 	* @param string $date date we want flight number info
782 782
 	* @return array Flight departure and arrival airports and time
783 783
 	*/
784
-	private function getAirCanada($callsign,$date = 'NOW') {
784
+	private function getAirCanada($callsign, $date = 'NOW') {
785 785
 		$Common = new Common();
786 786
 		if (class_exists("DomDocument") === FALSE) return array();
787 787
 		date_default_timezone_set('UTC');
788 788
 		$check_date = new Datetime($date);
789
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
790
-		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
789
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
790
+		$url = "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
792 792
 		$data = $Common->getData($url);
793 793
 		$dom = new DomDocument();
794 794
 		$dom->loadXML($data);
@@ -796,11 +796,11 @@  discard block
 block discarded – undo
796 796
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
797 797
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
798 798
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
799
-			$departureTime = date('H:i',strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
799
+			$departureTime = date('H:i', strtotime($departure->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
800 800
 			$arrival = $dom->getElementsByTagName('ArrivalStationInfo')->item(0);
801 801
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
802
-			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
802
+			$arrivalTime = date('H:i', strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_aircanada');
804 804
 		} else return array();
805 805
 	}
806 806
 
@@ -812,21 +812,21 @@  discard block
 block discarded – undo
812 812
 	*/
813 813
 	private function getVietnamAirlines($callsign, $date = 'NOW') {
814 814
 		$Common = new Common();
815
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
815
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
816 816
 		$check_date = new Datetime($date);
817
-		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
817
+		$url = "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
819 819
 		$data = $Common->getData($url);
820 820
 		if ($data != '') {
821 821
 			$table = $Common->table2array($data);
822 822
 			$flight = $table;
823
-			preg_match('/([A-Z]{3})/',$flight[3][0],$DepartureAirportIataMatch);
824
-			preg_match('/([A-Z]{3})/',$flight[21][0],$ArrivalAirportIataMatch);
823
+			preg_match('/([A-Z]{3})/', $flight[3][0], $DepartureAirportIataMatch);
824
+			preg_match('/([A-Z]{3})/', $flight[21][0], $ArrivalAirportIataMatch);
825 825
 			$DepartureAirportIata = $DepartureAirportIataMatch[0];
826 826
 			$ArrivalAirportIata = $ArrivalAirportIataMatch[0];
827 827
 			$departureTime = $flight[5][1];
828 828
 			$arrivalTime = $flight[23][1];
829
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_vietnamairlines');
829
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_vietnamairlines');
830 830
 		}
831 831
 		return array();
832 832
 	}
@@ -838,16 +838,16 @@  discard block
 block discarded – undo
838 838
 	* @param String $carrier airline code
839 839
 	* @return array Flight departure and arrival airports and time
840 840
 	*/
841
-	private function getAirBerlin($callsign, $date = 'NOW',$carrier = 'AB') {
841
+	private function getAirBerlin($callsign, $date = 'NOW', $carrier = 'AB') {
842 842
 		$Common = new Common();
843 843
 		date_default_timezone_set('UTC');
844 844
 		//AB = airberlin, HG/NLY = NIKI, 4T/BHP = Belair 
845
-		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
845
+		$numvol = preg_replace('/^[A-Z]*/', '', $callsign);
846 846
 		$check_date = new Datetime($date);
847
-		$url= "http://www.airberlin.com/en-US/site/aims.php";
848
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
849
-		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
850
-		$data = $Common->getData($url,'post',$post);
847
+		$url = "http://www.airberlin.com/en-US/site/aims.php";
848
+		if (!filter_var($numvol, FILTER_VALIDATE_INT)) return array();
849
+		$post = array('type' => 'departure', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => $carrier);
850
+		$data = $Common->getData($url, 'post', $post);
851 851
 		//echo $data;
852 852
 		$DepartureAirportIata = '';
853 853
 		$ArrivalAirportIata = '';
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
 			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
861 861
 			else $departureAirport = '';
862 862
 		} else return array();
863
-		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
864
-		$data = $Common->getData($url,'post',$post);
863
+		$post = array('type' => 'arrival', 'searchFlightNo' => '1', 'requestsent' => 'true', 'flightno' => $numvol, 'date' => $check_date->format('Y-m-d'), 'carrier' => 'AB');
864
+		$data = $Common->getData($url, 'post', $post);
865 865
 		if ($data != '') {
866 866
 			$table = $Common->table2array($data);
867 867
 			$flight = $table;
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 			}
890 890
 		}
891 891
 		if (isset($DepartureAirportIata)) {
892
-			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
892
+			return array('DepartureAirportIATA' => $DepartureAirportIata, 'DepartureTime' => $departureTime, 'ArrivalAirportIATA' => $ArrivalAirportIata, 'ArrivalTime' => $arrivalTime, 'Source' => 'website_airberlin');
893 893
 		} else return array();
894 894
 	}
895 895
 
@@ -899,7 +899,7 @@  discard block
 block discarded – undo
899 899
 	 * @param String $date Date
900 900
 	 * @return array Schedules info
901 901
 	*/
902
-	public function fetchSchedule($ident,$date = 'NOW') {
902
+	public function fetchSchedule($ident, $date = 'NOW') {
903 903
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
904 904
 		//$Common = new Common();
905 905
 		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 				// Brussels Airlines
970 970
 				case "BEL":
971 971
 				case "SN":
972
-					return $this->getBrussels($ident,$date);
972
+					return $this->getBrussels($ident, $date);
973 973
 /*
974 974
 				// Copa Airlines
975 975
 				case "CMP":
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
 				case "DS":
1069 1069
 				case "EZY":
1070 1070
 				case "EZS":
1071
-					return $this->getEasyJet($ident,$date);
1071
+					return $this->getEasyJet($ident, $date);
1072 1072
 				// Ryanair
1073 1073
 				case "FR":
1074 1074
 				case "RYR":
@@ -1120,19 +1120,19 @@  discard block
 block discarded – undo
1120 1120
 					return $this->getIberia($ident);
1121 1121
 				// Vietnam Airlines
1122 1122
 				case "HVN":
1123
-					return $this->getVietnamAirlines($ident,$date);
1123
+					return $this->getVietnamAirlines($ident, $date);
1124 1124
 				// Air Berlin
1125 1125
 				case "AB":
1126 1126
 				case "BER":
1127
-					return $this->getAirBerlin($ident,$date,'AB');
1127
+					return $this->getAirBerlin($ident, $date, 'AB');
1128 1128
 				// NIKI
1129 1129
 				case "HG":
1130 1130
 				case "NLY":
1131
-					return $this->getAirBerlin($ident,$date,'HG');
1131
+					return $this->getAirBerlin($ident, $date, 'HG');
1132 1132
 				// BelAir
1133 1133
 				case "4T":
1134 1134
 				case "BHP":
1135
-					return $this->getAirBerlin($ident,$date,'4T');
1135
+					return $this->getAirBerlin($ident, $date, '4T');
1136 1136
 				default:
1137 1137
 					if (strlen($airline_icao) == 3) {
1138 1138
 						$Spotter = new Spotter($this->db);
@@ -1141,9 +1141,9 @@  discard block
 block discarded – undo
1141 1141
 					}
1142 1142
 					// Randomly use a generic function to get hours
1143 1143
 					if (strlen($airline_icao) == 2) {
1144
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1144
+						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper', 'costtotravel', 'flightaware');
1145 1145
 						if (count($globalSchedulesSources) > 0) {
1146
-							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1146
+							$rand = mt_rand(0, count($globalSchedulesSources) - 1);
1147 1147
 							$source = $globalSchedulesSources[$rand];
1148 1148
 							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1149 1149
 							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
Please login to merge, or discard this patch.
Braces   +180 added lines, -62 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection.');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection.');
29
+		}
28 30
 	}
29 31
 
30 32
     /**
@@ -141,7 +143,9 @@  discard block
 block discarded – undo
141 143
 		$sth->closeCursor();
142 144
 		if (is_array($row) && count($row) > 0) {
143 145
 			return $row;
144
-		} else return array();
146
+		} else {
147
+			return array();
148
+		}
145 149
 	}
146 150
 
147 151
 	/*
@@ -182,7 +186,9 @@  discard block
 block discarded – undo
182 186
 		$Common = new Common();
183 187
 		$check_date = new Datetime($date);
184 188
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
185
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
189
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
190
+			return array();
191
+		}
186 192
 		$url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym');
187 193
 		$json = $Common->getData($url);
188 194
 		var_dump($json);
@@ -209,7 +215,9 @@  discard block
 block discarded – undo
209 215
 			*/
210 216
 		
211 217
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance');
212
-		} else return array();
218
+		} else {
219
+			return array();
220
+		}
213 221
 	}
214 222
 
215 223
     /**
@@ -224,7 +232,9 @@  discard block
 block discarded – undo
224 232
 		date_default_timezone_set($globalTimezone);
225 233
 		$check_date = new Datetime($date);
226 234
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
227
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
235
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
236
+			return array();
237
+		}
228 238
 		$url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign;
229 239
 		$json = $Common->getData($url);
230 240
 		$parsed_json = json_decode($json);
@@ -237,7 +247,9 @@  discard block
 block discarded – undo
237 247
 			$arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'};
238 248
 
239 249
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet');
240
-		} else return array();
250
+		} else {
251
+			return array();
252
+		}
241 253
 	}
242 254
 
243 255
     /**
@@ -248,7 +260,9 @@  discard block
 block discarded – undo
248 260
 	private function getRyanair($callsign) {
249 261
 		$Common = new Common();
250 262
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
251
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
263
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
264
+			return array();
265
+		}
252 266
 		$url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/";
253 267
 		$post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}';
254 268
 		$headers = array('Content-Type: application/json','Content-Length: ' . strlen($post));
@@ -262,8 +276,12 @@  discard block
 block discarded – undo
262 276
 				$departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'};
263 277
 				$arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'};
264 278
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair');
265
-			} else return array();
266
-		} else return array();
279
+			} else {
280
+				return array();
281
+			}
282
+		} else {
283
+			return array();
284
+		}
267 285
 	}
268 286
 
269 287
 	/**
@@ -274,7 +292,9 @@  discard block
 block discarded – undo
274 292
 	private function getSwiss($callsign) {
275 293
 		$Common = new Common();
276 294
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
277
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
295
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
296
+			return array();
297
+		}
278 298
 		$url = "http://www.world-of-swiss.com/fr/routenetwork.json";
279 299
 		$json = $Common->getData($url);
280 300
 		$parsed_json = json_decode($json);
@@ -294,8 +314,12 @@  discard block
 block discarded – undo
294 314
 			}
295 315
 			if (isset($DepartureAirportIata) && isset($ArrivalAirportIata)) {
296 316
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss');
297
-			} else return array();
298
-		} else return array();
317
+			} else {
318
+				return array();
319
+			}
320
+		} else {
321
+			return array();
322
+		}
299 323
 	}
300 324
 	
301 325
 	/**
@@ -309,12 +333,18 @@  discard block
 block discarded – undo
309 333
 		$Common = new Common();
310 334
 		$check_date = new Datetime($date);
311 335
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
312
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
313
-		if ($globalBritishAirwaysKey == '') return array();
336
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
337
+			return array();
338
+		}
339
+		if ($globalBritishAirwaysKey == '') {
340
+			return array();
341
+		}
314 342
 		$url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json";
315 343
 		$headers = array('Client-Key: '.$globalBritishAirwaysKey);
316 344
 		$json = $Common->getData($url,'get','',$headers);
317
-		if ($json == '') return array();
345
+		if ($json == '') {
346
+			return array();
347
+		}
318 348
 		$parsed_json = json_decode($json);
319 349
 		$flights = $parsed_json->{'FlightsResponse'};
320 350
 		if (count($flights) > 0) {
@@ -323,7 +353,9 @@  discard block
 block discarded – undo
323 353
 			$departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'}));
324 354
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'}));
325 355
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways');
326
-		} else return array();
356
+		} else {
357
+			return array();
358
+		}
327 359
 	}
328 360
 
329 361
 	/**
@@ -337,19 +369,27 @@  discard block
 block discarded – undo
337 369
 		$Common = new Common();
338 370
 		$check_date = new Datetime($date);
339 371
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
340
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
341
-		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array();
372
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
373
+			return array();
374
+		}
375
+		if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') {
376
+			return array();
377
+		}
342 378
 		$url = "https://api.lufthansa.com/v1/oauth/token";
343 379
 		$post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials');
344 380
 		$data = $Common->getData($url,'post',$post);
345 381
 		$parsed_data = json_decode($data);
346
-		if (!isset($parsed_data->{'access_token'})) return array();
382
+		if (!isset($parsed_data->{'access_token'})) {
383
+			return array();
384
+		}
347 385
 		$token = $parsed_data->{'access_token'};
348 386
 		
349 387
 		$url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d');
350 388
 		$headers = array('Authorization: Bearer '.$token,'Accept: application/json');
351 389
 		$json = $Common->getData($url,'get','',$headers);
352
-		if ($json == '') return array();
390
+		if ($json == '') {
391
+			return array();
392
+		}
353 393
 		$parsed_json = json_decode($json);
354 394
 		if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) {
355 395
 			$DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'};
@@ -357,7 +397,9 @@  discard block
 block discarded – undo
357 397
 			$ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'};
358 398
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'}));
359 399
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa');
360
-		} else return array();
400
+		} else {
401
+			return array();
402
+		}
361 403
 	}
362 404
 
363 405
 	/**
@@ -371,14 +413,20 @@  discard block
 block discarded – undo
371 413
 		$Common = new Common();
372 414
 		$check_date = new Datetime($date);
373 415
 		$numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign));
374
-		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array();
375
-		if ($globalTransaviaKey == '') return array();
416
+		if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) {
417
+			return array();
418
+		}
419
+		if ($globalTransaviaKey == '') {
420
+			return array();
421
+		}
376 422
 		$url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
377 423
 		//$url = "https://api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol;
378 424
 		$headers = array('apikey: '.$globalTransaviaKey);
379 425
 		$json = $Common->getData($url,'get','',$headers);
380 426
 		//echo 'result : '.$json;
381
-		if ($json == '') return array();
427
+		if ($json == '') {
428
+			return array();
429
+		}
382 430
 		$parsed_json = json_decode($json);
383 431
 		
384 432
 		if (isset($parsed_json->{'data'}[0])) {
@@ -387,7 +435,9 @@  discard block
 block discarded – undo
387 435
 			$ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'};
388 436
 			$arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'}));
389 437
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia');
390
-		} else return array();
438
+		} else {
439
+			return array();
440
+		}
391 441
 	}
392 442
 
393 443
 	/**
@@ -398,7 +448,9 @@  discard block
 block discarded – undo
398 448
 	public function getTunisair($callsign) {
399 449
 		$Common = new Common();
400 450
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
401
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
451
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
452
+			return array();
453
+		}
402 454
 		$url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp";
403 455
 		$data = $Common->getData($url);
404 456
 		$table = $Common->table2array($data);
@@ -420,7 +472,9 @@  discard block
 block discarded – undo
420 472
 		$Common = new Common();
421 473
 		$check_date = new Datetime($date);
422 474
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
423
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
475
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
476
+			return array();
477
+		}
424 478
 		$final_date = str_replace('/','%2F',$check_date->format('d/m/Y'));
425 479
 		$url = "http://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=FlightStatusResult&searchBy=bycode&date=".$final_date."&flightNumber=".$numvol."&idioma=en-GB";
426 480
 		$data = $Common->getData($url);
@@ -430,8 +484,11 @@  discard block
 block discarded – undo
430 484
 			$DepartureAirportIata = str_replace('flightOri=','',$result[0]);
431 485
 			preg_match('/flightDest=[A-Z]{3}/',$data,$result);
432 486
 			$ArrivalAirportIata = str_replace('flightDest=','',$result[0]);
433
-			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
434
-			else return array();
487
+			if ($DepartureAirportIata != '' && $ArrivalAirportIata != '') {
488
+				return array('DepartureAirportIATA' => $DepartureAirportIata,'ArrivalAirportIATA' => $ArrivalAirportIata,'Source' => 'website_vueling');
489
+			} else {
490
+				return array();
491
+			}
435 492
 		}
436 493
 		return array();
437 494
 	}
@@ -446,7 +503,9 @@  discard block
 block discarded – undo
446 503
 		$Common = new Common();
447 504
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
448 505
 		$check_date = new Datetime($date);
449
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
506
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
507
+			return array();
508
+		}
450 509
 		$url = "https://www.iberia.com/web/flightDetail.do";
451 510
 		$post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB');
452 511
 		$data = $Common->getData($url,'post',$post);
@@ -463,7 +522,9 @@  discard block
 block discarded – undo
463 522
 				$arrivalTime = trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][1])));
464 523
 				if ($arrivalTime == 'Hora estimada de llegada') {
465 524
 					$arrivalTime = substr(trim(str_replace(' lunes','',str_replace('&nbsp;','',$flight[5][2]))),0,5);
466
-				} else $arrivalTime = substr($arrivalTime,0,5);
525
+				} else {
526
+					$arrivalTime = substr($arrivalTime,0,5);
527
+				}
467 528
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia');
468 529
 			}
469 530
 		}
@@ -482,7 +543,9 @@  discard block
 block discarded – undo
482 543
 		$Common = new Common();
483 544
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
484 545
 		$check_date = new Datetime($date);
485
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
546
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
547
+			return array();
548
+		}
486 549
 		$url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y');
487 550
 		$data = $Common->getData($url);
488 551
 		if ($data != '') {
@@ -498,7 +561,9 @@  discard block
 block discarded – undo
498 561
 					$departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5);
499 562
 					$arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5);
500 563
 					return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance');
501
-				} else return array();
564
+				} else {
565
+					return array();
566
+				}
502 567
 			}
503 568
 			
504 569
 
@@ -518,7 +583,9 @@  discard block
 block discarded – undo
518 583
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
519 584
 		$check_date = new Datetime($date);
520 585
 		$url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y');
521
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
586
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
587
+			return array();
588
+		}
522 589
 		$data = $Common->getData($url);
523 590
 		if ($data != '') {
524 591
 			$table = $Common->text2array($data);
@@ -543,7 +610,9 @@  discard block
 block discarded – undo
543 610
 		$check_date = new Datetime($date);
544 611
 		$url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302";
545 612
 		//http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber";
546
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
613
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
614
+			return array();
615
+		}
547 616
 		$data = $Common->getData($url);
548 617
 		if ($data != '') {
549 618
 		    //echo $data;
@@ -634,7 +703,9 @@  discard block
 block discarded – undo
634 703
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
635 704
 		$url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees";
636 705
 		//$check_date = new Datetime($date);
637
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
706
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
707
+			return array();
708
+		}
638 709
 		$post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1');
639 710
 		$data = $Common->getData($url,'post',$post);
640 711
 		if ($data != '') {
@@ -666,11 +737,15 @@  discard block
 block discarded – undo
666 737
 				$airline_icao = substr($callsign, 0, 3);
667 738
 			} 
668 739
 		}
669
-		if ($airline_icao == '') return array();
740
+		if ($airline_icao == '') {
741
+			return array();
742
+		}
670 743
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
671 744
 		$url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol;
672 745
 		//$check_date = new Datetime($date);
673
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
746
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
747
+			return array();
748
+		}
674 749
 		$data = $Common->getData($url);
675 750
 		if ($data != '') {
676 751
 			$table = $Common->table2array($data);
@@ -763,10 +838,16 @@  discard block
 block discarded – undo
763 838
 		if ($data != '') {
764 839
 			$table = $Common->table2array($data);
765 840
 			if (isset($table[11][1])) {
766
-				if (is_numeric(substr($table[11][1],0,1))) $departureTime = substr($table[11][1],0,5);
767
-				else $departureTime = '';
768
-				if (is_numeric(substr($table[17][1],0,1))) $arrivalTime = substr($table[17][1],0,5);
769
-				else $arrivalTime = '';
841
+				if (is_numeric(substr($table[11][1],0,1))) {
842
+					$departureTime = substr($table[11][1],0,5);
843
+				} else {
844
+					$departureTime = '';
845
+				}
846
+				if (is_numeric(substr($table[17][1],0,1))) {
847
+					$arrivalTime = substr($table[17][1],0,5);
848
+				} else {
849
+					$arrivalTime = '';
850
+				}
770 851
 				$DepartureAirportIata = substr($table[13][1],0,3);
771 852
 				$ArrivalAirportIata = substr($table[15][1],0,3);
772 853
 				return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_costtotravel');
@@ -783,16 +864,22 @@  discard block
 block discarded – undo
783 864
 	*/
784 865
 	private function getAirCanada($callsign,$date = 'NOW') {
785 866
 		$Common = new Common();
786
-		if (class_exists("DomDocument") === FALSE) return array();
867
+		if (class_exists("DomDocument") === FALSE) {
868
+			return array();
869
+		}
787 870
 		date_default_timezone_set('UTC');
788 871
 		$check_date = new Datetime($date);
789 872
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
790 873
 		$url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249";
791
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
874
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
875
+			return array();
876
+		}
792 877
 		$data = $Common->getData($url);
793 878
 		$dom = new DomDocument();
794 879
 		$dom->loadXML($data);
795
-		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array();
880
+		if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) {
881
+			return array();
882
+		}
796 883
 		$departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0);
797 884
 		if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) {
798 885
 			$DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
@@ -801,7 +888,9 @@  discard block
 block discarded – undo
801 888
 			$ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue;
802 889
 			$arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue));
803 890
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada');
804
-		} else return array();
891
+		} else {
892
+			return array();
893
+		}
805 894
 	}
806 895
 
807 896
 	/**
@@ -815,7 +904,9 @@  discard block
 block discarded – undo
815 904
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
816 905
 		$check_date = new Datetime($date);
817 906
 		$url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&";
818
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
907
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
908
+			return array();
909
+		}
819 910
 		$data = $Common->getData($url);
820 911
 		if ($data != '') {
821 912
 			$table = $Common->table2array($data);
@@ -845,7 +936,9 @@  discard block
 block discarded – undo
845 936
 		$numvol = preg_replace('/^[A-Z]*/','',$callsign);
846 937
 		$check_date = new Datetime($date);
847 938
 		$url= "http://www.airberlin.com/en-US/site/aims.php";
848
-		if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array();
939
+		if (!filter_var($numvol,FILTER_VALIDATE_INT)) {
940
+			return array();
941
+		}
849 942
 		$post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => $carrier);
850 943
 		$data = $Common->getData($url,'post',$post);
851 944
 		//echo $data;
@@ -855,11 +948,19 @@  discard block
 block discarded – undo
855 948
 		if ($data != '') {
856 949
 			$table = $Common->table2array($data);
857 950
 			$flight = $table;
858
-			if (isset($flight[5][4])) $departureTime = $flight[5][4];
859
-			else $departureTime = '';
860
-			if (isset($flight[5][2])) $departureAirport = $flight[5][2];
861
-			else $departureAirport = '';
862
-		} else return array();
951
+			if (isset($flight[5][4])) {
952
+				$departureTime = $flight[5][4];
953
+			} else {
954
+				$departureTime = '';
955
+			}
956
+			if (isset($flight[5][2])) {
957
+				$departureAirport = $flight[5][2];
958
+			} else {
959
+				$departureAirport = '';
960
+			}
961
+		} else {
962
+			return array();
963
+		}
863 964
 		$post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB');
864 965
 		$data = $Common->getData($url,'post',$post);
865 966
 		if ($data != '') {
@@ -872,10 +973,14 @@  discard block
 block discarded – undo
872 973
 			    $arrivalTime = '';
873 974
 			    $arrivalAirport = '';
874 975
 			}
875
-		} else return array();
976
+		} else {
977
+			return array();
978
+		}
876 979
 		$url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner';
877 980
 		$json = $Common->getData($url);
878
-		if ($json == '') return array();
981
+		if ($json == '') {
982
+			return array();
983
+		}
879 984
 		$parsed_json = json_decode($json);
880 985
 		$airports = $parsed_json->{'suggestList'};
881 986
 		if (count($airports) > 0) {
@@ -890,7 +995,9 @@  discard block
 block discarded – undo
890 995
 		}
891 996
 		if (isset($DepartureAirportIata)) {
892 997
 			return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin');
893
-		} else return array();
998
+		} else {
999
+			return array();
1000
+		}
894 1001
 	}
895 1002
 
896 1003
 	/*
@@ -902,7 +1009,9 @@  discard block
 block discarded – undo
902 1009
 	public function fetchSchedule($ident,$date = 'NOW') {
903 1010
 		global $globalSchedulesSources, $globalSchedulesFetch, $globalOffline, $globalFlightAwareUsername;
904 1011
 		//$Common = new Common();
905
-		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) return array();
1012
+		if ($globalSchedulesFetch === FALSE || (isset($globalOffline) && $globalOffline === TRUE)) {
1013
+			return array();
1014
+		}
906 1015
 		$airline_icao = '';
907 1016
 		if (!is_numeric(substr($ident, 0, 3)))
908 1017
 		{
@@ -1137,18 +1246,27 @@  discard block
 block discarded – undo
1137 1246
 					if (strlen($airline_icao) == 3) {
1138 1247
 						$Spotter = new Spotter($this->db);
1139 1248
 						$airline_info = $Spotter->getAllAirlineInfo($airline_icao);
1140
-						if (isset($airline_info[0]['iata'])) $airline_icao = $airline_info[0]['iata'];
1249
+						if (isset($airline_info[0]['iata'])) {
1250
+							$airline_icao = $airline_info[0]['iata'];
1251
+						}
1141 1252
 					}
1142 1253
 					// Randomly use a generic function to get hours
1143 1254
 					if (strlen($airline_icao) == 2) {
1144
-						if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1255
+						if (!isset($globalSchedulesSources)) {
1256
+							$globalSchedulesSources = array('flightmapper','costtotravel','flightaware');
1257
+						}
1145 1258
 						if (count($globalSchedulesSources) > 0) {
1146 1259
 							$rand = mt_rand(0,count($globalSchedulesSources)-1);
1147 1260
 							$source = $globalSchedulesSources[$rand];
1148
-							if ($source == 'flightmapper') return $this->getFlightMapper($ident);
1149
-							elseif ($source == 'costtotravel') return $this->getCostToTravel($ident);
1261
+							if ($source == 'flightmapper') {
1262
+								return $this->getFlightMapper($ident);
1263
+							} elseif ($source == 'costtotravel') {
1264
+								return $this->getCostToTravel($ident);
1265
+							}
1150 1266
 							//elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date);
1151
-							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') return $this->getFlightAware($ident);
1267
+							elseif ($source == 'flightaware' && $globalFlightAwareUsername != '') {
1268
+								return $this->getFlightAware($ident);
1269
+							}
1152 1270
 						}
1153 1271
 					}
1154 1272
 			}
Please login to merge, or discard this patch.
require/class.Accident.php 3 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	}
37 37
 
38 38
 	/**
39
-	* Get Accidents data from DB
40
-	* @param String $limit Limit
41
-	* @param String $type Set type accident or incident
42
-	* @param String $date get data for a date
43
-	* @return array Return Accidents data in array
44
-	*/
39
+	 * Get Accidents data from DB
40
+	 * @param String $limit Limit
41
+	 * @param String $type Set type accident or incident
42
+	 * @param String $date get data for a date
43
+	 * @return array Return Accidents data in array
44
+	 */
45 45
 	public function getAccidentData($limit = '',$type = '',$date = '') {
46 46
 		global $globalDBdriver;
47 47
 		$Image = new Image($this->db);
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 		return $row['nb'];
385 385
 	}
386 386
 
387
-    /**
388
-     * Check if lastest accident update date is older than 1 day
389
-     * @return bool|string
390
-     */
391
-    public static function check_last_accidents_update() {
387
+	/**
388
+	 * Check if lastest accident update date is older than 1 day
389
+	 * @return bool|string
390
+	 */
391
+	public static function check_last_accidents_update() {
392 392
 		global $globalDBdriver;
393 393
 		if ($globalDBdriver == 'mysql') {
394 394
 			$query = "SELECT COUNT(*) as nb FROM config WHERE name = 'last_update_accident_db' AND value > DATE_SUB(NOW(), INTERVAL 1 DAY)";
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
 		else return true;
408 408
 	}
409 409
 
410
-    /**
411
-     * Insert accident update date
412
-     * @return string
413
-     */
414
-    public static function insert_last_accidents_update() {
410
+	/**
411
+	 * Insert accident update date
412
+	 * @return string
413
+	 */
414
+	public static function insert_last_accidents_update() {
415 415
 		$query = "DELETE FROM config WHERE name = 'last_update_accident_db';
416 416
 		    INSERT INTO config (name,value) VALUES ('last_update_accident_db',NOW());";
417 417
 		try {
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -42,20 +42,20 @@  discard block
 block discarded – undo
42 42
 	* @param String $date get data for a date
43 43
 	* @return array Return Accidents data in array
44 44
 	*/
45
-	public function getAccidentData($limit = '',$type = '',$date = '') {
45
+	public function getAccidentData($limit = '', $type = '', $date = '') {
46 46
 		global $globalDBdriver;
47 47
 		$Image = new Image($this->db);
48 48
 		$Spotter = new Spotter($this->db);
49 49
 		$Translation = new Translation($this->db);
50
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
50
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
51 51
 		date_default_timezone_set('UTC');
52 52
 		$result = array();
53 53
 		$limit_query = '';
54 54
 		if ($limit != "")
55 55
 		{
56 56
 			$limit_array = explode(",", $limit);
57
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
58
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
57
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
58
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
59 59
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
60 60
 			{
61 61
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -64,29 +64,29 @@  discard block
 block discarded – undo
64 64
 
65 65
 		if ($type != '') {
66 66
 			if ($date != '') {
67
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
67
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
68 68
 					$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;
69 69
 					//$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;
70
-					$query_values = array(':type' => $type,':date' => $date);
71
-				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) {
70
+					$query_values = array(':type' => $type, ':date' => $date);
71
+				} elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) {
72 72
 					$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;
73
-					$query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31');
74
-				} elseif (preg_match("/^[0-9]{4}$/",$date)) {
73
+					$query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31');
74
+				} elseif (preg_match("/^[0-9]{4}$/", $date)) {
75 75
 					if ($globalDBdriver == 'mysql') {
76 76
 						$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;
77 77
 					} else {
78 78
 						$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;
79 79
 					}
80
-					$query_values = array(':type' => $type,':date' => $date);
80
+					$query_values = array(':type' => $type, ':date' => $date);
81 81
 				} else {
82 82
 					$date = $date.'%';
83 83
 					if ($globalDBdriver == 'mysql') {
84 84
 						$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;
85
-						$query_values = array(':type' => $type,':date' => $date);
85
+						$query_values = array(':type' => $type, ':date' => $date);
86 86
 					} else {
87 87
 						$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;
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 type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query;
89
-						$query_values = array(':type' => $type,':date' => $date);
89
+						$query_values = array(':type' => $type, ':date' => $date);
90 90
 					}
91 91
 				}
92 92
 			} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 			}
98 98
 		} else {
99 99
 			if ($date != '') {
100
-				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) {
100
+				if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) {
101 101
 					$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;
102 102
 					//$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;
103 103
 				} else {
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 		try {
117 117
 			$sth = $this->db->prepare($query);
118 118
 			$sth->execute($query_values);
119
-		} catch(PDOException $e) {
119
+		} catch (PDOException $e) {
120 120
 			echo "error : ".$e->getMessage();
121 121
 			return array();
122 122
 		}
123 123
 		$i = 0;
124 124
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
125
-			if (preg_match('/^[\w\-]+$/',$row['registration'])) {
125
+			if (preg_match('/^[\w\-]+$/', $row['registration'])) {
126 126
 				$data = array();
127 127
 				if ($row['registration'] != '') {
128 128
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
129
+					if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website']));
130
+					else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
131 131
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 132
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 133
 					if (!empty($aircraft_info)) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 						$data['aircraft_name'] = $aircraft_info[0]['type'];
136 136
 						$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer'];
137 137
 					} else {
138
-						$data = array_merge($data,array('aircraft_type' => 'NA'));
138
+						$data = array_merge($data, array('aircraft_type' => 'NA'));
139 139
 					}
140 140
 					$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']);
141 141
 					if (!empty($owner_data)) {
@@ -143,18 +143,18 @@  discard block
 block discarded – undo
143 143
 						$data['aircraft_base'] = $owner_data['base'];
144 144
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 145
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
146
+				} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
147 147
 				if ($row['registration'] == '') $row['registration'] = 'NA';
148 148
 				if ($row['ident'] == '') $row['ident'] = 'NA';
149
-				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
149
+				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3));
150 150
 				if (isset($identicao[0])) {
151
-					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
155
-					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
151
+					if (substr($row['ident'], 0, 2) == 'AF') {
152
+						if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
+						else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
154
+					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
155
+					$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
156 156
 				} else $icao = $row['ident'];
157
-				$icao = $Translation->checkTranslation($icao,false);
157
+				$icao = $Translation->checkTranslation($icao, false);
158 158
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 159
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
160 160
 					//echo 'Check airline info... for '.$row['airline_name'].' ';
@@ -163,16 +163,16 @@  discard block
 block discarded – undo
163 163
 					if (!empty($airline_info)) {
164 164
 						//echo 'data found !'."\n";
165 165
 						//print_r($airline_info);
166
-						$data = array_merge($data,$airline_info);
166
+						$data = array_merge($data, $airline_info);
167 167
 					} 
168 168
 					//else echo 'No data...'."\n";
169 169
 				}
170
-				$data = array_merge($row,$data);
170
+				$data = array_merge($row, $data);
171 171
 				if ($data['ident'] == null) $data['ident'] = $icao;
172 172
 				if ($data['title'] == null) {
173 173
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174 174
 				} else $data['message'] = strtolower($data['title']);
175
-				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
175
+				$ids = $Spotter->getAllIDByRegistration($data['registration'], true);
176 176
 				$date = $data['date'];
177 177
 				if (isset($ids[$date])) {
178 178
 					$data['spotted'] = TRUE;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 		try {
205 205
 			$sth = $this->db->prepare($query);
206 206
 			$sth->execute();
207
-		} catch(PDOException $e) {
207
+		} catch (PDOException $e) {
208 208
 			echo "Error : ".$e->getMessage();
209 209
 			return array();
210 210
 		}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		try {
226 226
 			$sth = $this->db->prepare($query);
227 227
 			$sth->execute();
228
-		} catch(PDOException $e) {
228
+		} catch (PDOException $e) {
229 229
 			echo "Error : ".$e->getMessage();
230 230
 			return array();
231 231
 		}
@@ -241,15 +241,15 @@  discard block
 block discarded – undo
241 241
 		if ($globalDebug) echo 'Import '.$file."\n";
242 242
 		$result = array();
243 243
 		if (file_exists($file)) {
244
-			if (($handle = fopen($file,'r')) !== FALSE) {
245
-				while (($data = fgetcsv($handle,2000,",")) !== FALSE) {
244
+			if (($handle = fopen($file, 'r')) !== FALSE) {
245
+				while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) {
246 246
 					if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') {
247
-						$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');
247
+						$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');
248 248
 					}
249 249
 				}
250 250
 				fclose($handle);
251 251
 			}
252
-			if (!empty($result)) $this->add($result,true);
252
+			if (!empty($result)) $this->add($result, true);
253 253
 			elseif ($globalDebug) echo 'Nothing to import';
254 254
 		}
255 255
 	}
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 		$all_md5_new = array();
266 266
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
267 267
 			if ($this->check_accidents_nb() > 0) {
268
-				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
269
-					while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
268
+				if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
269
+					while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
270 270
 						if (isset($data[1])) {
271 271
 							$year = $data[0];
272 272
 							$all_md5[$year] = $data[1];
@@ -276,10 +276,10 @@  discard block
 block discarded – undo
276 276
 				}
277 277
 			}
278 278
 		}
279
-		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5');
279
+		$Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5');
280 280
 		if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) {
281
-			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) {
282
-				while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) {
281
+			if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) {
282
+				while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) {
283 283
 					if (isset($data[1])) {
284 284
 						$year = $data[0];
285 285
 						$all_md5_new[$year] = $data[1];
@@ -288,10 +288,10 @@  discard block
 block discarded – undo
288 288
 				fclose($handle);
289 289
 			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290 290
 		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
291
-		$result = $Common->arr_diff($all_md5_new,$all_md5);
291
+		$result = $Common->arr_diff($all_md5_new, $all_md5);
292 292
 		if (empty($result) && $globalDebug) echo 'Nothing to update';
293 293
 		foreach ($result as $file => $md5) {
294
-			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
294
+			$Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file);
295 295
 			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296 296
 			elseif ($globalDebug) echo 'Download '.$file.' failed';
297 297
 		}
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	* Add data to DB
302 302
 	* @param Array $crash An array with accidents/incidents data
303 303
 	*/
304
-	public function add($crash,$new = false) {
304
+	public function add($crash, $new = false) {
305 305
 		global $globalTransaction, $globalDebug, $globalAircraftImageFetch;
306 306
 		require_once('class.Connection.php');
307 307
 		require_once('class.Image.php');
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 318
 		}
319 319
 		if ($globalTransaction) $Connection->db->beginTransaction();
320
-		$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);
320
+		$initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null);
321 321
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 322
 		$sth_check = $Connection->db->prepare($query_check);
323 323
 		$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)';
@@ -330,15 +330,15 @@  discard block
 block discarded – undo
330 330
 				$cr = array_map(function($value) {
331 331
 					return $value === "" ? NULL : $value;
332 332
 				}, $cr);
333
-				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
-					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
333
+				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) {
334
+					if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
+					$query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']);
336 336
 					$sth_check->execute($query_check_values);
337 337
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
338 338
 					if ($result_check[0]['nb'] == 0) {
339
-						$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']);
339
+						$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']);
340 340
 						$sth->execute($query_values);
341
-						if ($cr['date'] > time()-(30*86400)) {
341
+						if ($cr['date'] > time() - (30*86400)) {
342 342
 							if ($globalAircraftImageFetch) {
343 343
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 344
 								if (empty($imgchk)) {
@@ -349,17 +349,17 @@  discard block
 block discarded – undo
349 349
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 350
 							}
351 351
 							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
352
-							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
352
+							$Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date']));
353 353
 						}
354 354
 					}
355 355
 				}
356
-				if ($globalTransaction && $j % 1000 == 0) {
356
+				if ($globalTransaction && $j%1000 == 0) {
357 357
 					$Connection->db->commit();
358 358
 					$Connection->db->beginTransaction();
359 359
 				}
360 360
 			}
361 361
 			if ($globalTransaction) $Connection->db->commit();
362
-		} catch(PDOException $e) {
362
+		} catch (PDOException $e) {
363 363
 			if ($globalTransaction) $Connection->db->rollBack();
364 364
 			echo $e->getMessage();
365 365
 		}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 			$Connection = new Connection();
378 378
 			$sth = $Connection->db->prepare($query);
379 379
 			$sth->execute();
380
-		} catch(PDOException $e) {
380
+		} catch (PDOException $e) {
381 381
 			return "error : ".$e->getMessage();
382 382
 		}
383 383
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 			$Connection = new Connection();
400 400
 			$sth = $Connection->db->prepare($query);
401 401
 			$sth->execute();
402
-		} catch(PDOException $e) {
402
+		} catch (PDOException $e) {
403 403
 			return "error : ".$e->getMessage();
404 404
 		}
405 405
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 			$Connection = new Connection();
419 419
 			$sth = $Connection->db->prepare($query);
420 420
 			$sth->execute();
421
-		} catch(PDOException $e) {
421
+		} catch (PDOException $e) {
422 422
 			return "error : ".$e->getMessage();
423 423
 		}
424 424
 		return '';
Please login to merge, or discard this patch.
Braces   +87 added lines, -31 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@  discard block
 block discarded – undo
20 20
 	public function __construct($dbc = null) {
21 21
 		$Connection = new Connection($dbc);
22 22
 		$this->db = $Connection->db();
23
-		if ($this->db === null) die('Error: No DB connection. (Accident)');
23
+		if ($this->db === null) {
24
+			die('Error: No DB connection. (Accident)');
25
+		}
24 26
 	}
25 27
 
26 28
 	/*
@@ -126,8 +128,11 @@  discard block
 block discarded – undo
126 128
 				$data = array();
127 129
 				if ($row['registration'] != '') {
128 130
 					$image_array = $Image->getSpotterImage($row['registration']);
129
-					if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
130
-					else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
131
+					if (count($image_array) > 0) {
132
+						$data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website']));
133
+					} else {
134
+						$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
135
+					}
131 136
 					$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
132 137
 					$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
133 138
 					if (!empty($aircraft_info)) {
@@ -143,17 +148,30 @@  discard block
 block discarded – undo
143 148
 						$data['aircraft_base'] = $owner_data['base'];
144 149
 						$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
145 150
 					}
146
-				} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
147
-				if ($row['registration'] == '') $row['registration'] = 'NA';
148
-				if ($row['ident'] == '') $row['ident'] = 'NA';
151
+				} else {
152
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
153
+				}
154
+				if ($row['registration'] == '') {
155
+					$row['registration'] = 'NA';
156
+				}
157
+				if ($row['ident'] == '') {
158
+					$row['ident'] = 'NA';
159
+				}
149 160
 				$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
150 161
 				if (isset($identicao[0])) {
151 162
 					if (substr($row['ident'],0,2) == 'AF') {
152
-						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
153
-						else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
154
-					} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
163
+						if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
164
+							$icao = $row['ident'];
165
+						} else {
166
+							$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
167
+						}
168
+					} else {
169
+						$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
170
+					}
155 171
 					$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
156
-				} else $icao = $row['ident'];
172
+				} else {
173
+					$icao = $row['ident'];
174
+				}
157 175
 				$icao = $Translation->checkTranslation($icao,false);
158 176
 				//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
159 177
 				if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -168,10 +186,14 @@  discard block
 block discarded – undo
168 186
 					//else echo 'No data...'."\n";
169 187
 				}
170 188
 				$data = array_merge($row,$data);
171
-				if ($data['ident'] == null) $data['ident'] = $icao;
189
+				if ($data['ident'] == null) {
190
+					$data['ident'] = $icao;
191
+				}
172 192
 				if ($data['title'] == null) {
173 193
 					$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
174
-				} else $data['message'] = strtolower($data['title']);
194
+				} else {
195
+					$data['message'] = strtolower($data['title']);
196
+				}
175 197
 				$ids = $Spotter->getAllIDByRegistration($data['registration'],true);
176 198
 				$date = $data['date'];
177 199
 				if (isset($ids[$date])) {
@@ -190,8 +212,9 @@  discard block
 block discarded – undo
190 212
 		if (isset($result)) {
191 213
 			$result[0]['query_number_rows'] = $i;
192 214
 			return $result;
215
+		} else {
216
+			return array();
193 217
 		}
194
-		else return array();
195 218
 	}
196 219
 
197 220
 	/*
@@ -238,7 +261,9 @@  discard block
 block discarded – undo
238 261
 	*/
239 262
 	public function import($file) {
240 263
 		global $globalDebug;
241
-		if ($globalDebug) echo 'Import '.$file."\n";
264
+		if ($globalDebug) {
265
+			echo 'Import '.$file."\n";
266
+		}
242 267
 		$result = array();
243 268
 		if (file_exists($file)) {
244 269
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -249,8 +274,11 @@  discard block
 block discarded – undo
249 274
 				}
250 275
 				fclose($handle);
251 276
 			}
252
-			if (!empty($result)) $this->add($result,true);
253
-			elseif ($globalDebug) echo 'Nothing to import';
277
+			if (!empty($result)) {
278
+				$this->add($result,true);
279
+			} elseif ($globalDebug) {
280
+				echo 'Nothing to import';
281
+			}
254 282
 		}
255 283
 	}
256 284
 
@@ -286,14 +314,23 @@  discard block
 block discarded – undo
286 314
 					}
287 315
 				}
288 316
 				fclose($handle);
289
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
290
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
317
+			} elseif ($globalDebug) {
318
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
319
+			}
320
+		} elseif ($globalDebug) {
321
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
322
+		}
291 323
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
292
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
324
+		if (empty($result) && $globalDebug) {
325
+			echo 'Nothing to update';
326
+		}
293 327
 		foreach ($result as $file => $md5) {
294 328
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
295
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
296
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
329
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
330
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
331
+			} elseif ($globalDebug) {
332
+				echo 'Download '.$file.' failed';
333
+			}
297 334
 		}
298 335
 	}
299 336
 
@@ -310,13 +347,17 @@  discard block
 block discarded – undo
310 347
 		$Image = new Image($this->db);
311 348
 		$Spotter = new Spotter($this->db);
312 349
 
313
-		if (empty($crash)) return false;
350
+		if (empty($crash)) {
351
+			return false;
352
+		}
314 353
 		if ($new === false) {
315 354
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
316 355
 			$sthd = $Connection->db->prepare($query_delete);
317 356
 			$sthd->execute(array(':source' => $crash[0]['source']));
318 357
 		}
319
-		if ($globalTransaction) $Connection->db->beginTransaction();
358
+		if ($globalTransaction) {
359
+			$Connection->db->beginTransaction();
360
+		}
320 361
 		$initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null);
321 362
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
322 363
 		$sth_check = $Connection->db->prepare($query_check);
@@ -331,7 +372,9 @@  discard block
 block discarded – undo
331 372
 					return $value === "" ? NULL : $value;
332 373
 				}, $cr);
333 374
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
334
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
375
+					if (strpos($cr['registration'],'-') === FALSE) {
376
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
377
+					}
335 378
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
336 379
 					$sth_check->execute($query_check_values);
337 380
 					$result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC);
@@ -342,13 +385,19 @@  discard block
 block discarded – undo
342 385
 							if ($globalAircraftImageFetch) {
343 386
 								$imgchk = $Image->getSpotterImage($cr['registration']);
344 387
 								if (empty($imgchk)) {
345
-									if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...';
388
+									if ($globalDebug) {
389
+										echo "\t".'Get image for '.$cr['registration'].'...';
390
+									}
346 391
 									$Image->addSpotterImage($cr['registration']);
347
-									if ($globalDebug) echo "\t".'Done'."\n";
392
+									if ($globalDebug) {
393
+										echo "\t".'Done'."\n";
394
+									}
348 395
 								}
349 396
 								// elseif ($globalDebug) echo 'Image already in DB'."\n";
350 397
 							}
351
-							if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type'];
398
+							if ($cr['title'] == '') {
399
+								$cr['title'] = $cr['registration'].' '.$cr['type'];
400
+							}
352 401
 							$Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date']));
353 402
 						}
354 403
 					}
@@ -358,9 +407,13 @@  discard block
 block discarded – undo
358 407
 					$Connection->db->beginTransaction();
359 408
 				}
360 409
 			}
361
-			if ($globalTransaction) $Connection->db->commit();
410
+			if ($globalTransaction) {
411
+				$Connection->db->commit();
412
+			}
362 413
 		} catch(PDOException $e) {
363
-			if ($globalTransaction) $Connection->db->rollBack();
414
+			if ($globalTransaction) {
415
+				$Connection->db->rollBack();
416
+			}
364 417
 			echo $e->getMessage();
365 418
 		}
366 419
 		$sth_check->closeCursor();
@@ -403,8 +456,11 @@  discard block
 block discarded – undo
403 456
 			return "error : ".$e->getMessage();
404 457
 		}
405 458
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
406
-		if ($row['nb'] > 0) return false;
407
-		else return true;
459
+		if ($row['nb'] > 0) {
460
+			return false;
461
+		} else {
462
+			return true;
463
+		}
408 464
 	}
409 465
 
410 466
     /**
Please login to merge, or discard this patch.
require/class.ACARS.php 3 patches
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
 	}
33 33
 
34 34
 	/**
35
-	* Change IATA to ICAO value for ident
36
-	*
37
-	* @param String $ident ident
38
-	* @return String the icao
39
-	*/
35
+	 * Change IATA to ICAO value for ident
36
+	 *
37
+	 * @param String $ident ident
38
+	 * @return String the icao
39
+	 */
40 40
 	public function ident2icao($ident) {
41 41
 		if (substr($ident,0,2) == 'AF') {
42 42
 			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
@@ -52,11 +52,11 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	/**
55
-	* Deletes all info in the live table
56
-	*
57
-	* @return String success or false
58
-	*
59
-	*/
55
+	 * Deletes all info in the live table
56
+	 *
57
+	 * @return String success or false
58
+	 *
59
+	 */
60 60
 	public function deleteLiveAcarsData()
61 61
 	{
62 62
 		global $globalDBdriver;
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 
78 78
 	/**
79
-	* Deletes all info in the archive table
80
-	*
81
-	* @return String success or false
82
-	*
83
-	*/
79
+	 * Deletes all info in the archive table
80
+	 *
81
+	 * @return String success or false
82
+	 *
83
+	 */
84 84
 	public function deleteArchiveAcarsData()
85 85
 	{
86 86
 		global $globalACARSArchiveKeepMonths, $globalDBdriver;
@@ -100,13 +100,13 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 
103
-    /**
104
-     * Parse ACARS data
105
-     *
106
-     * @param String ACARS data in acarsdec data
107
-     *
108
-     * @return array
109
-     */
103
+	/**
104
+	 * Parse ACARS data
105
+	 *
106
+	 * @param String ACARS data in acarsdec data
107
+	 *
108
+	 * @return array
109
+	 */
110 110
 	public function parse($data) {
111 111
 		global $globalDebug;
112 112
 		//$Image = new Image($this->db);
@@ -736,11 +736,11 @@  discard block
 block discarded – undo
736 736
 	}
737 737
 
738 738
 	/**
739
-	* Add ACARS data
740
-	*
741
-	* @param String ACARS data in acarsdec data
742
-	*
743
-	*/
739
+	 * Add ACARS data
740
+	 *
741
+	 * @param String ACARS data in acarsdec data
742
+	 *
743
+	 */
744 744
 	public function add($data,$message = array()) {
745 745
 		global $globalDebug, $globalACARSArchive;
746 746
 		$Image = new Image($this->db);
@@ -787,18 +787,18 @@  discard block
 block discarded – undo
787 787
 		}
788 788
 	}
789 789
 
790
-    /**
791
-     * Add Live ACARS data in DB
792
-     *
793
-     * @param String $ident ident
794
-     * @param String $registration Registration of the aircraft
795
-     * @param String $label Label of the ACARS message
796
-     * @param String $block_id Block id of the ACARS message
797
-     * @param String $msg_no Number of the ACARS message
798
-     * @param String $message ACARS message
799
-     * @param string $decode
800
-     * @return bool
801
-     */
790
+	/**
791
+	 * Add Live ACARS data in DB
792
+	 *
793
+	 * @param String $ident ident
794
+	 * @param String $registration Registration of the aircraft
795
+	 * @param String $label Label of the ACARS message
796
+	 * @param String $block_id Block id of the ACARS message
797
+	 * @param String $msg_no Number of the ACARS message
798
+	 * @param String $message ACARS message
799
+	 * @param string $decode
800
+	 * @return bool
801
+	 */
802 802
 	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
803 803
 		global $globalDebug;
804 804
 		date_default_timezone_set('UTC');
@@ -836,18 +836,18 @@  discard block
 block discarded – undo
836 836
 		return false;
837 837
 	}
838 838
 
839
-    /**
840
-     * Add Archive ACARS data in DB
841
-     *
842
-     * @param String $ident ident
843
-     * @param String $registration Registration of the aircraft
844
-     * @param String $label Label of the ACARS message
845
-     * @param String $block_id Block id of the ACARS message
846
-     * @param String $msg_no Number of the ACARS message
847
-     * @param String $message ACARS message
848
-     * @param string $decode
849
-     * @return string
850
-     */
839
+	/**
840
+	 * Add Archive ACARS data in DB
841
+	 *
842
+	 * @param String $ident ident
843
+	 * @param String $registration Registration of the aircraft
844
+	 * @param String $label Label of the ACARS message
845
+	 * @param String $block_id Block id of the ACARS message
846
+	 * @param String $msg_no Number of the ACARS message
847
+	 * @param String $message ACARS message
848
+	 * @param string $decode
849
+	 * @return string
850
+	 */
851 851
 	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
852 852
 		global $globalDebug;
853 853
 		date_default_timezone_set('UTC');
@@ -879,11 +879,11 @@  discard block
 block discarded – undo
879 879
 	}
880 880
 
881 881
 	/**
882
-	* Get Message title from label from DB
883
-	*
884
-	* @param String $label
885
-	* @return String Return ACARS title
886
-	*/
882
+	 * Get Message title from label from DB
883
+	 *
884
+	 * @param String $label
885
+	 * @return String Return ACARS title
886
+	 */
887 887
 	public function getTitlefromLabel($label) {
888 888
 		$Connection = new Connection($this->db);
889 889
 		$this->db = $Connection->db;
@@ -902,10 +902,10 @@  discard block
 block discarded – undo
902 902
 	}
903 903
 
904 904
 	/**
905
-	* List all Message title & label from DB
906
-	*
907
-	* @return array Return ACARS data in array
908
-	*/
905
+	 * List all Message title & label from DB
906
+	 *
907
+	 * @return array Return ACARS data in array
908
+	 */
909 909
 	public function getAllTitleLabel() {
910 910
 		$query = "SELECT * FROM acars_label ORDER BY title";
911 911
 		$query_values = array();
@@ -922,11 +922,11 @@  discard block
 block discarded – undo
922 922
 	}
923 923
 
924 924
 	/**
925
-	* Get Live ACARS data from DB
926
-	*
927
-	* @param String $ident
928
-	* @return array Return ACARS data in array
929
-	*/
925
+	 * Get Live ACARS data from DB
926
+	 *
927
+	 * @param String $ident
928
+	 * @return array Return ACARS data in array
929
+	 */
930 930
 	public function getLiveAcarsData($ident) {
931 931
 		$query = "SELECT * FROM acars_live WHERE ident = :ident ORDER BY acars_live_id DESC";
932 932
 		$query_values = array(':ident' => $ident);
@@ -942,13 +942,13 @@  discard block
 block discarded – undo
942 942
 		else return array();
943 943
 	}
944 944
 
945
-    /**
946
-     * Get Latest ACARS data from DB
947
-     *
948
-     * @param string $limit
949
-     * @param string $label
950
-     * @return array Return ACARS data in array
951
-     */
945
+	/**
946
+	 * Get Latest ACARS data from DB
947
+	 *
948
+	 * @param string $limit
949
+	 * @param string $label
950
+	 * @return array Return ACARS data in array
951
+	 */
952 952
 	public function getLatestAcarsData($limit = '',$label = '') {
953 953
 		global $globalURL;
954 954
 		$Image = new Image($this->db);
@@ -1036,13 +1036,13 @@  discard block
 block discarded – undo
1036 1036
 		else return array();
1037 1037
 	}
1038 1038
 
1039
-    /**
1040
-     * Get Archive ACARS data from DB
1041
-     *
1042
-     * @param string $limit
1043
-     * @param string $label
1044
-     * @return array Return ACARS data in array
1045
-     */
1039
+	/**
1040
+	 * Get Archive ACARS data from DB
1041
+	 *
1042
+	 * @param string $limit
1043
+	 * @param string $label
1044
+	 * @return array Return ACARS data in array
1045
+	 */
1046 1046
 	public function getArchiveAcarsData($limit = '',$label = '') {
1047 1047
 		global $globalURL;
1048 1048
 		$Image = new Image($this->db);
@@ -1131,17 +1131,17 @@  discard block
 block discarded – undo
1131 1131
 		} else return array();
1132 1132
 	}
1133 1133
 
1134
-    /**
1135
-     * Add ModeS data to DB
1136
-     *
1137
-     * @param String $ident ident
1138
-     * @param String $registration Registration of the aircraft
1139
-     * @param String $icao
1140
-     * @param String $ICAOTypeCode
1141
-     * @param string $latitude
1142
-     * @param string $longitude
1143
-     * @return string
1144
-     */
1134
+	/**
1135
+	 * Add ModeS data to DB
1136
+	 *
1137
+	 * @param String $ident ident
1138
+	 * @param String $registration Registration of the aircraft
1139
+	 * @param String $icao
1140
+	 * @param String $ICAOTypeCode
1141
+	 * @param string $latitude
1142
+	 * @param string $longitude
1143
+	 * @return string
1144
+	 */
1145 1145
 	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1146 1146
 		global $globalDebug, $globalDBdriver;
1147 1147
 		$ident = trim($ident);
Please login to merge, or discard this patch.
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 	/*
22 22
 	 * Initialize DB connection
23 23
 	*/
24
-	public function __construct($dbc = null,$fromACARSscript = false) {
24
+	public function __construct($dbc = null, $fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27 27
 		if ($this->db === null) die('Error: No DB connection. (ACARS)');
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	* @return String the icao
39 39
 	*/
40 40
 	public function ident2icao($ident) {
41
-		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
41
+		if (substr($ident, 0, 2) == 'AF') {
42
+			if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
+			else $icao = 'AFR'.ltrim(substr($ident, 2), '0');
44 44
 		} else {
45 45
 			$Spotter = new Spotter($this->db);
46
-			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
46
+			$identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2));
47 47
 			if (isset($identicao[0])) {
48
-				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
48
+				$icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0');
49 49
 			} else $icao = $ident;
50 50
 		}
51 51
 		return $icao;
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 			$sth = $this->db->prepare($query);
71 71
 			$sth->execute();
72
-		} catch(PDOException $e) {
72
+		} catch (PDOException $e) {
73 73
 			return "error";
74 74
 		}
75 75
 		return "success";
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
 			$sth = $this->db->prepare($query);
95 95
 			$sth->execute();
96
-		} catch(PDOException $e) {
96
+		} catch (PDOException $e) {
97 97
 			return "error";
98 98
 		}
99 99
 		return "success";
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 		$ident = '';
120 120
 		$message = '';
121 121
 		$result = array();
122
-		$n = sscanf($data,'%*[0-9a-z.] %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
125
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
122
+		$n = sscanf($data, '%*[0-9a-z.] %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
123
+		if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
124
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
125
+		if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message);
126 126
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
127
-			$registration = str_replace('.','',$registration);
128
-			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
127
+			$registration = str_replace('.', '', $registration);
128
+			$result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message);
129 129
 			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
130 130
 		} else $message = $data;
131 131
 		$decode = array();
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
 				$temp = '';
146 146
 				$n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp);
147 147
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
148
-					$latitude = $la / 10000.0;
149
-					$longitude = $ln / 10000.0;
148
+					$latitude = $la/10000.0;
149
+					$longitude = $ln/10000.0;
150 150
 					if ($lac == 'S') $latitude = '-'.$latitude;
151 151
 					if ($lnc == 'W') $longitude = '-'.$longitude;
152 152
 					// Temp not always available
153 153
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
154
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
155
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
154
+					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt);
155
+					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C');
156 156
 
157 157
 					//$icao = $Translation->checkTranslation($ident);
158 158
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -164,19 +164,19 @@  discard block
 block discarded – undo
164 164
 				$dhour = '';
165 165
 				$darr = '';
166 166
 				$ahour = '';
167
-				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
167
+				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour);
168 168
 				if ($n == 4 && strlen($darr) == 4) {
169
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
170
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
171
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
169
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
170
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
171
+					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n";
172 172
 					//$icao = ACARS->ident2icao($ident);
173 173
 					//$icao = $Translation->checkTranslation($ident);
174 174
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
175 175
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
176 176
 					$found = true;
177 177
 				}
178
-				elseif ($n == 2 || $n  == 4) {
179
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
178
+				elseif ($n == 2 || $n == 4) {
179
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
180 180
 					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
181 181
 					//$icao = ACARS->ident2icao($ident);
182 182
 					//$icao = $Translation->checkTranslation($ident);
@@ -234,11 +234,11 @@  discard block
 block discarded – undo
234 234
 				$ahour = '';
235 235
 				$aair = '';
236 236
 				$apiste = '';
237
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
237
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste);
238 238
 				if ($n > 8) {
239
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
241
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
239
+					if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
+					if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2);
241
+					if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2);
242 242
 					$icao = trim($aident);
243 243
 
244 244
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 				if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
264 264
 					$las = $las.'.'.$lass;
265 265
 					$lns = $lns.'.'.$lns;
266
-					$latitude = $las / 1000.0;
267
-					$longitude = $lns / 1000.0;
266
+					$latitude = $las/1000.0;
267
+					$longitude = $lns/1000.0;
268 268
 					if ($lac == 'S') $latitude = '-'.$latitude;
269 269
 					if ($lnc == 'W') $longitude = '-'.$longitude;
270 270
 					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
 				$alt = '';
360 360
 				$fuel = '';
361 361
 				$speed = '';
362
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
362
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed);
363 363
 				if ($n == 9) {
364 364
 					//if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
365 365
 					$icao = trim($aident);
366 366
 					$decode['icao'] = $icao;
367
-					$latitude = $las / 100.0;
368
-					$longitude = $lns / 100.0;
367
+					$latitude = $las/100.0;
368
+					$longitude = $lns/100.0;
369 369
 					if ($lac == 'S') $latitude = '-'.$latitude;
370 370
 					if ($lnc == 'W') $longitude = '-'.$longitude;
371 371
 
372
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
372
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed);
373 373
 					$found = true;
374 374
 				}
375 375
 			}
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 					if ($lac == 'S') $latitude = '-'.$latitude;
389 389
 					if ($lnc == 'W') $longitude = '-'.$longitude;
390 390
 
391
-					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
391
+					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
392 392
 					$found = true;
393 393
 				}
394 394
 			}
@@ -421,7 +421,7 @@  discard block
 block discarded – undo
421 421
 				$dair = '';
422 422
 				$darr = '';
423 423
 				$aident = '';
424
-				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
424
+				$n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
425 425
 				if ($n == 8) {
426 426
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
427 427
 					$icao = trim($aident);
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 				*/
454 454
 				$dair = '';
455 455
 				$darr = '';
456
-				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
456
+				$n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr);
457 457
 				if ($n == 3) {
458 458
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
459 459
 					//$icao = $Translation->checkTranslation($ident);
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 				*/
469 469
 				$dair = '';
470 470
 				$darr = '';
471
-				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
471
+				$n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr);
472 472
 				if ($n == 3) {
473 473
 					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
474 474
 					//$icao = $Translation->checkTranslation($ident);
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 				}
479 479
 			}
480 480
 			if (!$found) {
481
-				$n = sscanf($message,'MET01%4c',$airport);
481
+				$n = sscanf($message, 'MET01%4c', $airport);
482 482
 				if ($n == 1) {
483 483
 					if ($globalDebug) echo 'airport name : '.$airport;
484 484
 					$decode = array('Airport/Waypoint name' => $airport);
@@ -486,241 +486,241 @@  discard block
 block discarded – undo
486 486
 				}
487 487
 			}
488 488
 			if ($label == 'H1') {
489
-				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
490
-					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
489
+				if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) {
490
+					$decode = array_merge(array('Message nature' => 'Equipment failure'), $decode);
491 491
 				}
492
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
493
-					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
492
+				elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) {
493
+					$decode = array_merge(array('Message nature' => 'Take off performance data'), $decode);
494 494
 				}
495
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
496
-					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
495
+				elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) {
496
+					$decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode);
497 497
 				}
498
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499
-					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
498
+				elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) {
499
+					$decode = array_merge(array('Message nature' => 'Weather observation'), $decode);
500 500
 				}
501
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
502
-					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
501
+				elseif (preg_match(':^#DFB/PIREP:', $message)) {
502
+					$decode = array_merge(array('Message nature' => 'Pilot Report'), $decode);
503 503
 				}
504
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
505
-					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
504
+				elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) {
505
+					$decode = array_merge(array('Message nature' => 'Engine Data'), $decode);
506 506
 				}
507
-				elseif (preg_match(':^#M1AAEP:',$message)) {
508
-					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
507
+				elseif (preg_match(':^#M1AAEP:', $message)) {
508
+					$decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode);
509 509
 				}
510
-				elseif (preg_match(':^#M2APWD:',$message)) {
511
-					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
510
+				elseif (preg_match(':^#M2APWD:', $message)) {
511
+					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode);
512 512
 				}
513
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
514
-					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
513
+				elseif (preg_match(':^#M1BREQPWI:', $message)) {
514
+					$decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode);
515 515
 				}
516
-				elseif (preg_match(':^#CF:',$message)) {
517
-					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
516
+				elseif (preg_match(':^#CF:', $message)) {
517
+					$decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode);
518 518
 				}
519
-				elseif (preg_match(':^#DF:',$message)) {
520
-					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
519
+				elseif (preg_match(':^#DF:', $message)) {
520
+					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode);
521 521
 				}
522
-				elseif (preg_match(':^#EC:',$message)) {
523
-					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
522
+				elseif (preg_match(':^#EC:', $message)) {
523
+					$decode = array_merge(array('Message nature' => 'Engine Display System'), $decode);
524 524
 				}
525
-				elseif (preg_match(':^#EI:',$message)) {
526
-					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
525
+				elseif (preg_match(':^#EI:', $message)) {
526
+					$decode = array_merge(array('Message nature' => 'Engine Report'), $decode);
527 527
 				}
528
-				elseif (preg_match(':^#H1:',$message)) {
529
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
528
+				elseif (preg_match(':^#H1:', $message)) {
529
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode);
530 530
 				}
531
-				elseif (preg_match(':^#H2:',$message)) {
532
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
531
+				elseif (preg_match(':^#H2:', $message)) {
532
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode);
533 533
 				}
534
-				elseif (preg_match(':^#HD:',$message)) {
535
-					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
534
+				elseif (preg_match(':^#HD:', $message)) {
535
+					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode);
536 536
 				}
537
-				elseif (preg_match(':^#M1:',$message)) {
538
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
537
+				elseif (preg_match(':^#M1:', $message)) {
538
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode);
539 539
 				}
540
-				elseif (preg_match(':^#M2:',$message)) {
541
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
540
+				elseif (preg_match(':^#M2:', $message)) {
541
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode);
542 542
 				}
543
-				elseif (preg_match(':^#M3:',$message)) {
544
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
543
+				elseif (preg_match(':^#M3:', $message)) {
544
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode);
545 545
 				}
546
-				elseif (preg_match(':^#MD:',$message)) {
547
-					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
546
+				elseif (preg_match(':^#MD:', $message)) {
547
+					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode);
548 548
 				}
549
-				elseif (preg_match(':^#PS:',$message)) {
550
-					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
549
+				elseif (preg_match(':^#PS:', $message)) {
550
+					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode);
551 551
 				}
552
-				elseif (preg_match(':^#S1:',$message)) {
553
-					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
552
+				elseif (preg_match(':^#S1:', $message)) {
553
+					$decode = array_merge(array('Message nature' => 'SDU - Left'), $decode);
554 554
 				}
555
-				elseif (preg_match(':^#S2:',$message)) {
556
-					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
555
+				elseif (preg_match(':^#S2:', $message)) {
556
+					$decode = array_merge(array('Message nature' => 'SDU - Right'), $decode);
557 557
 				}
558
-				elseif (preg_match(':^#SD:',$message)) {
559
-					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
558
+				elseif (preg_match(':^#SD:', $message)) {
559
+					$decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode);
560 560
 				}
561
-				elseif (preg_match(':^#T[0-8]:',$message)) {
562
-					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
561
+				elseif (preg_match(':^#T[0-8]:', $message)) {
562
+					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode);
563 563
 				}
564
-				elseif (preg_match(':^#WO:',$message)) {
565
-					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
564
+				elseif (preg_match(':^#WO:', $message)) {
565
+					$decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode);
566 566
 				}
567
-				elseif (preg_match(':^#A1:',$message)) {
568
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
567
+				elseif (preg_match(':^#A1:', $message)) {
568
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode);
569 569
 				}
570
-				elseif (preg_match(':^#A3:',$message)) {
571
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
570
+				elseif (preg_match(':^#A3:', $message)) {
571
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode);
572 572
 				}
573
-				elseif (preg_match(':^#A4:',$message)) {
574
-					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
573
+				elseif (preg_match(':^#A4:', $message)) {
574
+					$decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode);
575 575
 				}
576
-				elseif (preg_match(':^#A6:',$message)) {
577
-					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
576
+				elseif (preg_match(':^#A6:', $message)) {
577
+					$decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode);
578 578
 				}
579
-				elseif (preg_match(':^#A8:',$message)) {
580
-					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
579
+				elseif (preg_match(':^#A8:', $message)) {
580
+					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode);
581 581
 				}
582
-				elseif (preg_match(':^#A9:',$message)) {
583
-					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
582
+				elseif (preg_match(':^#A9:', $message)) {
583
+					$decode = array_merge(array('Message nature' => 'ATIS report'), $decode);
584 584
 				}
585
-				elseif (preg_match(':^#A0:',$message)) {
586
-					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
585
+				elseif (preg_match(':^#A0:', $message)) {
586
+					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode);
587 587
 				}
588
-				elseif (preg_match(':^#AA:',$message)) {
589
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
588
+				elseif (preg_match(':^#AA:', $message)) {
589
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
590 590
 				}
591
-				elseif (preg_match(':^#AB:',$message)) {
592
-					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
591
+				elseif (preg_match(':^#AB:', $message)) {
592
+					$decode = array_merge(array('Message nature' => 'TWIP Report'), $decode);
593 593
 				}
594
-				elseif (preg_match(':^#AC:',$message)) {
595
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
594
+				elseif (preg_match(':^#AC:', $message)) {
595
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode);
596 596
 				}
597
-				elseif (preg_match(':^#AD:',$message)) {
598
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
597
+				elseif (preg_match(':^#AD:', $message)) {
598
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode);
599 599
 				}
600
-				elseif (preg_match(':^#AF:',$message)) {
601
-					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
600
+				elseif (preg_match(':^#AF:', $message)) {
601
+					$decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode);
602 602
 				}
603
-				elseif (preg_match(':^#B1:',$message)) {
604
-					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
603
+				elseif (preg_match(':^#B1:', $message)) {
604
+					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode);
605 605
 				}
606
-				elseif (preg_match(':^#B2:',$message)) {
607
-					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
606
+				elseif (preg_match(':^#B2:', $message)) {
607
+					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode);
608 608
 				}
609
-				elseif (preg_match(':^#B3:',$message)) {
610
-					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
609
+				elseif (preg_match(':^#B3:', $message)) {
610
+					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode);
611 611
 				}
612
-				elseif (preg_match(':^#B4:',$message)) {
613
-					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
612
+				elseif (preg_match(':^#B4:', $message)) {
613
+					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode);
614 614
 				}
615
-				elseif (preg_match(':^#B6:',$message)) {
616
-					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
615
+				elseif (preg_match(':^#B6:', $message)) {
616
+					$decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode);
617 617
 				}
618
-				elseif (preg_match(':^#B8:',$message)) {
619
-					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
618
+				elseif (preg_match(':^#B8:', $message)) {
619
+					$decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode);
620 620
 				}
621
-				elseif (preg_match(':^#B9:',$message)) {
622
-					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
621
+				elseif (preg_match(':^#B9:', $message)) {
622
+					$decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode);
623 623
 				}
624
-				elseif (preg_match(':^#B0:',$message)) {
625
-					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
624
+				elseif (preg_match(':^#B0:', $message)) {
625
+					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode);
626 626
 				}
627
-				elseif (preg_match(':^#BA:',$message)) {
628
-					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
627
+				elseif (preg_match(':^#BA:', $message)) {
628
+					$decode = array_merge(array('Message nature' => 'ATCComm'), $decode);
629 629
 				}
630
-				elseif (preg_match(':^#BB:',$message)) {
631
-					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
630
+				elseif (preg_match(':^#BB:', $message)) {
631
+					$decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode);
632 632
 				}
633
-				elseif (preg_match(':^#BC:',$message)) {
634
-					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
633
+				elseif (preg_match(':^#BC:', $message)) {
634
+					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode);
635 635
 				}
636
-				elseif (preg_match(':^#BD:',$message)) {
637
-					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
636
+				elseif (preg_match(':^#BD:', $message)) {
637
+					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode);
638 638
 				}
639
-				elseif (preg_match(':^#BE:',$message)) {
640
-					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
639
+				elseif (preg_match(':^#BE:', $message)) {
640
+					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode);
641 641
 				}
642
-				elseif (preg_match(':^#BF:',$message)) {
643
-					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
642
+				elseif (preg_match(':^#BF:', $message)) {
643
+					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode);
644 644
 				}
645
-				elseif (preg_match(':^#H3:',$message)) {
646
-					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
645
+				elseif (preg_match(':^#H3:', $message)) {
646
+					$decode = array_merge(array('Message nature' => 'Icing Report'), $decode);
647 647
 				}
648 648
 			}
649 649
 			if ($label == '10') {
650
-				if (preg_match(':^DTO01:',$message)) {
651
-					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
650
+				if (preg_match(':^DTO01:', $message)) {
651
+					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode);
652 652
 				}
653
-				elseif (preg_match(':^AIS01:',$message)) {
654
-					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
653
+				elseif (preg_match(':^AIS01:', $message)) {
654
+					$decode = array_merge(array('Message nature' => 'AIS Request'), $decode);
655 655
 				}
656
-				elseif (preg_match(':^FTX01:',$message)) {
657
-					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
656
+				elseif (preg_match(':^FTX01:', $message)) {
657
+					$decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode);
658 658
 				}
659
-				elseif (preg_match(':^FPL01:',$message)) {
660
-					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
659
+				elseif (preg_match(':^FPL01:', $message)) {
660
+					$decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode);
661 661
 				}
662
-				elseif (preg_match(':^WAB01:',$message)) {
663
-					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
662
+				elseif (preg_match(':^WAB01:', $message)) {
663
+					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode);
664 664
 				}
665
-				elseif (preg_match(':^MET01:',$message)) {
666
-					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
665
+				elseif (preg_match(':^MET01:', $message)) {
666
+					$decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode);
667 667
 				}
668
-				elseif (preg_match(':^WAB02:',$message)) {
669
-					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
668
+				elseif (preg_match(':^WAB02:', $message)) {
669
+					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode);
670 670
 				}
671 671
 			}
672 672
 			if ($label == '15') {
673
-				if (preg_match(':^FST01:',$message)) {
674
-					$decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode);
673
+				if (preg_match(':^FST01:', $message)) {
674
+					$decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode);
675 675
 				}
676 676
 			}
677 677
 			if (!$found && $label == 'SA') {
678
-				$n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at);
678
+				$n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at);
679 679
 				if ($n == 4) {
680 680
 					$vsta = array('Version' => $version);
681 681
 					if ($state == 'E') {
682
-						$vsta = array_merge($vsta,array('Link state' => 'Established'));
682
+						$vsta = array_merge($vsta, array('Link state' => 'Established'));
683 683
 					}
684 684
 					elseif ($state == 'L') {
685
-						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
685
+						$vsta = array_merge($vsta, array('Link state' => 'Lost'));
686 686
 					}
687 687
 					else {
688
-						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
688
+						$vsta = array_merge($vsta, array('Link state' => 'Unknown'));
689 689
 					}
690 690
 					if ($type == 'V') {
691
-						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
691
+						$vsta = array_merge($vsta, array('Link type' => 'VHF ACARS'));
692 692
 					}
693 693
 					elseif ($type == 'S') {
694
-						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
694
+						$vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM'));
695 695
 					}
696 696
 					elseif ($type == 'H') {
697
-						$vsta = array_merge($vsta,array('Link type' => 'HF'));
697
+						$vsta = array_merge($vsta, array('Link type' => 'HF'));
698 698
 					}
699 699
 					elseif ($type == 'G') {
700
-						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
700
+						$vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM'));
701 701
 					}
702 702
 					elseif ($type == 'C') {
703
-						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
703
+						$vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM'));
704 704
 					}
705 705
 					elseif ($type == '2') {
706
-						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
706
+						$vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2'));
707 707
 					}
708 708
 					elseif ($type == 'X') {
709
-						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
709
+						$vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero'));
710 710
 					}
711 711
 					elseif ($type == 'I') {
712
-						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
712
+						$vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM'));
713 713
 					}
714 714
 					else {
715
-						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
715
+						$vsta = array_merge($vsta, array('Link type' => 'Unknown'));
716 716
 					}
717
-					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
718
-					$decode = array_merge($vsta,$decode);
717
+					$vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2))));
718
+					$decode = array_merge($vsta, $decode);
719 719
 				}
720 720
 			}
721 721
 
722 722
 			$title = $this->getTitlefromLabel($label);
723
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
723
+			if ($title != '') $decode = array_merge(array('Message title' => $title), $decode);
724 724
 			/*
725 725
 			// Business jets always use GS0001
726 726
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -741,21 +741,21 @@  discard block
 block discarded – undo
741 741
 	* @param String ACARS data in acarsdec data
742 742
 	*
743 743
 	*/
744
-	public function add($data,$message = array()) {
744
+	public function add($data, $message = array()) {
745 745
 		global $globalDebug, $globalACARSArchive;
746 746
 		$Image = new Image($this->db);
747 747
 		$Schedule = new Schedule($this->db);
748 748
 		$Translation = new Translation($this->db);
749 749
 
750
-		$message = array_merge($message,$this->parse($data));
750
+		$message = array_merge($message, $this->parse($data));
751 751
 		if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') {
752
-			$ident = (string)$message['ident'];
752
+			$ident = (string) $message['ident'];
753 753
 			$label = $message['label'];
754 754
 			$block_id = $message['block_id'];
755 755
 			$msg_no = $message['msg_no'];
756 756
 			$msg = $message['message'];
757 757
 			$decode = $message['decode'];
758
-			$registration = (string)$message['registration'];
758
+			$registration = (string) $message['registration'];
759 759
 			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
760 760
 			else $latitude = '';
761 761
 			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
@@ -769,20 +769,20 @@  discard block
 block discarded – undo
769 769
 				$Image->addSpotterImage($registration);
770 770
 			}
771 771
 			// Business jets always use GS0001
772
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
772
+			if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude);
773 773
 			if ($globalDebug && isset($info) && $info != '') echo $info;
774 774
 			if (count($decode) > 0) $decode_json = json_encode($decode);
775 775
 			else $decode_json = '';
776 776
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
777
-				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
777
+				$Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS');
778 778
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
779
-				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
779
+				$Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS');
780 780
 			}
781
-			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
782
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
783
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
781
+			$result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
782
+			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F');
783
+			if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json);
784 784
 			if ($globalDebug && count($decode) > 0) {
785
-				echo "Human readable data : ".implode(' - ',$decode)."\n";
785
+				echo "Human readable data : ".implode(' - ', $decode)."\n";
786 786
 			}
787 787
 		}
788 788
 	}
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
      * @param string $decode
800 800
      * @return bool
801 801
      */
802
-	public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
802
+	public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
803 803
 		global $globalDebug;
804 804
 		date_default_timezone_set('UTC');
805 805
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
@@ -807,22 +807,22 @@  discard block
 block discarded – undo
807 807
 			$this->db = $Connection->db;
808 808
 			if ($globalDebug) echo "Test if not already in Live ACARS table...";
809 809
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
810
-			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
810
+			$query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message);
811 811
 			try {
812 812
 				$stht = $this->db->prepare($query_test);
813 813
 				$stht->execute($query_test_values);
814
-			} catch(PDOException $e) {
814
+			} catch (PDOException $e) {
815 815
 				echo "error : ".$e->getMessage();
816 816
 				return false;
817 817
 			}
818 818
 			if ($stht->fetchColumn() == 0) {
819 819
 				if ($globalDebug) echo "Add Live ACARS data...";
820 820
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
821
-				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
821
+				$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s"));
822 822
 				try {
823 823
 					$sth = $this->db->prepare($query);
824 824
 					$sth->execute($query_values);
825
-				} catch(PDOException $e) {
825
+				} catch (PDOException $e) {
826 826
 					echo "error : ".$e->getMessage();
827 827
 					return false;
828 828
 				}
@@ -848,10 +848,10 @@  discard block
 block discarded – undo
848 848
      * @param string $decode
849 849
      * @return string
850 850
      */
851
-	public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') {
851
+	public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') {
852 852
 		global $globalDebug;
853 853
 		date_default_timezone_set('UTC');
854
-		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) {
854
+		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) {
855 855
 			/*
856 856
 				    if ($globalDebug) echo "Test if not already in Archive ACARS table...";
857 857
 			    	    $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message";
@@ -866,11 +866,11 @@  discard block
 block discarded – undo
866 866
 			*/
867 867
 			if ($globalDebug) echo "Add Live ACARS data...";
868 868
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
869
-			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
869
+			$query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
870 870
 			try {
871 871
 				$sth = $this->db->prepare($query);
872 872
 				$sth->execute($query_values);
873
-			} catch(PDOException $e) {
873
+			} catch (PDOException $e) {
874 874
 				return "error : ".$e->getMessage();
875 875
 			}
876 876
 			if ($globalDebug) echo "Done\n";
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 		try {
893 893
 			$sth = $this->db->prepare($query);
894 894
 			$sth->execute($query_values);
895
-		} catch(PDOException $e) {
895
+		} catch (PDOException $e) {
896 896
 			echo "error : ".$e->getMessage();
897 897
 			return '';
898 898
 		}
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 		try {
913 913
 			$sth = $this->db->prepare($query);
914 914
 			$sth->execute($query_values);
915
-		} catch(PDOException $e) {
915
+		} catch (PDOException $e) {
916 916
 			echo "error : ".$e->getMessage();
917 917
 			return array();
918 918
 		}
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
 		try {
934 934
 			$sth = $this->db->prepare($query);
935 935
 			$sth->execute($query_values);
936
-		} catch(PDOException $e) {
936
+		} catch (PDOException $e) {
937 937
 			echo "error : ".$e->getMessage();
938 938
 			return array();
939 939
 		}
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
      * @param string $label
950 950
      * @return array Return ACARS data in array
951 951
      */
952
-	public function getLatestAcarsData($limit = '',$label = '') {
952
+	public function getLatestAcarsData($limit = '', $label = '') {
953 953
 		global $globalURL;
954 954
 		$Image = new Image($this->db);
955 955
 		$Spotter = new Spotter($this->db);
@@ -960,8 +960,8 @@  discard block
 block discarded – undo
960 960
 		if ($limit != "")
961 961
 		{
962 962
 			$limit_array = explode(",", $limit);
963
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
964
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
963
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
964
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
965 965
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
966 966
 			{
967 967
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -977,7 +977,7 @@  discard block
 block discarded – undo
977 977
 		try {
978 978
 			$sth = $this->db->prepare($query);
979 979
 			$sth->execute($query_values);
980
-		} catch(PDOException $e) {
980
+		} catch (PDOException $e) {
981 981
 			echo "error : ".$e->getMessage();
982 982
 			return array();
983 983
 		}
@@ -985,39 +985,39 @@  discard block
 block discarded – undo
985 985
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
986 986
 			$data = array();
987 987
 			if ($row['registration'] != '') {
988
-				$row['registration'] = str_replace('.','',$row['registration']);
988
+				$row['registration'] = str_replace('.', '', $row['registration']);
989 989
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				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']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
990
+				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']));
991
+				else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
992
+			} else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
993 993
 			if ($row['registration'] == '') $row['registration'] = 'NA';
994 994
 			if ($row['ident'] == '') $row['ident'] = 'NA';
995
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
995
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
996 996
 			if (isset($identicao[0])) {
997
-				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1001
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
997
+				if (substr($row['ident'], 0, 2) == 'AF') {
998
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1000
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1001
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1002 1002
 			} else $icao = $row['ident'];
1003
-			$icao = $Translation->checkTranslation($icao,false);
1004
-			$decode = json_decode($row['decode'],true);
1003
+			$icao = $Translation->checkTranslation($icao, false);
1004
+			$decode = json_decode($row['decode'], true);
1005 1005
 			$found = false;
1006
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1006
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1007 1007
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1008 1008
 				if (isset($airport_info[0]['icao'])) {
1009 1009
 					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1010 1010
 					$found = true;
1011 1011
 				}
1012 1012
 			}
1013
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1013
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1014 1014
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1015 1015
 				if (isset($airport_info[0]['icao'])) {
1016 1016
 					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1017 1017
 					$found = true;
1018 1018
 				}
1019 1019
 			}
1020
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1020
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1021 1021
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1022 1022
 				if (isset($airport_info[0]['icao'])) {
1023 1023
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
 				}
1026 1026
 			}
1027 1027
 			if ($found) $row['decode'] = json_encode($decode);
1028
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1028
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1029 1029
 			$result[] = $data;
1030 1030
 			$i++;
1031 1031
 		}
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
      * @param string $label
1044 1044
      * @return array Return ACARS data in array
1045 1045
      */
1046
-	public function getArchiveAcarsData($limit = '',$label = '') {
1046
+	public function getArchiveAcarsData($limit = '', $label = '') {
1047 1047
 		global $globalURL;
1048 1048
 		$Image = new Image($this->db);
1049 1049
 		$Spotter = new Spotter($this->db);
@@ -1053,8 +1053,8 @@  discard block
 block discarded – undo
1053 1053
 		if ($limit != "")
1054 1054
 		{
1055 1055
 			$limit_array = explode(",", $limit);
1056
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
1057
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
1056
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
1057
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
1058 1058
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
1059 1059
 			{
1060 1060
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -1075,45 +1075,45 @@  discard block
 block discarded – undo
1075 1075
 		try {
1076 1076
 			$sth = $this->db->prepare($query);
1077 1077
 			$sth->execute($query_values);
1078
-		} catch(PDOException $e) {
1078
+		} catch (PDOException $e) {
1079 1079
 			echo "error : ".$e->getMessage();
1080 1080
 			return array();
1081 1081
 		}
1082
-		$i=0;
1082
+		$i = 0;
1083 1083
 		$result = array();
1084 1084
 		while ($row = $sth->fetch(PDO::FETCH_ASSOC)) {
1085 1085
 			$data = array();
1086 1086
 			if ($row['registration'] != '') {
1087
-				$row['registration'] = str_replace('.','',$row['registration']);
1087
+				$row['registration'] = str_replace('.', '', $row['registration']);
1088 1088
 				$image_array = $Image->getSpotterImage($row['registration']);
1089
-				if (count($image_array) > 0) $data = array_merge($data,array('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']));
1090
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1091
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1089
+				if (count($image_array) > 0) $data = array_merge($data, array('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']));
1090
+				else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1091
+			} else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => ''));
1092 1092
 			$icao = '';
1093 1093
 			if ($row['registration'] == '') $row['registration'] = 'NA';
1094 1094
 			if ($row['ident'] == '') $row['ident'] = 'NA';
1095
-			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1095
+			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2));
1096 1096
 			if (isset($identicao[0])) {
1097
-				if (substr($row['ident'],0,2) == 'AF') {
1098
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1100
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1101
-				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1097
+				if (substr($row['ident'], 0, 2) == 'AF') {
1098
+					if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
+					else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0');
1100
+				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0');
1101
+				$data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name']));
1102 1102
 			} else $icao = $row['ident'];
1103 1103
 			$icao = $Translation->checkTranslation($icao);
1104
-			$decode = json_decode($row['decode'],true);
1104
+			$decode = json_decode($row['decode'], true);
1105 1105
 			$found = false;
1106
-			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1106
+			if ($decode != '' && array_key_exists('Departure airport', $decode)) {
1107 1107
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1108 1108
 				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1109 1109
 				$found = true;
1110 1110
 			}
1111
-			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1111
+			if ($decode != '' && array_key_exists('Arrival airport', $decode)) {
1112 1112
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1113 1113
 				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1114 1114
 				$found = true;
1115 1115
 			}
1116
-			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
1116
+			if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) {
1117 1117
 				$airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']);
1118 1118
 				if (isset($airport_info[0]['icao'])) {
1119 1119
 					$decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 				}
1122 1122
 			}
1123 1123
 			if ($found) $row['decode'] = json_encode($decode);
1124
-			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1124
+			$data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1125 1125
 			$result[] = $data;
1126 1126
 			$i++;
1127 1127
 		}
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
      * @param string $longitude
1143 1143
      * @return string
1144 1144
      */
1145
-	public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') {
1145
+	public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') {
1146 1146
 		global $globalDebug, $globalDBdriver;
1147 1147
 		$ident = trim($ident);
1148 1148
 		$Translation = new Translation($this->db);
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
 			if ($globalDebug) echo "Ident or registration null, exit\n";
1156 1156
 			return '';
1157 1157
 		}
1158
-		$registration = str_replace('.','',$registration);
1158
+		$registration = str_replace('.', '', $registration);
1159 1159
 		$ident = $Translation->ident2icao($ident);
1160 1160
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1161 1161
 		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 		try {
1165 1165
 			$sthsi = $this->db->prepare($querysi);
1166 1166
 			$sthsi->execute($querysi_values);
1167
-		} catch(PDOException $e) {
1167
+		} catch (PDOException $e) {
1168 1168
 			if ($globalDebug) echo $e->getMessage();
1169 1169
 			return "error : ".$e->getMessage();
1170 1170
 		}
@@ -1174,8 +1174,8 @@  discard block
 block discarded – undo
1174 1174
 			$Translation = new Translation($this->db);
1175 1175
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1176 1176
 			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1177
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1178
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1177
+			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS');
1178
+			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS');
1179 1179
 		} else {
1180 1180
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1181 1181
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
 				try {
1184 1184
 					$sth = $this->db->prepare($query);
1185 1185
 					$sth->execute($query_values);
1186
-				} catch(PDOException $e) {
1186
+				} catch (PDOException $e) {
1187 1187
 					if ($globalDebug) echo $e->getMessage();
1188 1188
 					return "error : ".$e->getMessage();
1189 1189
 				}
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 				$sth->closeCursor();
1192 1192
 				if (isset($result['modes'])) $hex = $result['modes'];
1193 1193
 				else $hex = '';
1194
-				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1194
+				$SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS');
1195 1195
 				if ($this->fromACARSscript) $this->SI->add($SI_data);
1196 1196
 			}
1197 1197
 		}
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 		try {
1202 1202
 			$sth = $this->db->prepare($query);
1203 1203
 			$sth->execute($query_values);
1204
-		} catch(PDOException $e) {
1204
+		} catch (PDOException $e) {
1205 1205
 			if ($globalDebug) echo $e->getMessage();
1206 1206
 			return "error : ".$e->getMessage();
1207 1207
 		}
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1212 1212
 			else $ModeS = '';
1213 1213
 			if ($ModeS == '') {
1214
-				$id = explode('-',$result['flightaware_id']);
1214
+				$id = explode('-', $result['flightaware_id']);
1215 1215
 				$ModeS = $id[0];
1216 1216
 			}
1217 1217
 			if ($ModeS != '') {
@@ -1221,20 +1221,20 @@  discard block
 block discarded – undo
1221 1221
 				try {
1222 1222
 					$sthc = $this->db->prepare($queryc);
1223 1223
 					$sthc->execute($queryc_values);
1224
-				} catch(PDOException $e) {
1224
+				} catch (PDOException $e) {
1225 1225
 					if ($globalDebug) echo $e->getMessage();
1226 1226
 					return "error : ".$e->getMessage();
1227 1227
 				}
1228 1228
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1229 1229
 				$sthc->closeCursor();
1230
-				if (count($row) ==  0) {
1230
+				if (count($row) == 0) {
1231 1231
 					if ($globalDebug) echo " Add to ModeS table - ";
1232 1232
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1233
-					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1233
+					$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1234 1234
 					try {
1235 1235
 						$sthi = $this->db->prepare($queryi);
1236 1236
 						$sthi->execute($queryi_values);
1237
-					} catch(PDOException $e) {
1237
+					} catch (PDOException $e) {
1238 1238
 						if ($globalDebug) echo $e->getMessage();
1239 1239
 						return "error : ".$e->getMessage();
1240 1240
 					}
@@ -1242,15 +1242,15 @@  discard block
 block discarded – undo
1242 1242
 					if ($globalDebug) echo " Update ModeS table - ";
1243 1243
 					if ($ICAOTypeCode != '') {
1244 1244
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1245
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1245
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1246 1246
 					} else {
1247 1247
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1248
-						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration);
1248
+						$queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration);
1249 1249
 					}
1250 1250
 					try {
1251 1251
 						$sthi = $this->db->prepare($queryi);
1252 1252
 						$sthi->execute($queryi_values);
1253
-					} catch(PDOException $e) {
1253
+					} catch (PDOException $e) {
1254 1254
 						if ($globalDebug) echo $e->getMessage();
1255 1255
 						return "error : ".$e->getMessage();
1256 1256
 					}
@@ -1287,12 +1287,12 @@  discard block
 block discarded – undo
1287 1287
 					elseif ($globalDBdriver == 'pgsql') {
1288 1288
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1289 1289
 					}
1290
-					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
1290
+					$queryi_values = array(':Registration' => $registration, ':ident' => $icao);
1291 1291
 				}
1292 1292
 				try {
1293 1293
 					$sthi = $this->db->prepare($queryi);
1294 1294
 					$sthi->execute($queryi_values);
1295
-				} catch(PDOException $e) {
1295
+				} catch (PDOException $e) {
1296 1296
 					if ($globalDebug) echo $e->getMessage();
1297 1297
 					return "error : ".$e->getMessage();
1298 1298
 				}
Please login to merge, or discard this patch.
Braces   +415 added lines, -263 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@  discard block
 block discarded – undo
24 24
 	public function __construct($dbc = null,$fromACARSscript = false) {
25 25
 		$Connection = new Connection($dbc);
26 26
 		$this->db = $Connection->db();
27
-		if ($this->db === null) die('Error: No DB connection. (ACARS)');
27
+		if ($this->db === null) {
28
+			die('Error: No DB connection. (ACARS)');
29
+		}
28 30
 		if ($fromACARSscript) {
29 31
 			$this->fromACARSscript = true;
30 32
 			$this->SI = new SpotterImport($this->db);
@@ -39,14 +41,19 @@  discard block
 block discarded – undo
39 41
 	*/
40 42
 	public function ident2icao($ident) {
41 43
 		if (substr($ident,0,2) == 'AF') {
42
-			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
43
-			else $icao = 'AFR'.ltrim(substr($ident,2),'0');
44
+			if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
45
+				$icao = $ident;
46
+			} else {
47
+				$icao = 'AFR'.ltrim(substr($ident,2),'0');
48
+			}
44 49
 		} else {
45 50
 			$Spotter = new Spotter($this->db);
46 51
 			$identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2));
47 52
 			if (isset($identicao[0])) {
48 53
 				$icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
49
-			} else $icao = $ident;
54
+			} else {
55
+				$icao = $ident;
56
+			}
50 57
 		}
51 58
 		return $icao;
52 59
 	}
@@ -120,14 +127,24 @@  discard block
 block discarded – undo
120 127
 		$message = '';
121 128
 		$result = array();
122 129
 		$n = sscanf($data,'%*[0-9a-z.] %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
123
-		if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
124
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
125
-		if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
130
+		if ($n == 0) {
131
+			$n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
132
+		}
133
+		if ($n == 0) {
134
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
135
+		}
136
+		if ($n == 0) {
137
+			$n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message);
138
+		}
126 139
 		if ($n != 0 && ($registration != '' || $ident != '' || $label != '' || $block_id != '' || $msg_no != '')) {
127 140
 			$registration = str_replace('.','',$registration);
128 141
 			$result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message);
129
-			if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
130
-		} else $message = $data;
142
+			if ($globalDebug) {
143
+				echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n";
144
+			}
145
+		} else {
146
+			$message = $data;
147
+		}
131 148
 		$decode = array();
132 149
 		$found = false;
133 150
 //		if ($registration != '' && $ident != '' && $registration != '!') {
@@ -147,12 +164,21 @@  discard block
 block discarded – undo
147 164
 				if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) {
148 165
 					$latitude = $la / 10000.0;
149 166
 					$longitude = $ln / 10000.0;
150
-					if ($lac == 'S') $latitude = '-'.$latitude;
151
-					if ($lnc == 'W') $longitude = '-'.$longitude;
167
+					if ($lac == 'S') {
168
+						$latitude = '-'.$latitude;
169
+					}
170
+					if ($lnc == 'W') {
171
+						$longitude = '-'.$longitude;
172
+					}
152 173
 					// Temp not always available
153
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
154
-					if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
155
-					else $decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
174
+					if ($globalDebug) {
175
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n";
176
+					}
177
+					if ($temp == '') {
178
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt);
179
+					} else {
180
+						$decode = array('Latitude' => $latitude, 'Longitude' =>  $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C');
181
+					}
156 182
 
157 183
 					//$icao = $Translation->checkTranslation($ident);
158 184
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -166,25 +192,35 @@  discard block
 block discarded – undo
166 192
 				$ahour = '';
167 193
 				$n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour);
168 194
 				if ($n == 4 && strlen($darr) == 4) {
169
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
170
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
171
-					if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
195
+					if ($dhour != '') {
196
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
197
+					}
198
+					if ($ahour != '') {
199
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
200
+					}
201
+					if ($globalDebug) {
202
+						echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n";
203
+					}
172 204
 					//$icao = ACARS->ident2icao($ident);
173 205
 					//$icao = $Translation->checkTranslation($ident);
174 206
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
175 207
 					$decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour);
176 208
 					$found = true;
177
-				}
178
-				elseif ($n == 2 || $n  == 4) {
179
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
180
-					if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
209
+				} elseif ($n == 2 || $n  == 4) {
210
+					if ($dhour != '') {
211
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
212
+					}
213
+					if ($globalDebug) {
214
+						echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n";
215
+					}
181 216
 					//$icao = ACARS->ident2icao($ident);
182 217
 					//$icao = $Translation->checkTranslation($ident);
183 218
 					$decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour);
184 219
 					$found = true;
185
-				}
186
-				elseif ($n == 1) {
187
-					if ($globalDebug) echo 'airport arrival : '.$darr."\n";
220
+				} elseif ($n == 1) {
221
+					if ($globalDebug) {
222
+						echo 'airport arrival : '.$darr."\n";
223
+					}
188 224
 					//$icao = ACARS->ident2icao($ident);
189 225
 					//$icao = $Translation->checkTranslation($ident);
190 226
 					$decode = array('Arrival airport' => $darr);
@@ -202,7 +238,9 @@  discard block
 block discarded – undo
202 238
 				$darr = '';
203 239
 				$n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr);
204 240
 				if ($n == 4) {
205
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
241
+					if ($globalDebug) {
242
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
243
+					}
206 244
 					//$icao = ACARS->ident2icao($ident);
207 245
 					//$icao = $Translation->checkTranslation($ident);
208 246
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -236,14 +274,23 @@  discard block
 block discarded – undo
236 274
 				$apiste = '';
237 275
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste);
238 276
 				if ($n > 8) {
239
-					if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
240
-					if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
241
-					if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
277
+					if ($globalDebug) {
278
+						echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n";
279
+					}
280
+					if ($dhour != '') {
281
+						$dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2);
282
+					}
283
+					if ($ahour != '') {
284
+						$ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2);
285
+					}
242 286
 					$icao = trim($aident);
243 287
 
244 288
 					//$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste;
245
-					if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
246
-					else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
289
+					if ($ahour == '') {
290
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr);
291
+					} else {
292
+						$decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste);
293
+					}
247 294
 					//$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS');
248 295
 					$decode['icao'] = $icao;
249 296
 					$found = true;
@@ -265,9 +312,15 @@  discard block
 block discarded – undo
265 312
 					$lns = $lns.'.'.$lns;
266 313
 					$latitude = $las / 1000.0;
267 314
 					$longitude = $lns / 1000.0;
268
-					if ($lac == 'S') $latitude = '-'.$latitude;
269
-					if ($lnc == 'W') $longitude = '-'.$longitude;
270
-					if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
315
+					if ($lac == 'S') {
316
+						$latitude = '-'.$latitude;
317
+					}
318
+					if ($lnc == 'W') {
319
+						$longitude = '-'.$longitude;
320
+					}
321
+					if ($globalDebug) {
322
+						echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n";
323
+					}
271 324
 					$decode = array('Latitude' => $latitude, 'Longitude' => $longitude);
272 325
 					$found = true;
273 326
 				}
@@ -285,7 +338,9 @@  discard block
 block discarded – undo
285 338
 				$darr = '';
286 339
 				$n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr);
287 340
 				if ($n == 4) {
288
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
341
+					if ($globalDebug) {
342
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
343
+					}
289 344
 					//$icao = $Translation->checkTranslation($ident);
290 345
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
291 346
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -298,7 +353,9 @@  discard block
 block discarded – undo
298 353
 				$darr = '';
299 354
 				$n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr);
300 355
 				if ($n == 4) {
301
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
356
+					if ($globalDebug) {
357
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
358
+					}
302 359
 					//$icao = $Translation->checkTranslation($ident);
303 360
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
304 361
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -311,7 +368,9 @@  discard block
 block discarded – undo
311 368
 				$darr = '';
312 369
 				$n = sscanf($message, "002AF %4c %4c ", $dair, $darr);
313 370
 				if ($n == 2) {
314
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
371
+					if ($globalDebug) {
372
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
373
+					}
315 374
 					//$icao = $Translation->checkTranslation($ident);
316 375
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
317 376
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
@@ -325,7 +384,9 @@  discard block
 block discarded – undo
325 384
 				$darr = '';
326 385
 				$n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
327 386
 				if ($n == 6) {
328
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
387
+					if ($globalDebug) {
388
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
389
+					}
329 390
 					//$icao = $Translation->checkTranslation($ident);
330 391
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
331 392
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -338,7 +399,9 @@  discard block
 block discarded – undo
338 399
 				$darr = '';
339 400
 				$n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr);
340 401
 				if ($n == 7) {
341
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
402
+					if ($globalDebug) {
403
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
404
+					}
342 405
 					//$icao = $Translation->checkTranslation($ident);
343 406
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
344 407
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -366,8 +429,12 @@  discard block
 block discarded – undo
366 429
 					$decode['icao'] = $icao;
367 430
 					$latitude = $las / 100.0;
368 431
 					$longitude = $lns / 100.0;
369
-					if ($lac == 'S') $latitude = '-'.$latitude;
370
-					if ($lnc == 'W') $longitude = '-'.$longitude;
432
+					if ($lac == 'S') {
433
+						$latitude = '-'.$latitude;
434
+					}
435
+					if ($lnc == 'W') {
436
+						$longitude = '-'.$longitude;
437
+					}
371 438
 
372 439
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed);
373 440
 					$found = true;
@@ -385,8 +452,12 @@  discard block
 block discarded – undo
385 452
 				if ($n == 4) {
386 453
 					$latitude = $las;
387 454
 					$longitude = $lns;
388
-					if ($lac == 'S') $latitude = '-'.$latitude;
389
-					if ($lnc == 'W') $longitude = '-'.$longitude;
455
+					if ($lac == 'S') {
456
+						$latitude = '-'.$latitude;
457
+					}
458
+					if ($lnc == 'W') {
459
+						$longitude = '-'.$longitude;
460
+					}
390 461
 
391 462
 					$decode = array('Latitude' => $latitude,'Longitude' => $longitude);
392 463
 					$found = true;
@@ -402,7 +473,9 @@  discard block
 block discarded – undo
402 473
 				$darr = '';
403 474
 				$n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr);
404 475
 				if ($n == 5) {
405
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
476
+					if ($globalDebug) {
477
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
478
+					}
406 479
 					//$icao = $Translation->checkTranslation($ident);
407 480
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
408 481
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -423,7 +496,9 @@  discard block
 block discarded – undo
423 496
 				$aident = '';
424 497
 				$n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident);
425 498
 				if ($n == 8) {
426
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
499
+					if ($globalDebug) {
500
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
501
+					}
427 502
 					$icao = trim($aident);
428 503
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
429 504
 					$decode['icao'] = $icao;
@@ -440,7 +515,9 @@  discard block
 block discarded – undo
440 515
 				$darr = '';
441 516
 				$n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr);
442 517
 				if ($n == 5) {
443
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
518
+					if ($globalDebug) {
519
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
520
+					}
444 521
 					//$icao = $Translation->checkTranslation($ident);
445 522
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
446 523
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -455,7 +532,9 @@  discard block
 block discarded – undo
455 532
 				$darr = '';
456 533
 				$n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr);
457 534
 				if ($n == 3) {
458
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
535
+					if ($globalDebug) {
536
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
537
+					}
459 538
 					//$icao = $Translation->checkTranslation($ident);
460 539
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
461 540
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -470,7 +549,9 @@  discard block
 block discarded – undo
470 549
 				$darr = '';
471 550
 				$n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr);
472 551
 				if ($n == 3) {
473
-					if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
552
+					if ($globalDebug) {
553
+						echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n";
554
+					}
474 555
 					//$icao = $Translation->checkTranslation($ident);
475 556
 					//$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS');
476 557
 					$decode = array('Departure airport' => $dair, 'Arrival airport' => $darr);
@@ -480,7 +561,9 @@  discard block
 block discarded – undo
480 561
 			if (!$found) {
481 562
 				$n = sscanf($message,'MET01%4c',$airport);
482 563
 				if ($n == 1) {
483
-					if ($globalDebug) echo 'airport name : '.$airport;
564
+					if ($globalDebug) {
565
+						echo 'airport name : '.$airport;
566
+					}
484 567
 					$decode = array('Airport/Waypoint name' => $airport);
485 568
 					$found = true;
486 569
 				}
@@ -488,184 +571,126 @@  discard block
 block discarded – undo
488 571
 			if ($label == 'H1') {
489 572
 				if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) {
490 573
 					$decode = array_merge(array('Message nature' => 'Equipment failure'),$decode);
491
-				}
492
-				elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
574
+				} elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) {
493 575
 					$decode = array_merge(array('Message nature' => 'Take off performance data'),$decode);
494
-				}
495
-				elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
576
+				} elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) {
496 577
 					$decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode);
497
-				}
498
-				elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
578
+				} elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) {
499 579
 					$decode = array_merge(array('Message nature' => 'Weather observation'),$decode);
500
-				}
501
-				elseif (preg_match(':^#DFB/PIREP:',$message)) {
580
+				} elseif (preg_match(':^#DFB/PIREP:',$message)) {
502 581
 					$decode = array_merge(array('Message nature' => 'Pilot Report'),$decode);
503
-				}
504
-				elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
582
+				} elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) {
505 583
 					$decode = array_merge(array('Message nature' => 'Engine Data'),$decode);
506
-				}
507
-				elseif (preg_match(':^#M1AAEP:',$message)) {
584
+				} elseif (preg_match(':^#M1AAEP:',$message)) {
508 585
 					$decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode);
509
-				}
510
-				elseif (preg_match(':^#M2APWD:',$message)) {
586
+				} elseif (preg_match(':^#M2APWD:',$message)) {
511 587
 					$decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode);
512
-				}
513
-				elseif (preg_match(':^#M1BREQPWI:',$message)) {
588
+				} elseif (preg_match(':^#M1BREQPWI:',$message)) {
514 589
 					$decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode);
515
-				}
516
-				elseif (preg_match(':^#CF:',$message)) {
590
+				} elseif (preg_match(':^#CF:',$message)) {
517 591
 					$decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode);
518
-				}
519
-				elseif (preg_match(':^#DF:',$message)) {
592
+				} elseif (preg_match(':^#DF:',$message)) {
520 593
 					$decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode);
521
-				}
522
-				elseif (preg_match(':^#EC:',$message)) {
594
+				} elseif (preg_match(':^#EC:',$message)) {
523 595
 					$decode = array_merge(array('Message nature' => 'Engine Display System'),$decode);
524
-				}
525
-				elseif (preg_match(':^#EI:',$message)) {
596
+				} elseif (preg_match(':^#EI:',$message)) {
526 597
 					$decode = array_merge(array('Message nature' => 'Engine Report'),$decode);
527
-				}
528
-				elseif (preg_match(':^#H1:',$message)) {
598
+				} elseif (preg_match(':^#H1:',$message)) {
529 599
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode);
530
-				}
531
-				elseif (preg_match(':^#H2:',$message)) {
600
+				} elseif (preg_match(':^#H2:',$message)) {
532 601
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode);
533
-				}
534
-				elseif (preg_match(':^#HD:',$message)) {
602
+				} elseif (preg_match(':^#HD:',$message)) {
535 603
 					$decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode);
536
-				}
537
-				elseif (preg_match(':^#M1:',$message)) {
604
+				} elseif (preg_match(':^#M1:',$message)) {
538 605
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode);
539
-				}
540
-				elseif (preg_match(':^#M2:',$message)) {
606
+				} elseif (preg_match(':^#M2:',$message)) {
541 607
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode);
542
-				}
543
-				elseif (preg_match(':^#M3:',$message)) {
608
+				} elseif (preg_match(':^#M3:',$message)) {
544 609
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode);
545
-				}
546
-				elseif (preg_match(':^#MD:',$message)) {
610
+				} elseif (preg_match(':^#MD:',$message)) {
547 611
 					$decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode);
548
-				}
549
-				elseif (preg_match(':^#PS:',$message)) {
612
+				} elseif (preg_match(':^#PS:',$message)) {
550 613
 					$decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode);
551
-				}
552
-				elseif (preg_match(':^#S1:',$message)) {
614
+				} elseif (preg_match(':^#S1:',$message)) {
553 615
 					$decode = array_merge(array('Message nature' => 'SDU - Left'),$decode);
554
-				}
555
-				elseif (preg_match(':^#S2:',$message)) {
616
+				} elseif (preg_match(':^#S2:',$message)) {
556 617
 					$decode = array_merge(array('Message nature' => 'SDU - Right'),$decode);
557
-				}
558
-				elseif (preg_match(':^#SD:',$message)) {
618
+				} elseif (preg_match(':^#SD:',$message)) {
559 619
 					$decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode);
560
-				}
561
-				elseif (preg_match(':^#T[0-8]:',$message)) {
620
+				} elseif (preg_match(':^#T[0-8]:',$message)) {
562 621
 					$decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode);
563
-				}
564
-				elseif (preg_match(':^#WO:',$message)) {
622
+				} elseif (preg_match(':^#WO:',$message)) {
565 623
 					$decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode);
566
-				}
567
-				elseif (preg_match(':^#A1:',$message)) {
624
+				} elseif (preg_match(':^#A1:',$message)) {
568 625
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode);
569
-				}
570
-				elseif (preg_match(':^#A3:',$message)) {
626
+				} elseif (preg_match(':^#A3:',$message)) {
571 627
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode);
572
-				}
573
-				elseif (preg_match(':^#A4:',$message)) {
628
+				} elseif (preg_match(':^#A4:',$message)) {
574 629
 					$decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode);
575
-				}
576
-				elseif (preg_match(':^#A6:',$message)) {
630
+				} elseif (preg_match(':^#A6:',$message)) {
577 631
 					$decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode);
578
-				}
579
-				elseif (preg_match(':^#A8:',$message)) {
632
+				} elseif (preg_match(':^#A8:',$message)) {
580 633
 					$decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode);
581
-				}
582
-				elseif (preg_match(':^#A9:',$message)) {
634
+				} elseif (preg_match(':^#A9:',$message)) {
583 635
 					$decode = array_merge(array('Message nature' => 'ATIS report'),$decode);
584
-				}
585
-				elseif (preg_match(':^#A0:',$message)) {
636
+				} elseif (preg_match(':^#A0:',$message)) {
586 637
 					$decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode);
587
-				}
588
-				elseif (preg_match(':^#AA:',$message)) {
638
+				} elseif (preg_match(':^#AA:',$message)) {
589 639
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
590
-				}
591
-				elseif (preg_match(':^#AB:',$message)) {
640
+				} elseif (preg_match(':^#AB:',$message)) {
592 641
 					$decode = array_merge(array('Message nature' => 'TWIP Report'),$decode);
593
-				}
594
-				elseif (preg_match(':^#AC:',$message)) {
642
+				} elseif (preg_match(':^#AC:',$message)) {
595 643
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode);
596
-				}
597
-				elseif (preg_match(':^#AD:',$message)) {
644
+				} elseif (preg_match(':^#AD:',$message)) {
598 645
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode);
599
-				}
600
-				elseif (preg_match(':^#AF:',$message)) {
646
+				} elseif (preg_match(':^#AF:',$message)) {
601 647
 					$decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode);
602
-				}
603
-				elseif (preg_match(':^#B1:',$message)) {
648
+				} elseif (preg_match(':^#B1:',$message)) {
604 649
 					$decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode);
605
-				}
606
-				elseif (preg_match(':^#B2:',$message)) {
650
+				} elseif (preg_match(':^#B2:',$message)) {
607 651
 					$decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode);
608
-				}
609
-				elseif (preg_match(':^#B3:',$message)) {
652
+				} elseif (preg_match(':^#B3:',$message)) {
610 653
 					$decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode);
611
-				}
612
-				elseif (preg_match(':^#B4:',$message)) {
654
+				} elseif (preg_match(':^#B4:',$message)) {
613 655
 					$decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode);
614
-				}
615
-				elseif (preg_match(':^#B6:',$message)) {
656
+				} elseif (preg_match(':^#B6:',$message)) {
616 657
 					$decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode);
617
-				}
618
-				elseif (preg_match(':^#B8:',$message)) {
658
+				} elseif (preg_match(':^#B8:',$message)) {
619 659
 					$decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode);
620
-				}
621
-				elseif (preg_match(':^#B9:',$message)) {
660
+				} elseif (preg_match(':^#B9:',$message)) {
622 661
 					$decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode);
623
-				}
624
-				elseif (preg_match(':^#B0:',$message)) {
662
+				} elseif (preg_match(':^#B0:',$message)) {
625 663
 					$decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode);
626
-				}
627
-				elseif (preg_match(':^#BA:',$message)) {
664
+				} elseif (preg_match(':^#BA:',$message)) {
628 665
 					$decode = array_merge(array('Message nature' => 'ATCComm'),$decode);
629
-				}
630
-				elseif (preg_match(':^#BB:',$message)) {
666
+				} elseif (preg_match(':^#BB:',$message)) {
631 667
 					$decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode);
632
-				}
633
-				elseif (preg_match(':^#BC:',$message)) {
668
+				} elseif (preg_match(':^#BC:',$message)) {
634 669
 					$decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode);
635
-				}
636
-				elseif (preg_match(':^#BD:',$message)) {
670
+				} elseif (preg_match(':^#BD:',$message)) {
637 671
 					$decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode);
638
-				}
639
-				elseif (preg_match(':^#BE:',$message)) {
672
+				} elseif (preg_match(':^#BE:',$message)) {
640 673
 					$decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode);
641
-				}
642
-				elseif (preg_match(':^#BF:',$message)) {
674
+				} elseif (preg_match(':^#BF:',$message)) {
643 675
 					$decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode);
644
-				}
645
-				elseif (preg_match(':^#H3:',$message)) {
676
+				} elseif (preg_match(':^#H3:',$message)) {
646 677
 					$decode = array_merge(array('Message nature' => 'Icing Report'),$decode);
647 678
 				}
648 679
 			}
649 680
 			if ($label == '10') {
650 681
 				if (preg_match(':^DTO01:',$message)) {
651 682
 					$decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode);
652
-				}
653
-				elseif (preg_match(':^AIS01:',$message)) {
683
+				} elseif (preg_match(':^AIS01:',$message)) {
654 684
 					$decode = array_merge(array('Message nature' => 'AIS Request'),$decode);
655
-				}
656
-				elseif (preg_match(':^FTX01:',$message)) {
685
+				} elseif (preg_match(':^FTX01:',$message)) {
657 686
 					$decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode);
658
-				}
659
-				elseif (preg_match(':^FPL01:',$message)) {
687
+				} elseif (preg_match(':^FPL01:',$message)) {
660 688
 					$decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode);
661
-				}
662
-				elseif (preg_match(':^WAB01:',$message)) {
689
+				} elseif (preg_match(':^WAB01:',$message)) {
663 690
 					$decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode);
664
-				}
665
-				elseif (preg_match(':^MET01:',$message)) {
691
+				} elseif (preg_match(':^MET01:',$message)) {
666 692
 					$decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode);
667
-				}
668
-				elseif (preg_match(':^WAB02:',$message)) {
693
+				} elseif (preg_match(':^WAB02:',$message)) {
669 694
 					$decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode);
670 695
 				}
671 696
 			}
@@ -680,38 +705,28 @@  discard block
 block discarded – undo
680 705
 					$vsta = array('Version' => $version);
681 706
 					if ($state == 'E') {
682 707
 						$vsta = array_merge($vsta,array('Link state' => 'Established'));
683
-					}
684
-					elseif ($state == 'L') {
708
+					} elseif ($state == 'L') {
685 709
 						$vsta = array_merge($vsta,array('Link state' => 'Lost'));
686
-					}
687
-					else {
710
+					} else {
688 711
 						$vsta = array_merge($vsta,array('Link state' => 'Unknown'));
689 712
 					}
690 713
 					if ($type == 'V') {
691 714
 						$vsta = array_merge($vsta,array('Link type' => 'VHF ACARS'));
692
-					}
693
-					elseif ($type == 'S') {
715
+					} elseif ($type == 'S') {
694 716
 						$vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM'));
695
-					}
696
-					elseif ($type == 'H') {
717
+					} elseif ($type == 'H') {
697 718
 						$vsta = array_merge($vsta,array('Link type' => 'HF'));
698
-					}
699
-					elseif ($type == 'G') {
719
+					} elseif ($type == 'G') {
700 720
 						$vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM'));
701
-					}
702
-					elseif ($type == 'C') {
721
+					} elseif ($type == 'C') {
703 722
 						$vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM'));
704
-					}
705
-					elseif ($type == '2') {
723
+					} elseif ($type == '2') {
706 724
 						$vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2'));
707
-					}
708
-					elseif ($type == 'X') {
725
+					} elseif ($type == 'X') {
709 726
 						$vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero'));
710
-					}
711
-					elseif ($type == 'I') {
727
+					} elseif ($type == 'I') {
712 728
 						$vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM'));
713
-					}
714
-					else {
729
+					} else {
715 730
 						$vsta = array_merge($vsta,array('Link type' => 'Unknown'));
716 731
 					}
717 732
 					$vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2))));
@@ -720,7 +735,9 @@  discard block
 block discarded – undo
720 735
 			}
721 736
 
722 737
 			$title = $this->getTitlefromLabel($label);
723
-			if ($title != '') $decode = array_merge(array('Message title' => $title),$decode);
738
+			if ($title != '') {
739
+				$decode = array_merge(array('Message title' => $title),$decode);
740
+			}
724 741
 			/*
725 742
 			// Business jets always use GS0001
726 743
 			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
@@ -756,31 +773,54 @@  discard block
 block discarded – undo
756 773
 			$msg = $message['message'];
757 774
 			$decode = $message['decode'];
758 775
 			$registration = (string)$message['registration'];
759
-			if (isset($decode['latitude'])) $latitude = $decode['latitude'];
760
-			else $latitude = '';
761
-			if (isset($decode['longitude'])) $longitude = $decode['longitude'];
762
-			else $longitude = '';
763
-			if (isset($decode['airicao'])) $airicao = $decode['airicao'];
764
-			else $airicao = '';
765
-			if (isset($decode['icao'])) $icao = $decode['icao'];
766
-			else $icao = $Translation->checkTranslation($ident);
776
+			if (isset($decode['latitude'])) {
777
+				$latitude = $decode['latitude'];
778
+			} else {
779
+				$latitude = '';
780
+			}
781
+			if (isset($decode['longitude'])) {
782
+				$longitude = $decode['longitude'];
783
+			} else {
784
+				$longitude = '';
785
+			}
786
+			if (isset($decode['airicao'])) {
787
+				$airicao = $decode['airicao'];
788
+			} else {
789
+				$airicao = '';
790
+			}
791
+			if (isset($decode['icao'])) {
792
+				$icao = $decode['icao'];
793
+			} else {
794
+				$icao = $Translation->checkTranslation($ident);
795
+			}
767 796
 			$image_array = $Image->getSpotterImage($registration);
768 797
 			if (!isset($image_array[0]['registration'])) {
769 798
 				$Image->addSpotterImage($registration);
770 799
 			}
771 800
 			// Business jets always use GS0001
772
-			if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
773
-			if ($globalDebug && isset($info) && $info != '') echo $info;
774
-			if (count($decode) > 0) $decode_json = json_encode($decode);
775
-			else $decode_json = '';
801
+			if ($ident != 'GS0001') {
802
+				$info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude);
803
+			}
804
+			if ($globalDebug && isset($info) && $info != '') {
805
+				echo $info;
806
+			}
807
+			if (count($decode) > 0) {
808
+				$decode_json = json_encode($decode);
809
+			} else {
810
+				$decode_json = '';
811
+			}
776 812
 			if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) {
777 813
 				$Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS');
778 814
 			} elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) {
779 815
 				$Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS');
780 816
 			}
781 817
 			$result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
782
-			if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F');
783
-			if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
818
+			if (!isset($globalACARSArchive)) {
819
+				$globalACARSArchive = array('10','80','81','82','3F');
820
+			}
821
+			if ($result && in_array($label,$globalACARSArchive)) {
822
+				$this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json);
823
+			}
784 824
 			if ($globalDebug && count($decode) > 0) {
785 825
 				echo "Human readable data : ".implode(' - ',$decode)."\n";
786 826
 			}
@@ -805,7 +845,9 @@  discard block
 block discarded – undo
805 845
 		if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') {
806 846
 			$Connection = new Connection($this->db);
807 847
 			$this->db = $Connection->db;
808
-			if ($globalDebug) echo "Test if not already in Live ACARS table...";
848
+			if ($globalDebug) {
849
+				echo "Test if not already in Live ACARS table...";
850
+			}
809 851
 			$query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message";
810 852
 			$query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message);
811 853
 			try {
@@ -816,7 +858,9 @@  discard block
 block discarded – undo
816 858
 				return false;
817 859
 			}
818 860
 			if ($stht->fetchColumn() == 0) {
819
-				if ($globalDebug) echo "Add Live ACARS data...";
861
+				if ($globalDebug) {
862
+					echo "Add Live ACARS data...";
863
+				}
820 864
 				$query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)";
821 865
 				$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s"));
822 866
 				try {
@@ -827,10 +871,14 @@  discard block
 block discarded – undo
827 871
 					return false;
828 872
 				}
829 873
 			} else {
830
-				if ($globalDebug) echo "Data already in DB...\n";
874
+				if ($globalDebug) {
875
+					echo "Data already in DB...\n";
876
+				}
831 877
 				return false;
832 878
 			}
833
-			if ($globalDebug) echo "Done\n";
879
+			if ($globalDebug) {
880
+				echo "Done\n";
881
+			}
834 882
 			return true;
835 883
 		}
836 884
 		return false;
@@ -864,7 +912,9 @@  discard block
 block discarded – undo
864 912
 			    	    }
865 913
 				    if ($stht->fetchColumn() == 0) {
866 914
 			*/
867
-			if ($globalDebug) echo "Add Live ACARS data...";
915
+			if ($globalDebug) {
916
+				echo "Add Live ACARS data...";
917
+			}
868 918
 			$query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)";
869 919
 			$query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode);
870 920
 			try {
@@ -873,7 +923,9 @@  discard block
 block discarded – undo
873 923
 			} catch(PDOException $e) {
874 924
 				return "error : ".$e->getMessage();
875 925
 			}
876
-			if ($globalDebug) echo "Done\n";
926
+			if ($globalDebug) {
927
+				echo "Done\n";
928
+			}
877 929
 		}
878 930
 		return '';
879 931
 	}
@@ -897,8 +949,11 @@  discard block
 block discarded – undo
897 949
 			return '';
898 950
 		}
899 951
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
900
-		if (count($row) > 0) return $row[0]['title'];
901
-		else return '';
952
+		if (count($row) > 0) {
953
+			return $row[0]['title'];
954
+		} else {
955
+			return '';
956
+		}
902 957
 	}
903 958
 
904 959
 	/**
@@ -917,8 +972,11 @@  discard block
 block discarded – undo
917 972
 			return array();
918 973
 		}
919 974
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
920
-		if (count($row) > 0) return $row;
921
-		else return array();
975
+		if (count($row) > 0) {
976
+			return $row;
977
+		} else {
978
+			return array();
979
+		}
922 980
 	}
923 981
 
924 982
 	/**
@@ -938,8 +996,11 @@  discard block
 block discarded – undo
938 996
 			return array();
939 997
 		}
940 998
 		$row = $sth->fetchAll(PDO::FETCH_ASSOC);
941
-		if (count($row) > 0) return $row[0];
942
-		else return array();
999
+		if (count($row) > 0) {
1000
+			return $row[0];
1001
+		} else {
1002
+			return array();
1003
+		}
943 1004
 	}
944 1005
 
945 1006
     /**
@@ -987,19 +1048,35 @@  discard block
 block discarded – undo
987 1048
 			if ($row['registration'] != '') {
988 1049
 				$row['registration'] = str_replace('.','',$row['registration']);
989 1050
 				$image_array = $Image->getSpotterImage($row['registration']);
990
-				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']));
991
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
992
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
993
-			if ($row['registration'] == '') $row['registration'] = 'NA';
994
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1051
+				if (count($image_array) > 0) {
1052
+					$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']));
1053
+				} else {
1054
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1055
+				}
1056
+			} else {
1057
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1058
+			}
1059
+			if ($row['registration'] == '') {
1060
+				$row['registration'] = 'NA';
1061
+			}
1062
+			if ($row['ident'] == '') {
1063
+				$row['ident'] = 'NA';
1064
+			}
995 1065
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
996 1066
 			if (isset($identicao[0])) {
997 1067
 				if (substr($row['ident'],0,2) == 'AF') {
998
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
999
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1000
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1068
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1069
+						$icao = $row['ident'];
1070
+					} else {
1071
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1072
+					}
1073
+				} else {
1074
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1075
+				}
1001 1076
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1002
-			} else $icao = $row['ident'];
1077
+			} else {
1078
+				$icao = $row['ident'];
1079
+			}
1003 1080
 			$icao = $Translation->checkTranslation($icao,false);
1004 1081
 			$decode = json_decode($row['decode'],true);
1005 1082
 			$found = false;
@@ -1024,7 +1101,9 @@  discard block
 block discarded – undo
1024 1101
 					$found = true;
1025 1102
 				}
1026 1103
 			}
1027
-			if ($found) $row['decode'] = json_encode($decode);
1104
+			if ($found) {
1105
+				$row['decode'] = json_encode($decode);
1106
+			}
1028 1107
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1029 1108
 			$result[] = $data;
1030 1109
 			$i++;
@@ -1032,8 +1111,9 @@  discard block
 block discarded – undo
1032 1111
 		if (isset($result)) {
1033 1112
 			$result[0]['query_number_rows'] = $i;
1034 1113
 			return $result;
1114
+		} else {
1115
+			return array();
1035 1116
 		}
1036
-		else return array();
1037 1117
 	}
1038 1118
 
1039 1119
     /**
@@ -1086,31 +1166,51 @@  discard block
 block discarded – undo
1086 1166
 			if ($row['registration'] != '') {
1087 1167
 				$row['registration'] = str_replace('.','',$row['registration']);
1088 1168
 				$image_array = $Image->getSpotterImage($row['registration']);
1089
-				if (count($image_array) > 0) $data = array_merge($data,array('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']));
1090
-				else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1091
-			} else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1169
+				if (count($image_array) > 0) {
1170
+					$data = array_merge($data,array('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']));
1171
+				} else {
1172
+					$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1173
+				}
1174
+			} else {
1175
+				$data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
1176
+			}
1092 1177
 			$icao = '';
1093
-			if ($row['registration'] == '') $row['registration'] = 'NA';
1094
-			if ($row['ident'] == '') $row['ident'] = 'NA';
1178
+			if ($row['registration'] == '') {
1179
+				$row['registration'] = 'NA';
1180
+			}
1181
+			if ($row['ident'] == '') {
1182
+				$row['ident'] = 'NA';
1183
+			}
1095 1184
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2));
1096 1185
 			if (isset($identicao[0])) {
1097 1186
 				if (substr($row['ident'],0,2) == 'AF') {
1098
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
1099
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1100
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1187
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
1188
+						$icao = $row['ident'];
1189
+					} else {
1190
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
1191
+					}
1192
+				} else {
1193
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
1194
+				}
1101 1195
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
1102
-			} else $icao = $row['ident'];
1196
+			} else {
1197
+				$icao = $row['ident'];
1198
+			}
1103 1199
 			$icao = $Translation->checkTranslation($icao);
1104 1200
 			$decode = json_decode($row['decode'],true);
1105 1201
 			$found = false;
1106 1202
 			if ($decode != '' && array_key_exists('Departure airport',$decode)) {
1107 1203
 				$airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']);
1108
-				if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1204
+				if (isset($airport_info[0]['icao'])) {
1205
+					$decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1206
+				}
1109 1207
 				$found = true;
1110 1208
 			}
1111 1209
 			if ($decode != '' && array_key_exists('Arrival airport',$decode)) {
1112 1210
 				$airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']);
1113
-				if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1211
+				if (isset($airport_info[0]['icao'])) {
1212
+					$decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>';
1213
+				}
1114 1214
 				$found = true;
1115 1215
 			}
1116 1216
 			if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) {
@@ -1120,7 +1220,9 @@  discard block
 block discarded – undo
1120 1220
 					$found = true;
1121 1221
 				}
1122 1222
 			}
1123
-			if ($found) $row['decode'] = json_encode($decode);
1223
+			if ($found) {
1224
+				$row['decode'] = json_encode($decode);
1225
+			}
1124 1226
 			$data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode']));
1125 1227
 			$result[] = $data;
1126 1228
 			$i++;
@@ -1128,7 +1230,9 @@  discard block
 block discarded – undo
1128 1230
 		if (!empty($result)) {
1129 1231
 			$result[0]['query_number_rows'] = $i;
1130 1232
 			return $result;
1131
-		} else return array();
1233
+		} else {
1234
+			return array();
1235
+		}
1132 1236
 	}
1133 1237
 
1134 1238
     /**
@@ -1147,25 +1251,37 @@  discard block
 block discarded – undo
1147 1251
 		$ident = trim($ident);
1148 1252
 		$Translation = new Translation($this->db);
1149 1253
 		$Spotter = new Spotter($this->db);
1150
-		if ($globalDebug) echo "Test if we add ModeS data...";
1254
+		if ($globalDebug) {
1255
+			echo "Test if we add ModeS data...";
1256
+		}
1151 1257
 		//if ($icao == '') $icao = ACARS->ident2icao($ident);
1152
-		if ($icao == '') $icao = $Translation->checkTranslation($ident);
1153
-		if ($globalDebug) echo '- Ident : '.$icao.' - ';
1258
+		if ($icao == '') {
1259
+			$icao = $Translation->checkTranslation($ident);
1260
+		}
1261
+		if ($globalDebug) {
1262
+			echo '- Ident : '.$icao.' - ';
1263
+		}
1154 1264
 		if ($ident == '' || $registration == '') {
1155
-			if ($globalDebug) echo "Ident or registration null, exit\n";
1265
+			if ($globalDebug) {
1266
+				echo "Ident or registration null, exit\n";
1267
+			}
1156 1268
 			return '';
1157 1269
 		}
1158 1270
 		$registration = str_replace('.','',$registration);
1159 1271
 		$ident = $Translation->ident2icao($ident);
1160 1272
 		// Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation
1161
-		if ($globalDebug) echo "Check if needed to add translation ".$ident.'... ';
1273
+		if ($globalDebug) {
1274
+			echo "Check if needed to add translation ".$ident.'... ';
1275
+		}
1162 1276
 		$querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1";
1163 1277
 		$querysi_values = array(':registration' => $registration);
1164 1278
 		try {
1165 1279
 			$sthsi = $this->db->prepare($querysi);
1166 1280
 			$sthsi->execute($querysi_values);
1167 1281
 		} catch(PDOException $e) {
1168
-			if ($globalDebug) echo $e->getMessage();
1282
+			if ($globalDebug) {
1283
+				echo $e->getMessage();
1284
+			}
1169 1285
 			return "error : ".$e->getMessage();
1170 1286
 		}
1171 1287
 		$resultsi = $sthsi->fetch(PDO::FETCH_ASSOC);
@@ -1173,9 +1289,14 @@  discard block
 block discarded – undo
1173 1289
 		if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') {
1174 1290
 			$Translation = new Translation($this->db);
1175 1291
 			$trans_ident = $Translation->getOperator($resultsi['ident']);
1176
-			if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1177
-			if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1178
-			elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1292
+			if ($globalDebug) {
1293
+				echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' ';
1294
+			}
1295
+			if ($ident != $trans_ident) {
1296
+				$Translation->addOperator($resultsi['ident'],$ident,'ACARS');
1297
+			} elseif ($trans_ident == $ident) {
1298
+				$Translation->updateOperator($resultsi['ident'],$ident,'ACARS');
1299
+			}
1179 1300
 		} else {
1180 1301
 			if ($registration != '' && $latitude != '' && $longitude != '') {
1181 1302
 				$query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1";
@@ -1184,32 +1305,46 @@  discard block
 block discarded – undo
1184 1305
 					$sth = $this->db->prepare($query);
1185 1306
 					$sth->execute($query_values);
1186 1307
 				} catch(PDOException $e) {
1187
-					if ($globalDebug) echo $e->getMessage();
1308
+					if ($globalDebug) {
1309
+						echo $e->getMessage();
1310
+					}
1188 1311
 					return "error : ".$e->getMessage();
1189 1312
 				}
1190 1313
 				$result = $sth->fetch(PDO::FETCH_ASSOC);
1191 1314
 				$sth->closeCursor();
1192
-				if (isset($result['modes'])) $hex = $result['modes'];
1193
-				else $hex = '';
1315
+				if (isset($result['modes'])) {
1316
+					$hex = $result['modes'];
1317
+				} else {
1318
+					$hex = '';
1319
+				}
1194 1320
 				$SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS');
1195
-				if ($this->fromACARSscript) $this->SI->add($SI_data);
1321
+				if ($this->fromACARSscript) {
1322
+					$this->SI->add($SI_data);
1323
+				}
1196 1324
 			}
1197 1325
 		}
1198
-		if ($globalDebug) echo 'Done'."\n";
1326
+		if ($globalDebug) {
1327
+			echo 'Done'."\n";
1328
+		}
1199 1329
 		$query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1";
1200 1330
 		$query_values = array(':ident' => $icao);
1201 1331
 		try {
1202 1332
 			$sth = $this->db->prepare($query);
1203 1333
 			$sth->execute($query_values);
1204 1334
 		} catch(PDOException $e) {
1205
-			if ($globalDebug) echo $e->getMessage();
1335
+			if ($globalDebug) {
1336
+				echo $e->getMessage();
1337
+			}
1206 1338
 			return "error : ".$e->getMessage();
1207 1339
 		}
1208 1340
 		$result = $sth->fetch(PDO::FETCH_ASSOC);
1209 1341
 		$sth->closeCursor();
1210 1342
 		if (isset($result['flightaware_id'])) {
1211
-			if (isset($result['ModeS'])) $ModeS = $result['ModeS'];
1212
-			else $ModeS = '';
1343
+			if (isset($result['ModeS'])) {
1344
+				$ModeS = $result['ModeS'];
1345
+			} else {
1346
+				$ModeS = '';
1347
+			}
1213 1348
 			if ($ModeS == '') {
1214 1349
 				$id = explode('-',$result['flightaware_id']);
1215 1350
 				$ModeS = $id[0];
@@ -1222,24 +1357,32 @@  discard block
 block discarded – undo
1222 1357
 					$sthc = $this->db->prepare($queryc);
1223 1358
 					$sthc->execute($queryc_values);
1224 1359
 				} catch(PDOException $e) {
1225
-					if ($globalDebug) echo $e->getMessage();
1360
+					if ($globalDebug) {
1361
+						echo $e->getMessage();
1362
+					}
1226 1363
 					return "error : ".$e->getMessage();
1227 1364
 				}
1228 1365
 				$row = $sthc->fetch(PDO::FETCH_ASSOC);
1229 1366
 				$sthc->closeCursor();
1230 1367
 				if (count($row) ==  0) {
1231
-					if ($globalDebug) echo " Add to ModeS table - ";
1368
+					if ($globalDebug) {
1369
+						echo " Add to ModeS table - ";
1370
+					}
1232 1371
 					$queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')";
1233 1372
 					$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
1234 1373
 					try {
1235 1374
 						$sthi = $this->db->prepare($queryi);
1236 1375
 						$sthi->execute($queryi_values);
1237 1376
 					} catch(PDOException $e) {
1238
-						if ($globalDebug) echo $e->getMessage();
1377
+						if ($globalDebug) {
1378
+							echo $e->getMessage();
1379
+						}
1239 1380
 						return "error : ".$e->getMessage();
1240 1381
 					}
1241 1382
 				} else {
1242
-					if ($globalDebug) echo " Update ModeS table - ";
1383
+					if ($globalDebug) {
1384
+						echo " Update ModeS table - ";
1385
+					}
1243 1386
 					if ($ICAOTypeCode != '') {
1244 1387
 						$queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS";
1245 1388
 						$queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode);
@@ -1251,7 +1394,9 @@  discard block
 block discarded – undo
1251 1394
 						$sthi = $this->db->prepare($queryi);
1252 1395
 						$sthi->execute($queryi_values);
1253 1396
 					} catch(PDOException $e) {
1254
-						if ($globalDebug) echo $e->getMessage();
1397
+						if ($globalDebug) {
1398
+							echo $e->getMessage();
1399
+						}
1255 1400
 						return "error : ".$e->getMessage();
1256 1401
 					}
1257 1402
 				}
@@ -1272,7 +1417,9 @@  discard block
 block discarded – undo
1272 1417
 					    return "error : ".$e->getMessage();
1273 1418
 				}
1274 1419
 				*/
1275
-				if ($globalDebug) echo " Update Spotter_output table - ";
1420
+				if ($globalDebug) {
1421
+					echo " Update Spotter_output table - ";
1422
+				}
1276 1423
 				if ($ICAOTypeCode != '') {
1277 1424
 					if ($globalDBdriver == 'mysql') {
1278 1425
 						$queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
@@ -1283,8 +1430,7 @@  discard block
 block discarded – undo
1283 1430
 				} else {
1284 1431
 					if ($globalDBdriver == 'mysql') {
1285 1432
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)";
1286
-					}
1287
-					elseif ($globalDBdriver == 'pgsql') {
1433
+					} elseif ($globalDBdriver == 'pgsql') {
1288 1434
 						$queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'";
1289 1435
 					}
1290 1436
 					$queryi_values = array(':Registration' => $registration,':ident' => $icao);
@@ -1293,14 +1439,20 @@  discard block
 block discarded – undo
1293 1439
 					$sthi = $this->db->prepare($queryi);
1294 1440
 					$sthi->execute($queryi_values);
1295 1441
 				} catch(PDOException $e) {
1296
-					if ($globalDebug) echo $e->getMessage();
1442
+					if ($globalDebug) {
1443
+						echo $e->getMessage();
1444
+					}
1297 1445
 					return "error : ".$e->getMessage();
1298 1446
 				}
1299 1447
 			}
1300 1448
 		} else {
1301
-			if ($globalDebug) echo " Can't find ModeS in spotter_output - ";
1449
+			if ($globalDebug) {
1450
+				echo " Can't find ModeS in spotter_output - ";
1451
+			}
1452
+		}
1453
+		if ($globalDebug) {
1454
+			echo "Done\n";
1302 1455
 		}
1303
-		if ($globalDebug) echo "Done\n";
1304 1456
 		return '';
1305 1457
 	}
1306 1458
 }
Please login to merge, or discard this patch.
airline-detailed.php 2 patches
Braces   +31 added lines, -11 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 		$limit_start = 0;
15 15
 		$limit_end = 25;
16 16
 		$absolute_difference = 25;
17
-	}  else {
17
+	} else {
18 18
 		$limit_explode = explode(",", $_GET['limit']);
19 19
 		$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
20 20
 		$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
@@ -55,7 +55,9 @@  discard block
 block discarded – undo
55 55
 				$title = sprintf(_("Detailed View for %s (%s)"),$airline_info[0]['name'],$airline_info[0]['icao']);
56 56
 			} elseif (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) {
57 57
 				$title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
58
-			} else $title = '';
58
+			} else {
59
+				$title = '';
60
+			}
59 61
 		}
60 62
 		require_once('header.php');
61 63
 	  
@@ -76,7 +78,9 @@  discard block
 block discarded – undo
76 78
 		}
77 79
 		$Stats = new Stats();
78 80
 		$airline_names = $Stats->getAllAirlineNames();
79
-		if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
81
+		if (empty($airline_names)) {
82
+			$airline_names = $Spotter->getAllAirlineNames();
83
+		}
80 84
 		foreach($airline_names as $airline_name)
81 85
 		{
82 86
 			if($airline == $airline_name['airline_icao'])
@@ -108,12 +112,22 @@  discard block
 block discarded – undo
108 112
 					print '<div><span class="label">'._("Name").'</span>'.$airline_info[0]['name'].'</div>';
109 113
 					print '<div><span class="label">'._("Country").'</span>'.$airline_info[0]['country'].'</div>';
110 114
 					print '<div><span class="label">'._("ICAO").'</span>'.$airline_info[0]['icao'].'</div>';
111
-					if ($airline_info[0]['iata'] != '') print '<div><span class="label">'._("IATA").'</span>'.$airline_info[0]['iata'].'</div>';
112
-					if ($airline_info[0]['callsign'] != '') print '<div><span class="label">'._("Callsign").'</span>'.$airline_info[0]['callsign'].'</div>'; 
115
+					if ($airline_info[0]['iata'] != '') {
116
+						print '<div><span class="label">'._("IATA").'</span>'.$airline_info[0]['iata'].'</div>';
117
+					}
118
+					if ($airline_info[0]['callsign'] != '') {
119
+						print '<div><span class="label">'._("Callsign").'</span>'.$airline_info[0]['callsign'].'</div>';
120
+					}
113 121
 					print '<div><span class="label">'._("Type").'</span>'.ucwords($airline_info[0]['type']).'</div>';
114
-					if (isset($airline_info[0]['home_link']) && $airline_info[0]['home_link'] != '') print '<div><a href="'.$airline_info[0]['home_link'].'"><i class="fa fa-home"></i></a></div>';
115
-					if (isset($airline_info[0]['wikipedia_link']) && $airline_info[0]['wikipedia_link'] != '') print '<div><a href="'.$airline_info[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>';
116
-					if (isset($airline_info[0]['ban_eu']) && $airline_info[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
122
+					if (isset($airline_info[0]['home_link']) && $airline_info[0]['home_link'] != '') {
123
+						print '<div><a href="'.$airline_info[0]['home_link'].'"><i class="fa fa-home"></i></a></div>';
124
+					}
125
+					if (isset($airline_info[0]['wikipedia_link']) && $airline_info[0]['wikipedia_link'] != '') {
126
+						print '<div><a href="'.$airline_info[0]['wikipedia_link'].'"><i class="fa fa-wikipedia-w"></i></a></div>';
127
+					}
128
+					if (isset($airline_info[0]['ban_eu']) && $airline_info[0]['ban_eu'] == 1) {
129
+						print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
130
+					}
117 131
 					print '</div>';
118 132
 				
119 133
 				} else {
@@ -129,10 +143,16 @@  discard block
 block discarded – undo
129 143
 					print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>';
130 144
 					print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>';
131 145
 					print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>';
132
-					if (isset($spotter_array[0]['airline_iata']) && $spotter_array[0]['airline_iata'] != '') print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>';
133
-					if (isset($spotter_array[0]['airline_callsign']) && $spotter_array[0]['airline_callsign'] != '') print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; 
146
+					if (isset($spotter_array[0]['airline_iata']) && $spotter_array[0]['airline_iata'] != '') {
147
+						print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>';
148
+					}
149
+					if (isset($spotter_array[0]['airline_callsign']) && $spotter_array[0]['airline_callsign'] != '') {
150
+						print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>';
151
+					}
134 152
 					print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>';
135
-					if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
153
+					if (isset($spotter_array[0]['ban_eu']) && $spotter_array[0]['ban_eu'] == 1) {
154
+						print '<div><img src="'.$globalURL.'/images/baneu.png" alt="'._("This airline is banned in Europe").'" title="'._("This airline is banned in Europe").'" /></div>';
155
+					}
136 156
 					print '</div>';
137 157
 				}
138 158
 			} else {
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -4,20 +4,20 @@  discard block
 block discarded – undo
4 4
 require_once('require/class.Stats.php');
5 5
 require_once('require/class.Language.php');
6 6
 
7
-if (!isset($_GET['airline'])){
7
+if (!isset($_GET['airline'])) {
8 8
 	header('Location: '.$globalURL.'/airline');
9
-} else{
9
+} else {
10 10
 	$Spotter = new Spotter();
11 11
 	//calculuation for the pagination
12
-	if(!isset($_GET['limit']) || $_GET['limit'] == "")
12
+	if (!isset($_GET['limit']) || $_GET['limit'] == "")
13 13
 	{
14 14
 		$limit_start = 0;
15 15
 		$limit_end = 25;
16 16
 		$absolute_difference = 25;
17
-	}  else {
17
+	} else {
18 18
 		$limit_explode = explode(",", $_GET['limit']);
19
-		$limit_start = filter_var($limit_explode[0],FILTER_SANITIZE_NUMBER_INT);
20
-		$limit_end = filter_var($limit_explode[1],FILTER_SANITIZE_NUMBER_INT);
19
+		$limit_start = filter_var($limit_explode[0], FILTER_SANITIZE_NUMBER_INT);
20
+		$limit_end = filter_var($limit_explode[1], FILTER_SANITIZE_NUMBER_INT);
21 21
 		if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
22 22
 			$limit_start = 0;
23 23
 			$limit_end = 25;
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 	$limit_previous_1 = $limit_start - $absolute_difference;
29 29
 	$limit_previous_2 = $limit_end - $absolute_difference;
30 30
 	
31
-	$airline = urldecode(filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING));
31
+	$airline = urldecode(filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING));
32 32
 	$page_url = $globalURL.'/airline/'.$airline;
33 33
 	$alliance = false;
34
-	$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
34
+	$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING);
35 35
 	$airline_info = array();
36
-	if (strpos($airline,'alliance_') !== FALSE) {
37
-		$spotter_array = $Spotter->getSpotterDataByAirline('',$limit_start.",".$absolute_difference, $sort,array('alliance' => str_replace('_',' ',str_replace('alliance_','',$airline))));
36
+	if (strpos($airline, 'alliance_') !== FALSE) {
37
+		$spotter_array = $Spotter->getSpotterDataByAirline('', $limit_start.",".$absolute_difference, $sort, array('alliance' => str_replace('_', ' ', str_replace('alliance_', '', $airline))));
38 38
 		$alliance = true;
39 39
 	} else {
40
-		$spotter_array = $Spotter->getSpotterDataByAirline($airline,$limit_start.",".$absolute_difference, $sort);
40
+		$spotter_array = $Spotter->getSpotterDataByAirline($airline, $limit_start.",".$absolute_difference, $sort);
41 41
 		if (isset($globalIVAO)) {
42
-			$airline_info = $Spotter->getAllAirlineInfo($airline,'ivao');
42
+			$airline_info = $Spotter->getAllAirlineInfo($airline, 'ivao');
43 43
 		} elseif (isset($globalVATSIM)) {
44
-			$airline_info = $Spotter->getAllAirlineInfo($airline,'vatsim');
44
+			$airline_info = $Spotter->getAllAirlineInfo($airline, 'vatsim');
45 45
 		} else {
46 46
 			$airline_info = $Spotter->getAllAirlineInfo($airline);
47 47
 		}
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
 	if (!empty($spotter_array) || !empty($airline_info))
50 50
 	{
51 51
 		if ($alliance) {
52
-			$title = sprintf(_("Detailed View for %s"),str_replace('_',' ',str_replace('alliance_','',$airline)));
52
+			$title = sprintf(_("Detailed View for %s"), str_replace('_', ' ', str_replace('alliance_', '', $airline)));
53 53
 		} else {
54 54
 			if (isset($airline_info[0]['name']) && isset($airline_info[0]['icao'])) {
55
-				$title = sprintf(_("Detailed View for %s (%s)"),$airline_info[0]['name'],$airline_info[0]['icao']);
55
+				$title = sprintf(_("Detailed View for %s (%s)"), $airline_info[0]['name'], $airline_info[0]['icao']);
56 56
 			} elseif (isset($spotter_array[0]['airline_name']) && isset($spotter_array[0]['airline_icao'])) {
57
-				$title = sprintf(_("Detailed View for %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']);
57
+				$title = sprintf(_("Detailed View for %s (%s)"), $spotter_array[0]['airline_name'], $spotter_array[0]['airline_icao']);
58 58
 			} else $title = '';
59 59
 		}
60 60
 		require_once('header.php');
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 		$alliances = $Spotter->getAllAllianceNames();
67 67
 		if (!empty($alliances)) {
68 68
 			foreach ($alliances as $al) {
69
-				if ($alliance && str_replace('_',' ',str_replace('alliance_','',$airline)) == $al['alliance']) {
70
-					print '<option value="alliance_'.str_replace(' ','_',$al['alliance']).'" selected>'.$al['alliance'].'</option>';
69
+				if ($alliance && str_replace('_', ' ', str_replace('alliance_', '', $airline)) == $al['alliance']) {
70
+					print '<option value="alliance_'.str_replace(' ', '_', $al['alliance']).'" selected>'.$al['alliance'].'</option>';
71 71
 				} else {
72
-					print '<option value="alliance_'.str_replace(' ','_',$al['alliance']).'">'.$al['alliance'].'</option>';
72
+					print '<option value="alliance_'.str_replace(' ', '_', $al['alliance']).'">'.$al['alliance'].'</option>';
73 73
 				}
74 74
 			}
75 75
 			print '<option disabled>───────────────</option>';
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 		$Stats = new Stats();
78 78
 		$airline_names = $Stats->getAllAirlineNames();
79 79
 		if (empty($airline_names)) $airline_names = $Spotter->getAllAirlineNames();
80
-		foreach($airline_names as $airline_name)
80
+		foreach ($airline_names as $airline_name)
81 81
 		{
82
-			if($airline == $airline_name['airline_icao'])
82
+			if ($airline == $airline_name['airline_icao'])
83 83
 			{
84 84
 				print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>';
85 85
 			} else {
@@ -137,12 +137,12 @@  discard block
 block discarded – undo
137 137
 				}
138 138
 			} else {
139 139
 				print '<div class="info column">';
140
-				print '<h1>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</h1>';
141
-				if (@getimagesize($globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png') || @getimagesize('images/airlines/'.str_replace('alliance_','',$airline).'.png'))
140
+				print '<h1>'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'</h1>';
141
+				if (@getimagesize($globalURL.'/images/airlines/'.str_replace('alliance_', '', $airline).'.png') || @getimagesize('images/airlines/'.str_replace('alliance_', '', $airline).'.png'))
142 142
 				{
143
-					print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_','',$airline).'.png" alt="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" title="'.str_replace('_',' ',str_replace('alliance_','',$airline)).'" class="logo" />';
143
+					print '<img src="'.$globalURL.'/images/airlines/'.str_replace('alliance_', '', $airline).'.png" alt="'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'" title="'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'" class="logo" />';
144 144
 				}
145
-				print '<div><span class="label">'._("Name").'</span>'.str_replace('_',' ',str_replace('alliance_','',$airline)).'</div>';
145
+				print '<div><span class="label">'._("Name").'</span>'.str_replace('_', ' ', str_replace('alliance_', '', $airline)).'</div>';
146 146
 				print '</div>';
147 147
 			}
148 148
 		} else {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			include('airline-sub-menu.php');
154 154
 			print '<div class="table column">';
155 155
 			if (isset($spotter_array[0]['airline_name']) && $alliance === false) {
156
-				print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>';
156
+				print '<p>'.sprintf(_("The table below shows the detailed information of all flights from <strong>%s</strong>."), $spotter_array[0]['airline_name']).'</p>';
157 157
 			}
158 158
 			include('table-output.php');  
159 159
 			print '<div class="pagination">';
Please login to merge, or discard this patch.
table-output.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 				}
366 366
 			}
367 367
 		}
368
-    		if ($type == 'aircraft') {
368
+			if ($type == 'aircraft') {
369 369
 			if ((isset($globalUsePilot) && $globalUsePilot) || (!isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalVAM) && $globalVAM) || (isset($globalphpVMS) && $globalphpVMS)))) {
370 370
 				print '<th class="pilot"><span class="nomobile">'._("Pilot name").'</span><span class="mobile">'._("Pilot").'</span></a></th>';
371 371
 			}
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
724 724
 		if ($type == 'aircraft') {
725 725
 			if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
726
-			    $spotter_item['squawk'] = '-';
726
+				$spotter_item['squawk'] = '-';
727 727
 			}
728 728
 			if ($spotter_item['image_thumbnail'] != "")
729 729
 			{
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 				print '</td>'."\n";
763 763
 			} else {
764 764
 				print '<td class="aircraft_thumbnail">'."\n";
765
-	       //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
765
+		   //   	 	print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
766 766
 		//}
767 767
 				if (!isset($spotter_item['airline_name']) && !isset($spotter_item['aircraft_name'])) {
768 768
 					print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$globalURL.'/images/placeholder_thumb.png" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '._("Not available").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n";
@@ -1034,11 +1034,11 @@  discard block
 block discarded – undo
1034 1034
 					if (!isset($Spotter)) $Spotter = new Spotter();
1035 1035
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
1036 1036
 					if (isset($arrival_airport_info[0])) {
1037
-                        print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
1038
-                    }
1039
-                    print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
1040
-                    if (isset($arrival_airport_info[0])) {
1041
-                        print '<span class="mobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
1037
+						print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
1038
+					}
1039
+					print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
1040
+					if (isset($arrival_airport_info[0])) {
1041
+						print '<span class="mobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
1042 1042
 					}
1043 1043
 				} elseif ($spotter_item['arrival_airport'] != 'NA') {
1044 1044
 					print '<span class="nomobile"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
Please login to merge, or discard this patch.
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -4,15 +4,15 @@  discard block
 block discarded – undo
4 4
 
5 5
 require_once(dirname(__FILE__).'/require/class.Common.php');
6 6
 $Common = new Common();
7
-$showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
7
+$showRouteStop = $Common->multiKeyExists($spotter_array, 'route_stop');
8 8
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
9
-	$showDuration = $Common->multiKeyExists($spotter_array,'race_time');
10
-	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration');
9
+	$showDuration = $Common->multiKeyExists($spotter_array, 'race_time');
10
+	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array, 'duration');
11 11
 } else {
12
-	$showDuration = $Common->multiKeyExists($spotter_array,'duration');
12
+	$showDuration = $Common->multiKeyExists($spotter_array, 'duration');
13 13
 }
14 14
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
15
-	$showDistance = $Common->multiKeyExists($spotter_array,'distance');
15
+	$showDistance = $Common->multiKeyExists($spotter_array, 'distance');
16 16
 }
17 17
 
18 18
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	}
179 179
 	print '<th class="more"></th>';
180 180
 	print '</thead>';
181
-} else if (strtolower($current_page) == "upcoming"){
181
+} else if (strtolower($current_page) == "upcoming") {
182 182
 	print '<thead>';
183 183
 	if (!isset($globalNoAirlines) || $globalNoAirlines === FALSE) {
184 184
 		if ($_GET['sort'] == "airline_name_asc")
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	}
233 233
 	*/
234 234
 	print '</thead>';
235
-} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive"){
235
+} else if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
236 236
 	print '<thead>';
237 237
 	print '<th class="aircraft_thumbnail"></th>';
238 238
 	print '<th class="logo">'._("Airline").'</th>';
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	print '</thead>';
270 270
 } else {
271 271
 
272
-	if ($hide_th_links === true){
272
+	if ($hide_th_links === true) {
273 273
 		print '<thead>';
274 274
 		if ($type == 'marine' && isset($globalVM) && $globalVM) {
275 275
 			print '<th class="rank">'._("Rank").'</th>';
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 }
588 588
 
589 589
 print '<tbody>'."\n";
590
-foreach($spotter_array as $spotter_item)
590
+foreach ($spotter_array as $spotter_item)
591 591
 {
592 592
 	if (isset($globalTimezone))
593 593
 	{
@@ -622,13 +622,13 @@  discard block
 block discarded – undo
622 622
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
623 623
 					}
624 624
 					if (isset($spotter_item['airline_name'])) {
625
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
625
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
626 626
 					} else {
627
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
627
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '._("Not available").'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
628 628
 					}
629 629
 				} else {
630 630
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
631
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
631
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
632 632
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
633 633
 					if (isset($spotter_item['airline_name'])) {
634 634
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			{
655 655
 				print '<td class="aircraft_thumbnail">'."\n";
656 656
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
657
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
657
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
658 658
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
659 659
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
660 660
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -676,7 +676,7 @@  discard block
 block discarded – undo
676 676
 			{
677 677
 				print '<td class="aircraft_thumbnail">'."\n";
678 678
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
679
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
679
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
680 680
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
681 681
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
682 682
 				print '</td>'."\n";
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				print '</td>'."\n";
721 721
 			}
722 722
 		}
723
-	} elseif(strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed"){
723
+	} elseif (strtolower($current_page) != "currently" && strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive" && strtolower($current_page) != "accident-latest" && strtolower($current_page) != "incident-latest" && strtolower($current_page) != "accident-detailed" && strtolower($current_page) != "incident-detailed") {
724 724
 		if ($type == 'aircraft') {
725 725
 			if (!isset($spotter_item['squawk']) || $spotter_item['squawk'] == 0) {
726 726
 			    $spotter_item['squawk'] = '-';
@@ -737,17 +737,17 @@  discard block
 block discarded – undo
737 737
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
738 738
 					}
739 739
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
740
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
740
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
741 741
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
742
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
742
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
743 743
 					} elseif (!isset($spotter_item['aircraft_name']) && !isset($spotter_item['airline_name'])) {
744
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
744
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
745 745
 					} else {
746
-						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
746
+						print '<a href="'.$image_src.'"><img src="'.preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']).'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '.$spotter_item['airline_name'].'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
747 747
 					}
748 748
 				} else {
749 749
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
750
-						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
750
+						$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
751 751
 					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
752 752
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
753 753
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 			{
788 788
 				print '<td class="aircraft_thumbnail">'."\n";
789 789
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
790
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
790
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
791 791
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
792 792
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
793 793
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n";
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 			{
812 812
 				print '<td class="aircraft_thumbnail">'."\n";
813 813
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
814
-					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
814
+					$image_thumbnail = preg_replace("/^http:/i", "https:", $spotter_item['image_thumbnail']);
815 815
 				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
816 816
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
817 817
 				print '</td>'."\n";
@@ -920,7 +920,7 @@  discard block
 block discarded – undo
920 920
 		print '</td>'."\n";
921 921
 	}
922 922
 	// Aircraft type
923
-	if(strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive"){
923
+	if (strtolower($current_page) != "upcoming" && strtolower($current_page) != "acars-latest" && strtolower($current_page) != "acars-archive") {
924 924
 		print '<td class="type">'."\n";
925 925
 		if ($type == 'aircraft') {
926 926
 			if (!isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_name'])) {
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 				//print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'._("Not available").'</a></span>'."\n";
930 930
 				print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
931 931
 			} else {
932
-				$aircraft_names = explode('/',$spotter_item['aircraft_name']);
932
+				$aircraft_names = explode('/', $spotter_item['aircraft_name']);
933 933
 				if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
934 934
 				else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
935 935
 			}
@@ -973,22 +973,22 @@  discard block
 block discarded – undo
973 973
 			}
974 974
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
975 975
 				if ($spotter_item['departure_airport_time'] > 2460) {
976
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
977
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
976
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
977
+				} else $departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
978 978
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
979
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
979
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
980 980
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
981 981
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
982 982
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
983 983
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
984
-					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
984
+					$real_departure_airport_time = date('H:m', $spotter_item['real_departure_airport_time']);
985 985
 				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
986 986
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
987 987
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
988 988
 				if ($spotter_item['departure_airport_time'] > 2460) {
989
-					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
989
+					$departure_airport_time = date('H:m', $spotter_item['departure_airport_time']);
990 990
 				} else {
991
-					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
991
+					$departure_airport_time = substr($spotter_item['departure_airport_time'], 0, -2).':'.substr($spotter_item['departure_airport_time'], -2);
992 992
 				}
993 993
 				print '<br /><span class="airport_time">'.$departure_airport_time.'</span>'."\n";
994 994
 			}
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 						$latitude = $spotter_item['latitude'];
1004 1004
 						$longitude = $spotter_item['longitude'];
1005 1005
 					}
1006
-					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
1006
+					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'], $latitude, $longitude);
1007 1007
 				} else $distance = '';
1008 1008
 				if ($distance != '') {
1009 1009
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
 					if (!isset($Spotter)) $Spotter = new Spotter();
1035 1035
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
1036 1036
 					if (isset($arrival_airport_info[0])) {
1037
-                        print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
1037
+                        print '<br /><span class="nomobile">'._("Real:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$arrival_airport_info[0]['city'].','.$arrival_airport_info[0]['country'].' ('.$spotter_item['real_arrival_airport'].')</a></span>'."\n";
1038 1038
                     }
1039 1039
                     print '<span class="mobile">'._("Scheduled:").' <a href="'.$globalURL.'/airport/'.$spotter_item['real_arrival_airport'].'">'.$spotter_item['real_arrival_airport'].'</a></span>'."\n";
1040 1040
                     if (isset($arrival_airport_info[0])) {
@@ -1050,20 +1050,20 @@  discard block
 block discarded – undo
1050 1050
 			}
1051 1051
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
1052 1052
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1053
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1053
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
1054 1054
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1055 1055
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1056
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1056
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
1057 1057
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1058 1058
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
1059 1059
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
1060 1060
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1061
-					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1061
+					$real_arrival_airport_time = date('H:m', $spotter_item['real_arrival_airport_time']);
1062 1062
 				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1063 1063
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
1064 1064
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
1065 1065
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1066
-					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1066
+					$arrival_airport_time = date('H:m', $spotter_item['arrival_airport_time']);
1067 1067
 				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1068 1068
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
1069 1069
 			}
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
 						$latitude = $spotter_item['latitude'];
1077 1077
 						$longitude = $spotter_item['longitude'];
1078 1078
 					}
1079
-					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
1079
+					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'], $latitude, $longitude);
1080 1080
 				} else $distance = '';
1081 1081
 				if ($distance != '') {
1082 1082
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
@@ -1138,19 +1138,19 @@  discard block
 block discarded – undo
1138 1138
 				print '<span class="mobile">-</span>'."\n";
1139 1139
 			} else {
1140 1140
 				if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1141
-					print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
1142
-					print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
1141
+					print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
1142
+					print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
1143 1143
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1144
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
1145
-					print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
1144
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
1145
+					print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
1146 1146
 				} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1147
-					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
1148
-					print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
1147
+					print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
1148
+					print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
1149 1149
 				}
1150 1150
 			}
1151 1151
 			print '</td>'."\n";
1152 1152
 		}
1153
-		if(strtolower($current_page) != "upcoming"){
1153
+		if (strtolower($current_page) != "upcoming") {
1154 1154
 			if ($type == 'aircraft') {
1155 1155
 				//if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) {
1156 1156
 				if ((isset($globalUsePilot) && $globalUsePilot) || !isset($globalUsePilot) && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM))) {
@@ -1195,14 +1195,14 @@  discard block
 block discarded – undo
1195 1195
 						if (isset($spotter_item['distance'])) {
1196 1196
 							print '<td class="distance">';
1197 1197
 							if ((!isset($_COOKIE['unitdistance']) && ((isset($globalUnitDistance) && $globalUnitDistance == 'km') || !isset($globalUnitDistance))) || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'km')) {
1198
-								print '<span class="nomobile">'.round($spotter_item['distance'],2).' km</span>'."\n";
1199
-								print '<span class="mobile">'.round($spotter_item['distance'],2).' km</span><br />'."\n";
1198
+								print '<span class="nomobile">'.round($spotter_item['distance'], 2).' km</span>'."\n";
1199
+								print '<span class="mobile">'.round($spotter_item['distance'], 2).' km</span><br />'."\n";
1200 1200
 							} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'mi') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'mi')) {
1201
-								print '<span class="nomobile">'.round($spotter_item['distance']*0.621371,2).' mi</span>'."\n";
1202
-								print '<span class="mobile">'.round($spotter_item['distance']*0.621371,2).' mi</span><br />'."\n";
1201
+								print '<span class="nomobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span>'."\n";
1202
+								print '<span class="mobile">'.round($spotter_item['distance']*0.621371, 2).' mi</span><br />'."\n";
1203 1203
 							} elseif ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1204
-								print '<span class="nomobile">'.round($spotter_item['distance']*0.539957,2).' nm</span>'."\n";
1205
-								print '<span class="mobile">'.round($spotter_item['distance']*0.539957,2).' nm</span><br />'."\n";
1204
+								print '<span class="nomobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span>'."\n";
1205
+								print '<span class="mobile">'.round($spotter_item['distance']*0.539957, 2).' nm</span><br />'."\n";
1206 1206
 							}
1207 1207
 							print '</td>'."\n";
1208 1208
 						} else {
@@ -1233,7 +1233,7 @@  discard block
 block discarded – undo
1233 1233
 		
1234 1234
 		if ($showRouteStop) {
1235 1235
 		// Route stop
1236
-			if(strtolower($current_page) != "upcoming"){
1236
+			if (strtolower($current_page) != "upcoming") {
1237 1237
 				print '<td class="route_stop">'."\n";
1238 1238
 				if (!isset($spotter_item['route_stop']) || $spotter_item['route_stop'] == '' || $spotter_item['route_stop'] == 'NULL') {
1239 1239
 					print '<span class="nomobile">-</span>'."\n";
@@ -1256,19 +1256,19 @@  discard block
 block discarded – undo
1256 1256
 				print '<td class="duration">'."\n";
1257 1257
 				if (isset($spotter_item['race_time'])) {
1258 1258
 					if ($spotter_item['race_time'] > 86400) {
1259
-						print '<span class="nomobile">'.gmdate("z\d. H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1260
-						print '<span class="mobile">'.gmdate("z\d. H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1259
+						print '<span class="nomobile">'.gmdate("z\d. H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1260
+						print '<span class="mobile">'.gmdate("z\d. H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1261 1261
 					} else {
1262
-						print '<span class="nomobile">'.gmdate("H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1263
-						print '<span class="mobile">'.gmdate("H\h. i\m. s\s.",$spotter_item['race_time']).'</span>'."\n";
1262
+						print '<span class="nomobile">'.gmdate("H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1263
+						print '<span class="mobile">'.gmdate("H\h. i\m. s\s.", $spotter_item['race_time']).'</span>'."\n";
1264 1264
 					}
1265 1265
 				} elseif (isset($spotter_item['duration'])) {
1266 1266
 					if ($spotter_item['duration'] > 86400) {
1267
-						print '<span class="nomobile">'.gmdate('z\d. H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1268
-						print '<span class="mobile">'.gmdate('z\d. H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1267
+						print '<span class="nomobile">'.gmdate('z\d. H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1268
+						print '<span class="mobile">'.gmdate('z\d. H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1269 1269
 					} else {
1270
-						print '<span class="nomobile">'.gmdate('H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1271
-						print '<span class="mobile">'.gmdate('H\h. i\m. s\s.',$spotter_item['duration']).'</span>'."\n";
1270
+						print '<span class="nomobile">'.gmdate('H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1271
+						print '<span class="mobile">'.gmdate('H\h. i\m. s\s.', $spotter_item['duration']).'</span>'."\n";
1272 1272
 					}
1273 1273
 				} else {
1274 1274
 					print '<span class="nomobile">-</span>'."\n";
@@ -1276,11 +1276,11 @@  discard block
 block discarded – undo
1276 1276
 				}
1277 1277
 				print '</td>'."\n";
1278 1278
 			} else {
1279
-				if(strtolower($current_page) != "upcoming"){
1279
+				if (strtolower($current_page) != "upcoming") {
1280 1280
 					print '<td class="duration">'."\n";
1281 1281
 					if (isset($spotter_item['duration'])) {
1282
-						print '<span class="nomobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
1283
-						print '<span class="mobile">'.gmdate('H:i:s',$spotter_item['duration']).'</span>'."\n";
1282
+						print '<span class="nomobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
1283
+						print '<span class="mobile">'.gmdate('H:i:s', $spotter_item['duration']).'</span>'."\n";
1284 1284
 					} else {
1285 1285
 						print '<span class="nomobile">-</span>'."\n";
1286 1286
 						print '<span class="mobile">-</span>'."\n";
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive") {
1295 1295
 		if (isset($spotter_item['decode']) && $spotter_item['decode'] != '') {
1296 1296
 			print '<td class="message"><p>'."\n";
1297
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1297
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1298 1298
 			print '</p><p class="decode">';
1299 1299
 			$decode_array = json_decode($spotter_item['decode']);
1300 1300
 			foreach ($decode_array as $key => $value) {
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 			print '</td>'."\n";
1305 1305
 		} else {
1306 1306
 			print '<td class="message">'."\n";
1307
-			print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1307
+			print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1308 1308
 			print '</td>'."\n";
1309 1309
 		}
1310 1310
 	}
@@ -1329,7 +1329,7 @@  discard block
 block discarded – undo
1329 1329
 		}
1330 1330
 		print '</td>'."\n";
1331 1331
 		print '<td class="message">'."\n";
1332
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1332
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1333 1333
 		print '</td>'."\n";
1334 1334
 	}
1335 1335
 	if (strtolower($current_page) == "incident-latest" || strtolower($current_page) == "incident-detailed") {
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
 		print '</td>'."\n";
1356 1356
 		*/
1357 1357
 		print '<td class="message">'."\n";
1358
-		print str_replace(array("\r\n", "\n", "\r"),'<br />',$spotter_item['message']);
1358
+		print str_replace(array("\r\n", "\n", "\r"), '<br />', $spotter_item['message']);
1359 1359
 		print '</td>'."\n";
1360 1360
 	}
1361 1361
 
Please login to merge, or discard this patch.
Braces   +78 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,8 +7,10 @@  discard block
 block discarded – undo
7 7
 $showRouteStop = $Common->multiKeyExists($spotter_array,'route_stop');
8 8
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
9 9
 	$showDuration = $Common->multiKeyExists($spotter_array,'race_time');
10
-	if ($showDuration === false) $showDuration = $Common->multiKeyExists($spotter_array,'duration');
11
-} else {
10
+	if ($showDuration === false) {
11
+		$showDuration = $Common->multiKeyExists($spotter_array,'duration');
12
+	}
13
+	} else {
12 14
 	$showDuration = $Common->multiKeyExists($spotter_array,'duration');
13 15
 }
14 16
 if (isset($globalVM) && $globalVM && isset($type) && $type == 'marine') {
@@ -16,7 +18,9 @@  discard block
 block discarded – undo
16 18
 }
17 19
 
18 20
 
19
-if (!isset($type)) $type = 'aircraft';
21
+if (!isset($type)) {
22
+	$type = 'aircraft';
23
+}
20 24
 
21 25
 if (!isset($_GET['sort'])) 
22 26
 {
@@ -592,7 +596,9 @@  discard block
 block discarded – undo
592 596
 	if (isset($globalTimezone))
593 597
 	{
594 598
 		date_default_timezone_set($globalTimezone);
595
-	} else date_default_timezone_set('UTC');
599
+	} else {
600
+		date_default_timezone_set('UTC');
601
+	}
596 602
 	if ($showSpecial === true)
597 603
 	{
598 604
 		print '<tr class="special">'."\n";
@@ -607,7 +613,9 @@  discard block
 block discarded – undo
607 613
 			print '<tr class="active">';
608 614
 		} elseif (isset($spotter_item['spotted_registration'])) {
609 615
 			print '<tr class="info">';
610
-		} else print '<tr>';
616
+		} else {
617
+			print '<tr>';
618
+		}
611 619
 	}
612 620
 	if (strtolower($current_page) == "acars-latest" || strtolower($current_page) == "acars-archive" || strtolower($current_page) == "currently" || strtolower($current_page) == "accident-latest" || strtolower($current_page) == "incident-latest" || strtolower($current_page) == "accident-detailed" || strtolower($current_page) == "incident-detailed") {
613 621
 		if ($type == 'aircraft') {
@@ -615,8 +623,9 @@  discard block
 block discarded – undo
615 623
 			{
616 624
 				print '<td class="aircraft_thumbnail">'."\n";
617 625
 				if ($spotter_item['image_source'] == 'planespotters') {
618
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
619
-					else {
626
+					if ($spotter_item['image_source_website'] != '') {
627
+						$image_src = $spotter_item['image_source_website'];
628
+					} else {
620 629
 						$planespotter_url_array = explode("_", $spotter_item['image']);
621 630
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
622 631
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -629,7 +638,9 @@  discard block
 block discarded – undo
629 638
 				} else {
630 639
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
631 640
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
632
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
641
+					} else {
642
+						$image_thumbnail = $spotter_item['image_thumbnail'];
643
+					}
633 644
 					if (isset($spotter_item['airline_name'])) {
634 645
 						print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" alt="'.$spotter_item['registration'].' - '.$spotter_item['airline_name'].'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Airline:").' '.$spotter_item['airline_name'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
635 646
 					} else {
@@ -655,7 +666,9 @@  discard block
 block discarded – undo
655 666
 				print '<td class="aircraft_thumbnail">'."\n";
656 667
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
657 668
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
658
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
669
+				} else {
670
+					$image_thumbnail = $spotter_item['image_thumbnail'];
671
+				}
659 672
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
660 673
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
661 674
 				} else {
@@ -677,7 +690,9 @@  discard block
 block discarded – undo
677 690
 				print '<td class="aircraft_thumbnail">'."\n";
678 691
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
679 692
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
680
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
693
+				} else {
694
+					$image_thumbnail = $spotter_item['image_thumbnail'];
695
+				}
681 696
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
682 697
 				print '</td>'."\n";
683 698
 			} else {
@@ -730,8 +745,9 @@  discard block
 block discarded – undo
730 745
 				print '<td class="aircraft_thumbnail">'."\n";
731 746
 				//print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$spotter_item['image_thumbnail'].'" alt="Click to see more information about this flight" title="Click to see more information about this flight" width="100px" /></a>';
732 747
 				if ($spotter_item['image_source'] == 'planespotters') {
733
-					if ($spotter_item['image_source_website'] != '') $image_src = $spotter_item['image_source_website'];
734
-					else {
748
+					if ($spotter_item['image_source_website'] != '') {
749
+						$image_src = $spotter_item['image_source_website'];
750
+					} else {
735 751
 						$planespotter_url_array = explode("_", $spotter_array[0]['image']);
736 752
 						$planespotter_id = str_replace(".jpg", "", $planespotter_url_array[1]);
737 753
 						$image_src = 'https://www.planespotters.net/Aviation_Photos/photo.show?id='.$planespotter_id;
@@ -748,7 +764,9 @@  discard block
 block discarded – undo
748 764
 				} else {
749 765
 					if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
750 766
 						$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
751
-					} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
767
+					} else {
768
+						$image_thumbnail = $spotter_item['image_thumbnail'];
769
+					}
752 770
 					if (!isset($spotter_item['airline_name']) && isset($spotter_item['aircraft_name'])) {
753 771
 						print '<a href="'.$globalURL.'/flightid/'.$spotter_item['spotter_id'].'"><img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" alt="'.$spotter_item['registration'].' - '.$spotter_item['aircraft_type'].' - '._("Not available").'" data-content="'._("Registration:").' '.$spotter_item['registration'].'<br />'._("Aircraft:").' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')<br />'._("Airline:").' '._("Not available").'<br />'._("Squawk:").' '.$spotter_item['squawk'].'" data-html="true" width="100px" /></a>'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
754 772
 					} elseif (!isset($spotter_item['aircraft_name']) && isset($spotter_item['airline_name'])) {
@@ -788,13 +806,19 @@  discard block
 block discarded – undo
788 806
 				print '<td class="aircraft_thumbnail">'."\n";
789 807
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
790 808
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
791
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
809
+				} else {
810
+					$image_thumbnail = $spotter_item['image_thumbnail'];
811
+				}
792 812
 				if (isset($spotter_item['mmsi']) && $spotter_item['mmsi'] != '') {
793 813
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['mmsi'].'" alt="'.$spotter_item['mmsi'].'" data-content="'._("MMSI:").' '.$spotter_item['mmsi'].'" data-html="true" width="100px" />'."\n";
794
-					if ($spotter_item['image_copyright'] != '') print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
814
+					if ($spotter_item['image_copyright'] != '') {
815
+						print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
816
+					}
795 817
 				} else {
796 818
 					print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['ident'].'" data-content="'._("Ident:").' '.$spotter_item['ident'].'" data-html="true" width="100px" />'."\n";
797
-					if ($spotter_item['image_copyright'] != '') print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
819
+					if ($spotter_item['image_copyright'] != '') {
820
+						print '<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
821
+					}
798 822
 				}
799 823
 				print '</td>'."\n";
800 824
 			} else {
@@ -812,7 +836,9 @@  discard block
 block discarded – undo
812 836
 				print '<td class="aircraft_thumbnail">'."\n";
813 837
 				if ($spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart' || $spotter_item['image_source'] == 'flickr') {
814 838
 					$image_thumbnail = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
815
-				} else 	$image_thumbnail = $spotter_item['image_thumbnail'];
839
+				} else {
840
+					$image_thumbnail = $spotter_item['image_thumbnail'];
841
+				}
816 842
 				print '<img src="'.$image_thumbnail.'" class="img-rounded" data-toggle="popover" title="'.$spotter_item['ident'].'" alt="'.$spotter_item['type'].'" data-content="'._("Type:").' '.$spotter_item['type'].'" data-html="true" width="100px" />'."\n".'<div class="thumbnail-copyright">&copy; '.$spotter_item['image_copyright'].'</div>';
817 843
 				print '</td>'."\n";
818 844
 			} else {
@@ -930,8 +956,11 @@  discard block
 block discarded – undo
930 956
 				print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
931 957
 			} else {
932 958
 				$aircraft_names = explode('/',$spotter_item['aircraft_name']);
933
-				if (count($aircraft_names) == 1) print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
934
-				else print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
959
+				if (count($aircraft_names) == 1) {
960
+					print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].'</a></span>'."\n";
961
+				} else {
962
+					print '<span class="nomobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].'</a></span>'."\n";
963
+				}
935 964
 			}
936 965
 			print '<span class="mobile"><a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a></span>'."\n";
937 966
 		} elseif ($type == 'marine') {
@@ -974,15 +1003,21 @@  discard block
 block discarded – undo
974 1003
 			if (isset($spotter_item['departure_airport_time']) && isset($spotter_item['real_departure_airport_time'])) {
975 1004
 				if ($spotter_item['departure_airport_time'] > 2460) {
976 1005
 					$departure_airport_time = date('H:m',$spotter_item['departure_airport_time']);
977
-				} else $departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
1006
+				} else {
1007
+					$departure_airport_time = substr($spotter_item['departure_airport_time'],0,-2).':'.substr($spotter_item['departure_airport_time'],-2);
1008
+				}
978 1009
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
979 1010
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
980
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1011
+				} else {
1012
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1013
+				}
981 1014
 				print '<br /><span class="airport_time">'.$departure_airport_time.' ('.$real_departure_airport_time.')</span>'."\n";
982 1015
 			} elseif (isset($spotter_item['real_departure_airport_time']) && $spotter_item['real_departure_airport_time'] != 'NULL') {
983 1016
 				if ($spotter_item['real_departure_airport_time'] > 2460) {
984 1017
 					$real_departure_airport_time = date('H:m',$spotter_item['real_departure_airport_time']);
985
-				} else $real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1018
+				} else {
1019
+					$real_departure_airport_time = $spotter_item['real_departure_airport_time'];
1020
+				}
986 1021
 				print '<br /><span class="airport_time">'.$real_departure_airport_time.'</span>'."\n";
987 1022
 			} elseif (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
988 1023
 				if ($spotter_item['departure_airport_time'] > 2460) {
@@ -1004,7 +1039,9 @@  discard block
 block discarded – undo
1004 1039
 						$longitude = $spotter_item['longitude'];
1005 1040
 					}
1006 1041
 					$distance = $Spotter->getAirportDistance($spotter_item['departure_airport'],$latitude,$longitude);
1007
-				} else $distance = '';
1042
+				} else {
1043
+					$distance = '';
1044
+				}
1008 1045
 				if ($distance != '') {
1009 1046
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1010 1047
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
@@ -1031,7 +1068,9 @@  discard block
 block discarded – undo
1031 1068
 			} else {
1032 1069
 				if (isset($spotter_item['real_arrival_airport']) && $spotter_item['real_arrival_airport'] != $spotter_item['arrival_airport']) {
1033 1070
 					print '<span class="nomobile">Scheduled : <a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'">'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].' ('.$spotter_item['arrival_airport'].')</a></span>'."\n";
1034
-					if (!isset($Spotter)) $Spotter = new Spotter();
1071
+					if (!isset($Spotter)) {
1072
+						$Spotter = new Spotter();
1073
+					}
1035 1074
 					$arrival_airport_info = $Spotter->getAllAirportInfo($spotter_item['real_arrival_airport']);
1036 1075
 					if (isset($arrival_airport_info[0])) {
1037 1076
                         print '<br /><span class="nomobile">' . _("Real:") . ' <a href="' . $globalURL . '/airport/' . $spotter_item['real_arrival_airport'] . '">' . $arrival_airport_info[0]['city'] . ',' . $arrival_airport_info[0]['country'] . ' (' . $spotter_item['real_arrival_airport'] . ')</a></span>' . "\n";
@@ -1051,20 +1090,28 @@  discard block
 block discarded – undo
1051 1090
 			if (isset($spotter_item['arrival_airport_time']) && isset($spotter_item['real_arrival_airport_time'])) {
1052 1091
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1053 1092
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1054
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1093
+				} else {
1094
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
1095
+				}
1055 1096
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1056 1097
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1057
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1098
+				} else {
1099
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1100
+				}
1058 1101
 				print '<br /><span class="airport_time">'.$spotter_item['arrival_airport_time'].' ('.$spotter_item['real_arrival_airport_time'].')</span>'."\n";
1059 1102
 			} elseif (isset($spotter_item['real_arrival_airport_time'])) {
1060 1103
 				if ($spotter_item['real_arrival_airport_time'] > 2460) {
1061 1104
 					$real_arrival_airport_time = date('H:m',$spotter_item['real_arrival_airport_time']);
1062
-				} else $real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1105
+				} else {
1106
+					$real_arrival_airport_time = $spotter_item['real_arrival_airport_time'];
1107
+				}
1063 1108
 				print '<br /><span class="airport_time">'.$real_arrival_airport_time.'</span>'."\n";
1064 1109
 			} elseif (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
1065 1110
 				if ($spotter_item['arrival_airport_time'] > 2460) {
1066 1111
 					$arrival_airport_time = date('H:m',$spotter_item['arrival_airport_time']);
1067
-				} else $arrival_airport_time = $spotter_item['arrival_airport_time'];
1112
+				} else {
1113
+					$arrival_airport_time = $spotter_item['arrival_airport_time'];
1114
+				}
1068 1115
 				print '<br /><span class="airport_time">'.$arrival_airport_time.'</span>'."\n";
1069 1116
 			}
1070 1117
 			if (!isset($spotter_item['real_arrival_airport']) && $spotter_item['arrival_airport'] != 'NA') {
@@ -1077,7 +1124,9 @@  discard block
 block discarded – undo
1077 1124
 						$longitude = $spotter_item['longitude'];
1078 1125
 					}
1079 1126
 					$distance = $Spotter->getAirportDistance($spotter_item['arrival_airport'],$latitude,$longitude);
1080
-				} else $distance = '';
1127
+				} else {
1128
+					$distance = '';
1129
+				}
1081 1130
 				if ($distance != '') {
1082 1131
 					if ((!isset($_COOKIE['unitdistance']) && isset($globalUnitDistance) && $globalUnitDistance == 'nm') || (isset($_COOKIE['unitdistance']) && $_COOKIE['unitdistance'] == 'nm')) {
1083 1132
 						echo '<br/><i>'.round($distance*0.539957).' nm</i>';
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +1205 added lines, -1205 removed lines patch added patch discarded remove patch
@@ -15,65 +15,65 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
16 16
 require_once(dirname(__FILE__).'/../require/class.Common.php');
17 17
 if (isset($globalTracker) && $globalTracker) {
18
-    require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
19 19
 }
20 20
 if (isset($globalMarine) && $globalMarine) {
21
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
21
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
22
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25 25
 if (!isset($globalDebug)) $globalDebug = FALSE;
26 26
 
27 27
 if ($globalInstalled === FALSE) {
28
-    echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
-    sleep(5);
30
-    die();
28
+	echo "This script MUST be run after install script. Use your web browser to run install/index.php";
29
+	sleep(5);
30
+	die();
31 31
 }
32 32
 
33 33
 
34 34
 // Check if schema is at latest version
35 35
 $Connection = new Connection();
36 36
 if ($Connection->connectionExists() === false) {
37
-    echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
-    exit();
37
+	echo "Can't connect to your database. Check DB is running, user/password and database logs.";
38
+	exit();
39 39
 }
40 40
 if ($Connection->latest() === false) {
41
-    echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
-    exit();
41
+	echo "You MUST update to latest schema. Use your web browser to run install/index.php";
42
+	exit();
43 43
 }
44 44
 if (PHP_SAPI != 'cli') {
45
-    echo "This script MUST be called from console, not a web browser.";
45
+	echo "This script MUST be called from console, not a web browser.";
46 46
 //    exit();
47 47
 }
48 48
 
49 49
 // This is to be compatible with old version of settings.php
50 50
 if (!isset($globalSources)) {
51
-    if (isset($globalSBS1Hosts)) {
52
-        //$hosts = $globalSBS1Hosts;
53
-        foreach ($globalSBS1Hosts as $host) {
54
-	    $globalSources[] = array('host' => $host);
55
-    	}
56
-    } else {
57
-        if (!isset($globalSBS1Host)) {
58
-	    echo '$globalSources MUST be defined !';
59
-	    die;
51
+	if (isset($globalSBS1Hosts)) {
52
+		//$hosts = $globalSBS1Hosts;
53
+		foreach ($globalSBS1Hosts as $host) {
54
+		$globalSources[] = array('host' => $host);
55
+		}
56
+	} else {
57
+		if (!isset($globalSBS1Host)) {
58
+		echo '$globalSources MUST be defined !';
59
+		die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62 62
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
63
-    }
63
+	}
64 64
 }
65 65
 
66 66
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70
-    $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
70
+	$globalSources = array();
71
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
+	else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74
-    $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
74
+	$globalSources = array();
75
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
+	else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
79 79
 	$globalServerAPRS = TRUE;
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
 if (isset($options['idsource'])) $id_source = $options['idsource'];
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
115
+	if ($globalDebug) echo "Using Server Mode\n";
116
+	$SI=new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
@@ -123,14 +123,14 @@  discard block
 block discarded – undo
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
126
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
126
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
127
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 128
 }
129 129
 
130 130
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
131 131
 if (isset($globalMarine) && $globalMarine) {
132
-    $AIS = new AIS();
133
-    $MI = new MarineImport($Connection->db);
132
+	$AIS = new AIS();
133
+	$MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136 136
 $SBS=new SBS();
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
147
-        global $sockets;
148
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
-        die("Bye!\n");
150
-    });
151
-    pcntl_signal_dispatch();
146
+	pcntl_signal(SIGINT,  function() {
147
+		global $sockets;
148
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149
+		die("Bye!\n");
150
+	});
151
+	pcntl_signal_dispatch();
152 152
 }
153 153
 
154 154
 // let's try and connect
@@ -158,47 +158,47 @@  discard block
 block discarded – undo
158 158
 $reset = 0;
159 159
 
160 160
 function connect_all($hosts) {
161
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
-    $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
165
-    foreach ($hosts as $id => $value) {
161
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163
+	$reset++;
164
+	if ($globalDebug) echo 'Connect to all...'."\n";
165
+	foreach ($hosts as $id => $value) {
166 166
 	$host = $value['host'];
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170 170
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
172
-        	//$formats[$id] = 'deltadbtxt';
173
-        	$globalSources[$id]['format'] = 'deltadbtxt';
174
-        	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
-        	//$formats[$id] = 'vatsimtxt';
178
-        	$globalSources[$id]['format'] = 'vatsimtxt';
179
-        	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182
-        	//$formats[$id] = 'aircraftlistjson';
183
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
184
-        	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
187
-        	//$formats[$id] = 'aircraftjson';
188
-        	$globalSources[$id]['format'] = 'aircraftjson';
189
-        	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
192
-        	//$formats[$id] = 'planefinderclient';
193
-        	$globalSources[$id]['format'] = 'planefinderclient';
194
-        	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
197
-        	//$formats[$id] = 'aircraftlistjson';
198
-        	$globalSources[$id]['format'] = 'opensky';
199
-        	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
-    	    /*
171
+			if (preg_match('/deltadb.txt$/i',$host)) {
172
+			//$formats[$id] = 'deltadbtxt';
173
+			$globalSources[$id]['format'] = 'deltadbtxt';
174
+			//$last_exec['deltadbtxt'] = 0;
175
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
177
+			//$formats[$id] = 'vatsimtxt';
178
+			$globalSources[$id]['format'] = 'vatsimtxt';
179
+			//$last_exec['vatsimtxt'] = 0;
180
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
182
+			//$formats[$id] = 'aircraftlistjson';
183
+			$globalSources[$id]['format'] = 'aircraftlistjson';
184
+			//$last_exec['aircraftlistjson'] = 0;
185
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
+			} else if (preg_match('/aircraft.json$/i',$host)) {
187
+			//$formats[$id] = 'aircraftjson';
188
+			$globalSources[$id]['format'] = 'aircraftjson';
189
+			//$last_exec['aircraftlistjson'] = 0;
190
+			if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
+			} else if (preg_match('/aircraft$/i',$host)) {
192
+			//$formats[$id] = 'planefinderclient';
193
+			$globalSources[$id]['format'] = 'planefinderclient';
194
+			//$last_exec['aircraftlistjson'] = 0;
195
+			if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
+			} else if (preg_match('/opensky/i',$host)) {
197
+			//$formats[$id] = 'aircraftlistjson';
198
+			$globalSources[$id]['format'] = 'opensky';
199
+			//$last_exec['aircraftlistjson'] = 0;
200
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
201
+			/*
202 202
     	    // Disabled for now, site change source format
203 203
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
204 204
         	//$formats[$id] = 'radarvirtueljson';
@@ -210,130 +210,130 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
-        	//$formats[$id] = 'planeupdatefaa';
215
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
216
-        	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
-        	    exit(0);
221
-        	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
-        	//$formats[$id] = 'phpvmacars';
224
-        	$globalSources[$id]['format'] = 'phpvmacars';
225
-        	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
-        	//$formats[$id] = 'phpvmacars';
229
-        	$globalSources[$id]['format'] = 'vaos';
230
-        	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
233
-        	//$formats[$id] = 'phpvmacars';
234
-        	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
237
-        	//$formats[$id] = 'whazzup';
238
-        	$globalSources[$id]['format'] = 'whazzup';
239
-        	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
242
-        	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
245
-        	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
248
-        	//$formats[$id] = 'pirepsjson';
249
-        	$globalSources[$id]['format'] = 'pirepsjson';
250
-        	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
-        	//$formats[$id] = 'fr24json';
254
-        	$globalSources[$id]['format'] = 'fr24json';
255
-        	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
-        	    exit(0);
260
-        	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
262
-        	//$formats[$id] = 'fr24json';
263
-        	$globalSources[$id]['format'] = 'myshiptracking';
264
-        	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
-        	    exit(0);
269
-        	}
270
-            //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
-        	//$formats[$id] = 'tsv';
273
-        	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
-            }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
-    		    if ($idf !== false) {
280
-    			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
-	    $hostport = explode(':',$host);
287
-	    if (isset($hostport[1])) {
213
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
214
+			//$formats[$id] = 'planeupdatefaa';
215
+			$globalSources[$id]['format'] = 'planeupdatefaa';
216
+			//$last_exec['planeupdatefaa'] = 0;
217
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
218
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220
+				exit(0);
221
+			}
222
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
223
+			//$formats[$id] = 'phpvmacars';
224
+			$globalSources[$id]['format'] = 'phpvmacars';
225
+			//$last_exec['phpvmacars'] = 0;
226
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
+			} else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228
+			//$formats[$id] = 'phpvmacars';
229
+			$globalSources[$id]['format'] = 'vaos';
230
+			//$last_exec['phpvmacars'] = 0;
231
+			if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
233
+			//$formats[$id] = 'phpvmacars';
234
+			$globalSources[$id]['format'] = 'vam';
235
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
+			} else if (preg_match('/whazzup/i',$host)) {
237
+			//$formats[$id] = 'whazzup';
238
+			$globalSources[$id]['format'] = 'whazzup';
239
+			//$last_exec['whazzup'] = 0;
240
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
+			} else if (preg_match('/blitzortung/i',$host)) {
242
+			$globalSources[$id]['format'] = 'blitzortung';
243
+			if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
+			} else if (preg_match('/airwhere/i',$host)) {
245
+			$globalSources[$id]['format'] = 'airwhere';
246
+			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
+			} else if (preg_match('/recentpireps/i',$host)) {
248
+			//$formats[$id] = 'pirepsjson';
249
+			$globalSources[$id]['format'] = 'pirepsjson';
250
+			//$last_exec['pirepsjson'] = 0;
251
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253
+			//$formats[$id] = 'fr24json';
254
+			$globalSources[$id]['format'] = 'fr24json';
255
+			//$last_exec['fr24json'] = 0;
256
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
257
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259
+				exit(0);
260
+			}
261
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
262
+			//$formats[$id] = 'fr24json';
263
+			$globalSources[$id]['format'] = 'myshiptracking';
264
+			//$last_exec['fr24json'] = 0;
265
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
266
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268
+				exit(0);
269
+			}
270
+			//} else if (preg_match('/10001/',$host)) {
271
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272
+			//$formats[$id] = 'tsv';
273
+			$globalSources[$id]['format'] = 'tsv';
274
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275
+			}
276
+		} elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277
+			if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
279
+				if ($idf !== false) {
280
+				$httpfeeds[$id] = $idf;
281
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
+				} elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
+			} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
+			elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
+		$hostport = explode(':',$host);
287
+		if (isset($hostport[1])) {
288 288
 		$port = $hostport[1];
289 289
 		$hostn = $hostport[0];
290
-	    } else {
290
+		} else {
291 291
 		$port = $globalSources[$id]['port'];
292 292
 		$hostn = $globalSources[$id]['host'];
293
-	    }
294
-	    $Common = new Common();
295
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
-    	    } else {
298
-    		$udp = true;
299
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
-	    }
301
-	    if ($s) {
302
-    	        $sockets[$id] = $s;
303
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
293
+		}
294
+		$Common = new Common();
295
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
297
+			} else {
298
+			$udp = true;
299
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
300
+		}
301
+		if ($s) {
302
+				$sockets[$id] = $s;
303
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
305 305
 			//$formats[$id] = 'aprs';
306 306
 			$globalSources[$id]['format'] = 'aprs';
307 307
 			//$aprs_connect = 0;
308 308
 			//$use_aprs = true;
309
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
309
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310 310
 			$globalSources[$id]['format'] = 'vrstcp';
311
-    		    } elseif ($port == '10001') {
312
-        		//$formats[$id] = 'tsv';
313
-        		$globalSources[$id]['format'] = 'tsv';
314
-		    } elseif ($port == '30002') {
315
-        		//$formats[$id] = 'raw';
316
-        		$globalSources[$id]['format'] = 'raw';
317
-		    } elseif ($port == '5001') {
318
-        		//$formats[$id] = 'raw';
319
-        		$globalSources[$id]['format'] = 'flightgearmp';
320
-		    } elseif ($port == '30005') {
311
+				} elseif ($port == '10001') {
312
+				//$formats[$id] = 'tsv';
313
+				$globalSources[$id]['format'] = 'tsv';
314
+			} elseif ($port == '30002') {
315
+				//$formats[$id] = 'raw';
316
+				$globalSources[$id]['format'] = 'raw';
317
+			} elseif ($port == '5001') {
318
+				//$formats[$id] = 'raw';
319
+				$globalSources[$id]['format'] = 'flightgearmp';
320
+			} elseif ($port == '30005') {
321 321
 			// Not yet supported
322
-        		//$formats[$id] = 'beast';
323
-        		$globalSources[$id]['format'] = 'beast';
324
-		    //} else $formats[$id] = 'sbs';
325
-		    } else $globalSources[$id]['format'] = 'sbs';
326
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
322
+				//$formats[$id] = 'beast';
323
+				$globalSources[$id]['format'] = 'beast';
324
+			//} else $formats[$id] = 'sbs';
325
+			} else $globalSources[$id]['format'] = 'sbs';
326
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
327 327
 		}
328 328
 		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
329 329
 		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
330
-            } else {
330
+			} else {
331 331
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
332 332
 		sleep(10);
333 333
 		connect_all($hosts);
334
-    	    }
335
-        }
336
-    }
334
+			}
335
+		}
336
+	}
337 337
 }
338 338
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
339 339
 
@@ -356,9 +356,9 @@  discard block
 block discarded – undo
356 356
 //connect_all($globalSources);
357 357
 
358 358
 if (isset($globalProxy) && $globalProxy) {
359
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
359
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
360 360
 } else {
361
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
361
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
362 362
 }
363 363
 
364 364
 // APRS Configuration
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 	die;
368 368
 }
369 369
 foreach ($globalSources as $key => $source) {
370
-    if (!isset($source['format'])) {
371
-        $globalSources[$key]['format'] = 'auto';
372
-    }
373
-    if (isset($source['callback']) && $source['callback'] === TRUE) {
374
-        unset($globalSources[$key]);
375
-    }
370
+	if (!isset($source['format'])) {
371
+		$globalSources[$key]['format'] = 'auto';
372
+	}
373
+	if (isset($source['callback']) && $source['callback'] === TRUE) {
374
+		unset($globalSources[$key]);
375
+	}
376 376
 }
377 377
 connect_all($globalSources);
378 378
 foreach ($globalSources as $key => $source) {
379
-    if (isset($source['format']) && $source['format'] == 'aprs') {
379
+	if (isset($source['format']) && $source['format'] == 'aprs') {
380 380
 	$aprs_connect = 0;
381 381
 	$use_aprs = true;
382 382
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
383 383
 	break;
384
-    }
384
+	}
385 385
 }
386 386
 
387 387
 if ($use_aprs) {
@@ -422,173 +422,173 @@  discard block
 block discarded – undo
422 422
 
423 423
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
424 424
 while ($i > 0) {
425
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
425
+	if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426 426
 
427
-    if (!$globalDaemon) $i = $endtime-time();
428
-    // Delete old ATC
429
-    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
427
+	if (!$globalDaemon) $i = $endtime-time();
428
+	// Delete old ATC
429
+	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430 430
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
431
-        $ATC->deleteOldATC();
432
-    }
431
+		$ATC->deleteOldATC();
432
+	}
433 433
     
434
-    if (count($last_exec) == count($globalSources)) {
434
+	if (count($last_exec) == count($globalSources)) {
435 435
 	$max = $globalMinFetch;
436 436
 	foreach ($last_exec as $last) {
437
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
437
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
438 438
 	}
439 439
 	if ($max < $globalMinFetch) {
440
-	    if ($globalDebug) echo 'Sleeping...'."\n";
441
-	    sleep($globalMinFetch-$max+2);
440
+		if ($globalDebug) echo 'Sleeping...'."\n";
441
+		sleep($globalMinFetch-$max+2);
442
+	}
442 443
 	}
443
-    }
444 444
 
445 445
     
446
-    //foreach ($formats as $id => $value) {
447
-    foreach ($globalSources as $id => $value) {
446
+	//foreach ($formats as $id => $value) {
447
+	foreach ($globalSources as $id => $value) {
448 448
 	date_default_timezone_set('UTC');
449 449
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
450 450
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
451 451
 	if ($value['format'] === 'deltadbtxt' && 
452
-	    (
452
+		(
453 453
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
454 454
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
455
-	    )
455
+		)
456 456
 	) {
457
-        //$buffer = $Common->getData($hosts[$id]);
458
-        $buffer = $Common->getData($value['host']);
459
-        if ($buffer != '') $reset = 0;
460
-        $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
461
-        $buffer = explode('\n', $buffer);
462
-        foreach ($buffer as $line) {
463
-            if ($line != '' && count($line) > 7) {
464
-                $line = explode(',', $line);
465
-                $data = array();
466
-                $data['hex'] = $line[1]; // hex
467
-                $data['ident'] = $line[2]; // ident
468
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
469
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
470
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
471
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
472
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
473
-                $data['verticalrate'] = ''; // vertical rate
474
-                //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
475
-                $data['emergency'] = ''; // emergency
476
-                $data['datetime'] = date('Y-m-d H:i:s');
477
-                $data['format_source'] = 'deltadbtxt';
478
-                $data['id_source'] = $id_source;
479
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
480
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
481
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
482
-                $SI->add($data);
483
-                unset($data);
484
-            }
485
-        }
486
-        $last_exec[$id]['last'] = time();
487
-    } elseif ($value['format'] === 'radarcapejson' &&
488
-            (
489
-                (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
490
-                (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
491
-            )
492
-        ) {
493
-            //$buffer = $Common->getData($hosts[$id]);
494
-            $buffer = $Common->getData($value['host']);
495
-            if ($buffer != '') {
496
-                $all_data = json_decode($buffer,true);
497
-                foreach ($all_data as $line) {
498
-                    $data = array();
499
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
-                    $data['hex'] = $line['hex']; // hex
501
-                    $data['ident'] = $line['fli']; // ident
502
-                    $data['altitude'] = $line['alt']; // altitude
503
-                    $data['speed'] = $line['spd']; // speed
504
-                    $data['heading'] = $line['trk']; // heading
505
-                    $data['latitude'] = $line['lat']; // lat
506
-                    $data['longitude'] = $line['lon']; // long
507
-                    $data['verticalrate'] = $line['vrt']; // vertical rate
508
-                    $data['squawk'] = $line['squ']; // squawk
509
-                    $data['ground'] = $line['gda']; // ground
510
-                    $data['registration'] = $line['reg'];
511
-                    //$data['emergency'] = ''; // emergency
512
-                    $data['datetime'] = date('Y-m-d H:i:s');
513
-                    $data['format_source'] = 'radarcapejson';
514
-                    $data['id_source'] = $id_source;
515
-                    if (isset($value['name']) && $value['name'] != '') {
516
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
517
-                        else $data['source_name'] = $value['name'];
518
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
519
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
457
+		//$buffer = $Common->getData($hosts[$id]);
458
+		$buffer = $Common->getData($value['host']);
459
+		if ($buffer != '') $reset = 0;
460
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
461
+		$buffer = explode('\n', $buffer);
462
+		foreach ($buffer as $line) {
463
+			if ($line != '' && count($line) > 7) {
464
+				$line = explode(',', $line);
465
+				$data = array();
466
+				$data['hex'] = $line[1]; // hex
467
+				$data['ident'] = $line[2]; // ident
468
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
469
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
470
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
471
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
472
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
473
+				$data['verticalrate'] = ''; // vertical rate
474
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
475
+				$data['emergency'] = ''; // emergency
476
+				$data['datetime'] = date('Y-m-d H:i:s');
477
+				$data['format_source'] = 'deltadbtxt';
478
+				$data['id_source'] = $id_source;
479
+				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
480
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
481
+				if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
482
+				$SI->add($data);
483
+				unset($data);
484
+			}
485
+		}
486
+		$last_exec[$id]['last'] = time();
487
+	} elseif ($value['format'] === 'radarcapejson' &&
488
+			(
489
+				(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
490
+				(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
491
+			)
492
+		) {
493
+			//$buffer = $Common->getData($hosts[$id]);
494
+			$buffer = $Common->getData($value['host']);
495
+			if ($buffer != '') {
496
+				$all_data = json_decode($buffer,true);
497
+				foreach ($all_data as $line) {
498
+					$data = array();
499
+					$data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
500
+					$data['hex'] = $line['hex']; // hex
501
+					$data['ident'] = $line['fli']; // ident
502
+					$data['altitude'] = $line['alt']; // altitude
503
+					$data['speed'] = $line['spd']; // speed
504
+					$data['heading'] = $line['trk']; // heading
505
+					$data['latitude'] = $line['lat']; // lat
506
+					$data['longitude'] = $line['lon']; // long
507
+					$data['verticalrate'] = $line['vrt']; // vertical rate
508
+					$data['squawk'] = $line['squ']; // squawk
509
+					$data['ground'] = $line['gda']; // ground
510
+					$data['registration'] = $line['reg'];
511
+					//$data['emergency'] = ''; // emergency
512
+					$data['datetime'] = date('Y-m-d H:i:s');
513
+					$data['format_source'] = 'radarcapejson';
514
+					$data['id_source'] = $id_source;
515
+					if (isset($value['name']) && $value['name'] != '') {
516
+						if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
517
+						else $data['source_name'] = $value['name'];
518
+					} elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
519
+					if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
+					if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
521 521
 
522
-                    $SI->add($data);
523
-                    unset($data);
524
-                }
525
-            }
526
-            $last_exec[$id]['last'] = time();
522
+					$SI->add($data);
523
+					unset($data);
524
+				}
525
+			}
526
+			$last_exec[$id]['last'] = time();
527 527
 	} elseif ($value['format'] === 'aisnmeatxt' && 
528
-	    (
528
+		(
529 529
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
530 530
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
531
-	    )
531
+		)
532 532
 	) {
533
-	    date_default_timezone_set('CET');
534
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
-	    date_default_timezone_set('UTC');
536
-	    if ($buffer != '') $reset = 0;
537
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
-	    $buffer = explode('\n',$buffer);
539
-	    foreach ($buffer as $line) {
533
+		date_default_timezone_set('CET');
534
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535
+		date_default_timezone_set('UTC');
536
+		if ($buffer != '') $reset = 0;
537
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
+		$buffer = explode('\n',$buffer);
539
+		foreach ($buffer as $line) {
540 540
 		if ($line != '') {
541
-		    //echo "'".$line."'\n";
542
-		    $add = false;
543
-		    $ais_data = $AIS->parse_line(trim($line));
544
-		    $data = array();
545
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
550
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
551
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
552
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
553
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
554
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
555
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557
-		    if (isset($ais_data['timestamp'])) {
541
+			//echo "'".$line."'\n";
542
+			$add = false;
543
+			$ais_data = $AIS->parse_line(trim($line));
544
+			$data = array();
545
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
550
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
551
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
552
+			if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
553
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
554
+			if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
555
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557
+			if (isset($ais_data['timestamp'])) {
558 558
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559 559
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
560
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561
-			    $add = true;
560
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561
+				$add = true;
562 562
 			}
563
-		    } else {
563
+			} else {
564 564
 			$data['datetime'] = date('Y-m-d H:i:s');
565 565
 			$add = true;
566
-		    }
567
-		    $data['format_source'] = 'aisnmeatxt';
568
-    		    $data['id_source'] = $id_source;
569
-		    //print_r($data);
570
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
571
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
572
-		    unset($data);
566
+			}
567
+			$data['format_source'] = 'aisnmeatxt';
568
+				$data['id_source'] = $id_source;
569
+			//print_r($data);
570
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
571
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
572
+			unset($data);
573 573
 		}
574
-    	    }
575
-    	    $last_exec[$id]['last'] = time();
574
+			}
575
+			$last_exec[$id]['last'] = time();
576 576
 	} elseif ($value['format'] === 'aisnmeahttp') {
577
-	    $arr = $httpfeeds;
578
-	    $w = $e = null;
577
+		$arr = $httpfeeds;
578
+		$w = $e = null;
579 579
 	    
580
-	    if (isset($arr[$id])) {
580
+		if (isset($arr[$id])) {
581 581
 		$nn = stream_select($arr,$w,$e,$timeout);
582 582
 		if ($nn > 0) {
583
-		    foreach ($httpfeeds as $feed) {
583
+			foreach ($httpfeeds as $feed) {
584 584
 			$buffer = stream_get_line($feed,2000,"\n");
585 585
 			if ($buffer === FALSE) {
586
-			    connect_all($globalSources);
586
+				connect_all($globalSources);
587 587
 			}
588 588
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
589 589
 			$buffer = explode('\n',$buffer);
590 590
 			foreach ($buffer as $line) {
591
-			    if ($line != '') {
591
+				if ($line != '') {
592 592
 				$ais_data = $AIS->parse_line(trim($line));
593 593
 				$data = array();
594 594
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -606,117 +606,117 @@  discard block
 block discarded – undo
606 606
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607 607
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
608 608
 				if (isset($ais_data['timestamp'])) {
609
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
609
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610 610
 				} else {
611
-				    $data['datetime'] = date('Y-m-d H:i:s');
611
+					$data['datetime'] = date('Y-m-d H:i:s');
612 612
 				}
613 613
 				$data['format_source'] = 'aisnmeahttp';
614 614
 				$data['id_source'] = $id_source;
615 615
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616 616
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
617 617
 				unset($data);
618
-			    }
618
+				}
619
+			}
619 620
 			}
620
-		    }
621 621
 		} else {
622
-		    $format = $value['format'];
623
-		    if (isset($tt[$format])) $tt[$format]++;
624
-		    else $tt[$format] = 0;
625
-		    if ($tt[$format] > 30) {
622
+			$format = $value['format'];
623
+			if (isset($tt[$format])) $tt[$format]++;
624
+			else $tt[$format] = 0;
625
+			if ($tt[$format] > 30) {
626 626
 			if ($globalDebug) echo 'Reconnect...'."\n";
627 627
 			sleep(2);
628 628
 			//$sourceeen[] = $value;
629 629
 			//connect_all($sourceeen);
630 630
 			//$sourceeen = array();
631 631
 			connect_all($globalSources);
632
-		    }
632
+			}
633
+		}
633 634
 		}
634
-	    }
635 635
 	} elseif ($value['format'] === 'myshiptracking' && 
636
-	    (
636
+		(
637 637
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
638 638
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
639
-	    )
639
+		)
640 640
 	) {
641
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
642
-	    if ($buffer != '') {
641
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
642
+		if ($buffer != '') {
643 643
 		//echo $buffer;
644 644
 		$all_data = json_decode($buffer,true);
645 645
 		//print_r($all_data);
646 646
 		if (isset($all_data[0]['DATA'])) {
647
-		    foreach ($all_data[0]['DATA'] as $line) {
647
+			foreach ($all_data[0]['DATA'] as $line) {
648 648
 			if ($line != '') {
649
-			    $data = array();
650
-			    $data['ident'] = $line['NAME'];
651
-			    $data['mmsi'] = $line['MMSI'];
652
-			    if (strlen($data['mmsi']) > 9) {
649
+				$data = array();
650
+				$data['ident'] = $line['NAME'];
651
+				$data['mmsi'] = $line['MMSI'];
652
+				if (strlen($data['mmsi']) > 9) {
653 653
 				$data['mmsi'] = substr($data['mmsi'],-9);
654
-			    }
655
-			    $data['speed'] = $line['SOG'];
656
-			    $data['heading'] = $line['COG'];
657
-			    $data['latitude'] = $line['LAT'];
658
-			    $data['longitude'] = $line['LNG'];
659
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
660
-			    //$data['type_id'] = $line['TYPE'];
661
-			    $data['imo'] = $line['IMO'];
662
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
665
-			    $data['format_source'] = 'myshiptracking';
666
-			    $data['id_source'] = $id_source;
667
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
668
-			    $MI->add($data);
669
-			    unset($data);
654
+				}
655
+				$data['speed'] = $line['SOG'];
656
+				$data['heading'] = $line['COG'];
657
+				$data['latitude'] = $line['LAT'];
658
+				$data['longitude'] = $line['LNG'];
659
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
660
+				//$data['type_id'] = $line['TYPE'];
661
+				$data['imo'] = $line['IMO'];
662
+				if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
+				if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
665
+				$data['format_source'] = 'myshiptracking';
666
+				$data['id_source'] = $id_source;
667
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
668
+				$MI->add($data);
669
+				unset($data);
670
+			}
670 671
 			}
671
-		    }
672 672
 		}
673
-	    }
674
-	    $last_exec[$id]['last'] = time();
673
+		}
674
+		$last_exec[$id]['last'] = time();
675 675
 	} elseif ($value['format'] === 'boatbeaconapp' && 
676
-	    (
676
+		(
677 677
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
678 678
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
679
-	    )
679
+		)
680 680
 	) {
681
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
-	    if ($buffer != '') {
681
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
682
+		if ($buffer != '') {
683 683
 		$all_data = json_decode($buffer,true);
684 684
 		if (isset($all_data[0]['mmsi'])) {
685
-		    foreach ($all_data as $line) {
685
+			foreach ($all_data as $line) {
686 686
 			if ($line != '') {
687
-			    $data = array();
688
-			    $data['ident'] = $line['shipname'];
689
-			    $data['callsign'] = $line['callsign'];
690
-			    $data['mmsi'] = substr($line['mmsi'],-9);
691
-			    $data['speed'] = $line['sog'];
692
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693
-			    $data['latitude'] = $line['latitude'];
694
-			    $data['longitude'] = $line['longitude'];
695
-			    $data['type_id'] = $line['shiptype'];
696
-			    $data['arrival_code'] = $line['destination'];
697
-			    $data['datetime'] = $line['time'];
698
-			    $data['format_source'] = 'boatbeaconapp';
699
-			    $data['id_source'] = $id_source;
700
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
-			    $MI->add($data);
702
-			    unset($data);
687
+				$data = array();
688
+				$data['ident'] = $line['shipname'];
689
+				$data['callsign'] = $line['callsign'];
690
+				$data['mmsi'] = substr($line['mmsi'],-9);
691
+				$data['speed'] = $line['sog'];
692
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693
+				$data['latitude'] = $line['latitude'];
694
+				$data['longitude'] = $line['longitude'];
695
+				$data['type_id'] = $line['shiptype'];
696
+				$data['arrival_code'] = $line['destination'];
697
+				$data['datetime'] = $line['time'];
698
+				$data['format_source'] = 'boatbeaconapp';
699
+				$data['id_source'] = $id_source;
700
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
701
+				$MI->add($data);
702
+				unset($data);
703
+			}
703 704
 			}
704
-		    }
705 705
 		}
706 706
 		
707
-	    }
708
-    	    $last_exec[$id]['last'] = time();
707
+		}
708
+			$last_exec[$id]['last'] = time();
709 709
 	} elseif ($value['format'] === 'boatnerd' && 
710
-	    (
710
+		(
711 711
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
712 712
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
713
-	    )
713
+		)
714 714
 	) {
715
-	    $buffer = $Common->getData($value['host']);
716
-	    if ($buffer != '') {
715
+		$buffer = $Common->getData($value['host']);
716
+		if ($buffer != '') {
717 717
 		$all_data = json_decode($buffer,true);
718 718
 		if (isset($all_data['features'][0]['id'])) {
719
-		    foreach ($all_data['features'] as $line) {
719
+			foreach ($all_data['features'] as $line) {
720 720
 			print_r($line);
721 721
 			$data = array();
722 722
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
@@ -736,75 +736,75 @@  discard block
 block discarded – undo
736 736
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
737 737
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
738 738
 			unset($data);
739
-		    }
739
+			}
740 740
 		}
741 741
 		
742
-	    }
743
-    	    $last_exec[$id]['last'] = time();
742
+		}
743
+			$last_exec[$id]['last'] = time();
744 744
 	} elseif ($value['format'] === 'shipplotter' && 
745
-	    (
745
+		(
746 746
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
747 747
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
748
-	    )
748
+		)
749 749
 	) {
750
-	    if ($globalDebug) echo 'download...';
751
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
-	    if ($globalDebug) echo 'done !'."\n";
753
-	    // FIXME: Need more work
754
-	    if ($buffer != '') $reset = 0;
755
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
-	    $buffer = explode('\n',$buffer);
757
-	    foreach ($buffer as $line) {
750
+		if ($globalDebug) echo 'download...';
751
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
+		if ($globalDebug) echo 'done !'."\n";
753
+		// FIXME: Need more work
754
+		if ($buffer != '') $reset = 0;
755
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
+		$buffer = explode('\n',$buffer);
757
+		foreach ($buffer as $line) {
758 758
 		if ($line != '') {
759
-		    $data = array();
760
-		    //echo $line."\n";
761
-		    $data['mmsi'] = (int)substr($line,0,9);
762
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
-		    $data['status_id'] = substr($line,21,2);
764
-		    $data['type_id'] = substr($line,24,3);
765
-		    $data['latitude'] = substr($line,29,9);
766
-		    $data['longitude'] = substr($line,41,9);
767
-		    $data['speed'] = round(substr($line,51,5));
768
-		    //$data['course'] = substr($line,57,5);
769
-		    $data['heading'] = round(substr($line,63,3));
770
-		    //$data['draft'] = substr($line,67,4);
771
-		    //$data['length'] = substr($line,72,3);
772
-		    //$data['beam'] = substr($line,76,2);
773
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
-		    //$data['callsign'] = trim(substr($line,100,7);
775
-		    $data['arrival_code'] = substr($line,108,20);
776
-		    //$data['etaDate'] = substr($line,129,5);
777
-		    //$data['etaTime'] = substr($line,135,5);
778
-		    $data['format_source'] = 'shipplotter';
779
-    		    $data['id_source'] = $id_source;
780
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
781
-		    //print_r($data);
782
-		    //echo 'Add...'."\n";
783
-		    $MI->add($data);
784
-		    unset($data);
759
+			$data = array();
760
+			//echo $line."\n";
761
+			$data['mmsi'] = (int)substr($line,0,9);
762
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
+			$data['status_id'] = substr($line,21,2);
764
+			$data['type_id'] = substr($line,24,3);
765
+			$data['latitude'] = substr($line,29,9);
766
+			$data['longitude'] = substr($line,41,9);
767
+			$data['speed'] = round(substr($line,51,5));
768
+			//$data['course'] = substr($line,57,5);
769
+			$data['heading'] = round(substr($line,63,3));
770
+			//$data['draft'] = substr($line,67,4);
771
+			//$data['length'] = substr($line,72,3);
772
+			//$data['beam'] = substr($line,76,2);
773
+			$data['ident'] = trim(utf8_encode(substr($line,78,20)));
774
+			//$data['callsign'] = trim(substr($line,100,7);
775
+			$data['arrival_code'] = substr($line,108,20);
776
+			//$data['etaDate'] = substr($line,129,5);
777
+			//$data['etaTime'] = substr($line,135,5);
778
+			$data['format_source'] = 'shipplotter';
779
+				$data['id_source'] = $id_source;
780
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
781
+			//print_r($data);
782
+			//echo 'Add...'."\n";
783
+			$MI->add($data);
784
+			unset($data);
785 785
 		}
786
-    	    }
787
-    	    $last_exec[$id]['last'] = time();
786
+			}
787
+			$last_exec[$id]['last'] = time();
788 788
 	} elseif ($value['format'] === 'sailaway' && 
789
-	    (
789
+		(
790 790
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > 5*60))
791
-	    )
791
+		)
792 792
 	) {
793
-	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
793
+		if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
794 794
 		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
795 795
 		//echo $authsailaway;
796 796
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
797 797
 		if (isset($setcookie[1][0])) {
798
-		    $sailaway_authcookie = $setcookie[1][0];
798
+			$sailaway_authcookie = $setcookie[1][0];
799
+		}
799 800
 		}
800
-	    }
801 801
 
802
-	    if ($globalDebug) echo '! Download... ';
803
-	    for ($i =0; $i <= 1; $i++) {
802
+		if ($globalDebug) echo '! Download... ';
803
+		for ($i =0; $i <= 1; $i++) {
804 804
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
805 805
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
806
-	    if ($globalDebug) echo 'done'."\n";
807
-	    if ($buffer != '') {
806
+		if ($globalDebug) echo 'done'."\n";
807
+		if ($buffer != '') {
808 808
 		$all_data = json_decode($buffer,true);
809 809
 		if (isset($all_data['missions'])) {
810 810
 			foreach ($all_data['missions'] as $mission) {
@@ -823,19 +823,19 @@  discard block
 block discarded – undo
823 823
 					//print_r($race_data);
824 824
 					unset($racebuffer);
825 825
 					if (isset($race_data['mission'])) {
826
-					    $datar = array();
827
-					    $datar['id'] = $mission['misnr'];
828
-					    $datar['desc'] = $race_data['mission']['misdescr'];
829
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
830
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
831
-					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
832
-					    $markers = array();
833
-					    foreach ($race_data['mission']['course'] as $course) {
826
+						$datar = array();
827
+						$datar['id'] = $mission['misnr'];
828
+						$datar['desc'] = $race_data['mission']['misdescr'];
829
+						$datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
830
+						$datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
831
+						$datar['startdate'] = $race_data['mission']['misstartdatetime'];
832
+						$markers = array();
833
+						foreach ($race_data['mission']['course'] as $course) {
834 834
 						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
835
-					    }
836
-					    $datar['markers'] = json_encode($markers);
837
-					    //print_r($datar);
838
-					    $MI->race_add($datar);
835
+						}
836
+						$datar['markers'] = json_encode($markers);
837
+						//print_r($datar);
838
+						$MI->race_add($datar);
839 839
 					}
840 840
 				}
841 841
 				if ($bufferm != '') {
@@ -900,35 +900,35 @@  discard block
 block discarded – undo
900 900
 				sleep(10);
901 901
 			}
902 902
 		}
903
-	    }
904
-	    sleep(5);
905
-	    }
906
-    	    $last_exec[$id]['last'] = time();
903
+		}
904
+		sleep(5);
905
+		}
906
+			$last_exec[$id]['last'] = time();
907 907
 	//} elseif (($value === 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value === 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
908 908
 	} elseif (
909
-	    (
909
+		(
910 910
 		$value['format'] === 'whazzup' && 
911 911
 		(
912
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
913
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
912
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
913
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
914 914
 		)
915
-	    ) || (
915
+		) || (
916 916
 		$value['format'] === 'vatsimtxt' && 
917 917
 		(
918
-		    (isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
919
-		    (!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
918
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
919
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
920
+		)
920 921
 		)
921
-	    )
922 922
 	) {
923
-	    //$buffer = $Common->getData($hosts[$id]);
924
-	    $buffer = $Common->getData($value['host']);
925
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
926
-	    $buffer = explode('\n',$buffer);
927
-	    $reset = 0;
928
-	    foreach ($buffer as $line) {
929
-    		if ($line != '') {
930
-    		    $line = explode(':', $line);
931
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
923
+		//$buffer = $Common->getData($hosts[$id]);
924
+		$buffer = $Common->getData($value['host']);
925
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
926
+		$buffer = explode('\n',$buffer);
927
+		$reset = 0;
928
+		foreach ($buffer as $line) {
929
+			if ($line != '') {
930
+				$line = explode(':', $line);
931
+				if (count($line) > 30 && $line[0] != 'callsign') {
932 932
 			$data = array();
933 933
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
934 934
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -941,37 +941,37 @@  discard block
 block discarded – undo
941 941
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
942 942
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
943 943
 			$data['latitude'] = $line[5]; // lat
944
-	        	$data['longitude'] = $line[6]; // long
945
-	        	$data['verticalrate'] = ''; // vertical rate
946
-	        	$data['squawk'] = ''; // squawk
947
-	        	$data['emergency'] = ''; // emergency
948
-	        	$data['waypoints'] = $line[30];
944
+				$data['longitude'] = $line[6]; // long
945
+				$data['verticalrate'] = ''; // vertical rate
946
+				$data['squawk'] = ''; // squawk
947
+				$data['emergency'] = ''; // emergency
948
+				$data['waypoints'] = $line[30];
949 949
 			$data['datetime'] = date('Y-m-d H:i:s');
950 950
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
951 951
 			//if (isset($line[37])) $data['last_update'] = $line[37];
952
-		        $data['departure_airport_icao'] = $line[11];
953
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
954
-		        $data['arrival_airport_icao'] = $line[13];
952
+				$data['departure_airport_icao'] = $line[11];
953
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
954
+				$data['arrival_airport_icao'] = $line[13];
955 955
 			$data['frequency'] = $line[4];
956 956
 			$data['type'] = $line[18];
957 957
 			$data['range'] = $line[19];
958 958
 			if (isset($line[35])) $data['info'] = $line[35];
959
-    			$data['id_source'] = $id_source;
960
-	    		//$data['arrival_airport_time'] = ;
961
-	    		if ($line[9] != '') {
962
-	    		    $aircraft_data = explode('/',$line[9]);
963
-	    		    if (isset($aircraft_data[1])) {
964
-	    			$data['aircraft_icao'] = $aircraft_data[1];
965
-	    		    }
966
-        		}
967
-	    		/*
959
+				$data['id_source'] = $id_source;
960
+				//$data['arrival_airport_time'] = ;
961
+				if ($line[9] != '') {
962
+					$aircraft_data = explode('/',$line[9]);
963
+					if (isset($aircraft_data[1])) {
964
+					$data['aircraft_icao'] = $aircraft_data[1];
965
+					}
966
+				}
967
+				/*
968 968
 	    		if ($value === 'whazzup') $data['format_source'] = 'whazzup';
969 969
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
970 970
 	    		*/
971
-	    		$data['format_source'] = $value['format'];
971
+				$data['format_source'] = $value['format'];
972 972
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
973 973
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
974
-    			if ($line[3] === 'PILOT') $SI->add($data);
974
+				if ($line[3] === 'PILOT') $SI->add($data);
975 975
 			elseif ($line[3] === 'ATC') {
976 976
 				//print_r($data);
977 977
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -992,21 +992,21 @@  discard block
 block discarded – undo
992 992
 					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
993 993
 				}
994 994
 			}
995
-    			unset($data);
996
-    		    }
997
-    		}
998
-    	    }
999
-    	    //if ($value === 'whazzup') $last_exec['whazzup'] = time();
1000
-    	    //elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1001
-    	    $last_exec[$id]['last'] = time();
1002
-    	} elseif ($value['format'] === 'airwhere' && 
1003
-    	    (
1004
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1005
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1006
-    	    )
1007
-    	) {
1008
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1009
-	    if ($buffer != '') {
995
+				unset($data);
996
+				}
997
+			}
998
+			}
999
+			//if ($value === 'whazzup') $last_exec['whazzup'] = time();
1000
+			//elseif ($value === 'vatsimtxt') $last_exec['vatsimtxt'] = time();
1001
+			$last_exec[$id]['last'] = time();
1002
+		} elseif ($value['format'] === 'airwhere' && 
1003
+			(
1004
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1005
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1006
+			)
1007
+		) {
1008
+		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1009
+		if ($buffer != '') {
1010 1010
 		$all_data = simplexml_load_string($buffer);
1011 1011
 		foreach($all_data->children() as $childdata) {
1012 1012
 			$data = array();
@@ -1028,10 +1028,10 @@  discard block
 block discarded – undo
1028 1028
 			$SI->add($data);
1029 1029
 			unset($data);
1030 1030
 		}
1031
-	    }
1032
-	    $Source->deleteOldLocationByType('gs');
1033
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1034
-	    if ($buffer != '') {
1031
+		}
1032
+		$Source->deleteOldLocationByType('gs');
1033
+		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1034
+		if ($buffer != '') {
1035 1035
 		$all_data = simplexml_load_string($buffer);
1036 1036
 		foreach($all_data->children() as $childdata) {
1037 1037
 			$data = array();
@@ -1049,8 +1049,8 @@  discard block
 block discarded – undo
1049 1049
 			}
1050 1050
 			unset($data);
1051 1051
 		}
1052
-	    }
1053
-	    $last_exec[$id]['last'] = time();
1052
+		}
1053
+		$last_exec[$id]['last'] = time();
1054 1054
 	/*
1055 1055
 	} if ($value['format'] === 'aircraftlistjson') {
1056 1056
 	    print_r($globalSources);
@@ -1058,17 +1058,17 @@  discard block
 block discarded – undo
1058 1058
 	    echo $globalMinFetch;
1059 1059
 	*/
1060 1060
 	} elseif ($value['format'] === 'aircraftlistjson' && 
1061
-	    (
1061
+		(
1062 1062
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1063 1063
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1064
-	    )
1064
+		)
1065 1065
 	) {
1066
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1067
-	    if ($buffer != '') {
1068
-	        $all_data = json_decode($buffer,true);
1066
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
1067
+		if ($buffer != '') {
1068
+			$all_data = json_decode($buffer,true);
1069 1069
 		if (isset($all_data['acList'])) {
1070
-		    $reset = 0;
1071
-		    foreach ($all_data['acList'] as $line) {
1070
+			$reset = 0;
1071
+			foreach ($all_data['acList'] as $line) {
1072 1072
 			$data = array();
1073 1073
 			$data['hex'] = $line['Icao']; // hex
1074 1074
 			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1091,10 +1091,10 @@  discard block
 block discarded – undo
1091 1091
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1092 1092
 			if (isset($data['latitude'])) $SI->add($data);
1093 1093
 			unset($data);
1094
-		    }
1094
+			}
1095 1095
 		} elseif (is_array($all_data)) {
1096
-		    $reset = 0;
1097
-		    foreach ($all_data as $line) {
1096
+			$reset = 0;
1097
+			foreach ($all_data as $line) {
1098 1098
 			$data = array();
1099 1099
 			$data['hex'] = $line['hex']; // hex
1100 1100
 			$data['ident'] = $line['flight']; // ident
@@ -1114,291 +1114,291 @@  discard block
 block discarded – undo
1114 1114
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1115 1115
 			$SI->add($data);
1116 1116
 			unset($data);
1117
-		    }
1117
+			}
1118 1118
 		}
1119
-	    } elseif ($globalDebug) echo 'No data'."\n";
1120
-    	    //$last_exec['aircraftlistjson'] = time();
1121
-    	    $last_exec[$id]['last'] = time();
1122
-    	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1123
-    	} elseif ($value['format'] === 'planeupdatefaa' && 
1124
-    	    (
1125
-    		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1126
-    		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1127
-    	    )
1128
-    	) {
1129
-	    $buffer = $Common->getData($value['host']);
1130
-	    $all_data = json_decode($buffer,true);
1131
-	    if (isset($all_data['planes'])) {
1119
+		} elseif ($globalDebug) echo 'No data'."\n";
1120
+			//$last_exec['aircraftlistjson'] = time();
1121
+			$last_exec[$id]['last'] = time();
1122
+		//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
1123
+		} elseif ($value['format'] === 'planeupdatefaa' && 
1124
+			(
1125
+			(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1126
+			(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1127
+			)
1128
+		) {
1129
+		$buffer = $Common->getData($value['host']);
1130
+		$all_data = json_decode($buffer,true);
1131
+		if (isset($all_data['planes'])) {
1132 1132
 		$reset = 0;
1133 1133
 		foreach ($all_data['planes'] as $key => $line) {
1134
-		    $data = array();
1135
-		    $data['hex'] = $key; // hex
1136
-		    $data['ident'] = $line[3]; // ident
1137
-		    $data['altitude'] = $line[6]; // altitude
1138
-		    $data['speed'] = $line[8]; // speed
1139
-		    $data['heading'] = $line[7]; // heading
1140
-		    $data['latitude'] = $line[4]; // lat
1141
-		    $data['longitude'] = $line[5]; // long
1142
-		    //$data['verticalrate'] = $line[]; // verticale rate
1143
-		    $data['squawk'] = $line[10]; // squawk
1144
-		    $data['emergency'] = ''; // emergency
1145
-		    $data['registration'] = $line[2];
1146
-		    $data['aircraft_icao'] = $line[0];
1147
-		    $deparr = explode('-',$line[1]);
1148
-		    if (count($deparr) === 2) {
1134
+			$data = array();
1135
+			$data['hex'] = $key; // hex
1136
+			$data['ident'] = $line[3]; // ident
1137
+			$data['altitude'] = $line[6]; // altitude
1138
+			$data['speed'] = $line[8]; // speed
1139
+			$data['heading'] = $line[7]; // heading
1140
+			$data['latitude'] = $line[4]; // lat
1141
+			$data['longitude'] = $line[5]; // long
1142
+			//$data['verticalrate'] = $line[]; // verticale rate
1143
+			$data['squawk'] = $line[10]; // squawk
1144
+			$data['emergency'] = ''; // emergency
1145
+			$data['registration'] = $line[2];
1146
+			$data['aircraft_icao'] = $line[0];
1147
+			$deparr = explode('-',$line[1]);
1148
+			if (count($deparr) === 2) {
1149 1149
 			$data['departure_airport_icao'] = $deparr[0];
1150 1150
 			$data['arrival_airport_icao'] = $deparr[1];
1151
-		    }
1152
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1153
-	    	    $data['format_source'] = 'planeupdatefaa';
1154
-    		    $data['id_source'] = $id_source;
1155
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1156
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1157
-		    $SI->add($data);
1158
-		    unset($data);
1151
+			}
1152
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1153
+				$data['format_source'] = 'planeupdatefaa';
1154
+				$data['id_source'] = $id_source;
1155
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1156
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1157
+			$SI->add($data);
1158
+			unset($data);
1159
+		}
1159 1160
 		}
1160
-	    }
1161
-	    //$last_exec['planeupdatefaa'] = time();
1162
-	    $last_exec[$id]['last'] = time();
1161
+		//$last_exec['planeupdatefaa'] = time();
1162
+		$last_exec[$id]['last'] = time();
1163 1163
 	} elseif ($value['format'] === 'opensky' && 
1164
-	    (
1164
+		(
1165 1165
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1166 1166
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1167
-	    )
1167
+		)
1168 1168
 	) {
1169
-	    $buffer = $Common->getData($value['host']);
1170
-	    $all_data = json_decode($buffer,true);
1171
-	    if (isset($all_data['states'])) {
1169
+		$buffer = $Common->getData($value['host']);
1170
+		$all_data = json_decode($buffer,true);
1171
+		if (isset($all_data['states'])) {
1172 1172
 		$reset = 0;
1173 1173
 		foreach ($all_data['states'] as $key => $line) {
1174
-		    $data = array();
1175
-		    $data['hex'] = $line[0]; // hex
1176
-		    $data['ident'] = trim($line[1]); // ident
1177
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
1178
-		    $data['speed'] = round($line[9]*1.94384); // speed
1179
-		    $data['heading'] = round($line[10]); // heading
1180
-		    $data['latitude'] = $line[6]; // lat
1181
-		    $data['longitude'] = $line[5]; // long
1182
-		    $data['verticalrate'] = $line[11]; // verticale rate
1183
-		    //$data['squawk'] = $line[10]; // squawk
1184
-		    //$data['emergency'] = ''; // emergency
1185
-		    //$data['registration'] = $line[2];
1186
-		    //$data['aircraft_icao'] = $line[0];
1187
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1188
-		    $data['format_source'] = 'opensky';
1189
-		    $data['id_source'] = $id_source;
1190
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1191
-		    $SI->add($data);
1192
-		    unset($data);
1174
+			$data = array();
1175
+			$data['hex'] = $line[0]; // hex
1176
+			$data['ident'] = trim($line[1]); // ident
1177
+			$data['altitude'] = round($line[7]*3.28084); // altitude
1178
+			$data['speed'] = round($line[9]*1.94384); // speed
1179
+			$data['heading'] = round($line[10]); // heading
1180
+			$data['latitude'] = $line[6]; // lat
1181
+			$data['longitude'] = $line[5]; // long
1182
+			$data['verticalrate'] = $line[11]; // verticale rate
1183
+			//$data['squawk'] = $line[10]; // squawk
1184
+			//$data['emergency'] = ''; // emergency
1185
+			//$data['registration'] = $line[2];
1186
+			//$data['aircraft_icao'] = $line[0];
1187
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1188
+			$data['format_source'] = 'opensky';
1189
+			$data['id_source'] = $id_source;
1190
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1191
+			$SI->add($data);
1192
+			unset($data);
1193 1193
 		}
1194
-	    }
1195
-	    //$last_exec['planeupdatefaa'] = time();
1196
-	    $last_exec[$id]['last'] = time();
1194
+		}
1195
+		//$last_exec['planeupdatefaa'] = time();
1196
+		$last_exec[$id]['last'] = time();
1197 1197
 	} elseif ($value['format'] === 'aircraftjson' && 
1198
-	    (
1198
+		(
1199 1199
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1200 1200
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1201
-	    )
1201
+		)
1202 1202
 	) {
1203
-	    $buffer = $Common->getData($value['host']);
1204
-	    $all_data = json_decode($buffer,true);
1205
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1203
+		$buffer = $Common->getData($value['host']);
1204
+		$all_data = json_decode($buffer,true);
1205
+		if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1206 1206
 		$reset = 0;
1207 1207
 		foreach ($all_data['aircraft'] as $key => $line) {
1208
-		    $data = array();
1209
-		    // add support for ground vehicule with ~ in front of hex
1210
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1211
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1212
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1213
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1214
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1215
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1216
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1217
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1218
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1219
-		    //$data['emergency'] = ''; // emergency
1220
-		    //$data['registration'] = $line[2];
1221
-		    //$data['aircraft_icao'] = $line[0];
1222
-		    $data['datetime'] = date('Y-m-d H:i:s');
1223
-		    $data['format_source'] = 'aircraftjson';
1224
-		    $data['id_source'] = $id_source;
1225
-		    if (isset($value['name']) && $value['name'] != '') {
1226
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1227
-			    else $data['source_name'] = $value['name'];
1228
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1229
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1230
-		    $SI->add($data);
1231
-		    unset($data);
1208
+			$data = array();
1209
+			// add support for ground vehicule with ~ in front of hex
1210
+			if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1211
+			if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1212
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1213
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1214
+			if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1215
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1216
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1217
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1218
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1219
+			//$data['emergency'] = ''; // emergency
1220
+			//$data['registration'] = $line[2];
1221
+			//$data['aircraft_icao'] = $line[0];
1222
+			$data['datetime'] = date('Y-m-d H:i:s');
1223
+			$data['format_source'] = 'aircraftjson';
1224
+			$data['id_source'] = $id_source;
1225
+			if (isset($value['name']) && $value['name'] != '') {
1226
+				if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1227
+				else $data['source_name'] = $value['name'];
1228
+			} elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1229
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1230
+			$SI->add($data);
1231
+			unset($data);
1232
+		}
1232 1233
 		}
1233
-	    }
1234
-	    //$last_exec['planeupdatefaa'] = time();
1235
-	    $last_exec[$id]['last'] = time();
1234
+		//$last_exec['planeupdatefaa'] = time();
1235
+		$last_exec[$id]['last'] = time();
1236 1236
 	} elseif ($value['format'] === 'planefinderclient' && 
1237
-	    (
1237
+		(
1238 1238
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1239 1239
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1240
-	    )
1240
+		)
1241 1241
 	) {
1242
-	    $buffer = $Common->getData($value['host']);
1243
-	    $all_data = json_decode($buffer,true);
1244
-	    if (isset($all_data['aircraft'])) {
1242
+		$buffer = $Common->getData($value['host']);
1243
+		$all_data = json_decode($buffer,true);
1244
+		if (isset($all_data['aircraft'])) {
1245 1245
 		$reset = 0;
1246 1246
 		foreach ($all_data['aircraft'] as $key => $line) {
1247
-		    $data = array();
1248
-		    $data['hex'] = $key; // hex
1249
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1250
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1251
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1252
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1253
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1254
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1255
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1256
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1257
-		    //$data['emergency'] = ''; // emergency
1258
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1259
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1260
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1261
-		    $data['format_source'] = 'planefinderclient';
1262
-		    $data['id_source'] = $id_source;
1263
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1264
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1265
-		    $SI->add($data);
1266
-		    unset($data);
1247
+			$data = array();
1248
+			$data['hex'] = $key; // hex
1249
+			if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1250
+			if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1251
+			if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1252
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1253
+			if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1254
+			if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1255
+			if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1256
+			if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1257
+			//$data['emergency'] = ''; // emergency
1258
+			if (isset($line['reg'])) $data['registration'] = $line['reg'];
1259
+			if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1260
+			$data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1261
+			$data['format_source'] = 'planefinderclient';
1262
+			$data['id_source'] = $id_source;
1263
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1264
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1265
+			$SI->add($data);
1266
+			unset($data);
1267 1267
 		}
1268
-	    }
1269
-	    $last_exec[$id]['last'] = time();
1268
+		}
1269
+		$last_exec[$id]['last'] = time();
1270 1270
 	//} elseif ($value === 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
1271 1271
 	} elseif ($value['format'] === 'fr24json' && 
1272
-	    (
1272
+		(
1273 1273
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1274 1274
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1275
-	    )
1275
+		)
1276 1276
 	) {
1277
-	    //$buffer = $Common->getData($hosts[$id]);
1278
-	    $buffer = $Common->getData($value['host']);
1279
-	    $all_data = json_decode($buffer,true);
1280
-	    if (!empty($all_data)) $reset = 0;
1281
-	    foreach ($all_data as $key => $line) {
1277
+		//$buffer = $Common->getData($hosts[$id]);
1278
+		$buffer = $Common->getData($value['host']);
1279
+		$all_data = json_decode($buffer,true);
1280
+		if (!empty($all_data)) $reset = 0;
1281
+		foreach ($all_data as $key => $line) {
1282 1282
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1283
-		    $data = array();
1284
-		    $data['hex'] = $line[0];
1285
-		    $data['ident'] = $line[16]; //$line[13]
1286
-	    	    $data['altitude'] = $line[4]; // altitude
1287
-	    	    $data['speed'] = $line[5]; // speed
1288
-	    	    $data['heading'] = $line[3]; // heading
1289
-	    	    $data['latitude'] = $line[1]; // lat
1290
-	    	    $data['longitude'] = $line[2]; // long
1291
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
1292
-	    	    $data['squawk'] = $line[6]; // squawk
1293
-	    	    $data['aircraft_icao'] = $line[8];
1294
-	    	    $data['registration'] = $line[9];
1295
-		    $data['departure_airport_iata'] = $line[11];
1296
-		    $data['arrival_airport_iata'] = $line[12];
1297
-	    	    $data['emergency'] = ''; // emergency
1298
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1299
-	    	    $data['format_source'] = 'fr24json';
1300
-    		    $data['id_source'] = $id_source;
1301
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1302
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1303
-		    $SI->add($data);
1304
-		    unset($data);
1283
+			$data = array();
1284
+			$data['hex'] = $line[0];
1285
+			$data['ident'] = $line[16]; //$line[13]
1286
+				$data['altitude'] = $line[4]; // altitude
1287
+				$data['speed'] = $line[5]; // speed
1288
+				$data['heading'] = $line[3]; // heading
1289
+				$data['latitude'] = $line[1]; // lat
1290
+				$data['longitude'] = $line[2]; // long
1291
+				$data['verticalrate'] = $line[15]; // verticale rate
1292
+				$data['squawk'] = $line[6]; // squawk
1293
+				$data['aircraft_icao'] = $line[8];
1294
+				$data['registration'] = $line[9];
1295
+			$data['departure_airport_iata'] = $line[11];
1296
+			$data['arrival_airport_iata'] = $line[12];
1297
+				$data['emergency'] = ''; // emergency
1298
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1299
+				$data['format_source'] = 'fr24json';
1300
+				$data['id_source'] = $id_source;
1301
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1302
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1303
+			$SI->add($data);
1304
+			unset($data);
1305 1305
 		}
1306
-	    }
1307
-	    //$last_exec['fr24json'] = time();
1308
-	    $last_exec[$id]['last'] = time();
1306
+		}
1307
+		//$last_exec['fr24json'] = time();
1308
+		$last_exec[$id]['last'] = time();
1309 1309
 	//} elseif ($value === 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
1310 1310
 	} elseif ($value['format'] === 'radarvirtueljson' && 
1311
-	    (
1311
+		(
1312 1312
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1313 1313
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1314
-	    )
1314
+		)
1315 1315
 	) {
1316
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1317
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1318
-	    //echo $buffer;
1319
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1320
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1321
-	    $all_data = json_decode($buffer,true);
1322
-	    if (json_last_error() != JSON_ERROR_NONE) {
1316
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1317
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
1318
+		//echo $buffer;
1319
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
1320
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1321
+		$all_data = json_decode($buffer,true);
1322
+		if (json_last_error() != JSON_ERROR_NONE) {
1323 1323
 		die(json_last_error_msg());
1324
-	    }
1325
-	    if (isset($all_data['mrkrs'])) {
1324
+		}
1325
+		if (isset($all_data['mrkrs'])) {
1326 1326
 		$reset = 0;
1327 1327
 		foreach ($all_data['mrkrs'] as $key => $line) {
1328
-		    if (isset($line['inf'])) {
1328
+			if (isset($line['inf'])) {
1329 1329
 			$data = array();
1330 1330
 			$data['hex'] = $line['inf']['ia'];
1331 1331
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1332
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1333
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1334
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1335
-	    		$data['latitude'] = $line['pt'][0]; // lat
1336
-	    		$data['longitude'] = $line['pt'][1]; // long
1337
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1338
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1339
-	    		//$data['aircraft_icao'] = $line[8];
1340
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1332
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1333
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1334
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1335
+				$data['latitude'] = $line['pt'][0]; // lat
1336
+				$data['longitude'] = $line['pt'][1]; // long
1337
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1338
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1339
+				//$data['aircraft_icao'] = $line[8];
1340
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1341 1341
 			//$data['departure_airport_iata'] = $line[11];
1342 1342
 			//$data['arrival_airport_iata'] = $line[12];
1343
-	    		//$data['emergency'] = ''; // emergency
1343
+				//$data['emergency'] = ''; // emergency
1344 1344
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1345
-	    		$data['format_source'] = 'radarvirtueljson';
1346
-    			$data['id_source'] = $id_source;
1345
+				$data['format_source'] = 'radarvirtueljson';
1346
+				$data['id_source'] = $id_source;
1347 1347
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1348 1348
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1349 1349
 			$SI->add($data);
1350 1350
 			unset($data);
1351
-		    }
1351
+			}
1352 1352
 		}
1353
-	    }
1354
-	    //$last_exec['radarvirtueljson'] = time();
1355
-	    $last_exec[$id]['last'] = time();
1353
+		}
1354
+		//$last_exec['radarvirtueljson'] = time();
1355
+		$last_exec[$id]['last'] = time();
1356 1356
 	//} elseif ($value === 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
1357 1357
 	} elseif ($value['format'] === 'pirepsjson' && 
1358
-	    (
1358
+		(
1359 1359
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1360 1360
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1361
-	    )
1361
+		)
1362 1362
 	) {
1363
-	    //$buffer = $Common->getData($hosts[$id]);
1364
-	    $buffer = $Common->getData($value['host'].'?'.time());
1365
-	    $all_data = json_decode(utf8_encode($buffer),true);
1363
+		//$buffer = $Common->getData($hosts[$id]);
1364
+		$buffer = $Common->getData($value['host'].'?'.time());
1365
+		$all_data = json_decode(utf8_encode($buffer),true);
1366 1366
 	    
1367
-	    if (isset($all_data['pireps'])) {
1367
+		if (isset($all_data['pireps'])) {
1368 1368
 		$reset = 0;
1369
-	        foreach ($all_data['pireps'] as $line) {
1370
-		    $data = array();
1371
-		    $data['id'] = $line['id'];
1372
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1373
-		    $data['ident'] = $line['callsign']; // ident
1374
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1375
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1376
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1377
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1378
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1379
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1380
-		    $data['latitude'] = $line['lat']; // lat
1381
-		    $data['longitude'] = $line['lon']; // long
1382
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1383
-		    //$data['squawk'] = $line['squawk']; // squawk
1384
-		    //$data['emergency'] = ''; // emergency
1385
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1386
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1387
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1388
-		    //$data['arrival_airport_time'] = $line['arrtime'];
1389
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1390
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1391
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1392
-		    else $data['info'] = '';
1393
-		    $data['format_source'] = 'pireps';
1394
-    		    $data['id_source'] = $id_source;
1395
-		    $data['datetime'] = date('Y-m-d H:i:s');
1396
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1397
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1398
-		    if ($line['icon'] === 'plane') {
1369
+			foreach ($all_data['pireps'] as $line) {
1370
+			$data = array();
1371
+			$data['id'] = $line['id'];
1372
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1373
+			$data['ident'] = $line['callsign']; // ident
1374
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1375
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1376
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1377
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1378
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1379
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1380
+			$data['latitude'] = $line['lat']; // lat
1381
+			$data['longitude'] = $line['lon']; // long
1382
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
1383
+			//$data['squawk'] = $line['squawk']; // squawk
1384
+			//$data['emergency'] = ''; // emergency
1385
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1386
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1387
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1388
+			//$data['arrival_airport_time'] = $line['arrtime'];
1389
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1390
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1391
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
1392
+			else $data['info'] = '';
1393
+			$data['format_source'] = 'pireps';
1394
+				$data['id_source'] = $id_source;
1395
+			$data['datetime'] = date('Y-m-d H:i:s');
1396
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1397
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1398
+			if ($line['icon'] === 'plane') {
1399 1399
 			$SI->add($data);
1400
-		    //    print_r($data);
1401
-    		    } elseif ($line['icon'] === 'ct') {
1400
+			//    print_r($data);
1401
+				} elseif ($line['icon'] === 'ct') {
1402 1402
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1403 1403
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1404 1404
 			$typec = substr($data['ident'],-3);
@@ -1413,209 +1413,209 @@  discard block
 block discarded – undo
1413 1413
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1414 1414
 			else $data['type'] = 'Observer';
1415 1415
 			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1416
-		    }
1417
-		    unset($data);
1416
+			}
1417
+			unset($data);
1418 1418
 		}
1419
-	    }
1420
-	    //$last_exec['pirepsjson'] = time();
1421
-	    $last_exec[$id]['last'] = time();
1419
+		}
1420
+		//$last_exec['pirepsjson'] = time();
1421
+		$last_exec[$id]['last'] = time();
1422 1422
 	//} elseif ($value === 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
1423 1423
 	} elseif ($value['format'] === 'phpvmacars' && 
1424
-	    (
1424
+		(
1425 1425
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1426 1426
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1427
-	    )
1427
+		)
1428 1428
 	) {
1429
-	    //$buffer = $Common->getData($hosts[$id]);
1430
-	    if ($globalDebug) echo 'Get Data...'."\n";
1431
-	    $buffer = $Common->getData($value['host']);
1432
-	    $all_data = json_decode($buffer,true);
1433
-	    if ($buffer != '' && is_array($all_data)) {
1429
+		//$buffer = $Common->getData($hosts[$id]);
1430
+		if ($globalDebug) echo 'Get Data...'."\n";
1431
+		$buffer = $Common->getData($value['host']);
1432
+		$all_data = json_decode($buffer,true);
1433
+		if ($buffer != '' && is_array($all_data)) {
1434 1434
 		$reset = 0;
1435 1435
 		foreach ($all_data as $line) {
1436
-	    	    $data = array();
1437
-	    	    //$data['id'] = $line['id']; // id not usable
1438
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1439
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1440
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1441
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1442
-	    	    $data['ident'] = $line['flightnum']; // ident
1443
-	    	    $data['altitude'] = $line['alt']; // altitude
1444
-	    	    $data['speed'] = $line['gs']; // speed
1445
-	    	    $data['heading'] = $line['heading']; // heading
1446
-	    	    $data['latitude'] = $line['lat']; // lat
1447
-	    	    $data['longitude'] = $line['lng']; // long
1448
-	    	    $data['verticalrate'] = ''; // verticale rate
1449
-	    	    $data['squawk'] = ''; // squawk
1450
-	    	    $data['emergency'] = ''; // emergency
1451
-	    	    //$data['datetime'] = $line['lastupdate'];
1452
-	    	    //$data['last_update'] = $line['lastupdate'];
1453
-	    	    if (isset($value['timezone'])) {
1454
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1455
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1456
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1457
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1458
-	    	    $data['departure_airport_icao'] = $line['depicao'];
1459
-	    	    $data['departure_airport_time'] = $line['deptime'];
1460
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
1461
-    		    $data['arrival_airport_time'] = $line['arrtime'];
1462
-    		    if (isset($line['registration'])) {
1463
-    			$data['registration'] = $line['registration'];
1464
-    			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1465
-    		    } else $data['registration'] = $line['aircraft'];
1466
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1467
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1468
-		    if (isset($line['aircraftname'])) {
1436
+				$data = array();
1437
+				//$data['id'] = $line['id']; // id not usable
1438
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1439
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1440
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1441
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1442
+				$data['ident'] = $line['flightnum']; // ident
1443
+				$data['altitude'] = $line['alt']; // altitude
1444
+				$data['speed'] = $line['gs']; // speed
1445
+				$data['heading'] = $line['heading']; // heading
1446
+				$data['latitude'] = $line['lat']; // lat
1447
+				$data['longitude'] = $line['lng']; // long
1448
+				$data['verticalrate'] = ''; // verticale rate
1449
+				$data['squawk'] = ''; // squawk
1450
+				$data['emergency'] = ''; // emergency
1451
+				//$data['datetime'] = $line['lastupdate'];
1452
+				//$data['last_update'] = $line['lastupdate'];
1453
+				if (isset($value['timezone'])) {
1454
+				$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1455
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1456
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1457
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1458
+				$data['departure_airport_icao'] = $line['depicao'];
1459
+				$data['departure_airport_time'] = $line['deptime'];
1460
+				$data['arrival_airport_icao'] = $line['arricao'];
1461
+				$data['arrival_airport_time'] = $line['arrtime'];
1462
+				if (isset($line['registration'])) {
1463
+				$data['registration'] = $line['registration'];
1464
+				//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1465
+				} else $data['registration'] = $line['aircraft'];
1466
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1467
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1468
+			if (isset($line['aircraftname'])) {
1469 1469
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1470 1470
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1471
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1472
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1473
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1474
-	    		else {
1475
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1476
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1477
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1478
-	    		}
1479
-	    	    }
1480
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1481
-    		    $data['id_source'] = $id_source;
1482
-	    	    $data['format_source'] = 'phpvmacars';
1483
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1484
-		    $SI->add($data);
1485
-		    unset($data);
1471
+				$aircraft_data = explode('-',$line['aircraftname']);
1472
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1473
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1474
+				else {
1475
+					$aircraft_data = explode(' ',$line['aircraftname']);
1476
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1477
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1478
+				}
1479
+				}
1480
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1481
+				$data['id_source'] = $id_source;
1482
+				$data['format_source'] = 'phpvmacars';
1483
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1484
+			$SI->add($data);
1485
+			unset($data);
1486 1486
 		}
1487 1487
 		if ($globalDebug) echo 'No more data...'."\n";
1488 1488
 		unset($buffer);
1489 1489
 		unset($all_data);
1490
-	    }
1491
-	    //$last_exec['phpvmacars'] = time();
1492
-	    $last_exec[$id]['last'] = time();
1490
+		}
1491
+		//$last_exec['phpvmacars'] = time();
1492
+		$last_exec[$id]['last'] = time();
1493 1493
 	} elseif ($value['format'] === 'vaos' && 
1494
-	    (
1494
+		(
1495 1495
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1496 1496
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1497
-	    )
1497
+		)
1498 1498
 	) {
1499
-	    //$buffer = $Common->getData($hosts[$id]);
1500
-	    if ($globalDebug) echo 'Get Data...'."\n";
1501
-	    $buffer = $Common->getData($value['host']);
1502
-	    $all_data = json_decode($buffer,true);
1503
-	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1499
+		//$buffer = $Common->getData($hosts[$id]);
1500
+		if ($globalDebug) echo 'Get Data...'."\n";
1501
+		$buffer = $Common->getData($value['host']);
1502
+		$all_data = json_decode($buffer,true);
1503
+		if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1504 1504
 		$reset = 0;
1505 1505
 		foreach ($all_data['ACARSData'] as $line) {
1506
-		    //print_r($line);
1507
-	    	    $data = array();
1508
-	    	    //$data['id'] = $line['id']; // id not usable
1509
-	    	    $data['id'] = $line['id'];
1510
-	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1511
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1512
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1513
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1514
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1515
-	    	    $data['altitude'] = $line['altitude']; // altitude
1516
-	    	    $data['speed'] = $line['groundspeed']; // speed
1517
-	    	    $data['heading'] = $line['heading']; // heading
1518
-	    	    $data['latitude'] = $line['lat']; // lat
1519
-	    	    $data['longitude'] = $line['lon']; // long
1520
-	    	    //$data['verticalrate'] = ''; // verticale rate
1521
-	    	    //$data['squawk'] = ''; // squawk
1522
-	    	    //$data['emergency'] = ''; // emergency
1523
-	    	    if (isset($value['timezone'])) {
1524
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1525
-	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1526
-	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1527
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1506
+			//print_r($line);
1507
+				$data = array();
1508
+				//$data['id'] = $line['id']; // id not usable
1509
+				$data['id'] = $line['id'];
1510
+				//$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1511
+				if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1512
+				if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1513
+				$data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1514
+				if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1515
+				$data['altitude'] = $line['altitude']; // altitude
1516
+				$data['speed'] = $line['groundspeed']; // speed
1517
+				$data['heading'] = $line['heading']; // heading
1518
+				$data['latitude'] = $line['lat']; // lat
1519
+				$data['longitude'] = $line['lon']; // long
1520
+				//$data['verticalrate'] = ''; // verticale rate
1521
+				//$data['squawk'] = ''; // squawk
1522
+				//$data['emergency'] = ''; // emergency
1523
+				if (isset($value['timezone'])) {
1524
+				$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1525
+				$datetime->setTimeZone(new DateTimeZone('UTC'));
1526
+				$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1527
+				} else $data['datetime'] = date('Y-m-d H:i:s');
1528 1528
 	    	    
1529
-	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1530
-	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
1531
-	    	    $data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1532
-		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1533
-		    $data['registration'] = $line['bid']['aircraft']['registration'];
1529
+				$data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1530
+				$data['departure_airport_time'] = $line['bid']['deptime'];
1531
+				$data['arrival_airport_icao'] = $line['bid']['arrapt']['icao'];
1532
+			$data['arrival_airport_time'] = $line['bid']['arrtime'];
1533
+			$data['registration'] = $line['bid']['aircraft']['registration'];
1534 1534
 
1535
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1536
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1537
-	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1535
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1536
+			if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
1537
+				$data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1538 1538
 
1539
-    		    $data['id_source'] = $id_source;
1540
-	    	    $data['format_source'] = 'vaos';
1541
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1542
-		    $SI->add($data);
1543
-		    unset($data);
1539
+				$data['id_source'] = $id_source;
1540
+				$data['format_source'] = 'vaos';
1541
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1542
+			$SI->add($data);
1543
+			unset($data);
1544 1544
 		}
1545 1545
 		if ($globalDebug) echo 'No more data...'."\n";
1546 1546
 		unset($buffer);
1547 1547
 		unset($all_data);
1548
-	    }
1549
-	    //$last_exec['phpvmacars'] = time();
1550
-	    $last_exec[$id]['last'] = time();
1548
+		}
1549
+		//$last_exec['phpvmacars'] = time();
1550
+		$last_exec[$id]['last'] = time();
1551 1551
 	} elseif ($value['format'] === 'vam' && 
1552
-	    (
1552
+		(
1553 1553
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) ||
1554 1554
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1555
-	    )
1555
+		)
1556 1556
 	) {
1557
-	    //$buffer = $Common->getData($hosts[$id]);
1558
-	    if ($globalDebug) echo 'Get Data...'."\n";
1559
-	    $buffer = $Common->getData($value['host']);
1560
-	    $all_data = json_decode($buffer,true);
1561
-	    if ($buffer != '' && is_array($all_data)) {
1557
+		//$buffer = $Common->getData($hosts[$id]);
1558
+		if ($globalDebug) echo 'Get Data...'."\n";
1559
+		$buffer = $Common->getData($value['host']);
1560
+		$all_data = json_decode($buffer,true);
1561
+		if ($buffer != '' && is_array($all_data)) {
1562 1562
 		$reset = 0;
1563 1563
 		foreach ($all_data as $line) {
1564
-	    	    $data = array();
1565
-	    	    //$data['id'] = $line['id']; // id not usable
1566
-	    	    $data['id'] = trim($line['flight_id']);
1567
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1568
-	    	    $data['pilot_name'] = $line['pilot_name'];
1569
-	    	    $data['pilot_id'] = $line['pilot_id'];
1570
-	    	    $data['ident'] = trim($line['callsign']); // ident
1571
-	    	    $data['altitude'] = $line['altitude']; // altitude
1572
-	    	    $data['speed'] = $line['gs']; // speed
1573
-	    	    $data['heading'] = $line['heading']; // heading
1574
-	    	    $data['latitude'] = $line['latitude']; // lat
1575
-	    	    $data['longitude'] = $line['longitude']; // long
1576
-	    	    $data['verticalrate'] = ''; // verticale rate
1577
-	    	    $data['squawk'] = ''; // squawk
1578
-	    	    $data['emergency'] = ''; // emergency
1579
-	    	    //$data['datetime'] = $line['lastupdate'];
1580
-	    	    $data['last_update'] = $line['last_update'];
1581
-		    $data['datetime'] = date('Y-m-d H:i:s');
1582
-	    	    $data['departure_airport_icao'] = $line['departure'];
1583
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1584
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1585
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1586
-    		    //$data['registration'] = $line['aircraft'];
1587
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1588
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1589
-    		    $data['id_source'] = $id_source;
1590
-	    	    $data['format_source'] = 'vam';
1591
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1592
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1593
-		    $SI->add($data);
1594
-		    unset($data);
1564
+				$data = array();
1565
+				//$data['id'] = $line['id']; // id not usable
1566
+				$data['id'] = trim($line['flight_id']);
1567
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1568
+				$data['pilot_name'] = $line['pilot_name'];
1569
+				$data['pilot_id'] = $line['pilot_id'];
1570
+				$data['ident'] = trim($line['callsign']); // ident
1571
+				$data['altitude'] = $line['altitude']; // altitude
1572
+				$data['speed'] = $line['gs']; // speed
1573
+				$data['heading'] = $line['heading']; // heading
1574
+				$data['latitude'] = $line['latitude']; // lat
1575
+				$data['longitude'] = $line['longitude']; // long
1576
+				$data['verticalrate'] = ''; // verticale rate
1577
+				$data['squawk'] = ''; // squawk
1578
+				$data['emergency'] = ''; // emergency
1579
+				//$data['datetime'] = $line['lastupdate'];
1580
+				$data['last_update'] = $line['last_update'];
1581
+			$data['datetime'] = date('Y-m-d H:i:s');
1582
+				$data['departure_airport_icao'] = $line['departure'];
1583
+				//$data['departure_airport_time'] = $line['departure_time'];
1584
+				$data['arrival_airport_icao'] = $line['arrival'];
1585
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1586
+				//$data['registration'] = $line['aircraft'];
1587
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1588
+				$data['aircraft_icao'] = $line['plane_type'];
1589
+				$data['id_source'] = $id_source;
1590
+				$data['format_source'] = 'vam';
1591
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1592
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1593
+			$SI->add($data);
1594
+			unset($data);
1595 1595
 		}
1596 1596
 		if ($globalDebug) echo 'No more data...'."\n";
1597 1597
 		unset($buffer);
1598 1598
 		unset($all_data);
1599
-	    }
1600
-	    //$last_exec['phpvmacars'] = time();
1601
-	    $last_exec[$id]['last'] = time();
1599
+		}
1600
+		//$last_exec['phpvmacars'] = time();
1601
+		$last_exec[$id]['last'] = time();
1602 1602
 	} elseif ($value['format'] === 'blitzortung' && 
1603
-	    (
1603
+		(
1604 1604
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
1605 1605
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1606
-	    )
1606
+		)
1607 1607
 	) {
1608
-	    //$buffer = $Common->getData($hosts[$id]);
1609
-	    if ($globalDebug) echo 'Get Data...'."\n";
1610
-	    $buffer = $Common->getData($value['host']);
1611
-	    $all_data = json_decode($buffer,true);
1612
-	    if ($buffer != '') {
1608
+		//$buffer = $Common->getData($hosts[$id]);
1609
+		if ($globalDebug) echo 'Get Data...'."\n";
1610
+		$buffer = $Common->getData($value['host']);
1611
+		$all_data = json_decode($buffer,true);
1612
+		if ($buffer != '') {
1613 1613
 		$Source->deleteLocationBySource('blitzortung');
1614 1614
 		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1615 1615
 		$buffer = explode('\n',$buffer);
1616 1616
 		foreach ($buffer as $buffer_line) {
1617
-		    $line = json_decode($buffer_line,true);
1618
-		    if (isset($line['time'])) {
1617
+			$line = json_decode($buffer_line,true);
1618
+			if (isset($line['time'])) {
1619 1619
 			$data = array();
1620 1620
 			$data['altitude'] = $line['alt']; // altitude
1621 1621
 			$data['latitude'] = $line['lat']; // lat
@@ -1627,92 +1627,92 @@  discard block
 block discarded – undo
1627 1627
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1628 1628
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1629 1629
 			unset($data);
1630
-		    }
1630
+			}
1631 1631
 		}
1632 1632
 		if ($globalDebug) echo 'No more data...'."\n";
1633 1633
 		unset($buffer);
1634
-	    }
1635
-	    $last_exec[$id]['last'] = time();
1634
+		}
1635
+		$last_exec[$id]['last'] = time();
1636 1636
 	} elseif ($value['format'] === 'acarsjson') {
1637
-        $arr = $httpfeeds;
1638
-        $w = $e = null;
1639
-        if (isset($arr[$id])) {
1640
-            $nn = stream_select($arr,$w,$e,$timeout);
1641
-            if ($nn > 0) {
1642
-                foreach ($httpfeeds as $feed) {
1643
-                    $buffer = stream_get_line($feed,2000,"\n");
1644
-                    if ($buffer === FALSE) {
1645
-                        connect_all($globalSources);
1646
-                    }
1647
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1648
-                    $buffer = explode('\n',$buffer);
1649
-                    foreach ($buffer as $line) {
1650
-                        if ($line != '') {
1651
-                            $line = json_decode($line, true);
1652
-                            if (!empty($line)) {
1653
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1654
-                                $ACARS->deleteLiveAcarsData();
1655
-                            }
1656
-                        }
1657
-                    }
1658
-                }
1659
-            } else {
1660
-                $format = $value['format'];
1661
-                if (isset($tt[$format])) $tt[$format]++;
1662
-                else $tt[$format] = 0;
1663
-                if ($tt[$format] > 30) {
1664
-                    if ($globalDebug) echo 'Reconnect...'."\n";
1665
-                    sleep(2);
1666
-                    //$sourceeen[] = $value;
1667
-                    //connect_all($sourceeen);
1668
-                    //$sourceeen = array();
1669
-                    connect_all($globalSources);
1670
-                }
1671
-            }
1672
-        }
1637
+		$arr = $httpfeeds;
1638
+		$w = $e = null;
1639
+		if (isset($arr[$id])) {
1640
+			$nn = stream_select($arr,$w,$e,$timeout);
1641
+			if ($nn > 0) {
1642
+				foreach ($httpfeeds as $feed) {
1643
+					$buffer = stream_get_line($feed,2000,"\n");
1644
+					if ($buffer === FALSE) {
1645
+						connect_all($globalSources);
1646
+					}
1647
+					$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1648
+					$buffer = explode('\n',$buffer);
1649
+					foreach ($buffer as $line) {
1650
+						if ($line != '') {
1651
+							$line = json_decode($line, true);
1652
+							if (!empty($line)) {
1653
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1654
+								$ACARS->deleteLiveAcarsData();
1655
+							}
1656
+						}
1657
+					}
1658
+				}
1659
+			} else {
1660
+				$format = $value['format'];
1661
+				if (isset($tt[$format])) $tt[$format]++;
1662
+				else $tt[$format] = 0;
1663
+				if ($tt[$format] > 30) {
1664
+					if ($globalDebug) echo 'Reconnect...'."\n";
1665
+					sleep(2);
1666
+					//$sourceeen[] = $value;
1667
+					//connect_all($sourceeen);
1668
+					//$sourceeen = array();
1669
+					connect_all($globalSources);
1670
+				}
1671
+			}
1672
+		}
1673 1673
 	//} elseif ($value === 'sbs' || $value === 'tsv' || $value === 'raw' || $value === 'aprs' || $value === 'beast') {
1674 1674
 	} elseif ($value['format'] === 'sbs' || $value['format'] === 'tsv' || $value['format'] === 'raw' || $value['format'] === 'aprs' || $value['format'] === 'famaprs' || $value['format'] === 'beast' || $value['format'] === 'flightgearmp' || $value['format'] === 'flightgearsp' || $value['format'] === 'acars' || $value['format'] === 'acarsjsonudp' || $value['format'] === 'acarssbs3' || $value['format'] === 'ais' || $value['format'] === 'vrstcp') {
1675
-	    //$last_exec[$id]['last'] = time();
1676
-	    //$read = array( $sockets[$id] );
1677
-	    $read = $sockets;
1678
-	    $write = NULL;
1679
-	    $e = NULL;
1680
-	    $n = socket_select($read, $write, $e, $timeout);
1681
-	    if ($e != NULL) var_dump($e);
1682
-	    if ($n > 0) {
1675
+		//$last_exec[$id]['last'] = time();
1676
+		//$read = array( $sockets[$id] );
1677
+		$read = $sockets;
1678
+		$write = NULL;
1679
+		$e = NULL;
1680
+		$n = socket_select($read, $write, $e, $timeout);
1681
+		if ($e != NULL) var_dump($e);
1682
+		if ($n > 0) {
1683 1683
 		$reset = 0;
1684 1684
 		foreach ($read as $nb => $r) {
1685
-		    //$value = $formats[$nb];
1686
-		    $format = $globalSources[$nb]['format'];
1687
-		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1685
+			//$value = $formats[$nb];
1686
+			$format = $globalSources[$nb]['format'];
1687
+			if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1688 1688
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1689
-		    } elseif ($format === 'vrstcp') {
1689
+			} elseif ($format === 'vrstcp') {
1690 1690
 			$buffer = @socket_read($r, 6000);
1691
-		    } else {
1691
+			} else {
1692 1692
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1693
-		    }
1694
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1695
-		    //echo $buffer."\n";
1696
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1697
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1698
-		    $error = false;
1699
-		    //$SI::del();
1700
-		    if ($buffer !== FALSE) {
1693
+			}
1694
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1695
+			//echo $buffer."\n";
1696
+			// lets play nice and handle signals such as ctrl-c/kill properly
1697
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1698
+			$error = false;
1699
+			//$SI::del();
1700
+			if ($buffer !== FALSE) {
1701 1701
 			if ($format === 'vrstcp') {
1702
-			    $buffer = explode('},{',$buffer);
1702
+				$buffer = explode('},{',$buffer);
1703 1703
 			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1704
-		    }
1705
-		    // SBS format is CSV format
1706
-		    if ($buffer !== FALSE && $buffer !== '') {
1704
+			}
1705
+			// SBS format is CSV format
1706
+			if ($buffer !== FALSE && $buffer !== '') {
1707 1707
 			$tt[$format] = 0;
1708 1708
 			if ($format === 'acarssbs3') {
1709
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1710
-			    $ACARS->add(trim($buffer));
1711
-			    $ACARS->deleteLiveAcarsData();
1709
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1710
+				$ACARS->add(trim($buffer));
1711
+				$ACARS->deleteLiveAcarsData();
1712 1712
 			} elseif ($format === 'raw') {
1713
-			    // AVR format
1714
-			    $data = $SBS->parse($buffer);
1715
-			    if (is_array($data)) {
1713
+				// AVR format
1714
+				$data = $SBS->parse($buffer);
1715
+				if (is_array($data)) {
1716 1716
 				//if (!empty($data)) print_r($data);
1717 1717
 				$data['datetime'] = date('Y-m-d H:i:s');
1718 1718
 				$data['format_source'] = 'raw';
@@ -1722,39 +1722,39 @@  discard block
 block discarded – undo
1722 1722
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1723 1723
 				$SI->add($data);
1724 1724
 				unset($data);
1725
-			    }
1725
+				}
1726 1726
 			} elseif ($format === 'ais') {
1727
-			    $ais_data = $AIS->parse_line(trim($buffer));
1728
-			    $data = array();
1729
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1730
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1731
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1732
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1733
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1734
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1735
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1736
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1737
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1738
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1739
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1740
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1741
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1742
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1743
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1744
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1727
+				$ais_data = $AIS->parse_line(trim($buffer));
1728
+				$data = array();
1729
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1730
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1731
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1732
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1733
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1734
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1735
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1736
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1737
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1738
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1739
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1740
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1741
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1742
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1743
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1744
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1745 1745
 
1746
-			    if (isset($ais_data['timestamp'])) {
1746
+				if (isset($ais_data['timestamp'])) {
1747 1747
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1748
-			    } else {
1748
+				} else {
1749 1749
 				$data['datetime'] = date('Y-m-d H:i:s');
1750
-			    }
1751
-			    $data['format_source'] = 'aisnmea';
1752
-    			    $data['id_source'] = $id_source;
1753
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1754
-			    unset($data);
1755
-                        } elseif ($format === 'flightgearsp') {
1756
-                    	    //echo $buffer."\n";
1757
-                    	    if (strlen($buffer) > 5) {
1750
+				}
1751
+				$data['format_source'] = 'aisnmea';
1752
+					$data['id_source'] = $id_source;
1753
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
1754
+				unset($data);
1755
+						} elseif ($format === 'flightgearsp') {
1756
+							//echo $buffer."\n";
1757
+							if (strlen($buffer) > 5) {
1758 1758
 				$line = explode(',',$buffer);
1759 1759
 				$data = array();
1760 1760
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1771,47 +1771,47 @@  discard block
 block discarded – undo
1771 1771
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1772 1772
 				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1773 1773
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1774
-			    }
1775
-                        } elseif ($format === 'acars') {
1776
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1777
-			    $ACARS->add(trim($buffer));
1778
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1779
-			    $ACARS->deleteLiveAcarsData();
1774
+				}
1775
+						} elseif ($format === 'acars') {
1776
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1777
+				$ACARS->add(trim($buffer));
1778
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1779
+				$ACARS->deleteLiveAcarsData();
1780 1780
 			} elseif ($format === 'acarsjsonudp') {
1781
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1782
-                            $line = json_decode(trim($buffer), true);
1783
-                            if (!empty($line)) {
1781
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1782
+							$line = json_decode(trim($buffer), true);
1783
+							if (!empty($line)) {
1784 1784
 				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1785
-                                $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1786
-                                $ACARS->deleteLiveAcarsData();
1787
-                            }
1788
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1785
+								$ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1786
+								$ACARS->deleteLiveAcarsData();
1787
+							}
1788
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1789 1789
 			} elseif ($format === 'flightgearmp') {
1790
-			    if (substr($buffer,0,1) != '#') {
1790
+				if (substr($buffer,0,1) != '#') {
1791 1791
 				$data = array();
1792 1792
 				//echo $buffer."\n";
1793 1793
 				$line = explode(' ',$buffer);
1794 1794
 				if (count($line) === 11) {
1795
-				    $userserver = explode('@',$line[0]);
1796
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1797
-				    $data['ident'] = $userserver[0];
1798
-				    $data['registration'] = $userserver[0];
1799
-				    $data['latitude'] = $line[4];
1800
-				    $data['longitude'] = $line[5];
1801
-				    $data['altitude'] = $line[6];
1802
-				    $data['datetime'] = date('Y-m-d H:i:s');
1803
-				    $aircraft_type = $line[10];
1804
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1805
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1806
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1807
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1795
+					$userserver = explode('@',$line[0]);
1796
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1797
+					$data['ident'] = $userserver[0];
1798
+					$data['registration'] = $userserver[0];
1799
+					$data['latitude'] = $line[4];
1800
+					$data['longitude'] = $line[5];
1801
+					$data['altitude'] = $line[6];
1802
+					$data['datetime'] = date('Y-m-d H:i:s');
1803
+					$aircraft_type = $line[10];
1804
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1805
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1806
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1807
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1808
+				}
1808 1809
 				}
1809
-			    }
1810 1810
 			} elseif ($format === 'beast') {
1811
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1812
-			    die;
1811
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1812
+				die;
1813 1813
 			} elseif ($format === 'vrstcp') {
1814
-			    foreach($buffer as $all_data) {
1814
+				foreach($buffer as $all_data) {
1815 1815
 				$line = json_decode('{'.$all_data.'}',true);
1816 1816
 				$data = array();
1817 1817
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1831,158 +1831,158 @@  discard block
 block discarded – undo
1831 1831
 				*/
1832 1832
 				$data['datetime'] = date('Y-m-d H:i:s');
1833 1833
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1834
-		    		$data['format_source'] = 'vrstcp';
1834
+					$data['format_source'] = 'vrstcp';
1835 1835
 				$data['id_source'] = $id_source;
1836 1836
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1837 1837
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1838 1838
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1839 1839
 				unset($data);
1840
-			    }
1840
+				}
1841 1841
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1842
-			    $line = explode("\t", $buffer);
1843
-			    for($k = 0; $k < count($line); $k=$k+2) {
1842
+				$line = explode("\t", $buffer);
1843
+				for($k = 0; $k < count($line); $k=$k+2) {
1844 1844
 				$key = $line[$k];
1845
-			        $lined[$key] = $line[$k+1];
1846
-			    }
1847
-    			    if (count($lined) > 3) {
1848
-    				$data['hex'] = $lined['hexid'];
1849
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1850
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1851
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1852
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1853
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1854
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1855
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1856
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1857
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1858
-    				$data['id_source'] = $id_source;
1859
-    				$data['format_source'] = 'tsv';
1860
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1861
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1845
+					$lined[$key] = $line[$k+1];
1846
+				}
1847
+					if (count($lined) > 3) {
1848
+					$data['hex'] = $lined['hexid'];
1849
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1850
+					$data['datetime'] = date('Y-m-d H:i:s');;
1851
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1852
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1853
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1854
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1855
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1856
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1857
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1858
+					$data['id_source'] = $id_source;
1859
+					$data['format_source'] = 'tsv';
1860
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1861
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1862 1862
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1863
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1864
-    				unset($lined);
1865
-    				unset($data);
1866
-    			    } else $error = true;
1863
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1864
+					unset($lined);
1865
+					unset($data);
1866
+					} else $error = true;
1867 1867
 			} elseif ($format === 'aprs' && $use_aprs) {
1868
-			    if ($aprs_connect === 0) {
1868
+				if ($aprs_connect === 0) {
1869 1869
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1870 1870
 				$aprs_connect = 1;
1871
-			    }
1871
+				}
1872 1872
 			    
1873
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1873
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1874 1874
 				$aprs_last_tx = time();
1875 1875
 				$data_aprs = "# Keep alive";
1876 1876
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1877
-			    }
1877
+				}
1878 1878
 			    
1879
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1880
-			    //echo 'APRS data : '.$buffer."\n";
1881
-			    $buffer = str_replace('APRS <- ','',$buffer);
1882
-			    $buffer = str_replace('APRS -> ','',$buffer);
1883
-			    //echo $buffer."\n";
1884
-			    date_default_timezone_set('UTC');
1885
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1879
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1880
+				//echo 'APRS data : '.$buffer."\n";
1881
+				$buffer = str_replace('APRS <- ','',$buffer);
1882
+				$buffer = str_replace('APRS -> ','',$buffer);
1883
+				//echo $buffer."\n";
1884
+				date_default_timezone_set('UTC');
1885
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1886 1886
 				$line = $APRS->parse($buffer);
1887 1887
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1888 1888
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1889
-				    $aprs_last_tx = time();
1890
-				    $data = array();
1891
-				    //print_r($line);
1892
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1893
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1894
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1895
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1896
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1897
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1898
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1899
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1900
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1901
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1902
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1903
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1904
-				    $data['latitude'] = $line['latitude'];
1905
-				    $data['longitude'] = $line['longitude'];
1906
-				    //$data['verticalrate'] = $line[16];
1907
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1908
-				    //else $data['speed'] = 0;
1909
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1910
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1911
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1912
-				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1889
+					$aprs_last_tx = time();
1890
+					$data = array();
1891
+					//print_r($line);
1892
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1893
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1894
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1895
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1896
+					if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1897
+					if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1898
+					if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1899
+					if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1900
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1901
+					else $data['datetime'] = date('Y-m-d H:i:s');
1902
+					//$data['datetime'] = date('Y-m-d H:i:s');
1903
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1904
+					$data['latitude'] = $line['latitude'];
1905
+					$data['longitude'] = $line['longitude'];
1906
+					//$data['verticalrate'] = $line[16];
1907
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1908
+					//else $data['speed'] = 0;
1909
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1910
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1911
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1912
+					//if (isset($line['heading'])) $data['heading'] = $line['heading'];
1913 1913
 				    
1914
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1915
-				    //else echo 'No heading...'."\n";
1916
-				    //else $data['heading'] = 0;
1917
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1918
-				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1919
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1920
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1921
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1922
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1923
-    				    $data['id_source'] = $id_source;
1924
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1925
-				    else $data['format_source'] = 'aprs';
1926
-				    $data['source_name'] = $line['source'];
1927
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1928
-				    else $data['source_type'] = 'flarm';
1929
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1930
-				    $currentdate = date('Y-m-d H:i:s');
1931
-				    $aprsdate = strtotime($data['datetime']);
1932
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1933
-				    // Accept data if time <= system time + 20s
1934
-				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1935
-				    if (
1914
+					if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
1915
+					//else echo 'No heading...'."\n";
1916
+					//else $data['heading'] = 0;
1917
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1918
+					//if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1919
+					if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1920
+					elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1921
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1922
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1923
+						$data['id_source'] = $id_source;
1924
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1925
+					else $data['format_source'] = 'aprs';
1926
+					$data['source_name'] = $line['source'];
1927
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1928
+					else $data['source_type'] = 'flarm';
1929
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1930
+					$currentdate = date('Y-m-d H:i:s');
1931
+					$aprsdate = strtotime($data['datetime']);
1932
+					if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
1933
+					// Accept data if time <= system time + 20s
1934
+					//if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1935
+					if (
1936 1936
 					($data['source_type'] === 'modes') || 
1937 1937
 					isset($line['stealth']) && 
1938 1938
 					(!isset($data['hex']) || $data['hex'] != 'FFFFFF') && 
1939 1939
 					 ($line['stealth'] === 0 || $line['stealth'] == '') && 
1940 1940
 					 (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1941 1941
 					$send = $SI->add($data);
1942
-				    } elseif ($data['source_type'] === 'ais') {
1942
+					} elseif ($data['source_type'] === 'ais') {
1943 1943
 					$data['type'] = '';
1944 1944
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1945
-				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1945
+					} elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1946 1946
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1947
-				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1948
-					    //$line['symbol'] === 'Balloon' ||
1949
-					    $line['symbol'] === 'Glider' || 
1950
-					    $line['symbol'] === 'No. Plane' || 
1951
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1952
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1953
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1954
-					    $send = $SI->add($data);
1955
-				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1956
-					    $line['symbol'] === 'Yacht (Sail)' || 
1957
-					    $line['symbol'] === 'Ship (Power Boat)')) {
1958
-					    $send = $MI->add($data);
1959
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1960
-					    $line['symbol'] === 'Car' || 
1961
-					    $line['symbol'] === 'Ambulance' || 
1962
-					    $line['symbol'] === 'Van' || 
1963
-					    $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1964
-					    $line['symbol'] === 'Motorcycle' || 
1965
-					    $line['symbol'] === 'Tractor' || 
1966
-					    $line['symbol'] === 'Police' || 
1967
-					    $line['symbol'] === 'Bike' || 
1968
-					    $line['symbol'] === 'Jogger' || 
1969
-					    $line['symbol'] === 'Horse' || 
1970
-					    $line['symbol'] === 'Bus' || 
1971
-					    $line['symbol'] === 'Jeep' || 
1972
-					    $line['symbol'] === 'Recreational Vehicle' || 
1973
-					    $line['symbol'] === 'Yacht (Sail)' || 
1974
-					    $line['symbol'] === 'Ship (Power Boat)' || 
1975
-					    $line['symbol'] === 'Firetruck' || 
1976
-					    $line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1977
-					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1978
-					    $line['symbol'] === 'SUV' ||
1979
-					    $line['symbol'] === 'Snowmobile' ||
1980
-					    $line['symbol'] === 'Mobile Satellite Station')) {
1981
-				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1947
+					} elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1948
+						//$line['symbol'] === 'Balloon' ||
1949
+						$line['symbol'] === 'Glider' || 
1950
+						$line['symbol'] === 'No. Plane' || 
1951
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1952
+						if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1953
+						if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
1954
+						$send = $SI->add($data);
1955
+					} elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1956
+						$line['symbol'] === 'Yacht (Sail)' || 
1957
+						$line['symbol'] === 'Ship (Power Boat)')) {
1958
+						$send = $MI->add($data);
1959
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1960
+						$line['symbol'] === 'Car' || 
1961
+						$line['symbol'] === 'Ambulance' || 
1962
+						$line['symbol'] === 'Van' || 
1963
+						$line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || 
1964
+						$line['symbol'] === 'Motorcycle' || 
1965
+						$line['symbol'] === 'Tractor' || 
1966
+						$line['symbol'] === 'Police' || 
1967
+						$line['symbol'] === 'Bike' || 
1968
+						$line['symbol'] === 'Jogger' || 
1969
+						$line['symbol'] === 'Horse' || 
1970
+						$line['symbol'] === 'Bus' || 
1971
+						$line['symbol'] === 'Jeep' || 
1972
+						$line['symbol'] === 'Recreational Vehicle' || 
1973
+						$line['symbol'] === 'Yacht (Sail)' || 
1974
+						$line['symbol'] === 'Ship (Power Boat)' || 
1975
+						$line['symbol'] === 'Firetruck' || 
1976
+						$line['symbol'] === 'Balloon' || $line['symbol'] === 'Glider' || 
1977
+						$line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter' || 
1978
+						$line['symbol'] === 'SUV' ||
1979
+						$line['symbol'] === 'Snowmobile' ||
1980
+						$line['symbol'] === 'Mobile Satellite Station')) {
1981
+					//} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1982 1982
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1983 1983
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1984 1984
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1985
-				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1985
+					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1986 1986
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1987 1987
 					$Source->deleteOldLocationByType('gs');
1988 1988
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
@@ -1990,7 +1990,7 @@  discard block
 block discarded – undo
1990 1990
 					} else {
1991 1991
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1992 1992
 					}
1993
-				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1993
+					} elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1994 1994
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1995 1995
 					if ($globalDebug) echo '# Weather Station added'."\n";
1996 1996
 					$Source->deleteOldLocationByType('wx');
@@ -2000,7 +2000,7 @@  discard block
 block discarded – undo
2000 2000
 					} else {
2001 2001
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2002 2002
 					}
2003
-				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2003
+					} elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2004 2004
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2005 2005
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2006 2006
 					$Source->deleteOldLocationByType('lightning');
@@ -2009,11 +2009,11 @@  discard block
 block discarded – undo
2009 2009
 					} else {
2010 2010
 						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2011 2011
 					}
2012
-				    } elseif ($globalDebug) {
2013
-				    	echo '/!\ Not added: '.$buffer."\n";
2014
-				    	print_r($line);
2015
-				    }
2016
-				    unset($data);
2012
+					} elseif ($globalDebug) {
2013
+						echo '/!\ Not added: '.$buffer."\n";
2014
+						print_r($line);
2015
+					}
2016
+					unset($data);
2017 2017
 				}
2018 2018
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2019 2019
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
@@ -2032,13 +2032,13 @@  discard block
 block discarded – undo
2032 2032
 				} elseif (!isset($globalSources[$nb]['last_weather_clean'])) {
2033 2033
 					$globalSources[$nb]['last_weather_clean'] = time();
2034 2034
 				}
2035
-			    }
2035
+				}
2036 2036
 			} else {
2037
-			    $line = explode(',', $buffer);
2038
-			    //print_r($line);
2039
-    			    if (count($line) > 20) {
2040
-    			    	$data['hex'] = $line[4];
2041
-    				/*
2037
+				$line = explode(',', $buffer);
2038
+				//print_r($line);
2039
+					if (count($line) > 20) {
2040
+						$data['hex'] = $line[4];
2041
+					/*
2042 2042
     				$data['datetime'] = $line[6].' '.$line[7];
2043 2043
     					date_default_timezone_set($globalTimezone);
2044 2044
     					$datetime = new DateTime($data['datetime']);
@@ -2046,31 +2046,31 @@  discard block
 block discarded – undo
2046 2046
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
2047 2047
     					date_default_timezone_set('UTC');
2048 2048
     				*/
2049
-    				// Force datetime to current UTC datetime
2050
-    				date_default_timezone_set('UTC');
2051
-    				$data['datetime'] = date('Y-m-d H:i:s');
2052
-    				$data['ident'] = trim($line[10]);
2053
-    				$data['latitude'] = $line[14];
2054
-    				$data['longitude'] = $line[15];
2055
-    				$data['verticalrate'] = $line[16];
2056
-    				$data['emergency'] = $line[20];
2057
-    				$data['speed'] = $line[12];
2058
-    				$data['squawk'] = $line[17];
2059
-    				$data['altitude'] = $line[11];
2060
-    				$data['heading'] = $line[13];
2061
-    				$data['ground'] = $line[21];
2062
-    				$data['emergency'] = $line[19];
2063
-    				$data['format_source'] = 'sbs';
2049
+					// Force datetime to current UTC datetime
2050
+					date_default_timezone_set('UTC');
2051
+					$data['datetime'] = date('Y-m-d H:i:s');
2052
+					$data['ident'] = trim($line[10]);
2053
+					$data['latitude'] = $line[14];
2054
+					$data['longitude'] = $line[15];
2055
+					$data['verticalrate'] = $line[16];
2056
+					$data['emergency'] = $line[20];
2057
+					$data['speed'] = $line[12];
2058
+					$data['squawk'] = $line[17];
2059
+					$data['altitude'] = $line[11];
2060
+					$data['heading'] = $line[13];
2061
+					$data['ground'] = $line[21];
2062
+					$data['emergency'] = $line[19];
2063
+					$data['format_source'] = 'sbs';
2064 2064
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2065 2065
 				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2066 2066
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2067 2067
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2068
-    				$data['id_source'] = $id_source;
2069
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2070
-    				else $error = true;
2071
-    				unset($data);
2072
-    			    } else $error = true;
2073
-			    if ($error) {
2068
+					$data['id_source'] = $id_source;
2069
+					if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2070
+					else $error = true;
2071
+					unset($data);
2072
+					} else $error = true;
2073
+				if ($error) {
2074 2074
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2075 2075
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
2076 2076
 				} else {
@@ -2086,13 +2086,13 @@  discard block
 block discarded – undo
2086 2086
 					connect_all($sourceer);
2087 2087
 					$sourceer = array();
2088 2088
 				}
2089
-			    }
2089
+				}
2090 2090
 			}
2091 2091
 			// Sleep for xxx microseconds
2092 2092
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2093
-		    } else {
2093
+			} else {
2094 2094
 			if ($format === 'flightgearmp') {
2095
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2095
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
2096 2096
 				//@socket_close($r);
2097 2097
 				sleep($globalMinFetch);
2098 2098
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2101,9 +2101,9 @@  discard block
 block discarded – undo
2101 2101
 				break;
2102 2102
 				
2103 2103
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2104
-			    if (isset($tt[$format])) $tt[$format]++;
2105
-			    else $tt[$format] = 0;
2106
-			    if ($tt[$format] > 30 || $buffer === FALSE) {
2104
+				if (isset($tt[$format])) $tt[$format]++;
2105
+				else $tt[$format] = 0;
2106
+				if ($tt[$format] > 30 || $buffer === FALSE) {
2107 2107
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2108 2108
 				//@socket_close($r);
2109 2109
 				sleep(2);
@@ -2114,24 +2114,24 @@  discard block
 block discarded – undo
2114 2114
 				//connect_all($globalSources);
2115 2115
 				$tt[$format]=0;
2116 2116
 				break;
2117
-			    } 
2118
-			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2117
+				} 
2118
+				//else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
2119
+			}
2119 2120
 			}
2120
-		    }
2121 2121
 		}
2122
-	    } else {
2122
+		} else {
2123 2123
 		$error = socket_strerror(socket_last_error());
2124 2124
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2125 2125
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2126 2126
 			if (isset($globalDebug)) echo "Restarting...\n";
2127 2127
 			// Restart the script if possible
2128 2128
 			if (is_array($sockets)) {
2129
-			    if ($globalDebug) echo "Shutdown all sockets...";
2129
+				if ($globalDebug) echo "Shutdown all sockets...";
2130 2130
 			    
2131
-			    foreach ($sockets as $sock) {
2131
+				foreach ($sockets as $sock) {
2132 2132
 				@socket_shutdown($sock,2);
2133 2133
 				@socket_close($sock);
2134
-			    }
2134
+				}
2135 2135
 			    
2136 2136
 			}
2137 2137
 			if ($globalDebug) echo "Waiting...";
@@ -2146,15 +2146,15 @@  discard block
 block discarded – undo
2146 2146
 			if ($globalDebug) echo "Restart all connections...";
2147 2147
 			connect_all($globalSources);
2148 2148
 		}
2149
-	    }
2149
+		}
2150 2150
 	}
2151 2151
 	if ($globalDaemon === false) {
2152
-	    if ($globalDebug) echo 'Check all...'."\n";
2153
-	    if (isset($SI)) $SI->checkAll();
2154
-	    if (isset($TI)) $TI->checkAll();
2155
-	    if (isset($MI)) $MI->checkAll();
2152
+		if ($globalDebug) echo 'Check all...'."\n";
2153
+		if (isset($SI)) $SI->checkAll();
2154
+		if (isset($TI)) $TI->checkAll();
2155
+		if (isset($MI)) $MI->checkAll();
2156
+	}
2156 2157
 	}
2157
-    }
2158 2158
 }
2159 2159
 
2160 2160
 ?>
Please login to merge, or discard this patch.
Spacing   +225 added lines, -225 removed lines patch added patch discarded remove patch
@@ -59,20 +59,20 @@  discard block
 block discarded – undo
59 59
 	    die;
60 60
 	}
61 61
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
62
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
62
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
63 63
     }
64 64
 }
65 65
 
66
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver','enable-aircraft','disable-aircraft','enable-tracker','disable-tracker','enable-marine','disable-marine'));
66
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver', 'enable-aircraft', 'disable-aircraft', 'enable-tracker', 'disable-tracker', 'enable-marine', 'disable-marine'));
67 67
 //if (isset($options['s'])) $hosts = array($options['s']);
68 68
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 69
 if (isset($options['s'])) {
70 70
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
71
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
72 72
     else $globalSources[] = array('host' => $options['s']);
73 73
 } elseif (isset($options['source'])) {
74 74
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
75
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
76 76
     else $globalSources[] = array('host' => $options['source']);
77 77
 }
78 78
 if (isset($options['aprsserverhost'])) {
@@ -113,13 +113,13 @@  discard block
 block discarded – undo
113 113
 else $id_source = 1;
114 114
 if (isset($globalServer) && $globalServer) {
115 115
     if ($globalDebug) echo "Using Server Mode\n";
116
-    $SI=new SpotterServer();
116
+    $SI = new SpotterServer();
117 117
 /*
118 118
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 119
     $SI = new adsb2aprs();
120 120
     $SI->connect();
121 121
 */
122
-} else $SI=new SpotterImport($Connection->db);
122
+} else $SI = new SpotterImport($Connection->db);
123 123
 
124 124
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
125 125
 if (isset($globalMarine) && $globalMarine) {
@@ -133,17 +133,17 @@  discard block
 block discarded – undo
133 133
     $MI = new MarineImport($Connection->db);
134 134
 }
135 135
 //$APRS=new APRS($Connection->db);
136
-$SBS=new SBS();
136
+$SBS = new SBS();
137 137
 if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
138
-	$ACARS=new ACARS($Connection->db,true);
139
-	$Source=new Source($Connection->db);
138
+	$ACARS = new ACARS($Connection->db, true);
139
+	$Source = new Source($Connection->db);
140 140
 }
141
-$Common=new Common();
141
+$Common = new Common();
142 142
 date_default_timezone_set('UTC');
143 143
 //$servertz = system('date +%Z');
144 144
 // signal handler - playing nice with sockets and dump1090
145 145
 if (function_exists('pcntl_fork')) {
146
-    pcntl_signal(SIGINT,  function() {
146
+    pcntl_signal(SIGINT, function() {
147 147
         global $sockets;
148 148
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
149 149
         die("Bye!\n");
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
 function connect_all($hosts) {
161 161
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
162
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
163 163
     $reset++;
164 164
     if ($globalDebug) echo 'Connect to all...'."\n";
165 165
     foreach ($hosts as $id => $value) {
@@ -167,33 +167,33 @@  discard block
 block discarded – undo
167 167
 	$udp = false;
168 168
 	$globalSources[$id]['last_exec'] = 0;
169 169
 	// Here we check type of source(s)
170
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
-            if (preg_match('/deltadb.txt$/i',$host)) {
170
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
171
+            if (preg_match('/deltadb.txt$/i', $host)) {
172 172
         	//$formats[$id] = 'deltadbtxt';
173 173
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 174
         	//$last_exec['deltadbtxt'] = 0;
175 175
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
176
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
176
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
177 177
         	//$formats[$id] = 'vatsimtxt';
178 178
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 179
         	//$last_exec['vatsimtxt'] = 0;
180 180
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
181
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
181
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
182 182
         	//$formats[$id] = 'aircraftlistjson';
183 183
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 184
         	//$last_exec['aircraftlistjson'] = 0;
185 185
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
186
-    	    } else if (preg_match('/aircraft.json$/i',$host)) {
186
+    	    } else if (preg_match('/aircraft.json$/i', $host)) {
187 187
         	//$formats[$id] = 'aircraftjson';
188 188
         	$globalSources[$id]['format'] = 'aircraftjson';
189 189
         	//$last_exec['aircraftlistjson'] = 0;
190 190
         	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
191
-    	    } else if (preg_match('/aircraft$/i',$host)) {
191
+    	    } else if (preg_match('/aircraft$/i', $host)) {
192 192
         	//$formats[$id] = 'planefinderclient';
193 193
         	$globalSources[$id]['format'] = 'planefinderclient';
194 194
         	//$last_exec['aircraftlistjson'] = 0;
195 195
         	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
196
-    	    } else if (preg_match('/opensky/i',$host)) {
196
+    	    } else if (preg_match('/opensky/i', $host)) {
197 197
         	//$formats[$id] = 'aircraftlistjson';
198 198
         	$globalSources[$id]['format'] = 'opensky';
199 199
         	//$last_exec['aircraftlistjson'] = 0;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
         	    exit(0);
211 211
         	}
212 212
     	    */
213
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
213
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
214 214
         	//$formats[$id] = 'planeupdatefaa';
215 215
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 216
         	//$last_exec['planeupdatefaa'] = 0;
@@ -219,37 +219,37 @@  discard block
 block discarded – undo
219 219
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 220
         	    exit(0);
221 221
         	}
222
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
222
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
223 223
         	//$formats[$id] = 'phpvmacars';
224 224
         	$globalSources[$id]['format'] = 'phpvmacars';
225 225
         	//$last_exec['phpvmacars'] = 0;
226 226
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
227
-            } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
227
+            } else if (preg_match('/\/api\/v1\/acars\/data$/i', $host)) {
228 228
         	//$formats[$id] = 'phpvmacars';
229 229
         	$globalSources[$id]['format'] = 'vaos';
230 230
         	//$last_exec['phpvmacars'] = 0;
231 231
         	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
232
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
232
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
233 233
         	//$formats[$id] = 'phpvmacars';
234 234
         	$globalSources[$id]['format'] = 'vam';
235 235
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
236
-            } else if (preg_match('/whazzup/i',$host)) {
236
+            } else if (preg_match('/whazzup/i', $host)) {
237 237
         	//$formats[$id] = 'whazzup';
238 238
         	$globalSources[$id]['format'] = 'whazzup';
239 239
         	//$last_exec['whazzup'] = 0;
240 240
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
241
-            } else if (preg_match('/blitzortung/i',$host)) {
241
+            } else if (preg_match('/blitzortung/i', $host)) {
242 242
         	$globalSources[$id]['format'] = 'blitzortung';
243 243
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
244
-            } else if (preg_match('/airwhere/i',$host)) {
244
+            } else if (preg_match('/airwhere/i', $host)) {
245 245
         	$globalSources[$id]['format'] = 'airwhere';
246 246
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
247
-            } else if (preg_match('/recentpireps/i',$host)) {
247
+            } else if (preg_match('/recentpireps/i', $host)) {
248 248
         	//$formats[$id] = 'pirepsjson';
249 249
         	$globalSources[$id]['format'] = 'pirepsjson';
250 250
         	//$last_exec['pirepsjson'] = 0;
251 251
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
252
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
252
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
253 253
         	//$formats[$id] = 'fr24json';
254 254
         	$globalSources[$id]['format'] = 'fr24json';
255 255
         	//$last_exec['fr24json'] = 0;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 259
         	    exit(0);
260 260
         	}
261
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
261
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
262 262
         	//$formats[$id] = 'fr24json';
263 263
         	$globalSources[$id]['format'] = 'myshiptracking';
264 264
         	//$last_exec['fr24json'] = 0;
@@ -268,22 +268,22 @@  discard block
 block discarded – undo
268 268
         	    exit(0);
269 269
         	}
270 270
             //} else if (preg_match('/10001/',$host)) {
271
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
271
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 272
         	//$formats[$id] = 'tsv';
273 273
         	$globalSources[$id]['format'] = 'tsv';
274 274
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
275 275
             }
276
-        } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
276
+        } elseif (filter_var($host, FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 277
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
278
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
279 279
     		    if ($idf !== false) {
280 280
     			$httpfeeds[$id] = $idf;
281 281
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282 282
     		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283 283
     		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284 284
     		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
285
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286
-	    $hostport = explode(':',$host);
285
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
286
+	    $hostport = explode(':', $host);
287 287
 	    if (isset($hostport[1])) {
288 288
 		$port = $hostport[1];
289 289
 		$hostn = $hostport[0];
@@ -293,20 +293,20 @@  discard block
 block discarded – undo
293 293
 	    }
294 294
 	    $Common = new Common();
295 295
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acarsjsonudp' && $globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
296
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
296
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
297 297
     	    } else {
298 298
     		$udp = true;
299
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
299
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
300 300
 	    }
301 301
 	    if ($s) {
302 302
     	        $sockets[$id] = $s;
303 303
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
304
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
304
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
305 305
 			//$formats[$id] = 'aprs';
306 306
 			$globalSources[$id]['format'] = 'aprs';
307 307
 			//$aprs_connect = 0;
308 308
 			//$use_aprs = true;
309
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
309
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
310 310
 			$globalSources[$id]['format'] = 'vrstcp';
311 311
     		    } elseif ($port == '10001') {
312 312
         		//$formats[$id] = 'tsv';
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
349 349
 else $timeout = 20;
350 350
 $errno = '';
351
-$errstr='';
351
+$errstr = '';
352 352
 
353 353
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
354 354
 /* Initiate connections to all the hosts simultaneously */
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 //connect_all($globalSources);
357 357
 
358 358
 if (isset($globalProxy) && $globalProxy) {
359
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
359
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
360 360
 } else {
361 361
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
362 362
 }
@@ -386,16 +386,16 @@  discard block
 block discarded – undo
386 386
 
387 387
 if ($use_aprs) {
388 388
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
389
-	$APRS=new APRS();
389
+	$APRS = new APRS();
390 390
 	$aprs_connect = 0;
391 391
 	$aprs_keep = 120;
392 392
 	$aprs_last_tx = time();
393 393
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
394
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
394
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
395 395
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
396
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
396
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
397 397
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
398
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
398
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399 399
 	if ($aprs_full) $aprs_filter = '';
400 400
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
401 401
 	else $aprs_pass = '-1';
@@ -409,12 +409,12 @@  discard block
 block discarded – undo
409 409
 sleep(1);
410 410
 if ($globalDebug) echo "SCAN MODE \n\n";
411 411
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
412
-$endtime = time()+$globalCronEnd;
412
+$endtime = time() + $globalCronEnd;
413 413
 $i = 1;
414 414
 $tt = array();
415 415
 // Delete all ATC
416 416
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
417
-	$ATC=new ATC($Connection->db);
417
+	$ATC = new ATC($Connection->db);
418 418
 }
419 419
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
420 420
 	$ATC->deleteAll();
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 while ($i > 0) {
425 425
     if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
426 426
 
427
-    if (!$globalDaemon) $i = $endtime-time();
427
+    if (!$globalDaemon) $i = $endtime - time();
428 428
     // Delete old ATC
429 429
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430 430
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	}
439 439
 	if ($max < $globalMinFetch) {
440 440
 	    if ($globalDebug) echo 'Sleeping...'."\n";
441
-	    sleep($globalMinFetch-$max+2);
441
+	    sleep($globalMinFetch - $max + 2);
442 442
 	}
443 443
     }
444 444
 
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
             //$buffer = $Common->getData($hosts[$id]);
494 494
             $buffer = $Common->getData($value['host']);
495 495
             if ($buffer != '') {
496
-                $all_data = json_decode($buffer,true);
496
+                $all_data = json_decode($buffer, true);
497 497
                 foreach ($all_data as $line) {
498 498
                     $data = array();
499
-                    $data['datetime'] = date('Y-m-d H:i:s',$line['uti']);
499
+                    $data['datetime'] = date('Y-m-d H:i:s', $line['uti']);
500 500
                     $data['hex'] = $line['hex']; // hex
501 501
                     $data['ident'] = $line['fli']; // ident
502 502
                     $data['altitude'] = $line['alt']; // altitude
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
 	    )
532 532
 	) {
533 533
 	    date_default_timezone_set('CET');
534
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
534
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
535 535
 	    date_default_timezone_set('UTC');
536 536
 	    if ($buffer != '') $reset = 0;
537
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538
-	    $buffer = explode('\n',$buffer);
537
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
538
+	    $buffer = explode('\n', $buffer);
539 539
 	    foreach ($buffer as $line) {
540 540
 		if ($line != '') {
541 541
 		    //echo "'".$line."'\n";
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 		    $ais_data = $AIS->parse_line(trim($line));
544 544
 		    $data = array();
545 545
 		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
546
+		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
547 547
 		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548 548
 		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549 549
 		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -555,7 +555,7 @@  discard block
 block discarded – undo
555 555
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556 556
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
557 557
 		    if (isset($ais_data['timestamp'])) {
558
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
558
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
559 559
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
560 560
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
561 561
 			    $add = true;
@@ -578,21 +578,21 @@  discard block
 block discarded – undo
578 578
 	    $w = $e = null;
579 579
 	    
580 580
 	    if (isset($arr[$id])) {
581
-		$nn = stream_select($arr,$w,$e,$timeout);
581
+		$nn = stream_select($arr, $w, $e, $timeout);
582 582
 		if ($nn > 0) {
583 583
 		    foreach ($httpfeeds as $feed) {
584
-			$buffer = stream_get_line($feed,2000,"\n");
584
+			$buffer = stream_get_line($feed, 2000, "\n");
585 585
 			if ($buffer === FALSE) {
586 586
 			    connect_all($globalSources);
587 587
 			}
588
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
589
-			$buffer = explode('\n',$buffer);
588
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
589
+			$buffer = explode('\n', $buffer);
590 590
 			foreach ($buffer as $line) {
591 591
 			    if ($line != '') {
592 592
 				$ais_data = $AIS->parse_line(trim($line));
593 593
 				$data = array();
594 594
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
595
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
595
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
596 596
 				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
597 597
 				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
598 598
 				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -604,9 +604,9 @@  discard block
 block discarded – undo
604 604
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
605 605
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
606 606
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
607
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
608 608
 				if (isset($ais_data['timestamp'])) {
609
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
609
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
610 610
 				} else {
611 611
 				    $data['datetime'] = date('Y-m-d H:i:s');
612 612
 				}
@@ -638,10 +638,10 @@  discard block
 block discarded – undo
638 638
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
639 639
 	    )
640 640
 	) {
641
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
641
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
642 642
 	    if ($buffer != '') {
643 643
 		//echo $buffer;
644
-		$all_data = json_decode($buffer,true);
644
+		$all_data = json_decode($buffer, true);
645 645
 		//print_r($all_data);
646 646
 		if (isset($all_data[0]['DATA'])) {
647 647
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
 			    $data['ident'] = $line['NAME'];
651 651
 			    $data['mmsi'] = $line['MMSI'];
652 652
 			    if (strlen($data['mmsi']) > 9) {
653
-				$data['mmsi'] = substr($data['mmsi'],-9);
653
+				$data['mmsi'] = substr($data['mmsi'], -9);
654 654
 			    }
655 655
 			    $data['speed'] = $line['SOG'];
656 656
 			    $data['heading'] = $line['COG'];
@@ -660,8 +660,8 @@  discard block
 block discarded – undo
660 660
 			    //$data['type_id'] = $line['TYPE'];
661 661
 			    $data['imo'] = $line['IMO'];
662 662
 			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
664
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
663
+			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s', strtotime($line['ARV']));
664
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
665 665
 			    $data['format_source'] = 'myshiptracking';
666 666
 			    $data['id_source'] = $id_source;
667 667
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -678,16 +678,16 @@  discard block
 block discarded – undo
678 678
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
679 679
 	    )
680 680
 	) {
681
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
681
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
682 682
 	    if ($buffer != '') {
683
-		$all_data = json_decode($buffer,true);
683
+		$all_data = json_decode($buffer, true);
684 684
 		if (isset($all_data[0]['mmsi'])) {
685 685
 		    foreach ($all_data as $line) {
686 686
 			if ($line != '') {
687 687
 			    $data = array();
688 688
 			    $data['ident'] = $line['shipname'];
689 689
 			    $data['callsign'] = $line['callsign'];
690
-			    $data['mmsi'] = substr($line['mmsi'],-9);
690
+			    $data['mmsi'] = substr($line['mmsi'], -9);
691 691
 			    $data['speed'] = $line['sog'];
692 692
 			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
693 693
 			    $data['latitude'] = $line['latitude'];
@@ -714,14 +714,14 @@  discard block
 block discarded – undo
714 714
 	) {
715 715
 	    $buffer = $Common->getData($value['host']);
716 716
 	    if ($buffer != '') {
717
-		$all_data = json_decode($buffer,true);
717
+		$all_data = json_decode($buffer, true);
718 718
 		if (isset($all_data['features'][0]['id'])) {
719 719
 		    foreach ($all_data['features'] as $line) {
720 720
 			print_r($line);
721 721
 			$data = array();
722 722
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
723 723
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
724
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
724
+			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'], -9);
725 725
 			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
726 726
 			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
727 727
 			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
@@ -748,31 +748,31 @@  discard block
 block discarded – undo
748 748
 	    )
749 749
 	) {
750 750
 	    if ($globalDebug) echo 'download...';
751
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
751
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
752 752
 	    if ($globalDebug) echo 'done !'."\n";
753 753
 	    // FIXME: Need more work
754 754
 	    if ($buffer != '') $reset = 0;
755
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756
-	    $buffer = explode('\n',$buffer);
755
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
756
+	    $buffer = explode('\n', $buffer);
757 757
 	    foreach ($buffer as $line) {
758 758
 		if ($line != '') {
759 759
 		    $data = array();
760 760
 		    //echo $line."\n";
761
-		    $data['mmsi'] = (int)substr($line,0,9);
762
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
763
-		    $data['status_id'] = substr($line,21,2);
764
-		    $data['type_id'] = substr($line,24,3);
765
-		    $data['latitude'] = substr($line,29,9);
766
-		    $data['longitude'] = substr($line,41,9);
767
-		    $data['speed'] = round(substr($line,51,5));
761
+		    $data['mmsi'] = (int) substr($line, 0, 9);
762
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
763
+		    $data['status_id'] = substr($line, 21, 2);
764
+		    $data['type_id'] = substr($line, 24, 3);
765
+		    $data['latitude'] = substr($line, 29, 9);
766
+		    $data['longitude'] = substr($line, 41, 9);
767
+		    $data['speed'] = round(substr($line, 51, 5));
768 768
 		    //$data['course'] = substr($line,57,5);
769
-		    $data['heading'] = round(substr($line,63,3));
769
+		    $data['heading'] = round(substr($line, 63, 3));
770 770
 		    //$data['draft'] = substr($line,67,4);
771 771
 		    //$data['length'] = substr($line,72,3);
772 772
 		    //$data['beam'] = substr($line,76,2);
773
-		    $data['ident'] = trim(utf8_encode(substr($line,78,20)));
773
+		    $data['ident'] = trim(utf8_encode(substr($line, 78, 20)));
774 774
 		    //$data['callsign'] = trim(substr($line,100,7);
775
-		    $data['arrival_code'] = substr($line,108,20);
775
+		    $data['arrival_code'] = substr($line, 108, 20);
776 776
 		    //$data['etaDate'] = substr($line,129,5);
777 777
 		    //$data['etaTime'] = substr($line,135,5);
778 778
 		    $data['format_source'] = 'shipplotter';
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
 	    )
792 792
 	) {
793 793
 	    if (isset($globalSailaway['email']) && $globalSailaway['email'] != '' && isset($globalSailaway['password']) && $globalSailaway['password'] != '') {
794
-		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl','post',array('submitlogin' => 'Login','email' => $globalSailaway['email'],'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'),'','','','','',false,false,true);
794
+		$authsailaway = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/weblogin.pl', 'post', array('submitlogin' => 'Login', 'email' => $globalSailaway['email'], 'pwd' => $globalSailaway['password'], 'page' => 'http://sailaway.world/cgi-bin/sailaway/missions.pl'), '', '', '', '', '', false, false, true);
795 795
 		//echo $authsailaway;
796 796
 		preg_match_all('/^Set-Cookie:\s*([^;]*)/mi', $authsailaway, $setcookie);
797 797
 		if (isset($setcookie[1][0])) {
@@ -800,19 +800,19 @@  discard block
 block discarded – undo
800 800
 	    }
801 801
 
802 802
 	    if ($globalDebug) echo '! Download... ';
803
-	    for ($i =0; $i <= 1; $i++) {
803
+	    for ($i = 0; $i <= 1; $i++) {
804 804
 		if ($globalDebug) echo 'Racetype: '.$i.' ';
805 805
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
806 806
 	    if ($globalDebug) echo 'done'."\n";
807 807
 	    if ($buffer != '') {
808
-		$all_data = json_decode($buffer,true);
808
+		$all_data = json_decode($buffer, true);
809 809
 		if (isset($all_data['missions'])) {
810 810
 			foreach ($all_data['missions'] as $mission) {
811 811
 				$mission_user = $mission['usrname'];
812
-				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($mission['mistitle']));
813
-				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'],$globalFilter['sailway']['race']))) {
812
+				$mission_name = preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($mission['mistitle']));
813
+				if (!isset($globalFilter['sailway']['race']) || (isset($globalFilter['sailway']['race']) && in_array($mission['misnr'], $globalFilter['sailway']['race']))) {
814 814
 					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
815
-						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
815
+						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'], 'get', '', '', $sailaway_authcookie);
816 816
 						sleep(10);
817 817
 					} else $racebuffer = '';
818 818
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
@@ -821,19 +821,19 @@  discard block
 block discarded – undo
821 821
 					$racebuffer = '';
822 822
 				}
823 823
 				if ($racebuffer != '') {
824
-					$race_data = json_decode($racebuffer,true);
824
+					$race_data = json_decode($racebuffer, true);
825 825
 					//print_r($race_data);
826 826
 					unset($racebuffer);
827 827
 					if (isset($race_data['mission'])) {
828 828
 					    $datar = array();
829 829
 					    $datar['id'] = $mission['misnr'];
830 830
 					    $datar['desc'] = $race_data['mission']['misdescr'];
831
-					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['usrname'])));
832
-					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($race_data['mission']['mistitle'])));
831
+					    $datar['creator'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['usrname'])));
832
+					    $datar['name'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($race_data['mission']['mistitle'])));
833 833
 					    $datar['startdate'] = $race_data['mission']['misstartdatetime'];
834 834
 					    $markers = array();
835 835
 					    foreach ($race_data['mission']['course'] as $course) {
836
-						$markers[] = array('lat' => $course['miclat'],'lon' => $course['miclon'],'name' => $course['micname'],'type' => $course['mictype']);
836
+						$markers[] = array('lat' => $course['miclat'], 'lon' => $course['miclon'], 'name' => $course['micname'], 'type' => $course['mictype']);
837 837
 					    }
838 838
 					    $datar['markers'] = json_encode($markers);
839 839
 					    //print_r($datar);
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 					}
842 842
 				}
843 843
 				if ($bufferm != '') {
844
-					$mission_data = json_decode($bufferm,true);
844
+					$mission_data = json_decode($bufferm, true);
845 845
 					unset($bufferm);
846 846
 					if (isset($mission_data['leaderboard'][0]['results'])) {
847 847
 						foreach ($mission_data['leaderboard'][0]['results'] as $sail) {
@@ -854,7 +854,7 @@  discard block
 block discarded – undo
854 854
 								//$data['id'] = $sail['misnr'].'-'.$sail['usrnr'].'-'.$sail['ubtnr'];
855 855
 								$data['id'] = $sail['misnr'].'-'.$sail['usrnr'];
856 856
 								$data['datetime'] = date('Y-m-d H:i:s');
857
-								$data['race_begin'] = date('Y-m-d H:i:s',strtotime($mission_data['leaderboard'][0]['misstart']));
857
+								$data['race_begin'] = date('Y-m-d H:i:s', strtotime($mission_data['leaderboard'][0]['misstart']));
858 858
 								$data['last_update'] = date('Y-m-d H:i:s');
859 859
 								$data['status'] = $sail['status'];
860 860
 								$data['type'] = $sail['btptype'];
@@ -865,16 +865,16 @@  discard block
 block discarded – undo
865 865
 									$data['longitude'] = $pos['longitude'];
866 866
 								}
867 867
 								if ($sail['status'] == 'Racing' && $sail['resultdescr'] != '-') {
868
-									$resultdescr = explode(',',$sail['resultdescr']);
868
+									$resultdescr = explode(',', $sail['resultdescr']);
869 869
 									if (count($resultdescr) > 2) {
870
-										$data['speed'] = round(str_replace(array('Spd: ','kn.'),'',trim($resultdescr[2]))*1.852,2);
871
-										$data['heading'] = str_replace(array('Hdg: ','°'),'',trim($resultdescr[1]));
870
+										$data['speed'] = round(str_replace(array('Spd: ', 'kn.'), '', trim($resultdescr[2]))*1.852, 2);
871
+										$data['heading'] = str_replace(array('Hdg: ', '°'), '', trim($resultdescr[1]));
872 872
 										if (isset($resultdescr[3])) {
873
-											$data['distance'] = round(str_replace('nm.','',trim(explode(' ',$resultdescr[3])[1]))*1.852,3);
873
+											$data['distance'] = round(str_replace('nm.', '', trim(explode(' ', $resultdescr[3])[1]))*1.852, 3);
874 874
 										}
875 875
 									}
876 876
 								}
877
-								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '',$Common->remove_accents($sail['ubtname'])));
877
+								$data['ident'] = trim(preg_replace('/[\x00-\x1F\x7F-\xFF]/', '', $Common->remove_accents($sail['ubtname'])));
878 878
 								$data['captain_id'] = $sail['usrnr'];
879 879
 								$data['captain_name'] = $sail['usrname'];
880 880
 								$data['race_id'] = $sail['misnr'];
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	) {
925 925
 	    //$buffer = $Common->getData($hosts[$id]);
926 926
 	    $buffer = $Common->getData($value['host']);
927
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
928
-	    $buffer = explode('\n',$buffer);
927
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
928
+	    $buffer = explode('\n', $buffer);
929 929
 	    $reset = 0;
930 930
 	    foreach ($buffer as $line) {
931 931
     		if ($line != '') {
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
937 937
 			$data['pilot_id'] = $line[1];
938 938
 			$data['pilot_name'] = $line[2];
939
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
939
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
940 940
 			$data['ident'] = $line[0]; // ident
941 941
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
942 942
 			$data['speed'] = $line[8]; // speed
@@ -952,7 +952,7 @@  discard block
 block discarded – undo
952 952
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
953 953
 			//if (isset($line[37])) $data['last_update'] = $line[37];
954 954
 		        $data['departure_airport_icao'] = $line[11];
955
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
955
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
956 956
 		        $data['arrival_airport_icao'] = $line[13];
957 957
 			$data['frequency'] = $line[4];
958 958
 			$data['type'] = $line[18];
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
     			$data['id_source'] = $id_source;
962 962
 	    		//$data['arrival_airport_time'] = ;
963 963
 	    		if ($line[9] != '') {
964
-	    		    $aircraft_data = explode('/',$line[9]);
964
+	    		    $aircraft_data = explode('/', $line[9]);
965 965
 	    		    if (isset($aircraft_data[1])) {
966 966
 	    			$data['aircraft_icao'] = $aircraft_data[1];
967 967
 	    		    }
@@ -976,9 +976,9 @@  discard block
 block discarded – undo
976 976
     			if ($line[3] === 'PILOT') $SI->add($data);
977 977
 			elseif ($line[3] === 'ATC') {
978 978
 				//print_r($data);
979
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
980
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
981
-				$typec = substr($data['ident'],-3);
979
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
980
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
981
+				$typec = substr($data['ident'], -3);
982 982
 				if ($typec === 'APP') $data['type'] = 'Approach';
983 983
 				elseif ($typec === 'TWR') $data['type'] = 'Tower';
984 984
 				elseif ($typec === 'OBS') $data['type'] = 'Observer';
@@ -990,8 +990,8 @@  discard block
 block discarded – undo
990 990
 				elseif ($data['type'] === '') $data['type'] = 'Observer';
991 991
 				if (!isset($data['source_name'])) $data['source_name'] = '';
992 992
 				if (isset($ATC)) {
993
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
994
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
993
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
994
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
995 995
 				}
996 996
 			}
997 997
     			unset($data);
@@ -1007,24 +1007,24 @@  discard block
 block discarded – undo
1007 1007
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1008 1008
     	    )
1009 1009
     	) {
1010
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
1010
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
1011 1011
 	    if ($buffer != '') {
1012 1012
 		$all_data = simplexml_load_string($buffer);
1013
-		foreach($all_data->children() as $childdata) {
1013
+		foreach ($all_data->children() as $childdata) {
1014 1014
 			$data = array();
1015 1015
 			$line = $childdata;
1016 1016
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
1017
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
1018
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1019
-			$data['latitude'] = (float)$line['pktLatitude'];
1020
-			$data['longitude'] = (float)$line['pktLongitude'];
1021
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1022
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1023
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1017
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
1018
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
1019
+			$data['latitude'] = (float) $line['pktLatitude'];
1020
+			$data['longitude'] = (float) $line['pktLongitude'];
1021
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
1022
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
1023
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
1024 1024
 			$data['altitude_relative'] = 'AMSL';
1025
-			$data['pilot_id'] = (int)$line['pktPilotID'];
1025
+			$data['pilot_id'] = (int) $line['pktPilotID'];
1026 1026
 			$data['aircraft_icao'] = 'PARAGLIDER';
1027
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1027
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1028 1028
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1029 1029
 			$data['format_source'] = $value['format'];
1030 1030
 			$SI->add($data);
@@ -1032,22 +1032,22 @@  discard block
 block discarded – undo
1032 1032
 		}
1033 1033
 	    }
1034 1034
 	    $Source->deleteOldLocationByType('gs');
1035
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
1035
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
1036 1036
 	    if ($buffer != '') {
1037 1037
 		$all_data = simplexml_load_string($buffer);
1038
-		foreach($all_data->children() as $childdata) {
1038
+		foreach ($all_data->children() as $childdata) {
1039 1039
 			$data = array();
1040 1040
 			$line = $childdata;
1041
-			$data['id'] = (int)$line['gsID'];
1042
-			$data['latitude'] = (float)$line['gsLatitude'];
1043
-			$data['longitude'] = (float)$line['gsLongitude'];
1044
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
1041
+			$data['id'] = (int) $line['gsID'];
1042
+			$data['latitude'] = (float) $line['gsLatitude'];
1043
+			$data['longitude'] = (float) $line['gsLongitude'];
1044
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
1045 1045
 			$data['altitude_relative'] = 'AMSL';
1046
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
1046
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
1047 1047
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
1048
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1048
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1049 1049
 			} else {
1050
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
1050
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
1051 1051
 			}
1052 1052
 			unset($data);
1053 1053
 		}
@@ -1065,9 +1065,9 @@  discard block
 block discarded – undo
1065 1065
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
1066 1066
 	    )
1067 1067
 	) {
1068
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
1068
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
1069 1069
 	    if ($buffer != '') {
1070
-	        $all_data = json_decode($buffer,true);
1070
+	        $all_data = json_decode($buffer, true);
1071 1071
 		if (isset($all_data['acList'])) {
1072 1072
 		    $reset = 0;
1073 1073
 		    foreach ($all_data['acList'] as $line) {
@@ -1083,7 +1083,7 @@  discard block
 block discarded – undo
1083 1083
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1084 1084
 			$data['emergency'] = ''; // emergency
1085 1085
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1086
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1086
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1087 1087
 			else $data['datetime'] = date('Y-m-d H:i:s');
1088 1088
 			//$data['datetime'] = date('Y-m-d H:i:s');
1089 1089
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1109 1109
 			$data['squawk'] = $line['squawk']; // squawk
1110 1110
 			$data['emergency'] = ''; // emergency
1111
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1111
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
1112 1112
 			else $data['datetime'] = date('Y-m-d H:i:s');
1113 1113
 			$data['format_source'] = 'aircraftlistjson';
1114 1114
 			$data['id_source'] = $id_source;
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
     	    )
1130 1130
     	) {
1131 1131
 	    $buffer = $Common->getData($value['host']);
1132
-	    $all_data = json_decode($buffer,true);
1132
+	    $all_data = json_decode($buffer, true);
1133 1133
 	    if (isset($all_data['planes'])) {
1134 1134
 		$reset = 0;
1135 1135
 		foreach ($all_data['planes'] as $key => $line) {
@@ -1146,12 +1146,12 @@  discard block
 block discarded – undo
1146 1146
 		    $data['emergency'] = ''; // emergency
1147 1147
 		    $data['registration'] = $line[2];
1148 1148
 		    $data['aircraft_icao'] = $line[0];
1149
-		    $deparr = explode('-',$line[1]);
1149
+		    $deparr = explode('-', $line[1]);
1150 1150
 		    if (count($deparr) === 2) {
1151 1151
 			$data['departure_airport_icao'] = $deparr[0];
1152 1152
 			$data['arrival_airport_icao'] = $deparr[1];
1153 1153
 		    }
1154
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1154
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
1155 1155
 	    	    $data['format_source'] = 'planeupdatefaa';
1156 1156
     		    $data['id_source'] = $id_source;
1157 1157
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	    )
1170 1170
 	) {
1171 1171
 	    $buffer = $Common->getData($value['host']);
1172
-	    $all_data = json_decode($buffer,true);
1172
+	    $all_data = json_decode($buffer, true);
1173 1173
 	    if (isset($all_data['states'])) {
1174 1174
 		$reset = 0;
1175 1175
 		foreach ($all_data['states'] as $key => $line) {
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 		    //$data['emergency'] = ''; // emergency
1187 1187
 		    //$data['registration'] = $line[2];
1188 1188
 		    //$data['aircraft_icao'] = $line[0];
1189
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1189
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
1190 1190
 		    $data['format_source'] = 'opensky';
1191 1191
 		    $data['id_source'] = $id_source;
1192 1192
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1203,8 +1203,8 @@  discard block
 block discarded – undo
1203 1203
 	    )
1204 1204
 	) {
1205 1205
 	    $buffer = $Common->getData($value['host']);
1206
-	    $all_data = json_decode($buffer,true);
1207
-	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time()-1800) {
1206
+	    $all_data = json_decode($buffer, true);
1207
+	    if (isset($all_data['aircraft']) && isset($all_data['now']) && $all_data['now'] > time() - 1800) {
1208 1208
 		$reset = 0;
1209 1209
 		foreach ($all_data['aircraft'] as $key => $line) {
1210 1210
 		    $data = array();
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 	    )
1243 1243
 	) {
1244 1244
 	    $buffer = $Common->getData($value['host']);
1245
-	    $all_data = json_decode($buffer,true);
1245
+	    $all_data = json_decode($buffer, true);
1246 1246
 	    if (isset($all_data['aircraft'])) {
1247 1247
 		$reset = 0;
1248 1248
 		foreach ($all_data['aircraft'] as $key => $line) {
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 		    //$data['emergency'] = ''; // emergency
1260 1260
 		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1261 1261
 		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1262
-		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1262
+		    $data['datetime'] = date('Y-m-d H:i:s', $line['pos_update_time']);
1263 1263
 		    $data['format_source'] = 'planefinderclient';
1264 1264
 		    $data['id_source'] = $id_source;
1265 1265
 		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
@@ -1278,7 +1278,7 @@  discard block
 block discarded – undo
1278 1278
 	) {
1279 1279
 	    //$buffer = $Common->getData($hosts[$id]);
1280 1280
 	    $buffer = $Common->getData($value['host']);
1281
-	    $all_data = json_decode($buffer,true);
1281
+	    $all_data = json_decode($buffer, true);
1282 1282
 	    if (!empty($all_data)) $reset = 0;
1283 1283
 	    foreach ($all_data as $key => $line) {
1284 1284
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1316,11 +1316,11 @@  discard block
 block discarded – undo
1316 1316
 	    )
1317 1317
 	) {
1318 1318
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1319
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1319
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1320 1320
 	    //echo $buffer;
1321
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1322
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1323
-	    $all_data = json_decode($buffer,true);
1321
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1322
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1323
+	    $all_data = json_decode($buffer, true);
1324 1324
 	    if (json_last_error() != JSON_ERROR_NONE) {
1325 1325
 		die(json_last_error_msg());
1326 1326
 	    }
@@ -1343,7 +1343,7 @@  discard block
 block discarded – undo
1343 1343
 			//$data['departure_airport_iata'] = $line[11];
1344 1344
 			//$data['arrival_airport_iata'] = $line[12];
1345 1345
 	    		//$data['emergency'] = ''; // emergency
1346
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1346
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1347 1347
 	    		$data['format_source'] = 'radarvirtueljson';
1348 1348
     			$data['id_source'] = $id_source;
1349 1349
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1364,14 +1364,14 @@  discard block
 block discarded – undo
1364 1364
 	) {
1365 1365
 	    //$buffer = $Common->getData($hosts[$id]);
1366 1366
 	    $buffer = $Common->getData($value['host'].'?'.time());
1367
-	    $all_data = json_decode(utf8_encode($buffer),true);
1367
+	    $all_data = json_decode(utf8_encode($buffer), true);
1368 1368
 	    
1369 1369
 	    if (isset($all_data['pireps'])) {
1370 1370
 		$reset = 0;
1371 1371
 	        foreach ($all_data['pireps'] as $line) {
1372 1372
 		    $data = array();
1373 1373
 		    $data['id'] = $line['id'];
1374
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1374
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1375 1375
 		    $data['ident'] = $line['callsign']; // ident
1376 1376
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1377 1377
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1401,9 +1401,9 @@  discard block
 block discarded – undo
1401 1401
 			$SI->add($data);
1402 1402
 		    //    print_r($data);
1403 1403
     		    } elseif ($line['icon'] === 'ct') {
1404
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1405
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1406
-			$typec = substr($data['ident'],-3);
1404
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1405
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1406
+			$typec = substr($data['ident'], -3);
1407 1407
 			$data['type'] = '';
1408 1408
 			if ($typec === 'APP') $data['type'] = 'Approach';
1409 1409
 			elseif ($typec === 'TWR') $data['type'] = 'Tower';
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
 			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1415 1415
 			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1416 1416
 			else $data['type'] = 'Observer';
1417
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1417
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1418 1418
 		    }
1419 1419
 		    unset($data);
1420 1420
 		}
@@ -1431,14 +1431,14 @@  discard block
 block discarded – undo
1431 1431
 	    //$buffer = $Common->getData($hosts[$id]);
1432 1432
 	    if ($globalDebug) echo 'Get Data...'."\n";
1433 1433
 	    $buffer = $Common->getData($value['host']);
1434
-	    $all_data = json_decode($buffer,true);
1434
+	    $all_data = json_decode($buffer, true);
1435 1435
 	    if ($buffer != '' && is_array($all_data)) {
1436 1436
 		$reset = 0;
1437 1437
 		foreach ($all_data as $line) {
1438 1438
 	    	    $data = array();
1439 1439
 	    	    //$data['id'] = $line['id']; // id not usable
1440 1440
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1441
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1441
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1442 1442
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1443 1443
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1444 1444
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1453,7 +1453,7 @@  discard block
 block discarded – undo
1453 1453
 	    	    //$data['datetime'] = $line['lastupdate'];
1454 1454
 	    	    //$data['last_update'] = $line['lastupdate'];
1455 1455
 	    	    if (isset($value['timezone'])) {
1456
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1456
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1457 1457
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1458 1458
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1459 1459
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1469,14 +1469,14 @@  discard block
 block discarded – undo
1469 1469
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1470 1470
 		    if (isset($line['aircraftname'])) {
1471 1471
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1472
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1473
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1472
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1473
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1474 1474
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1475 1475
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1476 1476
 	    		else {
1477
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1478
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1479
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1477
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1478
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1479
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1480 1480
 	    		}
1481 1481
 	    	    }
1482 1482
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
 	    //$buffer = $Common->getData($hosts[$id]);
1502 1502
 	    if ($globalDebug) echo 'Get Data...'."\n";
1503 1503
 	    $buffer = $Common->getData($value['host']);
1504
-	    $all_data = json_decode($buffer,true);
1504
+	    $all_data = json_decode($buffer, true);
1505 1505
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
1506 1506
 		$reset = 0;
1507 1507
 		foreach ($all_data['ACARSData'] as $line) {
@@ -1512,7 +1512,7 @@  discard block
 block discarded – undo
1512 1512
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1513 1513
 	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1514 1514
 	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
1515
-	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1515
+	    	    $data['ident'] = str_replace(' ', '', $line['bid']['flightnum']); // ident
1516 1516
 	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
1517 1517
 	    	    $data['altitude'] = $line['altitude']; // altitude
1518 1518
 	    	    $data['speed'] = $line['groundspeed']; // speed
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 	    	    //$data['squawk'] = ''; // squawk
1524 1524
 	    	    //$data['emergency'] = ''; // emergency
1525 1525
 	    	    if (isset($value['timezone'])) {
1526
-	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1526
+	    		$datetime = new DateTime($line['updated_at'], new DateTimeZone($value['timezone']));
1527 1527
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1528 1528
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1529 1529
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1559,14 +1559,14 @@  discard block
 block discarded – undo
1559 1559
 	    //$buffer = $Common->getData($hosts[$id]);
1560 1560
 	    if ($globalDebug) echo 'Get Data...'."\n";
1561 1561
 	    $buffer = $Common->getData($value['host']);
1562
-	    $all_data = json_decode($buffer,true);
1562
+	    $all_data = json_decode($buffer, true);
1563 1563
 	    if ($buffer != '' && is_array($all_data)) {
1564 1564
 		$reset = 0;
1565 1565
 		foreach ($all_data as $line) {
1566 1566
 	    	    $data = array();
1567 1567
 	    	    //$data['id'] = $line['id']; // id not usable
1568 1568
 	    	    $data['id'] = trim($line['flight_id']);
1569
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1569
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1570 1570
 	    	    $data['pilot_name'] = $line['pilot_name'];
1571 1571
 	    	    $data['pilot_id'] = $line['pilot_id'];
1572 1572
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1610,24 +1610,24 @@  discard block
 block discarded – undo
1610 1610
 	    //$buffer = $Common->getData($hosts[$id]);
1611 1611
 	    if ($globalDebug) echo 'Get Data...'."\n";
1612 1612
 	    $buffer = $Common->getData($value['host']);
1613
-	    $all_data = json_decode($buffer,true);
1613
+	    $all_data = json_decode($buffer, true);
1614 1614
 	    if ($buffer != '') {
1615 1615
 		$Source->deleteLocationBySource('blitzortung');
1616
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1617
-		$buffer = explode('\n',$buffer);
1616
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1617
+		$buffer = explode('\n', $buffer);
1618 1618
 		foreach ($buffer as $buffer_line) {
1619
-		    $line = json_decode($buffer_line,true);
1619
+		    $line = json_decode($buffer_line, true);
1620 1620
 		    if (isset($line['time'])) {
1621 1621
 			$data = array();
1622 1622
 			$data['altitude'] = $line['alt']; // altitude
1623 1623
 			$data['latitude'] = $line['lat']; // lat
1624 1624
 			$data['longitude'] = $line['lon']; // long
1625
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1625
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1626 1626
 			$data['id_source'] = $id_source;
1627 1627
 			$data['format_source'] = 'blitzortung';
1628 1628
 			$SI->add($data);
1629 1629
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1630
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1630
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1631 1631
 			unset($data);
1632 1632
 		    }
1633 1633
 		}
@@ -1639,15 +1639,15 @@  discard block
 block discarded – undo
1639 1639
         $arr = $httpfeeds;
1640 1640
         $w = $e = null;
1641 1641
         if (isset($arr[$id])) {
1642
-            $nn = stream_select($arr,$w,$e,$timeout);
1642
+            $nn = stream_select($arr, $w, $e, $timeout);
1643 1643
             if ($nn > 0) {
1644 1644
                 foreach ($httpfeeds as $feed) {
1645
-                    $buffer = stream_get_line($feed,2000,"\n");
1645
+                    $buffer = stream_get_line($feed, 2000, "\n");
1646 1646
                     if ($buffer === FALSE) {
1647 1647
                         connect_all($globalSources);
1648 1648
                     }
1649
-                    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1650
-                    $buffer = explode('\n',$buffer);
1649
+                    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1650
+                    $buffer = explode('\n', $buffer);
1651 1651
                     foreach ($buffer as $line) {
1652 1652
                         if ($line != '') {
1653 1653
                             $line = json_decode($line, true);
@@ -1687,11 +1687,11 @@  discard block
 block discarded – undo
1687 1687
 		    //$value = $formats[$nb];
1688 1688
 		    $format = $globalSources[$nb]['format'];
1689 1689
 		    if ($format === 'sbs' || $format === 'aprs' || $format === 'famaprs' || $format === 'raw' || $format === 'tsv' || $format === 'acarssbs3') {
1690
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1690
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1691 1691
 		    } elseif ($format === 'vrstcp') {
1692 1692
 			$buffer = @socket_read($r, 6000);
1693 1693
 		    } else {
1694
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1694
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1695 1695
 		    }
1696 1696
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1697 1697
 		    //echo $buffer."\n";
@@ -1701,8 +1701,8 @@  discard block
 block discarded – undo
1701 1701
 		    //$SI::del();
1702 1702
 		    if ($buffer !== FALSE) {
1703 1703
 			if ($format === 'vrstcp') {
1704
-			    $buffer = explode('},{',$buffer);
1705
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1704
+			    $buffer = explode('},{', $buffer);
1705
+			} else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1706 1706
 		    }
1707 1707
 		    // SBS format is CSV format
1708 1708
 		    if ($buffer !== FALSE && $buffer !== '') {
@@ -1729,7 +1729,7 @@  discard block
 block discarded – undo
1729 1729
 			    $ais_data = $AIS->parse_line(trim($buffer));
1730 1730
 			    $data = array();
1731 1731
 			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1732
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1732
+			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'], -9);
1733 1733
 			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1734 1734
 			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1735 1735
 			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
@@ -1740,13 +1740,13 @@  discard block
 block discarded – undo
1740 1740
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1741 1741
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1742 1742
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1743
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1743
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1744 1744
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1745 1745
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1746 1746
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1747 1747
 
1748 1748
 			    if (isset($ais_data['timestamp'])) {
1749
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1749
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1750 1750
 			    } else {
1751 1751
 				$data['datetime'] = date('Y-m-d H:i:s');
1752 1752
 			    }
@@ -1757,10 +1757,10 @@  discard block
 block discarded – undo
1757 1757
                         } elseif ($format === 'flightgearsp') {
1758 1758
                     	    //echo $buffer."\n";
1759 1759
                     	    if (strlen($buffer) > 5) {
1760
-				$line = explode(',',$buffer);
1760
+				$line = explode(',', $buffer);
1761 1761
 				$data = array();
1762 1762
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1763
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1763
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1764 1764
 				$data['ident'] = $line[6];
1765 1765
 				$data['aircraft_name'] = $line[7];
1766 1766
 				$data['longitude'] = $line[1];
@@ -1777,25 +1777,25 @@  discard block
 block discarded – undo
1777 1777
                         } elseif ($format === 'acars') {
1778 1778
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1779 1779
 			    $ACARS->add(trim($buffer));
1780
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1780
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1781 1781
 			    $ACARS->deleteLiveAcarsData();
1782 1782
 			} elseif ($format === 'acarsjsonudp') {
1783 1783
 			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1784 1784
                             $line = json_decode(trim($buffer), true);
1785 1785
                             if (!empty($line)) {
1786
-				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
1786
+				$line = array_merge(array('text' => '', 'tail' => '', 'label' => '', 'block_id' => '', 'flight' => '', 'msgno' => ''), $line);
1787 1787
                                 $ACARS->add(isset($line['text']) ? $line['text'] : '', array('registration' => str_replace('.', '', $line['tail']), 'ident' => $line['flight'], 'label' => $line['label'], 'block_id' => $line['block_id'], 'msg_no' => $line['msgno'], 'message' => (isset($line['text']) ? $line['text'] : '')));
1788 1788
                                 $ACARS->deleteLiveAcarsData();
1789 1789
                             }
1790
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1790
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1791 1791
 			} elseif ($format === 'flightgearmp') {
1792
-			    if (substr($buffer,0,1) != '#') {
1792
+			    if (substr($buffer, 0, 1) != '#') {
1793 1793
 				$data = array();
1794 1794
 				//echo $buffer."\n";
1795
-				$line = explode(' ',$buffer);
1795
+				$line = explode(' ', $buffer);
1796 1796
 				if (count($line) === 11) {
1797
-				    $userserver = explode('@',$line[0]);
1798
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1797
+				    $userserver = explode('@', $line[0]);
1798
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1799 1799
 				    $data['ident'] = $userserver[0];
1800 1800
 				    $data['registration'] = $userserver[0];
1801 1801
 				    $data['latitude'] = $line[4];
@@ -1803,8 +1803,8 @@  discard block
 block discarded – undo
1803 1803
 				    $data['altitude'] = $line[6];
1804 1804
 				    $data['datetime'] = date('Y-m-d H:i:s');
1805 1805
 				    $aircraft_type = $line[10];
1806
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1807
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1806
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1807
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1808 1808
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1809 1809
 				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1810 1810
 				}
@@ -1813,8 +1813,8 @@  discard block
 block discarded – undo
1813 1813
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1814 1814
 			    die;
1815 1815
 			} elseif ($format === 'vrstcp') {
1816
-			    foreach($buffer as $all_data) {
1817
-				$line = json_decode('{'.$all_data.'}',true);
1816
+			    foreach ($buffer as $all_data) {
1817
+				$line = json_decode('{'.$all_data.'}', true);
1818 1818
 				$data = array();
1819 1819
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1820 1820
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1840,16 +1840,16 @@  discard block
 block discarded – undo
1840 1840
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1841 1841
 				unset($data);
1842 1842
 			    }
1843
-			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
1843
+			} elseif ($format === 'tsv' || substr($buffer, 0, 4) === 'clock') {
1844 1844
 			    $line = explode("\t", $buffer);
1845
-			    for($k = 0; $k < count($line); $k=$k+2) {
1845
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1846 1846
 				$key = $line[$k];
1847
-			        $lined[$key] = $line[$k+1];
1847
+			        $lined[$key] = $line[$k + 1];
1848 1848
 			    }
1849 1849
     			    if (count($lined) > 3) {
1850 1850
     				$data['hex'] = $lined['hexid'];
1851 1851
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1852
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1852
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1853 1853
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1854 1854
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1855 1855
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1868,23 +1868,23 @@  discard block
 block discarded – undo
1868 1868
     			    } else $error = true;
1869 1869
 			} elseif ($format === 'aprs' && $use_aprs) {
1870 1870
 			    if ($aprs_connect === 0) {
1871
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1871
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1872 1872
 				$aprs_connect = 1;
1873 1873
 			    }
1874 1874
 			    
1875
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1875
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1876 1876
 				$aprs_last_tx = time();
1877 1877
 				$data_aprs = "# Keep alive";
1878
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1878
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1879 1879
 			    }
1880 1880
 			    
1881 1881
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1882 1882
 			    //echo 'APRS data : '.$buffer."\n";
1883
-			    $buffer = str_replace('APRS <- ','',$buffer);
1884
-			    $buffer = str_replace('APRS -> ','',$buffer);
1883
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1884
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1885 1885
 			    //echo $buffer."\n";
1886 1886
 			    date_default_timezone_set('UTC');
1887
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1887
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1888 1888
 				$line = $APRS->parse($buffer);
1889 1889
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1890 1890
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1899,7 +1899,7 @@  discard block
 block discarded – undo
1899 1899
 				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1900 1900
 				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1901 1901
 				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1902
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1902
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1903 1903
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1904 1904
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1905 1905
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1987,29 +1987,29 @@  discard block
 block discarded – undo
1987 1987
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1988 1988
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1989 1989
 					$Source->deleteOldLocationByType('gs');
1990
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1991
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1990
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1991
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1992 1992
 					} else {
1993
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1993
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1994 1994
 					}
1995 1995
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1996 1996
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1997 1997
 					if ($globalDebug) echo '# Weather Station added'."\n";
1998 1998
 					$Source->deleteOldLocationByType('wx');
1999 1999
 					$weather_data = json_encode($line);
2000
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
2001
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2000
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
2001
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2002 2002
 					} else {
2003
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
2003
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
2004 2004
 					}
2005 2005
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2006 2006
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2007 2007
 					if ($globalDebug) echo '☈ Lightning added'."\n";
2008 2008
 					$Source->deleteOldLocationByType('lightning');
2009
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2010
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2009
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
2010
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2011 2011
 					} else {
2012
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
2012
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
2013 2013
 					}
2014 2014
 				    } elseif ($globalDebug) {
2015 2015
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -2018,7 +2018,7 @@  discard block
 block discarded – undo
2018 2018
 				    unset($data);
2019 2019
 				}
2020 2020
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2021
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2021
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
2022 2022
 				}
2023 2023
 				/*
2024 2024
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] === 'Car' || $line['symbol'] === 'Ambulance' || $line['symbol'] === 'Van' || $line['symbol'] === 'Truck' || $line['symbol'] === 'Truck (18 Wheeler)' || $line['symbol'] === 'Motorcycle')) {
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 				*/
2028 2028
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2029 2029
 				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2030
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2030
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
2031 2031
 					$Source->deleteOldLocationByType('lightning');
2032 2032
 					$Source->deleteOldLocationByType('wx');
2033 2033
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -2114,7 +2114,7 @@  discard block
 block discarded – undo
2114 2114
 				connect_all($sourceee);
2115 2115
 				$sourceee = array();
2116 2116
 				//connect_all($globalSources);
2117
-				$tt[$format]=0;
2117
+				$tt[$format] = 0;
2118 2118
 				break;
2119 2119
 			    } 
2120 2120
 			    //else if ($globalDebug) echo "Trying again (".$tt[$format]."x) ".$format."...";
@@ -2124,14 +2124,14 @@  discard block
 block discarded – undo
2124 2124
 	    } else {
2125 2125
 		$error = socket_strerror(socket_last_error());
2126 2126
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2127
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2127
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
2128 2128
 			if (isset($globalDebug)) echo "Restarting...\n";
2129 2129
 			// Restart the script if possible
2130 2130
 			if (is_array($sockets)) {
2131 2131
 			    if ($globalDebug) echo "Shutdown all sockets...";
2132 2132
 			    
2133 2133
 			    foreach ($sockets as $sock) {
2134
-				@socket_shutdown($sock,2);
2134
+				@socket_shutdown($sock, 2);
2135 2135
 				@socket_close($sock);
2136 2136
 			    }
2137 2137
 			    
Please login to merge, or discard this patch.
Braces   +1234 added lines, -415 removed lines patch added patch discarded remove patch
@@ -22,7 +22,9 @@  discard block
 block discarded – undo
22 22
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
23 23
 }
24 24
 
25
-if (!isset($globalDebug)) $globalDebug = FALSE;
25
+if (!isset($globalDebug)) {
26
+	$globalDebug = FALSE;
27
+}
26 28
 
27 29
 if ($globalInstalled === FALSE) {
28 30
     echo "This script MUST be run after install script. Use your web browser to run install/index.php";
@@ -68,66 +70,107 @@  discard block
 block discarded – undo
68 70
 //elseif (isset($options['source'])) $hosts = array($options['source']);
69 71
 if (isset($options['s'])) {
70 72
     $globalSources = array();
71
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
72
-    else $globalSources[] = array('host' => $options['s']);
73
-} elseif (isset($options['source'])) {
73
+    if (isset($options['format'])) {
74
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
75
+    } else {
76
+    	$globalSources[] = array('host' => $options['s']);
77
+    }
78
+    } elseif (isset($options['source'])) {
74 79
     $globalSources = array();
75
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
76
-    else $globalSources[] = array('host' => $options['source']);
77
-}
80
+    if (isset($options['format'])) {
81
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
82
+    } else {
83
+    	$globalSources[] = array('host' => $options['source']);
84
+    }
85
+    }
78 86
 if (isset($options['aprsserverhost'])) {
79 87
 	$globalServerAPRS = TRUE;
80 88
 	$globalServerAPRShost = $options['aprsserverhost'];
81 89
 }
82
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
83
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
84
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
85
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
90
+if (isset($options['aprsserverport'])) {
91
+	$globalServerAPRSport = $options['aprsserverport'];
92
+}
93
+if (isset($options['aprsserverssid'])) {
94
+	$globalServerAPRSssid = $options['aprsserverssid'];
95
+}
96
+if (isset($options['aprsserverpass'])) {
97
+	$globalServerAPRSpass = $options['aprsserverpass'];
98
+}
99
+if (isset($options['noaprsserver'])) {
100
+	$globalServerAPRS = FALSE;
101
+}
86 102
 if (isset($options['enable-aircraft'])) {
87
-	if ($globalDebug) echo 'Enable Aircraft mode'."\n";
103
+	if ($globalDebug) {
104
+		echo 'Enable Aircraft mode'."\n";
105
+	}
88 106
 	$globalAircraft = TRUE; 
89 107
 }
90 108
 if (isset($options['disable-aircraft'])) {
91
-	if ($globalDebug) echo 'Disable Aircraft mode'."\n";
109
+	if ($globalDebug) {
110
+		echo 'Disable Aircraft mode'."\n";
111
+	}
92 112
 	$globalAircraft = FALSE;
93 113
 }
94 114
 if (isset($options['enable-tracker'])) {
95
-	if ($globalDebug) echo 'Enable Tracker mode'."\n";
115
+	if ($globalDebug) {
116
+		echo 'Enable Tracker mode'."\n";
117
+	}
96 118
 	$globalTracker = TRUE; 
97 119
 }
98 120
 if (isset($options['disable-tracker'])) {
99
-	if ($globalDebug) echo 'Disable Tracker mode'."\n";
121
+	if ($globalDebug) {
122
+		echo 'Disable Tracker mode'."\n";
123
+	}
100 124
 	$globalTracker = FALSE;
101 125
 }
102 126
 if (isset($options['enable-marine'])) {
103
-	if ($globalDebug) echo 'Enable Marine mode'."\n";
127
+	if ($globalDebug) {
128
+		echo 'Enable Marine mode'."\n";
129
+	}
104 130
 	$globalMarine = TRUE;
105 131
 }
106 132
 if (isset($options['disable-marine'])) {
107
-	if ($globalDebug) echo 'Disable Marine mode'."\n";
133
+	if ($globalDebug) {
134
+		echo 'Disable Marine mode'."\n";
135
+	}
108 136
 	$globalMarine = FALSE;
109 137
 }
110
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
111
-if (isset($options['server'])) $globalServer = TRUE;
112
-if (isset($options['idsource'])) $id_source = $options['idsource'];
113
-else $id_source = 1;
138
+if (isset($options['nodaemon'])) {
139
+	$globalDaemon = FALSE;
140
+}
141
+if (isset($options['server'])) {
142
+	$globalServer = TRUE;
143
+}
144
+if (isset($options['idsource'])) {
145
+	$id_source = $options['idsource'];
146
+} else {
147
+	$id_source = 1;
148
+}
114 149
 if (isset($globalServer) && $globalServer) {
115
-    if ($globalDebug) echo "Using Server Mode\n";
150
+    if ($globalDebug) {
151
+    	echo "Using Server Mode\n";
152
+    }
116 153
     $SI=new SpotterServer();
117 154
 /*
118 155
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
119 156
     $SI = new adsb2aprs();
120 157
     $SI->connect();
121 158
 */
122
-} else $SI=new SpotterImport($Connection->db);
159
+} else {
160
+	$SI=new SpotterImport($Connection->db);
161
+}
123 162
 
124
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
163
+if (isset($globalTracker) && $globalTracker) {
164
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
165
+}
125 166
 if (isset($globalMarine) && $globalMarine) {
126 167
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
127 168
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
128 169
 }
129 170
 
130
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
171
+if (isset($globalTracker) && $globalTracker) {
172
+	$TI = new TrackerImport($Connection->db);
173
+}
131 174
 if (isset($globalMarine) && $globalMarine) {
132 175
     $AIS = new AIS();
133 176
     $MI = new MarineImport($Connection->db);
@@ -152,7 +195,9 @@  discard block
 block discarded – undo
152 195
 }
153 196
 
154 197
 // let's try and connect
155
-if ($globalDebug) echo "Connecting...\n";
198
+if ($globalDebug) {
199
+	echo "Connecting...\n";
200
+}
156 201
 $use_aprs = false;
157 202
 $aprs_full = false;
158 203
 $reset = 0;
@@ -161,7 +206,9 @@  discard block
 block discarded – undo
161 206
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
162 207
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
163 208
     $reset++;
164
-    if ($globalDebug) echo 'Connect to all...'."\n";
209
+    if ($globalDebug) {
210
+    	echo 'Connect to all...'."\n";
211
+    }
165 212
     foreach ($hosts as $id => $value) {
166 213
 	$host = $value['host'];
167 214
 	$udp = false;
@@ -172,32 +219,44 @@  discard block
 block discarded – undo
172 219
         	//$formats[$id] = 'deltadbtxt';
173 220
         	$globalSources[$id]['format'] = 'deltadbtxt';
174 221
         	//$last_exec['deltadbtxt'] = 0;
175
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
222
+        	if ($globalDebug) {
223
+        		echo "Connect to deltadb source (".$host.")...\n";
224
+        	}
176 225
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
177 226
         	//$formats[$id] = 'vatsimtxt';
178 227
         	$globalSources[$id]['format'] = 'vatsimtxt';
179 228
         	//$last_exec['vatsimtxt'] = 0;
180
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
229
+        	if ($globalDebug) {
230
+        		echo "Connect to vatsim source (".$host.")...\n";
231
+        	}
181 232
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
182 233
         	//$formats[$id] = 'aircraftlistjson';
183 234
         	$globalSources[$id]['format'] = 'aircraftlistjson';
184 235
         	//$last_exec['aircraftlistjson'] = 0;
185
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
236
+        	if ($globalDebug) {
237
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
238
+        	}
186 239
     	    } else if (preg_match('/aircraft.json$/i',$host)) {
187 240
         	//$formats[$id] = 'aircraftjson';
188 241
         	$globalSources[$id]['format'] = 'aircraftjson';
189 242
         	//$last_exec['aircraftlistjson'] = 0;
190
-        	if ($globalDebug) echo "Connect to aircraft.json source (".$host.")...\n";
243
+        	if ($globalDebug) {
244
+        		echo "Connect to aircraft.json source (".$host.")...\n";
245
+        	}
191 246
     	    } else if (preg_match('/aircraft$/i',$host)) {
192 247
         	//$formats[$id] = 'planefinderclient';
193 248
         	$globalSources[$id]['format'] = 'planefinderclient';
194 249
         	//$last_exec['aircraftlistjson'] = 0;
195
-        	if ($globalDebug) echo "Connect to planefinderclient source (".$host.")...\n";
250
+        	if ($globalDebug) {
251
+        		echo "Connect to planefinderclient source (".$host.")...\n";
252
+        	}
196 253
     	    } else if (preg_match('/opensky/i',$host)) {
197 254
         	//$formats[$id] = 'aircraftlistjson';
198 255
         	$globalSources[$id]['format'] = 'opensky';
199 256
         	//$last_exec['aircraftlistjson'] = 0;
200
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
257
+        	if ($globalDebug) {
258
+        		echo "Connect to opensky source (".$host.")...\n";
259
+        	}
201 260
     	    /*
202 261
     	    // Disabled for now, site change source format
203 262
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -214,7 +273,9 @@  discard block
 block discarded – undo
214 273
         	//$formats[$id] = 'planeupdatefaa';
215 274
         	$globalSources[$id]['format'] = 'planeupdatefaa';
216 275
         	//$last_exec['planeupdatefaa'] = 0;
217
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
276
+        	if ($globalDebug) {
277
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
278
+        	}
218 279
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
219 280
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
220 281
         	    exit(0);
@@ -223,37 +284,53 @@  discard block
 block discarded – undo
223 284
         	//$formats[$id] = 'phpvmacars';
224 285
         	$globalSources[$id]['format'] = 'phpvmacars';
225 286
         	//$last_exec['phpvmacars'] = 0;
226
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
287
+        	if ($globalDebug) {
288
+        		echo "Connect to phpvmacars source (".$host.")...\n";
289
+        	}
227 290
             } else if (preg_match('/\/api\/v1\/acars\/data$/i',$host)) {
228 291
         	//$formats[$id] = 'phpvmacars';
229 292
         	$globalSources[$id]['format'] = 'vaos';
230 293
         	//$last_exec['phpvmacars'] = 0;
231
-        	if ($globalDebug) echo "Connect to vaos source (".$host.")...\n";
294
+        	if ($globalDebug) {
295
+        		echo "Connect to vaos source (".$host.")...\n";
296
+        	}
232 297
             } else if (preg_match('/VAM-json.php$/i',$host)) {
233 298
         	//$formats[$id] = 'phpvmacars';
234 299
         	$globalSources[$id]['format'] = 'vam';
235
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
300
+        	if ($globalDebug) {
301
+        		echo "Connect to Vam source (".$host.")...\n";
302
+        	}
236 303
             } else if (preg_match('/whazzup/i',$host)) {
237 304
         	//$formats[$id] = 'whazzup';
238 305
         	$globalSources[$id]['format'] = 'whazzup';
239 306
         	//$last_exec['whazzup'] = 0;
240
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
307
+        	if ($globalDebug) {
308
+        		echo "Connect to whazzup source (".$host.")...\n";
309
+        	}
241 310
             } else if (preg_match('/blitzortung/i',$host)) {
242 311
         	$globalSources[$id]['format'] = 'blitzortung';
243
-        	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
312
+        	if ($globalDebug) {
313
+        		echo "Connect to blitzortung source (".$host.")...\n";
314
+        	}
244 315
             } else if (preg_match('/airwhere/i',$host)) {
245 316
         	$globalSources[$id]['format'] = 'airwhere';
246
-        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
317
+        	if ($globalDebug) {
318
+        		echo "Connect to airwhere source (".$host.")...\n";
319
+        	}
247 320
             } else if (preg_match('/recentpireps/i',$host)) {
248 321
         	//$formats[$id] = 'pirepsjson';
249 322
         	$globalSources[$id]['format'] = 'pirepsjson';
250 323
         	//$last_exec['pirepsjson'] = 0;
251
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
324
+        	if ($globalDebug) {
325
+        		echo "Connect to pirepsjson source (".$host.")...\n";
326
+        	}
252 327
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
253 328
         	//$formats[$id] = 'fr24json';
254 329
         	$globalSources[$id]['format'] = 'fr24json';
255 330
         	//$last_exec['fr24json'] = 0;
256
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
331
+        	if ($globalDebug) {
332
+        		echo "Connect to fr24 source (".$host.")...\n";
333
+        	}
257 334
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
258 335
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
259 336
         	    exit(0);
@@ -262,7 +339,9 @@  discard block
 block discarded – undo
262 339
         	//$formats[$id] = 'fr24json';
263 340
         	$globalSources[$id]['format'] = 'myshiptracking';
264 341
         	//$last_exec['fr24json'] = 0;
265
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
342
+        	if ($globalDebug) {
343
+        		echo "Connect to myshiptracking source (".$host.")...\n";
344
+        	}
266 345
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
267 346
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
268 347
         	    exit(0);
@@ -271,17 +350,26 @@  discard block
 block discarded – undo
271 350
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
272 351
         	//$formats[$id] = 'tsv';
273 352
         	$globalSources[$id]['format'] = 'tsv';
274
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
353
+        	if ($globalDebug) {
354
+        		echo "Connect to tsv source (".$host.")...\n";
355
+        	}
275 356
             }
276 357
         } elseif (filter_var($host,FILTER_VALIDATE_URL) || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') || (isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'acarsjson')) {
277 358
     		if ($globalSources[$id]['format'] == 'aisnmeahttp' || $globalSources[$id]['format'] == 'acarsjson') {
278 359
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
279 360
     		    if ($idf !== false) {
280 361
     			$httpfeeds[$id] = $idf;
281
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
282
-    		    } elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
283
-    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
284
-    		elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
362
+        		if ($globalDebug) {
363
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
364
+        		}
365
+    		    } elseif ($globalDebug) {
366
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
367
+    		    }
368
+    		} elseif ($globalDebug && isset($globalSources[$id]['format']) && $globalSources[$id]['format'] == 'sailaway') {
369
+    			echo "Connect to ".$globalSources[$id]['format']." source (sailaway)...\n";
370
+    		} elseif ($globalDebug) {
371
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
372
+    		}
285 373
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
286 374
 	    $hostport = explode(':',$host);
287 375
 	    if (isset($hostport[1])) {
@@ -322,20 +410,29 @@  discard block
 block discarded – undo
322 410
         		//$formats[$id] = 'beast';
323 411
         		$globalSources[$id]['format'] = 'beast';
324 412
 		    //} else $formats[$id] = 'sbs';
325
-		    } else $globalSources[$id]['format'] = 'sbs';
413
+		    } else {
414
+		    	$globalSources[$id]['format'] = 'sbs';
415
+		    }
326 416
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
327 417
 		}
328
-		if ($globalDebug && $udp) echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
329
-		elseif ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
418
+		if ($globalDebug && $udp) {
419
+			echo 'Listening in UDP from '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
420
+		} elseif ($globalDebug) {
421
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
422
+		}
330 423
             } else {
331
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
424
+		if ($globalDebug) {
425
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
426
+		}
332 427
 		sleep(10);
333 428
 		connect_all($hosts);
334 429
     	    }
335 430
         }
336 431
     }
337 432
 }
338
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
433
+if (!isset($globalMinFetch)) {
434
+	$globalMinFetch = 15;
435
+}
339 436
 
340 437
 // Initialize all
341 438
 $status = array();
@@ -344,13 +441,19 @@  discard block
 block discarded – undo
344 441
 $formats = array();
345 442
 $last_exec = array();
346 443
 $time = time();
347
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
348
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
349
-else $timeout = 20;
444
+if (isset($globalSourcesTimeout)) {
445
+	$timeout = $globalSourcesTimeOut;
446
+} else if (isset($globalSBS1TimeOut)) {
447
+	$timeout = $globalSBS1TimeOut;
448
+} else {
449
+	$timeout = 20;
450
+}
350 451
 $errno = '';
351 452
 $errstr='';
352 453
 
353
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
454
+if (!isset($globalDaemon)) {
455
+	$globalDaemon = TRUE;
456
+}
354 457
 /* Initiate connections to all the hosts simultaneously */
355 458
 //connect_all($hosts);
356 459
 //connect_all($globalSources);
@@ -379,7 +482,9 @@  discard block
 block discarded – undo
379 482
     if (isset($source['format']) && $source['format'] == 'aprs') {
380 483
 	$aprs_connect = 0;
381 484
 	$use_aprs = true;
382
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
485
+	if (isset($source['port']) && $source['port'] == '10152') {
486
+		$aprs_full = true;
487
+	}
383 488
 	break;
384 489
     }
385 490
 }
@@ -390,25 +495,46 @@  discard block
 block discarded – undo
390 495
 	$aprs_connect = 0;
391 496
 	$aprs_keep = 120;
392 497
 	$aprs_last_tx = time();
393
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
394
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
395
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
396
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
397
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
398
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
399
-	if ($aprs_full) $aprs_filter = '';
400
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
401
-	else $aprs_pass = '-1';
498
+	if (isset($globalAPRSversion)) {
499
+		$aprs_version = $globalAPRSversion;
500
+	} else {
501
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
502
+	}
503
+	if (isset($globalAPRSssid)) {
504
+		$aprs_ssid = $globalAPRSssid;
505
+	} else {
506
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
507
+	}
508
+	if (isset($globalAPRSfilter)) {
509
+		$aprs_filter = $globalAPRSfilter;
510
+	} else {
511
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
512
+	}
513
+	if ($aprs_full) {
514
+		$aprs_filter = '';
515
+	}
516
+	if (isset($globalAPRSpass)) {
517
+		$aprs_pass = $globalAPRSpass;
518
+	} else {
519
+		$aprs_pass = '-1';
520
+	}
402 521
 
403
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
404
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
405
-}
522
+	if ($aprs_filter != '') {
523
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
524
+	} else {
525
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
526
+	}
527
+	}
406 528
 
407 529
 // connected - lets do some work
408 530
 //if ($globalDebug) echo "Connected!\n";
409 531
 sleep(1);
410
-if ($globalDebug) echo "SCAN MODE \n\n";
411
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
532
+if ($globalDebug) {
533
+	echo "SCAN MODE \n\n";
534
+}
535
+if (!isset($globalCronEnd)) {
536
+	$globalCronEnd = 60;
537
+}
412 538
 $endtime = time()+$globalCronEnd;
413 539
 $i = 1;
414 540
 $tt = array();
@@ -422,22 +548,32 @@  discard block
 block discarded – undo
422 548
 
423 549
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
424 550
 while ($i > 0) {
425
-    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
551
+    if (function_exists('pcntl_fork')) {
552
+    	pcntl_signal_dispatch();
553
+    }
426 554
 
427
-    if (!$globalDaemon) $i = $endtime-time();
555
+    if (!$globalDaemon) {
556
+    	$i = $endtime-time();
557
+    }
428 558
     // Delete old ATC
429 559
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
430
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
560
+	if ($globalDebug) {
561
+		echo 'Delete old ATC...'."\n";
562
+	}
431 563
         $ATC->deleteOldATC();
432 564
     }
433 565
     
434 566
     if (count($last_exec) == count($globalSources)) {
435 567
 	$max = $globalMinFetch;
436 568
 	foreach ($last_exec as $last) {
437
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
569
+	    if ((time() - $last['last']) < $max) {
570
+	    	$max = time() - $last['last'];
571
+	    }
438 572
 	}
439 573
 	if ($max < $globalMinFetch) {
440
-	    if ($globalDebug) echo 'Sleeping...'."\n";
574
+	    if ($globalDebug) {
575
+	    	echo 'Sleeping...'."\n";
576
+	    }
441 577
 	    sleep($globalMinFetch-$max+2);
442 578
 	}
443 579
     }
@@ -447,7 +583,9 @@  discard block
 block discarded – undo
447 583
     foreach ($globalSources as $id => $value) {
448 584
 	date_default_timezone_set('UTC');
449 585
 	//if ($globalDebug) echo 'Source host : '.$value['host'].' - Source format: '.$value['format']."\n";
450
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
586
+	if (!isset($last_exec[$id]['last'])) {
587
+		$last_exec[$id]['last'] = 0;
588
+	}
451 589
 	if ($value['format'] === 'deltadbtxt' && 
452 590
 	    (
453 591
 		(isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalSources[$id]['minfetch'])) || 
@@ -456,7 +594,9 @@  discard block
 block discarded – undo
456 594
 	) {
457 595
         //$buffer = $Common->getData($hosts[$id]);
458 596
         $buffer = $Common->getData($value['host']);
459
-        if ($buffer != '') $reset = 0;
597
+        if ($buffer != '') {
598
+        	$reset = 0;
599
+        }
460 600
         $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
461 601
         $buffer = explode('\n', $buffer);
462 602
         foreach ($buffer as $line) {
@@ -465,20 +605,41 @@  discard block
 block discarded – undo
465 605
                 $data = array();
466 606
                 $data['hex'] = $line[1]; // hex
467 607
                 $data['ident'] = $line[2]; // ident
468
-                if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
469
-                if (isset($line[4])) $data['speed'] = $line[4]; // speed
470
-                if (isset($line[5])) $data['heading'] = $line[5]; // heading
471
-                if (isset($line[6])) $data['latitude'] = $line[6]; // lat
472
-                if (isset($line[7])) $data['longitude'] = $line[7]; // long
608
+                if (isset($line[3])) {
609
+                	$data['altitude'] = $line[3];
610
+                }
611
+                // altitude
612
+                if (isset($line[4])) {
613
+                	$data['speed'] = $line[4];
614
+                }
615
+                // speed
616
+                if (isset($line[5])) {
617
+                	$data['heading'] = $line[5];
618
+                }
619
+                // heading
620
+                if (isset($line[6])) {
621
+                	$data['latitude'] = $line[6];
622
+                }
623
+                // lat
624
+                if (isset($line[7])) {
625
+                	$data['longitude'] = $line[7];
626
+                }
627
+                // long
473 628
                 $data['verticalrate'] = ''; // vertical rate
474 629
                 //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
475 630
                 $data['emergency'] = ''; // emergency
476 631
                 $data['datetime'] = date('Y-m-d H:i:s');
477 632
                 $data['format_source'] = 'deltadbtxt';
478 633
                 $data['id_source'] = $id_source;
479
-                if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
480
-                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
481
-                if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
634
+                if (isset($value['name']) && $value['name'] != '') {
635
+                	$data['source_name'] = $value['name'];
636
+                }
637
+                if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
638
+                	$data['noarchive'] = true;
639
+                }
640
+                if (isset($value['sourcestats'])) {
641
+                	$data['sourcestats'] = $value['sourcestats'];
642
+                }
482 643
                 $SI->add($data);
483 644
                 unset($data);
484 645
             }
@@ -513,11 +674,20 @@  discard block
 block discarded – undo
513 674
                     $data['format_source'] = 'radarcapejson';
514 675
                     $data['id_source'] = $id_source;
515 676
                     if (isset($value['name']) && $value['name'] != '') {
516
-                        if (isset($line['src']) && !$line['src'] == 'M') $data['source_name'] = $value['name'].'_MLAT';
517
-                        else $data['source_name'] = $value['name'];
518
-                    } elseif (isset($line['src']) && $line['src'] == 'M') $data['source_name'] = 'MLAT';
519
-                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
520
-                    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
677
+                        if (isset($line['src']) && !$line['src'] == 'M') {
678
+                        	$data['source_name'] = $value['name'].'_MLAT';
679
+                        } else {
680
+                        	$data['source_name'] = $value['name'];
681
+                        }
682
+                    } elseif (isset($line['src']) && $line['src'] == 'M') {
683
+                    	$data['source_name'] = 'MLAT';
684
+                    }
685
+                    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
686
+                    	$data['noarchive'] = true;
687
+                    }
688
+                    if (isset($value['sourcestats'])) {
689
+                    	$data['sourcestats'] = $value['sourcestats'];
690
+                    }
521 691
 
522 692
                     $SI->add($data);
523 693
                     unset($data);
@@ -533,7 +703,9 @@  discard block
 block discarded – undo
533 703
 	    date_default_timezone_set('CET');
534 704
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
535 705
 	    date_default_timezone_set('UTC');
536
-	    if ($buffer != '') $reset = 0;
706
+	    if ($buffer != '') {
707
+	    	$reset = 0;
708
+	    }
537 709
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
538 710
 	    $buffer = explode('\n',$buffer);
539 711
 	    foreach ($buffer as $line) {
@@ -542,18 +714,42 @@  discard block
 block discarded – undo
542 714
 		    $add = false;
543 715
 		    $ais_data = $AIS->parse_line(trim($line));
544 716
 		    $data = array();
545
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
546
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
547
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
548
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
549
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
550
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
551
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
552
-		    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
553
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
554
-		    if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
555
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
556
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
717
+		    if (isset($ais_data['ident'])) {
718
+		    	$data['ident'] = $ais_data['ident'];
719
+		    }
720
+		    if (isset($ais_data['mmsi'])) {
721
+		    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
722
+		    }
723
+		    if (isset($ais_data['speed'])) {
724
+		    	$data['speed'] = $ais_data['speed'];
725
+		    }
726
+		    if (isset($ais_data['heading'])) {
727
+		    	$data['heading'] = $ais_data['heading'];
728
+		    }
729
+		    if (isset($ais_data['latitude'])) {
730
+		    	$data['latitude'] = $ais_data['latitude'];
731
+		    }
732
+		    if (isset($ais_data['longitude'])) {
733
+		    	$data['longitude'] = $ais_data['longitude'];
734
+		    }
735
+		    if (isset($ais_data['status'])) {
736
+		    	$data['status'] = $ais_data['status'];
737
+		    }
738
+		    if (isset($ais_data['statusid'])) {
739
+		    	$data['status_id'] = $ais_data['statusid'];
740
+		    }
741
+		    if (isset($ais_data['type'])) {
742
+		    	$data['type'] = $ais_data['type'];
743
+		    }
744
+		    if (isset($ais_data['typeid'])) {
745
+		    	$data['type_id'] = $ais_data['typeid'];
746
+		    }
747
+		    if (isset($ais_data['imo'])) {
748
+		    	$data['imo'] = $ais_data['imo'];
749
+		    }
750
+		    if (isset($ais_data['callsign'])) {
751
+		    	$data['callsign'] = $ais_data['callsign'];
752
+		    }
557 753
 		    if (isset($ais_data['timestamp'])) {
558 754
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
559 755
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -567,8 +763,12 @@  discard block
 block discarded – undo
567 763
 		    $data['format_source'] = 'aisnmeatxt';
568 764
     		    $data['id_source'] = $id_source;
569 765
 		    //print_r($data);
570
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
571
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
766
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
767
+		    	$data['noarchive'] = true;
768
+		    }
769
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
770
+		    	$MI->add($data);
771
+		    }
572 772
 		    unset($data);
573 773
 		}
574 774
     	    }
@@ -591,20 +791,48 @@  discard block
 block discarded – undo
591 791
 			    if ($line != '') {
592 792
 				$ais_data = $AIS->parse_line(trim($line));
593 793
 				$data = array();
594
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
595
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
596
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
597
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
598
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
599
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
600
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
601
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
602
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
603
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
604
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
605
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
606
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
607
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
794
+				if (isset($ais_data['ident'])) {
795
+					$data['ident'] = $ais_data['ident'];
796
+				}
797
+				if (isset($ais_data['mmsi'])) {
798
+					$data['mmsi'] = substr($ais_data['mmsi'],-9);
799
+				}
800
+				if (isset($ais_data['speed'])) {
801
+					$data['speed'] = $ais_data['speed'];
802
+				}
803
+				if (isset($ais_data['heading'])) {
804
+					$data['heading'] = $ais_data['heading'];
805
+				}
806
+				if (isset($ais_data['latitude'])) {
807
+					$data['latitude'] = $ais_data['latitude'];
808
+				}
809
+				if (isset($ais_data['longitude'])) {
810
+					$data['longitude'] = $ais_data['longitude'];
811
+				}
812
+				if (isset($ais_data['status'])) {
813
+					$data['status'] = $ais_data['status'];
814
+				}
815
+				if (isset($ais_data['statusid'])) {
816
+					$data['status_id'] = $ais_data['statusid'];
817
+				}
818
+				if (isset($ais_data['type'])) {
819
+					$data['type'] = $ais_data['type'];
820
+				}
821
+				if (isset($ais_data['typeid'])) {
822
+					$data['type_id'] = $ais_data['typeid'];
823
+				}
824
+				if (isset($ais_data['imo'])) {
825
+					$data['imo'] = $ais_data['imo'];
826
+				}
827
+				if (isset($ais_data['callsign'])) {
828
+					$data['callsign'] = $ais_data['callsign'];
829
+				}
830
+				if (isset($ais_data['destination'])) {
831
+					$data['arrival_code'] = $ais_data['destination'];
832
+				}
833
+				if (isset($ais_data['eta_ts'])) {
834
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
835
+				}
608 836
 				if (isset($ais_data['timestamp'])) {
609 837
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
610 838
 				} else {
@@ -612,18 +840,27 @@  discard block
 block discarded – undo
612 840
 				}
613 841
 				$data['format_source'] = 'aisnmeahttp';
614 842
 				$data['id_source'] = $id_source;
615
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
616
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
843
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
844
+					$data['noarchive'] = true;
845
+				}
846
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
847
+					$MI->add($data);
848
+				}
617 849
 				unset($data);
618 850
 			    }
619 851
 			}
620 852
 		    }
621 853
 		} else {
622 854
 		    $format = $value['format'];
623
-		    if (isset($tt[$format])) $tt[$format]++;
624
-		    else $tt[$format] = 0;
855
+		    if (isset($tt[$format])) {
856
+		    	$tt[$format]++;
857
+		    } else {
858
+		    	$tt[$format] = 0;
859
+		    }
625 860
 		    if ($tt[$format] > 30) {
626
-			if ($globalDebug) echo 'Reconnect...'."\n";
861
+			if ($globalDebug) {
862
+				echo 'Reconnect...'."\n";
863
+			}
627 864
 			sleep(2);
628 865
 			//$sourceeen[] = $value;
629 866
 			//connect_all($sourceeen);
@@ -659,12 +896,18 @@  discard block
 block discarded – undo
659 896
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
660 897
 			    //$data['type_id'] = $line['TYPE'];
661 898
 			    $data['imo'] = $line['IMO'];
662
-			    if ($line['DEST'] != '') $data['arrival_code'] = $line['DEST'];
663
-			    if ($line['ARV'] != '') $data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
899
+			    if ($line['DEST'] != '') {
900
+			    	$data['arrival_code'] = $line['DEST'];
901
+			    }
902
+			    if ($line['ARV'] != '') {
903
+			    	$data['arrival_time'] = date('Y-m-d H:i:s',strtotime($line['ARV']));
904
+			    }
664 905
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
665 906
 			    $data['format_source'] = 'myshiptracking';
666 907
 			    $data['id_source'] = $id_source;
667
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
908
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
909
+			    	$data['noarchive'] = true;
910
+			    }
668 911
 			    $MI->add($data);
669 912
 			    unset($data);
670 913
 			}
@@ -689,7 +932,9 @@  discard block
 block discarded – undo
689 932
 			    $data['callsign'] = $line['callsign'];
690 933
 			    $data['mmsi'] = substr($line['mmsi'],-9);
691 934
 			    $data['speed'] = $line['sog'];
692
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
935
+			    if ($line['heading'] != '511') {
936
+			    	$data['heading'] = $line['heading'];
937
+			    }
693 938
 			    $data['latitude'] = $line['latitude'];
694 939
 			    $data['longitude'] = $line['longitude'];
695 940
 			    $data['type_id'] = $line['shiptype'];
@@ -697,7 +942,9 @@  discard block
 block discarded – undo
697 942
 			    $data['datetime'] = $line['time'];
698 943
 			    $data['format_source'] = 'boatbeaconapp';
699 944
 			    $data['id_source'] = $id_source;
700
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
945
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
946
+			    	$data['noarchive'] = true;
947
+			    }
701 948
 			    $MI->add($data);
702 949
 			    unset($data);
703 950
 			}
@@ -719,22 +966,44 @@  discard block
 block discarded – undo
719 966
 		    foreach ($all_data['features'] as $line) {
720 967
 			print_r($line);
721 968
 			$data = array();
722
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
723
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
724
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = substr($line['properties']['mmsi'],-9);
725
-			if (isset($line['properties']['imo'])) $data['imo'] = $line['properties']['imo'];
726
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
727
-			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) $data['heading'] = $line['properties']['heading'];
969
+			if (isset($line['properties']['name'])) {
970
+				$data['ident'] = $line['properties']['name'];
971
+			}
972
+			if (isset($line['properties']['callsign'])) {
973
+				$data['callsign'] = $line['properties']['callsign'];
974
+			}
975
+			if (isset($line['properties']['mmsi'])) {
976
+				$data['mmsi'] = substr($line['properties']['mmsi'],-9);
977
+			}
978
+			if (isset($line['properties']['imo'])) {
979
+				$data['imo'] = $line['properties']['imo'];
980
+			}
981
+			if (isset($line['properties']['speed'])) {
982
+				$data['speed'] = $line['properties']['speed'];
983
+			}
984
+			if (isset($line['properties']['heading']) && $line['properties']['heading'] != 0) {
985
+				$data['heading'] = $line['properties']['heading'];
986
+			}
728 987
 			$data['latitude'] = $line['geometry']['coordinates'][1];
729 988
 			$data['longitude'] = $line['geometry']['coordinates'][0];
730
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
731
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
732
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
989
+			if (isset($line['properties']['vesselType'])) {
990
+				$data['type'] = $line['properties']['vesselType'];
991
+			}
992
+			if (isset($line['properties']['destination'])) {
993
+				$data['arrival_code'] = $line['properties']['destination'];
994
+			}
995
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
996
+				$data['arrival_date'] = $line['properties']['eta'];
997
+			}
733 998
 			$data['format_source'] = 'boatnerd';
734 999
 			$data['id_source'] = $id_source;
735 1000
 			$data['datetime'] = date('Y-m-d H:i:s');
736
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
737
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
1001
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1002
+				$data['noarchive'] = true;
1003
+			}
1004
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
1005
+				$MI->add($data);
1006
+			}
738 1007
 			unset($data);
739 1008
 		    }
740 1009
 		}
@@ -747,11 +1016,17 @@  discard block
 block discarded – undo
747 1016
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
748 1017
 	    )
749 1018
 	) {
750
-	    if ($globalDebug) echo 'download...';
1019
+	    if ($globalDebug) {
1020
+	    	echo 'download...';
1021
+	    }
751 1022
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
752
-	    if ($globalDebug) echo 'done !'."\n";
1023
+	    if ($globalDebug) {
1024
+	    	echo 'done !'."\n";
1025
+	    }
753 1026
 	    // FIXME: Need more work
754
-	    if ($buffer != '') $reset = 0;
1027
+	    if ($buffer != '') {
1028
+	    	$reset = 0;
1029
+	    }
755 1030
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
756 1031
 	    $buffer = explode('\n',$buffer);
757 1032
 	    foreach ($buffer as $line) {
@@ -777,7 +1052,9 @@  discard block
 block discarded – undo
777 1052
 		    //$data['etaTime'] = substr($line,135,5);
778 1053
 		    $data['format_source'] = 'shipplotter';
779 1054
     		    $data['id_source'] = $id_source;
780
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1055
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1056
+		    	$data['noarchive'] = true;
1057
+		    }
781 1058
 		    //print_r($data);
782 1059
 		    //echo 'Add...'."\n";
783 1060
 		    $MI->add($data);
@@ -799,11 +1076,17 @@  discard block
 block discarded – undo
799 1076
 		}
800 1077
 	    }
801 1078
 
802
-	    if ($globalDebug) echo '! Download... ';
1079
+	    if ($globalDebug) {
1080
+	    	echo '! Download... ';
1081
+	    }
803 1082
 	    for ($i =0; $i <= 1; $i++) {
804
-		if ($globalDebug) echo 'Racetype: '.$i.' ';
1083
+		if ($globalDebug) {
1084
+			echo 'Racetype: '.$i.' ';
1085
+		}
805 1086
 		$buffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMissions.pl?race=1&tutorial=0&hist=1&racetype='.$i);
806
-	    if ($globalDebug) echo 'done'."\n";
1087
+	    if ($globalDebug) {
1088
+	    	echo 'done'."\n";
1089
+	    }
807 1090
 	    if ($buffer != '') {
808 1091
 		$all_data = json_decode($buffer,true);
809 1092
 		if (isset($all_data['missions'])) {
@@ -814,7 +1097,9 @@  discard block
 block discarded – undo
814 1097
 					if (isset($sailaway_authcookie) && $sailaway_authcookie != '') {
815 1098
 						$racebuffer = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetMission.pl?misnr='.$mission['misnr'],'get','','',$sailaway_authcookie);
816 1099
 						sleep(10);
817
-					} else $racebuffer = '';
1100
+					} else {
1101
+						$racebuffer = '';
1102
+					}
818 1103
 					$bufferm = $Common->getData('http://backend.sailaway.world/cgi-bin/sailaway/GetLeaderboard.pl?misnr='.$mission['misnr']);
819 1104
 				} else {
820 1105
 					$bufferm = '';
@@ -878,7 +1163,9 @@  discard block
 block discarded – undo
878 1163
 								$data['captain_id'] = $sail['usrnr'];
879 1164
 								$data['captain_name'] = $sail['usrname'];
880 1165
 								$data['race_id'] = $sail['misnr'];
881
-								if ($sail['rank'] != 'DNF') $data['race_rank'] = $sail['rank'];
1166
+								if ($sail['rank'] != 'DNF') {
1167
+									$data['race_rank'] = $sail['rank'];
1168
+								}
882 1169
 								$data['race_time'] = $sail['racetime'];
883 1170
 								if ($mission_user != '') {
884 1171
 									$data['race_name'] = $mission_name.' ('.$mission_user.')';
@@ -888,7 +1175,9 @@  discard block
 block discarded – undo
888 1175
 								//$data['callsign'] = trim(substr($line,100,7);
889 1176
 								$data['format_source'] = 'sailaway';
890 1177
 								$data['id_source'] = $id_source;
891
-								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1178
+								if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1179
+									$data['noarchive'] = true;
1180
+								}
892 1181
 								//print_r($data);
893 1182
 								//if ($data['race_id'] == '48') print_r($data);
894 1183
 								//echo 'Add...'."\n";
@@ -932,16 +1221,28 @@  discard block
 block discarded – undo
932 1221
     		    $line = explode(':', $line);
933 1222
     		    if (count($line) > 30 && $line[0] != 'callsign') {
934 1223
 			$data = array();
935
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
936
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1224
+			if (isset($line[37]) && $line[37] != '') {
1225
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
1226
+			} else {
1227
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
1228
+			}
937 1229
 			$data['pilot_id'] = $line[1];
938 1230
 			$data['pilot_name'] = $line[2];
939 1231
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
940 1232
 			$data['ident'] = $line[0]; // ident
941
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
1233
+			if ($line[7] != '' && $line[7] != 0) {
1234
+				$data['altitude'] = $line[7];
1235
+			}
1236
+			// altitude
942 1237
 			$data['speed'] = $line[8]; // speed
943
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
944
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
1238
+			if (isset($line[45])) {
1239
+				$data['heading'] = $line[45];
1240
+			}
1241
+			// heading
1242
+			elseif (isset($line[38])) {
1243
+				$data['heading'] = $line[38];
1244
+			}
1245
+			// heading
945 1246
 			$data['latitude'] = $line[5]; // lat
946 1247
 	        	$data['longitude'] = $line[6]; // long
947 1248
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -957,7 +1258,9 @@  discard block
 block discarded – undo
957 1258
 			$data['frequency'] = $line[4];
958 1259
 			$data['type'] = $line[18];
959 1260
 			$data['range'] = $line[19];
960
-			if (isset($line[35])) $data['info'] = $line[35];
1261
+			if (isset($line[35])) {
1262
+				$data['info'] = $line[35];
1263
+			}
961 1264
     			$data['id_source'] = $id_source;
962 1265
 	    		//$data['arrival_airport_time'] = ;
963 1266
 	    		if ($line[9] != '') {
@@ -971,27 +1274,47 @@  discard block
 block discarded – undo
971 1274
 	    		elseif ($value === 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
972 1275
 	    		*/
973 1276
 	    		$data['format_source'] = $value['format'];
974
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
975
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
976
-    			if ($line[3] === 'PILOT') $SI->add($data);
977
-			elseif ($line[3] === 'ATC') {
1277
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1278
+				$data['noarchive'] = true;
1279
+			}
1280
+			if (isset($value['name']) && $value['name'] != '') {
1281
+				$data['source_name'] = $value['name'];
1282
+			}
1283
+    			if ($line[3] === 'PILOT') {
1284
+    				$SI->add($data);
1285
+    			} elseif ($line[3] === 'ATC') {
978 1286
 				//print_r($data);
979 1287
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
980 1288
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
981 1289
 				$typec = substr($data['ident'],-3);
982
-				if ($typec === 'APP') $data['type'] = 'Approach';
983
-				elseif ($typec === 'TWR') $data['type'] = 'Tower';
984
-				elseif ($typec === 'OBS') $data['type'] = 'Observer';
985
-				elseif ($typec === 'GND') $data['type'] = 'Ground';
986
-				elseif ($typec === 'DEL') $data['type'] = 'Delivery';
987
-				elseif ($typec === 'DEP') $data['type'] = 'Departure';
988
-				elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
989
-				elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
990
-				elseif ($data['type'] === '') $data['type'] = 'Observer';
991
-				if (!isset($data['source_name'])) $data['source_name'] = '';
1290
+				if ($typec === 'APP') {
1291
+					$data['type'] = 'Approach';
1292
+				} elseif ($typec === 'TWR') {
1293
+					$data['type'] = 'Tower';
1294
+				} elseif ($typec === 'OBS') {
1295
+					$data['type'] = 'Observer';
1296
+				} elseif ($typec === 'GND') {
1297
+					$data['type'] = 'Ground';
1298
+				} elseif ($typec === 'DEL') {
1299
+					$data['type'] = 'Delivery';
1300
+				} elseif ($typec === 'DEP') {
1301
+					$data['type'] = 'Departure';
1302
+				} elseif ($typec === 'FSS') {
1303
+					$data['type'] = 'Flight Service Station';
1304
+				} elseif ($typec === 'CTR') {
1305
+					$data['type'] = 'Control Radar or Centre';
1306
+				} elseif ($data['type'] === '') {
1307
+					$data['type'] = 'Observer';
1308
+				}
1309
+				if (!isset($data['source_name'])) {
1310
+					$data['source_name'] = '';
1311
+				}
992 1312
 				if (isset($ATC)) {
993
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
994
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1313
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
1314
+						echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1315
+					} else {
1316
+						echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
1317
+					}
995 1318
 				}
996 1319
 			}
997 1320
     			unset($data);
@@ -1018,14 +1341,20 @@  discard block
 block discarded – undo
1018 1341
 			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
1019 1342
 			$data['latitude'] = (float)$line['pktLatitude'];
1020 1343
 			$data['longitude'] = (float)$line['pktLongitude'];
1021
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
1022
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
1344
+			if ((float)$line['pktTrack'] != 0) {
1345
+				$data['heading'] = (float)$line['pktTrack'];
1346
+			}
1347
+			if ((int)$line['pktSpeed'] != 0) {
1348
+				$data['speed'] = (int)$line['pktSpeed'];
1349
+			}
1023 1350
 			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
1024 1351
 			$data['altitude_relative'] = 'AMSL';
1025 1352
 			$data['pilot_id'] = (int)$line['pktPilotID'];
1026 1353
 			$data['aircraft_icao'] = 'PARAGLIDER';
1027 1354
 			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
1028
-			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
1355
+			if (isset($pilot_data[4])) {
1356
+				$data['pilot_name'] = $pilot_data[4];
1357
+			}
1029 1358
 			$data['format_source'] = $value['format'];
1030 1359
 			$SI->add($data);
1031 1360
 			unset($data);
@@ -1073,25 +1402,59 @@  discard block
 block discarded – undo
1073 1402
 		    foreach ($all_data['acList'] as $line) {
1074 1403
 			$data = array();
1075 1404
 			$data['hex'] = $line['Icao']; // hex
1076
-			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1077
-			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1078
-			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1079
-			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1080
-			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1081
-			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1405
+			if (isset($line['Call'])) {
1406
+				$data['ident'] = $line['Call'];
1407
+			}
1408
+			// ident
1409
+			if (isset($line['Alt'])) {
1410
+				$data['altitude'] = $line['Alt'];
1411
+			}
1412
+			// altitude
1413
+			if (isset($line['Spd'])) {
1414
+				$data['speed'] = $line['Spd'];
1415
+			}
1416
+			// speed
1417
+			if (isset($line['Trak'])) {
1418
+				$data['heading'] = $line['Trak'];
1419
+			}
1420
+			// heading
1421
+			if (isset($line['Lat'])) {
1422
+				$data['latitude'] = $line['Lat'];
1423
+			}
1424
+			// lat
1425
+			if (isset($line['Long'])) {
1426
+				$data['longitude'] = $line['Long'];
1427
+			}
1428
+			// long
1082 1429
 			//$data['verticalrate'] = $line['']; // verticale rate
1083
-			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1430
+			if (isset($line['Sqk'])) {
1431
+				$data['squawk'] = $line['Sqk'];
1432
+			}
1433
+			// squawk
1084 1434
 			$data['emergency'] = ''; // emergency
1085
-			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1086
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1087
-			else $data['datetime'] = date('Y-m-d H:i:s');
1435
+			if (isset($line['Reg'])) {
1436
+				$data['registration'] = $line['Reg'];
1437
+			}
1438
+			if (isset($line['PosTime'])) {
1439
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1440
+			} else {
1441
+				$data['datetime'] = date('Y-m-d H:i:s');
1442
+			}
1088 1443
 			//$data['datetime'] = date('Y-m-d H:i:s');
1089
-			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1444
+			if (isset($line['Type'])) {
1445
+				$data['aircraft_icao'] = $line['Type'];
1446
+			}
1090 1447
 			$data['format_source'] = 'aircraftlistjson';
1091 1448
 			$data['id_source'] = $id_source;
1092
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1093
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1094
-			if (isset($data['latitude'])) $SI->add($data);
1449
+			if (isset($value['name']) && $value['name'] != '') {
1450
+				$data['source_name'] = $value['name'];
1451
+			}
1452
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1453
+				$data['noarchive'] = true;
1454
+			}
1455
+			if (isset($data['latitude'])) {
1456
+				$SI->add($data);
1457
+			}
1095 1458
 			unset($data);
1096 1459
 		    }
1097 1460
 		} elseif (is_array($all_data)) {
@@ -1108,17 +1471,26 @@  discard block
 block discarded – undo
1108 1471
 			$data['verticalrate'] = $line['vrt']; // verticale rate
1109 1472
 			$data['squawk'] = $line['squawk']; // squawk
1110 1473
 			$data['emergency'] = ''; // emergency
1111
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1112
-			else $data['datetime'] = date('Y-m-d H:i:s');
1474
+			if (isset($line['PosTime'])) {
1475
+				$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1476
+			} else {
1477
+				$data['datetime'] = date('Y-m-d H:i:s');
1478
+			}
1113 1479
 			$data['format_source'] = 'aircraftlistjson';
1114 1480
 			$data['id_source'] = $id_source;
1115
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1116
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1481
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1482
+				$data['noarchive'] = true;
1483
+			}
1484
+			if (isset($value['name']) && $value['name'] != '') {
1485
+				$data['source_name'] = $value['name'];
1486
+			}
1117 1487
 			$SI->add($data);
1118 1488
 			unset($data);
1119 1489
 		    }
1120 1490
 		}
1121
-	    } elseif ($globalDebug) echo 'No data'."\n";
1491
+	    } elseif ($globalDebug) {
1492
+	    	echo 'No data'."\n";
1493
+	    }
1122 1494
     	    //$last_exec['aircraftlistjson'] = time();
1123 1495
     	    $last_exec[$id]['last'] = time();
1124 1496
     	//} elseif ($value === 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
@@ -1154,8 +1526,12 @@  discard block
 block discarded – undo
1154 1526
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
1155 1527
 	    	    $data['format_source'] = 'planeupdatefaa';
1156 1528
     		    $data['id_source'] = $id_source;
1157
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1158
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1529
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1530
+		    	$data['noarchive'] = true;
1531
+		    }
1532
+		    if (isset($value['name']) && $value['name'] != '') {
1533
+		    	$data['source_name'] = $value['name'];
1534
+		    }
1159 1535
 		    $SI->add($data);
1160 1536
 		    unset($data);
1161 1537
 		}
@@ -1189,7 +1565,9 @@  discard block
 block discarded – undo
1189 1565
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
1190 1566
 		    $data['format_source'] = 'opensky';
1191 1567
 		    $data['id_source'] = $id_source;
1192
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1568
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1569
+		    	$data['noarchive'] = true;
1570
+		    }
1193 1571
 		    $SI->add($data);
1194 1572
 		    unset($data);
1195 1573
 		}
@@ -1209,15 +1587,42 @@  discard block
 block discarded – undo
1209 1587
 		foreach ($all_data['aircraft'] as $key => $line) {
1210 1588
 		    $data = array();
1211 1589
 		    // add support for ground vehicule with ~ in front of hex
1212
-		    if (isset($line['hex'])) $data['hex'] = $line['hex']; // hex
1213
-		    if (isset($line['flight'])) $data['ident'] = trim($line['flight']); // ident
1214
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1215
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1216
-		    if (isset($line['track'])) $data['heading'] = $line['track']; // heading
1217
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1218
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1219
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1220
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1590
+		    if (isset($line['hex'])) {
1591
+		    	$data['hex'] = $line['hex'];
1592
+		    }
1593
+		    // hex
1594
+		    if (isset($line['flight'])) {
1595
+		    	$data['ident'] = trim($line['flight']);
1596
+		    }
1597
+		    // ident
1598
+		    if (isset($line['altitude'])) {
1599
+		    	$data['altitude'] = $line['altitude'];
1600
+		    }
1601
+		    // altitude
1602
+		    if (isset($line['speed'])) {
1603
+		    	$data['speed'] = $line['speed'];
1604
+		    }
1605
+		    // speed
1606
+		    if (isset($line['track'])) {
1607
+		    	$data['heading'] = $line['track'];
1608
+		    }
1609
+		    // heading
1610
+		    if (isset($line['lat'])) {
1611
+		    	$data['latitude'] = $line['lat'];
1612
+		    }
1613
+		    // lat
1614
+		    if (isset($line['lon'])) {
1615
+		    	$data['longitude'] = $line['lon'];
1616
+		    }
1617
+		    // long
1618
+		    if (isset($line['vert_rate'])) {
1619
+		    	$data['verticalrate'] = $line['vert_rate'];
1620
+		    }
1621
+		    // verticale rate
1622
+		    if (isset($line['squawk'])) {
1623
+		    	$data['squawk'] = $line['squawk'];
1624
+		    }
1625
+		    // squawk
1221 1626
 		    //$data['emergency'] = ''; // emergency
1222 1627
 		    //$data['registration'] = $line[2];
1223 1628
 		    //$data['aircraft_icao'] = $line[0];
@@ -1225,10 +1630,17 @@  discard block
 block discarded – undo
1225 1630
 		    $data['format_source'] = 'aircraftjson';
1226 1631
 		    $data['id_source'] = $id_source;
1227 1632
 		    if (isset($value['name']) && $value['name'] != '') {
1228
-			    if (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = $value['name'].'_MLAT';
1229
-			    else $data['source_name'] = $value['name'];
1230
-		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) $data['source_name'] = 'MLAT';
1231
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1633
+			    if (isset($line['mlat']) && !empty($line['mlat'])) {
1634
+			    	$data['source_name'] = $value['name'].'_MLAT';
1635
+			    } else {
1636
+			    	$data['source_name'] = $value['name'];
1637
+			    }
1638
+		    } elseif (isset($line['mlat']) && !empty($line['mlat'])) {
1639
+		    	$data['source_name'] = 'MLAT';
1640
+		    }
1641
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1642
+		    	$data['noarchive'] = true;
1643
+		    }
1232 1644
 		    $SI->add($data);
1233 1645
 		    unset($data);
1234 1646
 		}
@@ -1248,22 +1660,54 @@  discard block
 block discarded – undo
1248 1660
 		foreach ($all_data['aircraft'] as $key => $line) {
1249 1661
 		    $data = array();
1250 1662
 		    $data['hex'] = $key; // hex
1251
-		    if (isset($line['callsign'])) $data['ident'] = trim($line['callsign']); // ident
1252
-		    if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; // altitude
1253
-		    if (isset($line['speed'])) $data['speed'] = $line['speed']; // speed
1254
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1255
-		    if (isset($line['lat'])) $data['latitude'] = $line['lat']; // lat
1256
-		    if (isset($line['lon'])) $data['longitude'] = $line['lon']; // long
1257
-		    if (isset($line['vert_rate'])) $data['verticalrate'] = $line['vert_rate']; // verticale rate
1258
-		    if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; // squawk
1663
+		    if (isset($line['callsign'])) {
1664
+		    	$data['ident'] = trim($line['callsign']);
1665
+		    }
1666
+		    // ident
1667
+		    if (isset($line['altitude'])) {
1668
+		    	$data['altitude'] = $line['altitude'];
1669
+		    }
1670
+		    // altitude
1671
+		    if (isset($line['speed'])) {
1672
+		    	$data['speed'] = $line['speed'];
1673
+		    }
1674
+		    // speed
1675
+		    if (isset($line['heading'])) {
1676
+		    	$data['heading'] = $line['heading'];
1677
+		    }
1678
+		    // heading
1679
+		    if (isset($line['lat'])) {
1680
+		    	$data['latitude'] = $line['lat'];
1681
+		    }
1682
+		    // lat
1683
+		    if (isset($line['lon'])) {
1684
+		    	$data['longitude'] = $line['lon'];
1685
+		    }
1686
+		    // long
1687
+		    if (isset($line['vert_rate'])) {
1688
+		    	$data['verticalrate'] = $line['vert_rate'];
1689
+		    }
1690
+		    // verticale rate
1691
+		    if (isset($line['squawk'])) {
1692
+		    	$data['squawk'] = $line['squawk'];
1693
+		    }
1694
+		    // squawk
1259 1695
 		    //$data['emergency'] = ''; // emergency
1260
-		    if (isset($line['reg'])) $data['registration'] = $line['reg'];
1261
-		    if (isset($line['type'])) $data['aircraft_icao'] = $line['type'];
1696
+		    if (isset($line['reg'])) {
1697
+		    	$data['registration'] = $line['reg'];
1698
+		    }
1699
+		    if (isset($line['type'])) {
1700
+		    	$data['aircraft_icao'] = $line['type'];
1701
+		    }
1262 1702
 		    $data['datetime'] = date('Y-m-d H:i:s',$line['pos_update_time']);
1263 1703
 		    $data['format_source'] = 'planefinderclient';
1264 1704
 		    $data['id_source'] = $id_source;
1265
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1266
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1705
+		    if (isset($value['name']) && $value['name'] != '') {
1706
+		    	$data['source_name'] = $value['name'];
1707
+		    }
1708
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1709
+		    	$data['noarchive'] = true;
1710
+		    }
1267 1711
 		    $SI->add($data);
1268 1712
 		    unset($data);
1269 1713
 		}
@@ -1279,7 +1723,9 @@  discard block
 block discarded – undo
1279 1723
 	    //$buffer = $Common->getData($hosts[$id]);
1280 1724
 	    $buffer = $Common->getData($value['host']);
1281 1725
 	    $all_data = json_decode($buffer,true);
1282
-	    if (!empty($all_data)) $reset = 0;
1726
+	    if (!empty($all_data)) {
1727
+	    	$reset = 0;
1728
+	    }
1283 1729
 	    foreach ($all_data as $key => $line) {
1284 1730
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
1285 1731
 		    $data = array();
@@ -1300,8 +1746,12 @@  discard block
 block discarded – undo
1300 1746
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
1301 1747
 	    	    $data['format_source'] = 'fr24json';
1302 1748
     		    $data['id_source'] = $id_source;
1303
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1304
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1749
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1750
+		    	$data['noarchive'] = true;
1751
+		    }
1752
+		    if (isset($value['name']) && $value['name'] != '') {
1753
+		    	$data['source_name'] = $value['name'];
1754
+		    }
1305 1755
 		    $SI->add($data);
1306 1756
 		    unset($data);
1307 1757
 		}
@@ -1330,24 +1780,42 @@  discard block
 block discarded – undo
1330 1780
 		    if (isset($line['inf'])) {
1331 1781
 			$data = array();
1332 1782
 			$data['hex'] = $line['inf']['ia'];
1333
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1783
+			if (isset($line['inf']['cs'])) {
1784
+				$data['ident'] = $line['inf']['cs'];
1785
+			}
1786
+			//$line[13]
1334 1787
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
1335
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
1336
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1788
+	    		if (isset($line['inf']['gs'])) {
1789
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1790
+	    		}
1791
+	    		// speed
1792
+	    		if (isset($line['inf']['tr'])) {
1793
+	    			$data['heading'] = $line['inf']['tr'];
1794
+	    		}
1795
+	    		// heading
1337 1796
 	    		$data['latitude'] = $line['pt'][0]; // lat
1338 1797
 	    		$data['longitude'] = $line['pt'][1]; // long
1339 1798
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
1340
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1799
+	    		if (isset($line['inf']['sq'])) {
1800
+	    			$data['squawk'] = $line['inf']['sq'];
1801
+	    		}
1802
+	    		// squawk
1341 1803
 	    		//$data['aircraft_icao'] = $line[8];
1342
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1804
+	    		if (isset($line['inf']['rc'])) {
1805
+	    			$data['registration'] = $line['inf']['rc'];
1806
+	    		}
1343 1807
 			//$data['departure_airport_iata'] = $line[11];
1344 1808
 			//$data['arrival_airport_iata'] = $line[12];
1345 1809
 	    		//$data['emergency'] = ''; // emergency
1346 1810
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1347 1811
 	    		$data['format_source'] = 'radarvirtueljson';
1348 1812
     			$data['id_source'] = $id_source;
1349
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1350
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1813
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1814
+				$data['noarchive'] = true;
1815
+			}
1816
+			if (isset($value['name']) && $value['name'] != '') {
1817
+				$data['source_name'] = $value['name'];
1818
+			}
1351 1819
 			$SI->add($data);
1352 1820
 			unset($data);
1353 1821
 		    }
@@ -1373,30 +1841,65 @@  discard block
 block discarded – undo
1373 1841
 		    $data['id'] = $line['id'];
1374 1842
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1375 1843
 		    $data['ident'] = $line['callsign']; // ident
1376
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1377
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
1378
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
1379
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
1380
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
1381
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1844
+		    if (isset($line['pilotid'])) {
1845
+		    	$data['pilot_id'] = $line['pilotid'];
1846
+		    }
1847
+		    // pilot id
1848
+		    if (isset($line['name'])) {
1849
+		    	$data['pilot_name'] = $line['name'];
1850
+		    }
1851
+		    // pilot name
1852
+		    if (isset($line['alt'])) {
1853
+		    	$data['altitude'] = $line['alt'];
1854
+		    }
1855
+		    // altitude
1856
+		    if (isset($line['gs'])) {
1857
+		    	$data['speed'] = $line['gs'];
1858
+		    }
1859
+		    // speed
1860
+		    if (isset($line['heading'])) {
1861
+		    	$data['heading'] = $line['heading'];
1862
+		    }
1863
+		    // heading
1864
+		    if (isset($line['route'])) {
1865
+		    	$data['waypoints'] = $line['route'];
1866
+		    }
1867
+		    // route
1382 1868
 		    $data['latitude'] = $line['lat']; // lat
1383 1869
 		    $data['longitude'] = $line['lon']; // long
1384 1870
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
1385 1871
 		    //$data['squawk'] = $line['squawk']; // squawk
1386 1872
 		    //$data['emergency'] = ''; // emergency
1387
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
1388
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
1389
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1873
+		    if (isset($line['depicao'])) {
1874
+		    	$data['departure_airport_icao'] = $line['depicao'];
1875
+		    }
1876
+		    if (isset($line['deptime'])) {
1877
+		    	$data['departure_airport_time'] = $line['deptime'];
1878
+		    }
1879
+		    if (isset($line['arricao'])) {
1880
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1881
+		    }
1390 1882
 		    //$data['arrival_airport_time'] = $line['arrtime'];
1391
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
1392
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
1393
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
1394
-		    else $data['info'] = '';
1883
+		    if (isset($line['aircraft'])) {
1884
+		    	$data['aircraft_icao'] = $line['aircraft'];
1885
+		    }
1886
+		    if (isset($line['transponder'])) {
1887
+		    	$data['squawk'] = $line['transponder'];
1888
+		    }
1889
+		    if (isset($line['atis'])) {
1890
+		    	$data['info'] = $line['atis'];
1891
+		    } else {
1892
+		    	$data['info'] = '';
1893
+		    }
1395 1894
 		    $data['format_source'] = 'pireps';
1396 1895
     		    $data['id_source'] = $id_source;
1397 1896
 		    $data['datetime'] = date('Y-m-d H:i:s');
1398
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1399
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1897
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1898
+		    	$data['noarchive'] = true;
1899
+		    }
1900
+		    if (isset($value['name']) && $value['name'] != '') {
1901
+		    	$data['source_name'] = $value['name'];
1902
+		    }
1400 1903
 		    if ($line['icon'] === 'plane') {
1401 1904
 			$SI->add($data);
1402 1905
 		    //    print_r($data);
@@ -1405,16 +1908,28 @@  discard block
 block discarded – undo
1405 1908
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1406 1909
 			$typec = substr($data['ident'],-3);
1407 1910
 			$data['type'] = '';
1408
-			if ($typec === 'APP') $data['type'] = 'Approach';
1409
-			elseif ($typec === 'TWR') $data['type'] = 'Tower';
1410
-			elseif ($typec === 'OBS') $data['type'] = 'Observer';
1411
-			elseif ($typec === 'GND') $data['type'] = 'Ground';
1412
-			elseif ($typec === 'DEL') $data['type'] = 'Delivery';
1413
-			elseif ($typec === 'DEP') $data['type'] = 'Departure';
1414
-			elseif ($typec === 'FSS') $data['type'] = 'Flight Service Station';
1415
-			elseif ($typec === 'CTR') $data['type'] = 'Control Radar or Centre';
1416
-			else $data['type'] = 'Observer';
1417
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1911
+			if ($typec === 'APP') {
1912
+				$data['type'] = 'Approach';
1913
+			} elseif ($typec === 'TWR') {
1914
+				$data['type'] = 'Tower';
1915
+			} elseif ($typec === 'OBS') {
1916
+				$data['type'] = 'Observer';
1917
+			} elseif ($typec === 'GND') {
1918
+				$data['type'] = 'Ground';
1919
+			} elseif ($typec === 'DEL') {
1920
+				$data['type'] = 'Delivery';
1921
+			} elseif ($typec === 'DEP') {
1922
+				$data['type'] = 'Departure';
1923
+			} elseif ($typec === 'FSS') {
1924
+				$data['type'] = 'Flight Service Station';
1925
+			} elseif ($typec === 'CTR') {
1926
+				$data['type'] = 'Control Radar or Centre';
1927
+			} else {
1928
+				$data['type'] = 'Observer';
1929
+			}
1930
+			if (isset($ATC)) {
1931
+				echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1932
+			}
1418 1933
 		    }
1419 1934
 		    unset($data);
1420 1935
 		}
@@ -1429,7 +1944,9 @@  discard block
 block discarded – undo
1429 1944
 	    )
1430 1945
 	) {
1431 1946
 	    //$buffer = $Common->getData($hosts[$id]);
1432
-	    if ($globalDebug) echo 'Get Data...'."\n";
1947
+	    if ($globalDebug) {
1948
+	    	echo 'Get Data...'."\n";
1949
+	    }
1433 1950
 	    $buffer = $Common->getData($value['host']);
1434 1951
 	    $all_data = json_decode($buffer,true);
1435 1952
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1437,10 +1954,16 @@  discard block
 block discarded – undo
1437 1954
 		foreach ($all_data as $line) {
1438 1955
 	    	    $data = array();
1439 1956
 	    	    //$data['id'] = $line['id']; // id not usable
1440
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1957
+	    	    if (isset($line['pilotid'])) {
1958
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1959
+	    	    }
1441 1960
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1442
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1443
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1961
+	    	    if (isset($line['pilotname'])) {
1962
+	    	    	$data['pilot_name'] = $line['pilotname'];
1963
+	    	    }
1964
+	    	    if (isset($line['pilotid'])) {
1965
+	    	    	$data['pilot_id'] = $line['pilotid'];
1966
+	    	    }
1444 1967
 	    	    $data['ident'] = $line['flightnum']; // ident
1445 1968
 	    	    $data['altitude'] = $line['alt']; // altitude
1446 1969
 	    	    $data['speed'] = $line['gs']; // speed
@@ -1456,7 +1979,9 @@  discard block
 block discarded – undo
1456 1979
 	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1457 1980
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1458 1981
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1459
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
1982
+	    	    } else {
1983
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
1984
+	    	    }
1460 1985
 	    	    $data['departure_airport_icao'] = $line['depicao'];
1461 1986
 	    	    $data['departure_airport_time'] = $line['deptime'];
1462 1987
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
@@ -1464,29 +1989,47 @@  discard block
 block discarded – undo
1464 1989
     		    if (isset($line['registration'])) {
1465 1990
     			$data['registration'] = $line['registration'];
1466 1991
     			//if (isset($line['aircraft'])) $data['id'] = $line['aircraft'];
1467
-    		    } else $data['registration'] = $line['aircraft'];
1468
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1469
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1992
+    		    } else {
1993
+    		    	$data['registration'] = $line['aircraft'];
1994
+    		    }
1995
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1996
+		    	$data['noarchive'] = true;
1997
+		    }
1998
+		    if (isset($line['route'])) {
1999
+		    	$data['waypoints'] = $line['route'];
2000
+		    }
2001
+		    // route
1470 2002
 		    if (isset($line['aircraftname'])) {
1471 2003
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1472 2004
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1473 2005
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1474
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1475
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1476
-	    		else {
2006
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
2007
+	    			$data['aircraft_icao'] = $aircraft_data[0];
2008
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
2009
+	    			$data['aircraft_icao'] = $aircraft_data[1];
2010
+	    		} else {
1477 2011
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1478
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1479
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2012
+	    		    if (isset($aircraft_data[1])) {
2013
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
2014
+	    		    } else {
2015
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
2016
+	    		    }
1480 2017
 	    		}
1481 2018
 	    	    }
1482
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
2019
+    		    if (isset($line['route'])) {
2020
+    		    	$data['waypoints'] = $line['route'];
2021
+    		    }
1483 2022
     		    $data['id_source'] = $id_source;
1484 2023
 	    	    $data['format_source'] = 'phpvmacars';
1485
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2024
+		    if (isset($value['name']) && $value['name'] != '') {
2025
+		    	$data['source_name'] = $value['name'];
2026
+		    }
1486 2027
 		    $SI->add($data);
1487 2028
 		    unset($data);
1488 2029
 		}
1489
-		if ($globalDebug) echo 'No more data...'."\n";
2030
+		if ($globalDebug) {
2031
+			echo 'No more data...'."\n";
2032
+		}
1490 2033
 		unset($buffer);
1491 2034
 		unset($all_data);
1492 2035
 	    }
@@ -1499,7 +2042,9 @@  discard block
 block discarded – undo
1499 2042
 	    )
1500 2043
 	) {
1501 2044
 	    //$buffer = $Common->getData($hosts[$id]);
1502
-	    if ($globalDebug) echo 'Get Data...'."\n";
2045
+	    if ($globalDebug) {
2046
+	    	echo 'Get Data...'."\n";
2047
+	    }
1503 2048
 	    $buffer = $Common->getData($value['host']);
1504 2049
 	    $all_data = json_decode($buffer,true);
1505 2050
 	    if ($buffer != '' && is_array($all_data) && isset($all_data['ACARSData'])) {
@@ -1510,10 +2055,16 @@  discard block
 block discarded – undo
1510 2055
 	    	    //$data['id'] = $line['id']; // id not usable
1511 2056
 	    	    $data['id'] = $line['id'];
1512 2057
 	    	    //$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1513
-	    	    if (isset($line['user']['username'])) $data['pilot_name'] = $line['user']['username'];
1514
-	    	    if (isset($line['user_id'])) $data['pilot_id'] = $line['user_id'];
2058
+	    	    if (isset($line['user']['username'])) {
2059
+	    	    	$data['pilot_name'] = $line['user']['username'];
2060
+	    	    }
2061
+	    	    if (isset($line['user_id'])) {
2062
+	    	    	$data['pilot_id'] = $line['user_id'];
2063
+	    	    }
1515 2064
 	    	    $data['ident'] = str_replace(' ','',$line['bid']['flightnum']); // ident
1516
-	    	    if (is_numeric($data['ident'])) $data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2065
+	    	    if (is_numeric($data['ident'])) {
2066
+	    	    	$data['ident'] = $line['bid']['airline']['icao'].$data['ident'];
2067
+	    	    }
1517 2068
 	    	    $data['altitude'] = $line['altitude']; // altitude
1518 2069
 	    	    $data['speed'] = $line['groundspeed']; // speed
1519 2070
 	    	    $data['heading'] = $line['heading']; // heading
@@ -1526,7 +2077,9 @@  discard block
 block discarded – undo
1526 2077
 	    		$datetime = new DateTime($line['updated_at'],new DateTimeZone($value['timezone']));
1527 2078
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1528 2079
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1529
-	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
2080
+	    	    } else {
2081
+	    	    	$data['datetime'] = date('Y-m-d H:i:s');
2082
+	    	    }
1530 2083
 	    	    
1531 2084
 	    	    $data['departure_airport_icao'] = $line['bid']['depapt']['icao'];
1532 2085
 	    	    $data['departure_airport_time'] = $line['bid']['deptime'];
@@ -1534,17 +2087,26 @@  discard block
 block discarded – undo
1534 2087
 		    $data['arrival_airport_time'] = $line['bid']['arrtime'];
1535 2088
 		    $data['registration'] = $line['bid']['aircraft']['registration'];
1536 2089
 
1537
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1538
-		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') $data['waypoints'] = $line['bid']['route']; // route
2090
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2091
+		    	$data['noarchive'] = true;
2092
+		    }
2093
+		    if (isset($line['bid']['route']) && $line['bid']['route'] != '') {
2094
+		    	$data['waypoints'] = $line['bid']['route'];
2095
+		    }
2096
+		    // route
1539 2097
 	    	    $data['aircraft_icao'] = $line['bid']['aircraft']['icao'];
1540 2098
 
1541 2099
     		    $data['id_source'] = $id_source;
1542 2100
 	    	    $data['format_source'] = 'vaos';
1543
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2101
+		    if (isset($value['name']) && $value['name'] != '') {
2102
+		    	$data['source_name'] = $value['name'];
2103
+		    }
1544 2104
 		    $SI->add($data);
1545 2105
 		    unset($data);
1546 2106
 		}
1547
-		if ($globalDebug) echo 'No more data...'."\n";
2107
+		if ($globalDebug) {
2108
+			echo 'No more data...'."\n";
2109
+		}
1548 2110
 		unset($buffer);
1549 2111
 		unset($all_data);
1550 2112
 	    }
@@ -1557,7 +2119,9 @@  discard block
 block discarded – undo
1557 2119
 	    )
1558 2120
 	) {
1559 2121
 	    //$buffer = $Common->getData($hosts[$id]);
1560
-	    if ($globalDebug) echo 'Get Data...'."\n";
2122
+	    if ($globalDebug) {
2123
+	    	echo 'Get Data...'."\n";
2124
+	    }
1561 2125
 	    $buffer = $Common->getData($value['host']);
1562 2126
 	    $all_data = json_decode($buffer,true);
1563 2127
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1586,16 +2150,25 @@  discard block
 block discarded – undo
1586 2150
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1587 2151
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1588 2152
     		    //$data['registration'] = $line['aircraft'];
1589
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
2153
+		    if (isset($line['route'])) {
2154
+		    	$data['waypoints'] = $line['route'];
2155
+		    }
2156
+		    // route
1590 2157
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1591 2158
     		    $data['id_source'] = $id_source;
1592 2159
 	    	    $data['format_source'] = 'vam';
1593
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1594
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
2160
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
2161
+		    	$data['noarchive'] = true;
2162
+		    }
2163
+		    if (isset($value['name']) && $value['name'] != '') {
2164
+		    	$data['source_name'] = $value['name'];
2165
+		    }
1595 2166
 		    $SI->add($data);
1596 2167
 		    unset($data);
1597 2168
 		}
1598
-		if ($globalDebug) echo 'No more data...'."\n";
2169
+		if ($globalDebug) {
2170
+			echo 'No more data...'."\n";
2171
+		}
1599 2172
 		unset($buffer);
1600 2173
 		unset($all_data);
1601 2174
 	    }
@@ -1608,7 +2181,9 @@  discard block
 block discarded – undo
1608 2181
 	    )
1609 2182
 	) {
1610 2183
 	    //$buffer = $Common->getData($hosts[$id]);
1611
-	    if ($globalDebug) echo 'Get Data...'."\n";
2184
+	    if ($globalDebug) {
2185
+	    	echo 'Get Data...'."\n";
2186
+	    }
1612 2187
 	    $buffer = $Common->getData($value['host']);
1613 2188
 	    $all_data = json_decode($buffer,true);
1614 2189
 	    if ($buffer != '') {
@@ -1626,12 +2201,16 @@  discard block
 block discarded – undo
1626 2201
 			$data['id_source'] = $id_source;
1627 2202
 			$data['format_source'] = 'blitzortung';
1628 2203
 			$SI->add($data);
1629
-			if ($globalDebug) echo '☈ Lightning added'."\n";
2204
+			if ($globalDebug) {
2205
+				echo '☈ Lightning added'."\n";
2206
+			}
1630 2207
 			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1631 2208
 			unset($data);
1632 2209
 		    }
1633 2210
 		}
1634
-		if ($globalDebug) echo 'No more data...'."\n";
2211
+		if ($globalDebug) {
2212
+			echo 'No more data...'."\n";
2213
+		}
1635 2214
 		unset($buffer);
1636 2215
 	    }
1637 2216
 	    $last_exec[$id]['last'] = time();
@@ -1660,10 +2239,15 @@  discard block
 block discarded – undo
1660 2239
                 }
1661 2240
             } else {
1662 2241
                 $format = $value['format'];
1663
-                if (isset($tt[$format])) $tt[$format]++;
1664
-                else $tt[$format] = 0;
2242
+                if (isset($tt[$format])) {
2243
+                	$tt[$format]++;
2244
+                } else {
2245
+                	$tt[$format] = 0;
2246
+                }
1665 2247
                 if ($tt[$format] > 30) {
1666
-                    if ($globalDebug) echo 'Reconnect...'."\n";
2248
+                    if ($globalDebug) {
2249
+                    	echo 'Reconnect...'."\n";
2250
+                    }
1667 2251
                     sleep(2);
1668 2252
                     //$sourceeen[] = $value;
1669 2253
                     //connect_all($sourceeen);
@@ -1680,7 +2264,9 @@  discard block
 block discarded – undo
1680 2264
 	    $write = NULL;
1681 2265
 	    $e = NULL;
1682 2266
 	    $n = socket_select($read, $write, $e, $timeout);
1683
-	    if ($e != NULL) var_dump($e);
2267
+	    if ($e != NULL) {
2268
+	    	var_dump($e);
2269
+	    }
1684 2270
 	    if ($n > 0) {
1685 2271
 		$reset = 0;
1686 2272
 		foreach ($read as $nb => $r) {
@@ -1702,13 +2288,17 @@  discard block
 block discarded – undo
1702 2288
 		    if ($buffer !== FALSE) {
1703 2289
 			if ($format === 'vrstcp') {
1704 2290
 			    $buffer = explode('},{',$buffer);
1705
-			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2291
+			} else {
2292
+				$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
2293
+			}
1706 2294
 		    }
1707 2295
 		    // SBS format is CSV format
1708 2296
 		    if ($buffer !== FALSE && $buffer !== '') {
1709 2297
 			$tt[$format] = 0;
1710 2298
 			if ($format === 'acarssbs3') {
1711
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2299
+			    if ($globalDebug) {
2300
+			    	echo 'ACARS : '.$buffer."\n";
2301
+			    }
1712 2302
 			    $ACARS->add(trim($buffer));
1713 2303
 			    $ACARS->deleteLiveAcarsData();
1714 2304
 			} elseif ($format === 'raw') {
@@ -1718,9 +2308,15 @@  discard block
 block discarded – undo
1718 2308
 				//if (!empty($data)) print_r($data);
1719 2309
 				$data['datetime'] = date('Y-m-d H:i:s');
1720 2310
 				$data['format_source'] = 'raw';
1721
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1722
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1723
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2311
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2312
+					$data['source_name'] = $globalSources[$nb]['name'];
2313
+				}
2314
+				if (isset($globalSources[$nb]['sourcestats'])) {
2315
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2316
+				}
2317
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2318
+					$data['noarchive'] = true;
2319
+				}
1724 2320
 				//if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1725 2321
 				$SI->add($data);
1726 2322
 				unset($data);
@@ -1728,22 +2324,54 @@  discard block
 block discarded – undo
1728 2324
 			} elseif ($format === 'ais') {
1729 2325
 			    $ais_data = $AIS->parse_line(trim($buffer));
1730 2326
 			    $data = array();
1731
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1732
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = substr($ais_data['mmsi'],-9);
1733
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1734
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1735
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1736
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1737
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1738
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1739
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1740
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1741
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1742
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1743
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1744
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1745
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1746
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2327
+			    if (isset($ais_data['ident'])) {
2328
+			    	$data['ident'] = $ais_data['ident'];
2329
+			    }
2330
+			    if (isset($ais_data['mmsi'])) {
2331
+			    	$data['mmsi'] = substr($ais_data['mmsi'],-9);
2332
+			    }
2333
+			    if (isset($ais_data['speed'])) {
2334
+			    	$data['speed'] = $ais_data['speed'];
2335
+			    }
2336
+			    if (isset($ais_data['heading'])) {
2337
+			    	$data['heading'] = $ais_data['heading'];
2338
+			    }
2339
+			    if (isset($ais_data['latitude'])) {
2340
+			    	$data['latitude'] = $ais_data['latitude'];
2341
+			    }
2342
+			    if (isset($ais_data['longitude'])) {
2343
+			    	$data['longitude'] = $ais_data['longitude'];
2344
+			    }
2345
+			    if (isset($ais_data['status'])) {
2346
+			    	$data['status'] = $ais_data['status'];
2347
+			    }
2348
+			    if (isset($ais_data['statusid'])) {
2349
+			    	$data['status_id'] = $ais_data['statusid'];
2350
+			    }
2351
+			    if (isset($ais_data['type'])) {
2352
+			    	$data['type'] = $ais_data['type'];
2353
+			    }
2354
+			    if (isset($ais_data['imo'])) {
2355
+			    	$data['imo'] = $ais_data['imo'];
2356
+			    }
2357
+			    if (isset($ais_data['callsign'])) {
2358
+			    	$data['callsign'] = $ais_data['callsign'];
2359
+			    }
2360
+			    if (isset($ais_data['destination'])) {
2361
+			    	$data['arrival_code'] = $ais_data['destination'];
2362
+			    }
2363
+			    if (isset($ais_data['eta_ts'])) {
2364
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
2365
+			    }
2366
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2367
+			    	$data['noarchive'] = true;
2368
+			    }
2369
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2370
+			    	$data['source_name'] = $globalSources[$nb]['name'];
2371
+			    }
2372
+			    if (isset($globalSources[$nb]['sourcestats'])) {
2373
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2374
+			    }
1747 2375
 
1748 2376
 			    if (isset($ais_data['timestamp'])) {
1749 2377
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1752,7 +2380,9 @@  discard block
 block discarded – undo
1752 2380
 			    }
1753 2381
 			    $data['format_source'] = 'aisnmea';
1754 2382
     			    $data['id_source'] = $id_source;
1755
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') $MI->add($data);
2383
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] === 'Ship') {
2384
+			    	$MI->add($data);
2385
+			    }
1756 2386
 			    unset($data);
1757 2387
                         } elseif ($format === 'flightgearsp') {
1758 2388
                     	    //echo $buffer."\n";
@@ -1770,17 +2400,25 @@  discard block
 block discarded – undo
1770 2400
 				$data['speed'] = round($line[5]*1.94384);
1771 2401
 				$data['datetime'] = date('Y-m-d H:i:s');
1772 2402
 				$data['format_source'] = 'flightgearsp';
1773
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1774
-				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2403
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2404
+					$data['noarchive'] = true;
2405
+				}
2406
+				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2407
+					$SI->add($data);
2408
+				}
1775 2409
 				//$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1776 2410
 			    }
1777 2411
                         } elseif ($format === 'acars') {
1778
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2412
+                    	    if ($globalDebug) {
2413
+                    	    	echo 'ACARS : '.$buffer."\n";
2414
+                    	    }
1779 2415
 			    $ACARS->add(trim($buffer));
1780 2416
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1781 2417
 			    $ACARS->deleteLiveAcarsData();
1782 2418
 			} elseif ($format === 'acarsjsonudp') {
1783
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
2419
+			    if ($globalDebug) {
2420
+			    	echo 'ACARS : '.$buffer."\n";
2421
+			    }
1784 2422
                             $line = json_decode(trim($buffer), true);
1785 2423
                             if (!empty($line)) {
1786 2424
 				$line = array_merge(array('text' => '','tail' => '','label' => '','block_id' => '','flight' => '','msgno' => ''),$line);
@@ -1805,8 +2443,12 @@  discard block
 block discarded – undo
1805 2443
 				    $aircraft_type = $line[10];
1806 2444
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1807 2445
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1808
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1809
-				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2446
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2447
+				    	$data['noarchive'] = true;
2448
+				    }
2449
+				    if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2450
+				    	$SI->add($data);
2451
+				    }
1810 2452
 				}
1811 2453
 			    }
1812 2454
 			} elseif ($format === 'beast') {
@@ -1816,28 +2458,62 @@  discard block
 block discarded – undo
1816 2458
 			    foreach($buffer as $all_data) {
1817 2459
 				$line = json_decode('{'.$all_data.'}',true);
1818 2460
 				$data = array();
1819
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1820
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1821
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1822
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1823
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1824
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1825
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
2461
+				if (isset($line['Icao'])) {
2462
+					$data['hex'] = $line['Icao'];
2463
+				}
2464
+				// hex
2465
+				if (isset($line['Call'])) {
2466
+					$data['ident'] = $line['Call'];
2467
+				}
2468
+				// ident
2469
+				if (isset($line['Alt'])) {
2470
+					$data['altitude'] = $line['Alt'];
2471
+				}
2472
+				// altitude
2473
+				if (isset($line['Spd'])) {
2474
+					$data['speed'] = $line['Spd'];
2475
+				}
2476
+				// speed
2477
+				if (isset($line['Trak'])) {
2478
+					$data['heading'] = $line['Trak'];
2479
+				}
2480
+				// heading
2481
+				if (isset($line['Lat'])) {
2482
+					$data['latitude'] = $line['Lat'];
2483
+				}
2484
+				// lat
2485
+				if (isset($line['Long'])) {
2486
+					$data['longitude'] = $line['Long'];
2487
+				}
2488
+				// long
1826 2489
 				//$data['verticalrate'] = $line['']; // verticale rate
1827
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
2490
+				if (isset($line['Sqk'])) {
2491
+					$data['squawk'] = $line['Sqk'];
2492
+				}
2493
+				// squawk
1828 2494
 				$data['emergency'] = ''; // emergency
1829
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
2495
+				if (isset($line['Reg'])) {
2496
+					$data['registration'] = $line['Reg'];
2497
+				}
1830 2498
 				/*
1831 2499
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1832 2500
 				else $data['datetime'] = date('Y-m-d H:i:s');
1833 2501
 				*/
1834 2502
 				$data['datetime'] = date('Y-m-d H:i:s');
1835
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
2503
+				if (isset($line['Type'])) {
2504
+					$data['aircraft_icao'] = $line['Type'];
2505
+				}
1836 2506
 		    		$data['format_source'] = 'vrstcp';
1837 2507
 				$data['id_source'] = $id_source;
1838
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1839
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1840
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
2508
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2509
+					$data['noarchive'] = true;
2510
+				}
2511
+				if (isset($value['name']) && $value['name'] != '') {
2512
+					$data['source_name'] = $value['name'];
2513
+				}
2514
+				if (isset($data['latitude']) && isset($data['hex'])) {
2515
+					$SI->add($data);
2516
+				}
1841 2517
 				unset($data);
1842 2518
 			    }
1843 2519
 			} elseif ($format === 'tsv' || substr($buffer,0,4) === 'clock') {
@@ -1850,22 +2526,46 @@  discard block
 block discarded – undo
1850 2526
     				$data['hex'] = $lined['hexid'];
1851 2527
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1852 2528
     				$data['datetime'] = date('Y-m-d H:i:s');;
1853
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1854
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1855
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1856
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1857
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1858
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1859
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
2529
+    				if (isset($lined['ident'])) {
2530
+    					$data['ident'] = $lined['ident'];
2531
+    				}
2532
+    				if (isset($lined['lat'])) {
2533
+    					$data['latitude'] = $lined['lat'];
2534
+    				}
2535
+    				if (isset($lined['lon'])) {
2536
+    					$data['longitude'] = $lined['lon'];
2537
+    				}
2538
+    				if (isset($lined['speed'])) {
2539
+    					$data['speed'] = $lined['speed'];
2540
+    				}
2541
+    				if (isset($lined['squawk'])) {
2542
+    					$data['squawk'] = $lined['squawk'];
2543
+    				}
2544
+    				if (isset($lined['alt'])) {
2545
+    					$data['altitude'] = $lined['alt'];
2546
+    				}
2547
+    				if (isset($lined['heading'])) {
2548
+    					$data['heading'] = $lined['heading'];
2549
+    				}
1860 2550
     				$data['id_source'] = $id_source;
1861 2551
     				$data['format_source'] = 'tsv';
1862
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1863
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1864
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1865
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
2552
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2553
+    					$data['source_name'] = $globalSources[$nb]['name'];
2554
+    				}
2555
+    				if (isset($globalSources[$nb]['sourcestats'])) {
2556
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2557
+    				}
2558
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2559
+					$data['noarchive'] = true;
2560
+				}
2561
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2562
+    					$SI->add($data);
2563
+    				}
1866 2564
     				unset($lined);
1867 2565
     				unset($data);
1868
-    			    } else $error = true;
2566
+    			    } else {
2567
+    			    	$error = true;
2568
+    			    }
1869 2569
 			} elseif ($format === 'aprs' && $use_aprs) {
1870 2570
 			    if ($aprs_connect === 0) {
1871 2571
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1891,47 +2591,96 @@  discard block
 block discarded – undo
1891 2591
 				    $aprs_last_tx = time();
1892 2592
 				    $data = array();
1893 2593
 				    //print_r($line);
1894
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1895
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1896
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1897
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1898
-				    if (isset($line['arrival_code'])) $data['arrival_code'] = $line['arrival_code'];
1899
-				    if (isset($line['arrival_date'])) $data['arrival_date'] = $line['arrival_date'];
1900
-				    if (isset($line['typeid'])) $data['type_id'] = $line['typeid'];
1901
-				    if (isset($line['statusid'])) $data['status_id'] = $line['statusid'];
1902
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1903
-				    else $data['datetime'] = date('Y-m-d H:i:s');
2594
+				    if (isset($line['address'])) {
2595
+				    	$data['hex'] = $line['address'];
2596
+				    }
2597
+				    if (isset($line['mmsi'])) {
2598
+				    	$data['mmsi'] = $line['mmsi'];
2599
+				    }
2600
+				    if (isset($line['imo'])) {
2601
+				    	$data['imo'] = $line['imo'];
2602
+				    }
2603
+				    if (isset($line['squawk'])) {
2604
+				    	$data['squawk'] = $line['squawk'];
2605
+				    }
2606
+				    if (isset($line['arrival_code'])) {
2607
+				    	$data['arrival_code'] = $line['arrival_code'];
2608
+				    }
2609
+				    if (isset($line['arrival_date'])) {
2610
+				    	$data['arrival_date'] = $line['arrival_date'];
2611
+				    }
2612
+				    if (isset($line['typeid'])) {
2613
+				    	$data['type_id'] = $line['typeid'];
2614
+				    }
2615
+				    if (isset($line['statusid'])) {
2616
+				    	$data['status_id'] = $line['statusid'];
2617
+				    }
2618
+				    if (isset($line['timestamp'])) {
2619
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
2620
+				    } else {
2621
+				    	$data['datetime'] = date('Y-m-d H:i:s');
2622
+				    }
1904 2623
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1905
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
2624
+				    if (isset($line['ident'])) {
2625
+				    	$data['ident'] = $line['ident'];
2626
+				    }
1906 2627
 				    $data['latitude'] = $line['latitude'];
1907 2628
 				    $data['longitude'] = $line['longitude'];
1908 2629
 				    //$data['verticalrate'] = $line[16];
1909
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
2630
+				    if (isset($line['speed'])) {
2631
+				    	$data['speed'] = $line['speed'];
2632
+				    }
1910 2633
 				    //else $data['speed'] = 0;
1911
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1912
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1913
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
2634
+				    if (isset($line['altitude'])) {
2635
+				    	$data['altitude'] = $line['altitude'];
2636
+				    }
2637
+				    if (isset($line['comment'])) {
2638
+				    	$data['comment'] = $line['comment'];
2639
+				    }
2640
+				    if (isset($line['symbol'])) {
2641
+				    	$data['type'] = $line['symbol'];
2642
+				    }
1914 2643
 				    //if (isset($line['heading'])) $data['heading'] = $line['heading'];
1915 2644
 				    
1916
-				    if (isset($line['heading']) && isset($line['format_source'])) $data['heading'] = $line['heading'];
2645
+				    if (isset($line['heading']) && isset($line['format_source'])) {
2646
+				    	$data['heading'] = $line['heading'];
2647
+				    }
1917 2648
 				    //else echo 'No heading...'."\n";
1918 2649
 				    //else $data['heading'] = 0;
1919
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
2650
+				    if (isset($line['stealth'])) {
2651
+				    	$data['aircraft_type'] = $line['stealth'];
2652
+				    }
1920 2653
 				    //if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1921
-				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) $data['noarchive'] = true;
1922
-				    elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) $data['noarchive'] = false;
1923
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1924
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
2654
+				    if (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE) {
2655
+				    	$data['noarchive'] = true;
2656
+				    } elseif (isset($globalAPRSarchive) && $globalAPRSarchive === TRUE) {
2657
+				    	$data['noarchive'] = false;
2658
+				    }
2659
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2660
+				    	$data['noarchive'] = true;
2661
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
2662
+				    	$data['noarchive'] = false;
2663
+				    }
1925 2664
     				    $data['id_source'] = $id_source;
1926
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1927
-				    else $data['format_source'] = 'aprs';
2665
+    				    if (isset($line['format_source'])) {
2666
+    				    	$data['format_source'] = $line['format_source'];
2667
+    				    } else {
2668
+				    	$data['format_source'] = 'aprs';
2669
+				    }
1928 2670
 				    $data['source_name'] = $line['source'];
1929
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1930
-				    else $data['source_type'] = 'flarm';
1931
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2671
+				    if (isset($line['source_type'])) {
2672
+				    	$data['source_type'] = $line['source_type'];
2673
+				    } else {
2674
+				    	$data['source_type'] = 'flarm';
2675
+				    }
2676
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
2677
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2678
+    				    }
1932 2679
 				    $currentdate = date('Y-m-d H:i:s');
1933 2680
 				    $aprsdate = strtotime($data['datetime']);
1934
-				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') $data['altitude_relative'] = 'AMSL';
2681
+				    if ($data['source_type'] != 'modes' && $data['source_type'] != 'ais') {
2682
+				    	$data['altitude_relative'] = 'AMSL';
2683
+				    }
1935 2684
 				    // Accept data if time <= system time + 20s
1936 2685
 				    //if (($data['source_type'] === 'modes') || isset($line['stealth']) && ($line['stealth'] === 0 || $line['stealth'] === '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1937 2686
 				    if (
@@ -1943,7 +2692,9 @@  discard block
 block discarded – undo
1943 2692
 					$send = $SI->add($data);
1944 2693
 				    } elseif ($data['source_type'] === 'ais') {
1945 2694
 					$data['type'] = '';
1946
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
2695
+					if (isset($globalMarine) && $globalMarine) {
2696
+						$send = $MI->add($data);
2697
+					}
1947 2698
 				    } elseif (isset($line['stealth']) && $line['stealth'] != 0) {
1948 2699
 					 echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1949 2700
 				    } elseif (isset($globalAircraft) && $globalAircraft && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
@@ -1951,8 +2702,12 @@  discard block
 block discarded – undo
1951 2702
 					    $line['symbol'] === 'Glider' || 
1952 2703
 					    $line['symbol'] === 'No. Plane' || 
1953 2704
 					    $line['symbol'] === 'Aircraft (small)' || $line['symbol'] === 'Helicopter')) {
1954
-					    if ($line['symbol'] === 'Ballon') $data['aircraft_icao'] = 'BALL';
1955
-					    if ($line['symbol'] === 'Glider') $data['aircraft_icao'] = 'PARAGLIDER';
2705
+					    if ($line['symbol'] === 'Ballon') {
2706
+					    	$data['aircraft_icao'] = 'BALL';
2707
+					    }
2708
+					    if ($line['symbol'] === 'Glider') {
2709
+					    	$data['aircraft_icao'] = 'PARAGLIDER';
2710
+					    }
1956 2711
 					    $send = $SI->add($data);
1957 2712
 				    } elseif (isset($globalMarine) && $globalMarine && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && (
1958 2713
 					    $line['symbol'] === 'Yacht (Sail)' || 
@@ -1983,9 +2738,13 @@  discard block
 block discarded – undo
1983 2738
 				    //} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1984 2739
 				//    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1985 2740
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1986
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
2741
+					if (isset($globalTracker) && $globalTracker) {
2742
+						$send = $TI->add($data);
2743
+					}
1987 2744
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1988
-					if (!isset($data['altitude'])) $data['altitude'] = 0;
2745
+					if (!isset($data['altitude'])) {
2746
+						$data['altitude'] = 0;
2747
+					}
1989 2748
 					$Source->deleteOldLocationByType('gs');
1990 2749
 					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1991 2750
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
@@ -1994,7 +2753,9 @@  discard block
 block discarded – undo
1994 2753
 					}
1995 2754
 				    } elseif (isset($line['symbol']) && $line['symbol'] === 'Weather Station') {
1996 2755
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1997
-					if ($globalDebug) echo '# Weather Station added'."\n";
2756
+					if ($globalDebug) {
2757
+						echo '# Weather Station added'."\n";
2758
+					}
1998 2759
 					$Source->deleteOldLocationByType('wx');
1999 2760
 					$weather_data = json_encode($line);
2000 2761
 					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
@@ -2004,7 +2765,9 @@  discard block
 block discarded – undo
2004 2765
 					}
2005 2766
 				    } elseif (isset($line['symbol']) && ($line['symbol'] === 'Lightning' || $line['symbol'] === 'Thunderstorm')) {
2006 2767
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
2007
-					if ($globalDebug) echo '☈ Lightning added'."\n";
2768
+					if ($globalDebug) {
2769
+						echo '☈ Lightning added'."\n";
2770
+					}
2008 2771
 					$Source->deleteOldLocationByType('lightning');
2009 2772
 					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
2010 2773
 						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
@@ -2016,8 +2779,7 @@  discard block
 block discarded – undo
2016 2779
 				    	print_r($line);
2017 2780
 				    }
2018 2781
 				    unset($data);
2019
-				}
2020
-				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2782
+				} elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
2021 2783
 					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
2022 2784
 				}
2023 2785
 				/*
@@ -2026,7 +2788,9 @@  discard block
 block discarded – undo
2026 2788
 				}
2027 2789
 				*/
2028 2790
 				//elseif ($line === false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
2029
-				elseif ($line === true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
2791
+				elseif ($line === true && $globalDebug) {
2792
+					echo '!! Failed : '.$buffer."!!\n";
2793
+				}
2030 2794
 				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
2031 2795
 					$Source->deleteOldLocationByType('lightning');
2032 2796
 					$Source->deleteOldLocationByType('wx');
@@ -2063,27 +2827,47 @@  discard block
 block discarded – undo
2063 2827
     				$data['ground'] = $line[21];
2064 2828
     				$data['emergency'] = $line[19];
2065 2829
     				$data['format_source'] = 'sbs';
2066
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
2067
-				elseif ($line[0] == 'MLAT') $data['source_name'] = 'MLAT';
2068
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2069
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
2830
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
2831
+					$data['source_name'] = $globalSources[$nb]['name'];
2832
+				} elseif ($line[0] == 'MLAT') {
2833
+					$data['source_name'] = 'MLAT';
2834
+				}
2835
+				if (isset($globalSources[$nb]['sourcestats'])) {
2836
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
2837
+				}
2838
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
2839
+					$data['noarchive'] = true;
2840
+				}
2070 2841
     				$data['id_source'] = $id_source;
2071
-    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
2072
-    				else $error = true;
2842
+    				if (($data['latitude'] === '' && $data['longitude'] === '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
2843
+    					$send = $SI->add($data);
2844
+    				} else {
2845
+    					$error = true;
2846
+    				}
2073 2847
     				unset($data);
2074
-    			    } else $error = true;
2848
+    			    } else {
2849
+    			    	$error = true;
2850
+    			    }
2075 2851
 			    if ($error) {
2076 2852
 				if (count($line) > 1 && ($line[0] === 'STA' || $line[0] === 'AIR' || $line[0] === 'SEL' || $line[0] === 'ID' || $line[0] === 'CLK')) { 
2077
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
2853
+					if ($globalDebug) {
2854
+						echo "Not a message. Ignoring... \n";
2855
+					}
2078 2856
 				} else {
2079
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
2857
+					if ($globalDebug) {
2858
+						echo "Wrong line format. Ignoring... \n";
2859
+					}
2080 2860
 					if ($globalDebug) {
2081 2861
 						echo $buffer;
2082 2862
 						//print_r($line);
2083 2863
 					}
2084 2864
 					//socket_close($r);
2085
-					if ($globalDebug) echo "Reconnect after an error...\n";
2086
-					if ($format === 'aprs') $aprs_connect = 0;
2865
+					if ($globalDebug) {
2866
+						echo "Reconnect after an error...\n";
2867
+					}
2868
+					if ($format === 'aprs') {
2869
+						$aprs_connect = 0;
2870
+					}
2087 2871
 					$sourceer[$nb] = $globalSources[$nb];
2088 2872
 					connect_all($sourceer);
2089 2873
 					$sourceer = array();
@@ -2091,10 +2875,14 @@  discard block
 block discarded – undo
2091 2875
 			    }
2092 2876
 			}
2093 2877
 			// Sleep for xxx microseconds
2094
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2878
+			if (isset($globalSBSSleep)) {
2879
+				usleep($globalSBSSleep);
2880
+			}
2095 2881
 		    } else {
2096 2882
 			if ($format === 'flightgearmp') {
2097
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2883
+			    	if ($globalDebug) {
2884
+			    		echo "Reconnect FlightGear MP...";
2885
+			    	}
2098 2886
 				//@socket_close($r);
2099 2887
 				sleep($globalMinFetch);
2100 2888
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -2103,10 +2891,15 @@  discard block
 block discarded – undo
2103 2891
 				break;
2104 2892
 				
2105 2893
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
2106
-			    if (isset($tt[$format])) $tt[$format]++;
2107
-			    else $tt[$format] = 0;
2894
+			    if (isset($tt[$format])) {
2895
+			    	$tt[$format]++;
2896
+			    } else {
2897
+			    	$tt[$format] = 0;
2898
+			    }
2108 2899
 			    if ($tt[$format] > 30 || $buffer === FALSE) {
2109
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2900
+				if ($globalDebug) {
2901
+					echo "ERROR : Reconnect ".$format."...";
2902
+				}
2110 2903
 				//@socket_close($r);
2111 2904
 				sleep(2);
2112 2905
 				$aprs_connect = 0;
@@ -2124,11 +2917,17 @@  discard block
 block discarded – undo
2124 2917
 	    } else {
2125 2918
 		$error = socket_strerror(socket_last_error());
2126 2919
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
2127
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
2128
-			if (isset($globalDebug)) echo "Restarting...\n";
2920
+			if ($globalDebug) {
2921
+				echo "ERROR : socket_select give this error ".$error . "\n";
2922
+			}
2923
+			if (isset($globalDebug)) {
2924
+				echo "Restarting...\n";
2925
+			}
2129 2926
 			// Restart the script if possible
2130 2927
 			if (is_array($sockets)) {
2131
-			    if ($globalDebug) echo "Shutdown all sockets...";
2928
+			    if ($globalDebug) {
2929
+			    	echo "Shutdown all sockets...";
2930
+			    }
2132 2931
 			    
2133 2932
 			    foreach ($sockets as $sock) {
2134 2933
 				@socket_shutdown($sock,2);
@@ -2136,25 +2935,45 @@  discard block
 block discarded – undo
2136 2935
 			    }
2137 2936
 			    
2138 2937
 			}
2139
-			if ($globalDebug) echo "Waiting...";
2938
+			if ($globalDebug) {
2939
+				echo "Waiting...";
2940
+			}
2140 2941
 			sleep(2);
2141 2942
 			$time = time();
2142 2943
 			//connect_all($hosts);
2143 2944
 			$aprs_connect = 0;
2144
-			if ($reset%5 === 0) sleep(20);
2145
-			if ($reset%10 === 0) sleep(100);
2146
-			if ($reset%20 === 0) sleep(200);
2147
-			if ($reset > 100) exit('Too many attempts...');
2148
-			if ($globalDebug) echo "Restart all connections...";
2945
+			if ($reset%5 === 0) {
2946
+				sleep(20);
2947
+			}
2948
+			if ($reset%10 === 0) {
2949
+				sleep(100);
2950
+			}
2951
+			if ($reset%20 === 0) {
2952
+				sleep(200);
2953
+			}
2954
+			if ($reset > 100) {
2955
+				exit('Too many attempts...');
2956
+			}
2957
+			if ($globalDebug) {
2958
+				echo "Restart all connections...";
2959
+			}
2149 2960
 			connect_all($globalSources);
2150 2961
 		}
2151 2962
 	    }
2152 2963
 	}
2153 2964
 	if ($globalDaemon === false) {
2154
-	    if ($globalDebug) echo 'Check all...'."\n";
2155
-	    if (isset($SI)) $SI->checkAll();
2156
-	    if (isset($TI)) $TI->checkAll();
2157
-	    if (isset($MI)) $MI->checkAll();
2965
+	    if ($globalDebug) {
2966
+	    	echo 'Check all...'."\n";
2967
+	    }
2968
+	    if (isset($SI)) {
2969
+	    	$SI->checkAll();
2970
+	    }
2971
+	    if (isset($TI)) {
2972
+	    	$TI->checkAll();
2973
+	    }
2974
+	    if (isset($MI)) {
2975
+	    	$MI->checkAll();
2976
+	    }
2158 2977
 	}
2159 2978
     }
2160 2979
 }
Please login to merge, or discard this patch.