Completed
Push — master ( d44f1f...2285a7 )
by Yannick
09:57
created
install/class.create_db.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -3,6 +3,10 @@
 block discarded – undo
3 3
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
4 4
 
5 5
 class create_db {
6
+
7
+	/**
8
+	 * @param string $filename
9
+	 */
6 10
 	public static function import_file($filename) {
7 11
 		$filename = filter_var($filename,FILTER_SANITIZE_STRING);
8 12
 		$Connection = new Connection();
Please login to merge, or discard this patch.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,9 @@  discard block
 block discarded – undo
14 14
 			//foreach ($lines as $line)
15 15
 			while (($line = fgets($handle,4096)) !== false)
16 16
 			{
17
-				if (substr($line,0,2) == '--' || $line == '') continue;
17
+				if (substr($line,0,2) == '--' || $line == '') {
18
+					continue;
19
+				}
18 20
 				$templine .= $line;
19 21
 				if (substr(trim($line), -1,1) == ';')
20 22
 				{
@@ -40,7 +42,9 @@  discard block
 block discarded – undo
40 42
 		//foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory)) as $filename)
41 43
 		while(false !== ($filename = readdir($dh)))
42 44
 		{
43
-		    if (preg_match('/\.sql$/',$filename)) $error .= create_db::import_file($directory.$filename);
45
+		    if (preg_match('/\.sql$/',$filename)) {
46
+		    	$error .= create_db::import_file($directory.$filename);
47
+		    }
44 48
 		}
45 49
 		return $error;
46 50
 	}
@@ -56,13 +60,17 @@  discard block
 block discarded – undo
56 60
 		// Dirty hack
57 61
 		if ($host != 'localhost' && $host != '127.0.0.1') {
58 62
 		    $grantright = $_SERVER['SERVER_ADDR'];
59
-		} else $grantright = 'localhost';
63
+		} else {
64
+			$grantright = 'localhost';
65
+		}
60 66
 		try {
61 67
 			$dbh = new PDO($db_type.':host='.$host,$root,$root_pass);
62 68
 			$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
63 69
 			if ($db_type == 'mysql') {
64 70
 				$dbh->exec('CREATE DATABASE IF NOT EXISTS `'.$db.'`;GRANT ALL ON `'.$db."`.* TO '".$user."'@'".$grantright."' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
65
-				if ($grantright == 'localhost') $dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
71
+				if ($grantright == 'localhost') {
72
+					$dbh->exec('GRANT ALL ON `'.$db."`.* TO '".$user."'@'127.0.0.1' IDENTIFIED BY '".$password."';FLUSH PRIVILEGES;");
73
+				}
66 74
 			} else if ($db_type == 'pgsql') {
67 75
 				$dbh->exec("CREATE DATABASE ".$db.";");
68 76
 				$dbh->exec("CREATE USER ".$user." WITH PASSWORD '".$password."';
Please login to merge, or discard this patch.
install/libs/sparqllib.php 2 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -13,6 +13,9 @@  discard block
 block discarded – undo
13 13
 function sparql_connect( $endpoint ) { return new sparql_connection( $endpoint ); }
14 14
 
15 15
 function sparql_ns( $short, $long, $db = null ) { return _sparql_a_connection( $db )->ns( $short, $long ); }
16
+/**
17
+ * @param string $sparql
18
+ */
16 19
 function sparql_query( $sparql, $db = null ) { return _sparql_a_connection( $db )->query( $sparql ); }
17 20
 function sparql_errno( $db = null ) { return _sparql_a_connection( $db )->errno(); }
18 21
 function sparql_error( $db = null ) { return _sparql_a_connection( $db )->error(); }
@@ -84,6 +87,9 @@  discard block
 block discarded – undo
84 87
 		$this->params = $params;
85 88
 	}
86 89
 
90
+	/**
91
+	 * @param integer $timeout
92
+	 */
87 93
 	function query( $query, $timeout=null )
88 94
 	{	
89 95
 		$prefixes = "";
@@ -324,6 +330,10 @@  discard block
 block discarded – undo
324 330
 	var $fields;
325 331
 	var $db;
326 332
 	var $i = 0;
333
+
334
+	/**
335
+	 * @param sparql_connection $db
336
+	 */
327 337
 	function __construct( $db, $rows, $fields )
328 338
 	{
329 339
 		$this->rows = $rows;
Please login to merge, or discard this patch.
Braces   +2 added lines, -10 removed lines patch added patch discarded remove patch
@@ -215,14 +215,7 @@  discard block
 block discarded – undo
215 215
 		}
216 216
 		$r = null;
217 217
 
218
-		if( $code == "select" ) { $r = $this->test_select(); }
219
-		elseif( $code == "constant_as" ) { $r = $this->test_constant_as(); }
220
-		elseif( $code == "math_as" ) { $r = $this->test_math_as(); }
221
-		elseif( $code == "count" ) { $r = $this->test_count(); }
222
-		elseif( $code == "max" ) { $r = $this->test_max(); }
223
-		elseif( $code == "load" ) { $r = $this->test_load(); }
224
-		elseif( $code == "sample" ) { $r = $this->test_sample(); }
225
-		else { print "<p>Unknown capability code: '$code'</p>"; return false; }
218
+		if( $code == "select" ) { $r = $this->test_select(); } elseif( $code == "constant_as" ) { $r = $this->test_constant_as(); } elseif( $code == "math_as" ) { $r = $this->test_math_as(); } elseif( $code == "count" ) { $r = $this->test_count(); } elseif( $code == "max" ) { $r = $this->test_max(); } elseif( $code == "load" ) { $r = $this->test_load(); } elseif( $code == "sample" ) { $r = $this->test_sample(); } else { print "<p>Unknown capability code: '$code'</p>"; return false; }
226 219
 		$this->caps[$code] = $r;
227 220
 		if( isset( $this->caps_cache ) )
228 221
 		{
@@ -231,8 +224,7 @@  discard block
 block discarded – undo
231 224
 			if( $was_cached )
232 225
 			{
233 226
 				dba_replace( $db_key, $db_val, $this->caps_cache );
234
-			}
235
-			else
227
+			} else
236 228
 			{
237 229
 				dba_insert( $db_key, $db_val, $this->caps_cache );
238 230
 			}
Please login to merge, or discard this patch.
require/class.APRS.php 2 patches
Doc Comments   +5 added lines patch added patch discarded remove patch
@@ -1,5 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 class aprs {
3
+
4
+    /**
5
+     * @param integer $n
6
+     * @param integer $s
7
+     */
3 8
     private function urshift($n, $s) {
4 9
 	return ($n >= 0) ? ($n >> $s) :
5 10
     	    (($n & 0x7fffffff) >> $s) | 
Please login to merge, or discard this patch.
Braces   +83 added lines, -34 removed lines patch added patch discarded remove patch
@@ -18,7 +18,9 @@  discard block
 block discarded – undo
18 18
 	
19 19
 	/* Check that end was found and body has at least one byte. */
20 20
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
21
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
21
+	    if ($globalDebug) {
22
+	    	echo '!!! APRS invalid : '.$input."\n";
23
+	    }
22 24
 	    return false;
23 25
 	}
24 26
 	
@@ -27,23 +29,31 @@  discard block
 block discarded – undo
27 29
 	$body_len = strlen($body);
28 30
 	$header = substr($input,0,$splitpos);
29 31
 	//$header_len = strlen($header);
30
-	if ($debug) echo 'header : '.$header."\n";
32
+	if ($debug) {
33
+		echo 'header : '.$header."\n";
34
+	}
31 35
 	
32 36
 	/* Parse source, target and path. */
33 37
 	//FLRDF0A52>APRS,qAS,LSTB
34 38
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
35 39
 	    $ident = $matches[1];
36 40
 	    $all_elements = $matches[2];
37
-	    if ($debug) echo 'ident : '.$ident."\n";
41
+	    if ($debug) {
42
+	    	echo 'ident : '.$ident."\n";
43
+	    }
38 44
 	    $result['ident'] = $ident;
39
-	} else return false;
45
+	} else {
46
+		return false;
47
+	}
40 48
 	$elements = explode(',',$all_elements);
41 49
 	$source = end($elements);
42 50
 	$result['source'] = $source;
43 51
 	foreach ($elements as $element) {
44 52
 	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
45 53
 	        //echo "ok";
46
-	        if ($element == 'TCPIP*') return false;
54
+	        if ($element == 'TCPIP*') {
55
+	        	return false;
56
+	        }
47 57
 	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
48 58
 		return false;
49 59
 	    }
@@ -89,7 +99,9 @@  discard block
 block discarded – undo
89 99
 		//$symbol_table = $matches[4];
90 100
 		$lat = intval($lat_deg);
91 101
 		$lon = intval($lon_deg);
92
-		if ($lat > 89 || $lon > 179) return false;
102
+		if ($lat > 89 || $lon > 179) {
103
+			return false;
104
+		}
93 105
 	    
94 106
 	    /*
95 107
 	    $tmp_5b = str_replace('.','',$lat_min);
@@ -99,8 +111,12 @@  discard block
 block discarded – undo
99 111
 	    */
100 112
 		$latitude = $lat + floatval($lat_min)/60;
101 113
 		$longitude = $lon + floatval($lon_min)/60;
102
-		if ($sind == 'S') $latitude = 0-$latitude;
103
-		if ($wind == 'W') $longitude = 0-$longitude;
114
+		if ($sind == 'S') {
115
+			$latitude = 0-$latitude;
116
+		}
117
+		if ($wind == 'W') {
118
+			$longitude = 0-$longitude;
119
+		}
104 120
 		$result['latitude'] = $latitude;
105 121
 		$result['longitude'] = $longitude;
106 122
 	    }
@@ -115,7 +131,9 @@  discard block
 block discarded – undo
115 131
 		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
116 132
 		    	    $course = substr($body_parse,0,3);
117 133
 		    	    $tmp_s = intval($course);
118
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course);
134
+		    	    if ($tmp_s >= 1 && $tmp_s <= 360) {
135
+		    	    	$result['course'] = intval($course);
136
+		    	    }
119 137
 		    	    $speed = substr($body_parse,4,3);
120 138
 		    	    $result['speed'] = round($speed*1.852);
121 139
 		    	    $body_parse = substr($body_parse,7);
@@ -149,10 +167,16 @@  discard block
 block discarded – undo
149 167
 			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
150 168
 			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
151 169
 			    
152
-				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
153
-				else $result['latitude'] += $lat_off;
154
-				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
155
-				else $result['longitude'] += $lon_off;
170
+				if ($result['latitude'] < 0) {
171
+					$result['latitude'] -= $lat_off;
172
+				} else {
173
+					$result['latitude'] += $lat_off;
174
+				}
175
+				if ($result['longitude'] < 0) {
176
+					$result['longitude'] -= $lon_off;
177
+				} else {
178
+					$result['longitude'] += $lon_off;
179
+				}
156 180
 			    }
157 181
 		            $body_parse = substr($body_parse,6);
158 182
 		    }
@@ -165,27 +189,48 @@  discard block
 block discarded – undo
165 189
 			$address = substr($id,2);
166 190
 			//print_r($matches);
167 191
 			$addressType = (intval(substr($id,0,2),16))&3;
168
-			if ($addressType == 0) $result['addresstype'] = "RANDOM";
169
-			elseif ($addressType == 1) $result['addresstype'] = "ICAO";
170
-			elseif ($addressType == 2) $result['addresstype'] = "FLARM";
171
-			elseif ($addressType == 3) $result['addresstype'] = "OGN";
192
+			if ($addressType == 0) {
193
+				$result['addresstype'] = "RANDOM";
194
+			} elseif ($addressType == 1) {
195
+				$result['addresstype'] = "ICAO";
196
+			} elseif ($addressType == 2) {
197
+				$result['addresstype'] = "FLARM";
198
+			} elseif ($addressType == 3) {
199
+				$result['addresstype'] = "OGN";
200
+			}
172 201
 			$aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2);
173 202
 			$result['aircrafttype_code'] = $aircraftType;
174
-			if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN";
175
-			elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER";
176
-			elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE";
177
-			elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
178
-			elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE";
179
-			elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE";
180
-			elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER";
181
-			elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER";
182
-			elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT";
183
-			elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT";
184
-			elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO";
185
-			elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON";
186
-			elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP";
187
-			elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV";
188
-			elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT";
203
+			if ($aircraftType == 0) {
204
+				$result['aircrafttype'] = "UNKNOWN";
205
+			} elseif ($aircraftType == 1) {
206
+				$result['aircrafttype'] = "GLIDER";
207
+			} elseif ($aircraftType == 2) {
208
+				$result['aircrafttype'] = "TOW_PLANE";
209
+			} elseif ($aircraftType == 3) {
210
+				$result['aircrafttype'] = "HELICOPTER_ROTORCRAFT";
211
+			} elseif ($aircraftType == 4) {
212
+				$result['aircrafttype'] = "PARACHUTE";
213
+			} elseif ($aircraftType == 5) {
214
+				$result['aircrafttype'] = "DROP_PLANE";
215
+			} elseif ($aircraftType == 6) {
216
+				$result['aircrafttype'] = "HANG_GLIDER";
217
+			} elseif ($aircraftType == 7) {
218
+				$result['aircrafttype'] = "PARA_GLIDER";
219
+			} elseif ($aircraftType == 8) {
220
+				$result['aircrafttype'] = "POWERED_AIRCRAFT";
221
+			} elseif ($aircraftType == 9) {
222
+				$result['aircrafttype'] = "JET_AIRCRAFT";
223
+			} elseif ($aircraftType == 10) {
224
+				$result['aircrafttype'] = "UFO";
225
+			} elseif ($aircraftType == 11) {
226
+				$result['aircrafttype'] = "BALLOON";
227
+			} elseif ($aircraftType == 12) {
228
+				$result['aircrafttype'] = "AIRSHIP";
229
+			} elseif ($aircraftType == 13) {
230
+				$result['aircrafttype'] = "UAV";
231
+			} elseif ($aircraftType == 15) {
232
+				$result['aircrafttype'] = "STATIC_OBJECT";
233
+			}
189 234
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
190 235
 			$result['stealth'] = $stealth;
191 236
 			$result['address'] = $address;
@@ -227,8 +272,12 @@  discard block
 block discarded – undo
227 272
 		}
228 273
 	    }
229 274
 	}
230
-	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
231
-	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
275
+	if (isset($result['latitude'])) {
276
+		$result['latitude'] = round($result['latitude'],4);
277
+	}
278
+	if (isset($result['longitude'])) {
279
+		$result['longitude'] = round($result['longitude'],4);
280
+	}
232 281
 	//print_r($result);
233 282
 	return $result;
234 283
     }
Please login to merge, or discard this patch.
require/class.Language.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@
 block discarded – undo
77 77
 	/**
78 78
 	* Returns list of available locales
79 79
 	*
80
-	* @return array
80
+	* @return string[]
81 81
 	 */
82 82
 	public function listLocaleDir()
83 83
 	{
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -86,7 +86,9 @@  discard block
 block discarded – undo
86 86
 			return $result;
87 87
 		}
88 88
 		$handle = @opendir('./locale');
89
-		if ($handle === false) return $result;
89
+		if ($handle === false) {
90
+			return $result;
91
+		}
90 92
 		while (false !== ($file = readdir($handle))) {
91 93
 			$path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo';
92 94
 			if ($file != "." && $file != ".." && @file_exists($path)) {
@@ -112,7 +114,9 @@  discard block
 block discarded – undo
112 114
 		$available = $this->listLocaleDir();
113 115
 		$allAvailableLanguages = array();
114 116
 		foreach ($available as $lang) {
115
-			if (isset($this->all_languages[$lang])) $allAvailableLanguages[$lang] = $this->all_languages[$lang];
117
+			if (isset($this->all_languages[$lang])) {
118
+				$allAvailableLanguages[$lang] = $this->all_languages[$lang];
119
+			}
116 120
 		}
117 121
 		return $allAvailableLanguages;
118 122
 	}
Please login to merge, or discard this patch.
require/class.SBS.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -178,6 +178,10 @@  discard block
 block discarded – undo
178 178
 	return 1;
179 179
     }
180 180
     
181
+    /**
182
+     * @param double $lat
183
+     * @param integer $isodd
184
+     */
181 185
     function cprN($lat,$isodd) {
182 186
 	$nl = $this->cprNL($lat) - $isodd;
183 187
 	if ($nl > 1) return $nl;
@@ -185,6 +189,10 @@  discard block
 block discarded – undo
185 189
     }
186 190
 
187 191
 
192
+    /**
193
+     * @param string $msg
194
+     * @param string $bin
195
+     */
188 196
     function parityCheck($msg, $bin) {
189 197
 $modes_checksum_table = array(
190 198
 0x3935ea, 0x1c9af5, 0xf1b77e, 0x78dbbf, 0xc397db, 0x9e31e9, 0xb0e2f0, 0x587178,
Please login to merge, or discard this patch.
Braces   +223 added lines, -77 removed lines patch added patch discarded remove patch
@@ -6,9 +6,13 @@  discard block
 block discarded – undo
6 6
 	// Not yet finished, no CRC checks
7 7
 	//echo $buffer."\n";
8 8
 	$typehex = substr($buffer,0,1);
9
-	if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1);
10
-	elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13);
11
-	else $hex = substr($buffer,1,-1);
9
+	if ($typehex == '*' || $typehex == ':') {
10
+		$hex = substr($buffer,1,-1);
11
+	} elseif ($typehex == '@' || $typehex == '%') {
12
+		$hex = substr($buffer,13,-13);
13
+	} else {
14
+		$hex = substr($buffer,1,-1);
15
+	}
12 16
 	$bin = gmp_strval( gmp_init($hex,16), 2);
13 17
 	//if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) {
14 18
 	if (strlen($hex) == 28) {
@@ -51,8 +55,9 @@  discard block
 block discarded – undo
51 55
 		    //  131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits.
52 56
 		    $cprlat = intval(substr($bin,54,17),2)/131072.0;
53 57
 		    $cprlon = intval(substr($bin,71,17),2)/131072.0;
54
-		    if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
55
-		    elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
58
+		    if ($oe == 0) {
59
+		    	$this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time());
60
+		    } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) {
56 61
 			$cprlat_odd = $cprlat;
57 62
 			$cprlon_odd = $cprlon;
58 63
 			$cprlat_even = $this::$latlon[$icao]['latitude'];
@@ -61,8 +66,12 @@  discard block
 block discarded – undo
61 66
 			$j = 59*$cprlat_even-60*$cprlat_odd+0.5;
62 67
 			$lat_even = (360.0/60)*($j%60+$cprlat_even);
63 68
 			$lat_odd = (360.0/59)*($j%59+$cprlat_odd);
64
-			if ($lat_even >= 270) $lat_even = $lat_even - 360;
65
-			if ($lat_odd >= 270) $lat_odd = $lat_odd - 360;
69
+			if ($lat_even >= 270) {
70
+				$lat_even = $lat_even - 360;
71
+			}
72
+			if ($lat_odd >= 270) {
73
+				$lat_odd = $lat_odd - 360;
74
+			}
66 75
 			// check latitude zone
67 76
 			if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) {
68 77
 			    if ($this::$latlon[$icao]['created'] > time()) {
@@ -70,7 +79,9 @@  discard block
 block discarded – undo
70 79
 				$m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5);
71 80
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_even);
72 81
 				$lat = $lat_even;
73
-				if ($lon > 180) $lon = $lon -360;
82
+				if ($lon > 180) {
83
+					$lon = $lon -360;
84
+				}
74 85
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
75 86
 				    //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon;
76 87
 				    $data['latitude'] = $lat;
@@ -81,14 +92,18 @@  discard block
 block discarded – undo
81 92
 				$m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5);
82 93
 				$lon = (360.0/$ni)*($m%$ni+$cprlon_odd);
83 94
 				$lat = $lat_odd;
84
-				if ($lon > 180) $lon = $lon -360;
95
+				if ($lon > 180) {
96
+					$lon = $lon -360;
97
+				}
85 98
 				if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) {
86 99
 				    //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n";
87 100
 				    $data['latitude'] = $lat;
88 101
 				    $data['longitude'] = $lon;
89 102
 				}
90 103
 			    }
91
-			} else echo "Not cprNL";
104
+			} else {
105
+				echo "Not cprNL";
106
+			}
92 107
 			unset($this::$latlon[$icao]);
93 108
 		    }
94 109
 		} elseif ($tc == 19) {
@@ -97,11 +112,17 @@  discard block
 block discarded – undo
97 112
 		    $v_ew = intval(substr($bin,46,10),2);
98 113
 		    $v_ns_dir = intval(substr($bin,56,1));
99 114
 		    $v_ns = intval(substr($bin,57,10),2);
100
-		    if ($v_ew_dir) $v_ew = -1*$v_ew;
101
-		    if ($v_ns_dir) $v_ns = -1*$v_ns;
115
+		    if ($v_ew_dir) {
116
+		    	$v_ew = -1*$v_ew;
117
+		    }
118
+		    if ($v_ns_dir) {
119
+		    	$v_ns = -1*$v_ns;
120
+		    }
102 121
 		    $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew);
103 122
 		    $heading = atan2($v_ew,$v_ns)*360.0/(2*pi());
104
-		    if ($heading <0) $heading = $heading+360;
123
+		    if ($heading <0) {
124
+		    	$heading = $heading+360;
125
+		    }
105 126
 		    $data['speed'] = $speed;
106 127
 		    $data['heading'] = $heading;
107 128
 		}
@@ -116,72 +137,194 @@  discard block
 block discarded – undo
116 137
 
117 138
     function cprNL($lat) {
118 139
 	//Lookup table to convert the latitude to index.
119
-	if ($lat < 0) $lat = -$lat;             // Table is simmetric about the equator.
120
-	if ($lat < 10.47047130) return 59;
121
-	if ($lat < 14.82817437) return 58;
122
-	if ($lat < 18.18626357) return 57;
123
-	if ($lat < 21.02939493) return 56;
124
-	if ($lat < 23.54504487) return 55;
125
-	if ($lat < 25.82924707) return 54;
126
-	if ($lat < 27.93898710) return 53;
127
-	if ($lat < 29.91135686) return 52;
128
-	if ($lat < 31.77209708) return 51;
129
-	if ($lat < 33.53993436) return 50;
130
-	if ($lat < 35.22899598) return 49;
131
-	if ($lat < 36.85025108) return 48;
132
-	if ($lat < 38.41241892) return 47;
133
-	if ($lat < 39.92256684) return 46;
134
-	if ($lat < 41.38651832) return 45;
135
-	if ($lat < 42.80914012) return 44;
136
-	if ($lat < 44.19454951) return 43;
137
-	if ($lat < 45.54626723) return 42;
138
-	if ($lat < 46.86733252) return 41;
139
-	if ($lat < 48.16039128) return 40;
140
-	if ($lat < 49.42776439) return 39;
141
-	if ($lat < 50.67150166) return 38;
142
-	if ($lat < 51.89342469) return 37;
143
-	if ($lat < 53.09516153) return 36;
144
-	if ($lat < 54.27817472) return 35;
145
-	if ($lat < 55.44378444) return 34;
146
-	if ($lat < 56.59318756) return 33;
147
-	if ($lat < 57.72747354) return 32;
148
-	if ($lat < 58.84763776) return 31;
149
-	if ($lat < 59.95459277) return 30;
150
-	if ($lat < 61.04917774) return 29;
151
-	if ($lat < 62.13216659) return 28;
152
-	if ($lat < 63.20427479) return 27;
153
-	if ($lat < 64.26616523) return 26;
154
-	if ($lat < 65.31845310) return 25;
155
-	if ($lat < 66.36171008) return 24;
156
-	if ($lat < 67.39646774) return 23;
157
-	if ($lat < 68.42322022) return 22;
158
-	if ($lat < 69.44242631) return 21;
159
-	if ($lat < 70.45451075) return 20;
160
-	if ($lat < 71.45986473) return 19;
161
-	if ($lat < 72.45884545) return 18;
162
-	if ($lat < 73.45177442) return 17;
163
-	if ($lat < 74.43893416) return 16;
164
-	if ($lat < 75.42056257) return 15;
165
-	if ($lat < 76.39684391) return 14;
166
-	if ($lat < 77.36789461) return 13;
167
-	if ($lat < 78.33374083) return 12;
168
-	if ($lat < 79.29428225) return 11;
169
-	if ($lat < 80.24923213) return 10;
170
-	if ($lat < 81.19801349) return 9;
171
-	if ($lat < 82.13956981) return 8;
172
-	if ($lat < 83.07199445) return 7;
173
-	if ($lat < 83.99173563) return 6;
174
-	if ($lat < 84.89166191) return 5;
175
-	if ($lat < 85.75541621) return 4;
176
-	if ($lat < 86.53536998) return 3;
177
-	if ($lat < 87.00000000) return 2;
140
+	if ($lat < 0) {
141
+		$lat = -$lat;
142
+	}
143
+	// Table is simmetric about the equator.
144
+	if ($lat < 10.47047130) {
145
+		return 59;
146
+	}
147
+	if ($lat < 14.82817437) {
148
+		return 58;
149
+	}
150
+	if ($lat < 18.18626357) {
151
+		return 57;
152
+	}
153
+	if ($lat < 21.02939493) {
154
+		return 56;
155
+	}
156
+	if ($lat < 23.54504487) {
157
+		return 55;
158
+	}
159
+	if ($lat < 25.82924707) {
160
+		return 54;
161
+	}
162
+	if ($lat < 27.93898710) {
163
+		return 53;
164
+	}
165
+	if ($lat < 29.91135686) {
166
+		return 52;
167
+	}
168
+	if ($lat < 31.77209708) {
169
+		return 51;
170
+	}
171
+	if ($lat < 33.53993436) {
172
+		return 50;
173
+	}
174
+	if ($lat < 35.22899598) {
175
+		return 49;
176
+	}
177
+	if ($lat < 36.85025108) {
178
+		return 48;
179
+	}
180
+	if ($lat < 38.41241892) {
181
+		return 47;
182
+	}
183
+	if ($lat < 39.92256684) {
184
+		return 46;
185
+	}
186
+	if ($lat < 41.38651832) {
187
+		return 45;
188
+	}
189
+	if ($lat < 42.80914012) {
190
+		return 44;
191
+	}
192
+	if ($lat < 44.19454951) {
193
+		return 43;
194
+	}
195
+	if ($lat < 45.54626723) {
196
+		return 42;
197
+	}
198
+	if ($lat < 46.86733252) {
199
+		return 41;
200
+	}
201
+	if ($lat < 48.16039128) {
202
+		return 40;
203
+	}
204
+	if ($lat < 49.42776439) {
205
+		return 39;
206
+	}
207
+	if ($lat < 50.67150166) {
208
+		return 38;
209
+	}
210
+	if ($lat < 51.89342469) {
211
+		return 37;
212
+	}
213
+	if ($lat < 53.09516153) {
214
+		return 36;
215
+	}
216
+	if ($lat < 54.27817472) {
217
+		return 35;
218
+	}
219
+	if ($lat < 55.44378444) {
220
+		return 34;
221
+	}
222
+	if ($lat < 56.59318756) {
223
+		return 33;
224
+	}
225
+	if ($lat < 57.72747354) {
226
+		return 32;
227
+	}
228
+	if ($lat < 58.84763776) {
229
+		return 31;
230
+	}
231
+	if ($lat < 59.95459277) {
232
+		return 30;
233
+	}
234
+	if ($lat < 61.04917774) {
235
+		return 29;
236
+	}
237
+	if ($lat < 62.13216659) {
238
+		return 28;
239
+	}
240
+	if ($lat < 63.20427479) {
241
+		return 27;
242
+	}
243
+	if ($lat < 64.26616523) {
244
+		return 26;
245
+	}
246
+	if ($lat < 65.31845310) {
247
+		return 25;
248
+	}
249
+	if ($lat < 66.36171008) {
250
+		return 24;
251
+	}
252
+	if ($lat < 67.39646774) {
253
+		return 23;
254
+	}
255
+	if ($lat < 68.42322022) {
256
+		return 22;
257
+	}
258
+	if ($lat < 69.44242631) {
259
+		return 21;
260
+	}
261
+	if ($lat < 70.45451075) {
262
+		return 20;
263
+	}
264
+	if ($lat < 71.45986473) {
265
+		return 19;
266
+	}
267
+	if ($lat < 72.45884545) {
268
+		return 18;
269
+	}
270
+	if ($lat < 73.45177442) {
271
+		return 17;
272
+	}
273
+	if ($lat < 74.43893416) {
274
+		return 16;
275
+	}
276
+	if ($lat < 75.42056257) {
277
+		return 15;
278
+	}
279
+	if ($lat < 76.39684391) {
280
+		return 14;
281
+	}
282
+	if ($lat < 77.36789461) {
283
+		return 13;
284
+	}
285
+	if ($lat < 78.33374083) {
286
+		return 12;
287
+	}
288
+	if ($lat < 79.29428225) {
289
+		return 11;
290
+	}
291
+	if ($lat < 80.24923213) {
292
+		return 10;
293
+	}
294
+	if ($lat < 81.19801349) {
295
+		return 9;
296
+	}
297
+	if ($lat < 82.13956981) {
298
+		return 8;
299
+	}
300
+	if ($lat < 83.07199445) {
301
+		return 7;
302
+	}
303
+	if ($lat < 83.99173563) {
304
+		return 6;
305
+	}
306
+	if ($lat < 84.89166191) {
307
+		return 5;
308
+	}
309
+	if ($lat < 85.75541621) {
310
+		return 4;
311
+	}
312
+	if ($lat < 86.53536998) {
313
+		return 3;
314
+	}
315
+	if ($lat < 87.00000000) {
316
+		return 2;
317
+	}
178 318
 	return 1;
179 319
     }
180 320
     
181 321
     function cprN($lat,$isodd) {
182 322
 	$nl = $this->cprNL($lat) - $isodd;
183
-	if ($nl > 1) return $nl;
184
-	else return 1;
323
+	if ($nl > 1) {
324
+		return $nl;
325
+	} else {
326
+		return 1;
327
+	}
185 328
     }
186 329
 
187 330
 
@@ -207,10 +350,13 @@  discard block
 block discarded – undo
207 350
 	$checksum = intval(substr($msg,22,6),16);
208 351
 
209 352
 	for ($j = 0; $j < strlen($bin); $j++) {
210
-	    if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0);
353
+	    if ($bin[$j]) {
354
+	    	$crc = $crc^intval($modes_checksum_table[$j],0);
355
+	    }
211 356
 	}
212
-	if ($crc == $checksum) return true;
213
-	else {
357
+	if ($crc == $checksum) {
358
+		return true;
359
+	} else {
214 360
 	    //echo "**** CRC ERROR ****\n";
215 361
 	    return false;
216 362
 	}
Please login to merge, or discard this patch.
require/class.SpotterImport.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -40,6 +40,10 @@
 block discarded – undo
40 40
 	}
41 41
     }
42 42
 
43
+    /**
44
+     * @param string $id
45
+     * @param string $ident
46
+     */
43 47
     function get_Schedule($id,$ident) {
44 48
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
45 49
 	// Get schedule here, so it's done only one time
Please login to merge, or discard this patch.
Braces   +327 added lines, -116 removed lines patch added patch discarded remove patch
@@ -53,7 +53,9 @@  discard block
 block discarded – undo
53 53
 	$dbc = $this->db;
54 54
 	$this->all_flights[$id]['schedule_check'] = true;
55 55
 	if ($globalSchedulesFetch) {
56
-	if ($globalDebug) echo 'Getting schedule info...'."\n";
56
+	if ($globalDebug) {
57
+		echo 'Getting schedule info...'."\n";
58
+	}
57 59
 	$Spotter = new Spotter($dbc);
58 60
 	$Schedule = new Schedule($dbc);
59 61
 	$Translation = new Translation($dbc);
@@ -64,7 +66,9 @@  discard block
 block discarded – undo
64 66
 	    if ($Schedule->checkSchedule($operator) == 0) {
65 67
 		$schedule = $Schedule->fetchSchedule($operator);
66 68
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
67
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
69
+		    if ($globalDebug) {
70
+		    	echo "-> Schedule info for ".$operator." (".$ident.")\n";
71
+		    }
68 72
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
69 73
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
70 74
 		    // Should also check if route schedule = route from DB
@@ -73,7 +77,9 @@  discard block
 block discarded – undo
73 77
 			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
74 78
 			    if ($airport_icao != '') {
75 79
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
76
-				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
80
+				if ($globalDebug) {
81
+					echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
82
+				}
77 83
 			    }
78 84
 			}
79 85
 		    }
@@ -82,17 +88,25 @@  discard block
 block discarded – undo
82 88
 			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
83 89
 			    if ($airport_icao != '') {
84 90
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
85
-				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
91
+				if ($globalDebug) {
92
+					echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
93
+				}
86 94
 			    }
87 95
 			}
88 96
 		    }
89 97
 		    $Schedule->addSchedule($operator,$this->all_flights[$id]['departure_airport'],$this->all_flights[$id]['departure_airport_time'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time'],$schedule['Source']);
90 98
 		}
91
-	    } else $scheduleexist = true;
92
-	} else $scheduleexist = true;
99
+	    } else {
100
+	    	$scheduleexist = true;
101
+	    }
102
+	} else {
103
+		$scheduleexist = true;
104
+	}
93 105
 	// close connection, at least one way will work ?
94 106
        if ($scheduleexist) {
95
-		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
107
+		if ($globalDebug) {
108
+			echo "-> get arrival/departure airport info for ".$ident."\n";
109
+		}
96 110
     		$sch = $Schedule->getSchedule($operator);
97 111
 		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport' => $sch['arrival_airport_icao'],'departure_airport' => $sch['departure_airport_icao'],'departure_airport_time' => $sch['departure_airport_time'],'arrival_airport_time' => $sch['arrival_airport_time']));
98 112
        }
@@ -114,7 +128,9 @@  discard block
 block discarded – undo
114 128
 
115 129
     public function checkAll() {
116 130
 	global $globalDebug;
117
-	if ($globalDebug) echo "Update last seen flights data...\n";
131
+	if ($globalDebug) {
132
+		echo "Update last seen flights data...\n";
133
+	}
118 134
 	foreach ($this->all_flights as $key => $flight) {
119 135
 	    if (isset($this->all_flights[$key]['id'])) {
120 136
 		//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
@@ -127,24 +143,32 @@  discard block
 block discarded – undo
127 143
 
128 144
     public function arrival($key) {
129 145
 	global $globalClosestMinDist, $globalDebug;
130
-	if ($globalDebug) echo 'Update arrival...'."\n";
146
+	if ($globalDebug) {
147
+		echo 'Update arrival...'."\n";
148
+	}
131 149
 	$Spotter = new Spotter($this->db);
132 150
         $airport_icao = '';
133 151
         $airport_time = '';
134
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
152
+        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') {
153
+        	$globalClosestMinDist = 50;
154
+        }
135 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
136 156
 	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
137 157
     	    if (isset($closestAirports[0])) {
138 158
         	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
139 159
         	    $airport_icao = $closestAirports[0]['icao'];
140 160
         	    $airport_time = $this->all_flights[$key]['datetime'];
141
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
161
+        	    if ($globalDebug) {
162
+        	    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
163
+        	    }
142 164
         	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
143 165
         	    foreach ($closestAirports as $airport) {
144 166
         		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
145 167
         		    $airport_icao = $airport['icao'];
146 168
         		    $airport_time = $this->all_flights[$key]['datetime'];
147
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
169
+        		    if ($globalDebug) {
170
+        		    	echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
171
+        		    }
148 172
         		    break;
149 173
         		}
150 174
         	    }
@@ -152,14 +176,20 @@  discard block
 block discarded – undo
152 176
         		$airport_icao = $closestAirports[0]['icao'];
153 177
         		$airport_time = $this->all_flights[$key]['datetime'];
154 178
         	} else {
155
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
179
+        		if ($globalDebug) {
180
+        			echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
181
+        		}
156 182
         	}
157 183
     	    } else {
158
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
184
+    		    if ($globalDebug) {
185
+    		    	echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
186
+    		    }
159 187
     	    }
160 188
 
161 189
         } else {
162
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
190
+        	if ($globalDebug) {
191
+        		echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
192
+        	}
163 193
         }
164 194
         return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
165 195
     }
@@ -169,12 +199,16 @@  discard block
 block discarded – undo
169 199
     public function del() {
170 200
 	global $globalDebug;
171 201
 	// Delete old infos
172
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
202
+	if ($globalDebug) {
203
+		echo 'Delete old values and update latest data...'."\n";
204
+	}
173 205
 	foreach ($this->all_flights as $key => $flight) {
174 206
     	    if (isset($flight['lastupdate'])) {
175 207
         	if ($flight['lastupdate'] < (time()-3000)) {
176 208
             	    if (isset($this->all_flights[$key]['id'])) {
177
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
209
+            		if ($globalDebug) {
210
+            			echo "--- Delete old values with id ".$this->all_flights[$key]['id']."\n";
211
+            		}
178 212
 			/*
179 213
 			$SpotterLive = new SpotterLive();
180 214
             		$SpotterLive->deleteLiveSpotterDataById($this->all_flights[$key]['id']);
@@ -184,7 +218,9 @@  discard block
 block discarded – undo
184 218
             		$Spotter = new Spotter($this->db);
185 219
             		if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
186 220
 				$result = $Spotter->updateLatestSpotterData($this->all_flights[$key]['id'],$this->all_flights[$key]['ident'],$this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$this->all_flights[$key]['altitude'],$this->all_flights[$key]['ground'],$this->all_flights[$key]['speed'],$this->all_flights[$key]['datetime'],$real_arrival['airport_icao'],$real_arrival['airport_time']);
187
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
221
+				if ($globalDebug && $result != 'success') {
222
+					echo '!!! ERROR : '.$result."\n";
223
+				}
188 224
 			}
189 225
 			// Put in archive
190 226
 //			$Spotter->db = null;
@@ -198,8 +234,10 @@  discard block
 block discarded – undo
198 234
     public function add($line) {
199 235
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights;
200 236
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
201
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
202
-/*
237
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
238
+		$globalCoordMinChange = '0.02';
239
+	}
240
+	/*
203 241
 	$Spotter = new Spotter();
204 242
 	$dbc = $Spotter->db;
205 243
 	$SpotterLive = new SpotterLive($dbc);
@@ -227,11 +265,15 @@  discard block
 block discarded – undo
227 265
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
228 266
 		    $current_date = date('Y-m-d');
229 267
 		    $source = $line['source_name'];
230
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
268
+		    if ($source == '' || $line['format_source'] == 'aprs') {
269
+		    	$source = $line['format_source'];
270
+		    }
231 271
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
232 272
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
233 273
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
234
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
274
+		    } else {
275
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
276
+		    }
235 277
 		}
236 278
 		
237 279
 		/*
@@ -247,8 +289,11 @@  discard block
 block discarded – undo
247 289
 		//$this->db = $dbc;
248 290
 
249 291
 		$hex = trim($line['hex']);
250
-	        if (!isset($line['id'])) $id = trim($line['hex']);
251
-	        else $id = trim($line['id']);
292
+	        if (!isset($line['id'])) {
293
+	        	$id = trim($line['hex']);
294
+	        } else {
295
+	        	$id = trim($line['id']);
296
+	        }
252 297
 		
253 298
 		//print_r($this->all_flights);
254 299
 		if (!isset($this->all_flights[$id]['hex']) && ctype_xdigit($hex)) {
@@ -263,13 +308,20 @@  discard block
 block discarded – undo
263 308
 			$Spotter = new Spotter($this->db);
264 309
 			$aircraft_icao = $Spotter->getAllAircraftType($hex);
265 310
 			$Spotter->db = null;
266
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
311
+			if ($globalDebugTimeElapsed) {
312
+				echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
+			}
267 314
 
268 315
 			if ($aircraft_icao == '' && isset($line['aircraft_type'])) {
269
-			    if ($line['aircraft_type'] == 'PARA_GLIDER') $aircraft_icao = 'GLID';
270
-			    elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') $aircraft_icao = 'UHEL';
271
-			    elseif ($line['aircraft_type'] == 'TOW_PLANE') $aircraft_icao = 'TOWPLANE';
272
-			    elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') $aircraft_icao = 'POWAIRC';
316
+			    if ($line['aircraft_type'] == 'PARA_GLIDER') {
317
+			    	$aircraft_icao = 'GLID';
318
+			    } elseif ($line['aircraft_type'] == 'HELICOPTER_ROTORCRAFT') {
319
+			    	$aircraft_icao = 'UHEL';
320
+			    } elseif ($line['aircraft_type'] == 'TOW_PLANE') {
321
+			    	$aircraft_icao = 'TOWPLANE';
322
+			    } elseif ($line['aircraft_type'] == 'POWERED_AIRCRAFT') {
323
+			    	$aircraft_icao = 'POWAIRC';
324
+			    }
273 325
 			}
274 326
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
275 327
 		    } else if (isset($line['aircraft_name'])) {
@@ -277,29 +329,47 @@  discard block
 block discarded – undo
277 329
 			$Spotter = new Spotter($this->db);
278 330
 			$aircraft_icao = $Spotter->getAircraftIcao($line['aircraft_name']);
279 331
 			$Spotter->db = null;
280
-			if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
281
-			else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
282
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
332
+			if ($aircraft_icao != '') {
333
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
334
+			} else {
335
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => 'NA'));
336
+			}
337
+		    } else {
338
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $line['aircraft_icao']));
339
+		    }
283 340
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true));
284 341
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
285 342
 		    if (!isset($line['id'])) {
286
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
287
-//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
343
+			if (!isset($globalDaemon)) {
344
+				$globalDaemon = TRUE;
345
+			}
346
+			//			if (isset($line['format_source']) && ($line['format_source'] == 'sbs' || $line['format_source'] == 'tsv' || $line['format_source'] == 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident'].'-'.date('YmdGi')));
288 347
 //			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
289
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
348
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
349
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
350
+			}
290 351
 		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
291
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
352
+		     } else {
353
+		     	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
354
+		     }
292 355
 
293
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$hex." ***********\n";
294
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
356
+		    if ($globalDebug) {
357
+		    	echo "*********** New aircraft hex : ".$hex." ***********\n";
358
+		    }
359
+		    if ($globalAllFlights !== FALSE) {
360
+		    	$dataFound = true;
361
+		    }
295 362
 		}
296 363
 		
297 364
 		if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
298 365
 		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
299 366
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
300 367
 		    } else {
301
-				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
302
-				elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
368
+				if (strtotime($line['datetime']) == strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
369
+					echo "!!! Date is the same as previous data for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
370
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_flights[$id]['datetime']) && $globalDebug) {
371
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_flights[$id]['datetime'].") !!! for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."\n";
372
+				}
303 373
 				/*
304 374
 				echo strtotime($line['datetime']).' > '.strtotime($this->all_flights[$id]['datetime']);
305 375
 				print_r($this->all_flights[$id]);
@@ -307,7 +377,9 @@  discard block
 block discarded – undo
307 377
 				*/
308 378
 				return '';
309 379
 		    }
310
-		} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
380
+		} else {
381
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
382
+		}
311 383
 
312 384
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG') {
313 385
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
@@ -328,15 +400,25 @@  discard block
 block discarded – undo
328 400
 			$timeelapsed = microtime(true);
329 401
             		$Spotter = new Spotter($this->db);
330 402
             		$fromsource = NULL;
331
-            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
332
-            		elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
333
-			elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
334
-			elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
335
-			elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
403
+            		if (isset($globalAirlinesSource) && $globalAirlinesSource != '') {
404
+            			$fromsource = $globalAirlinesSource;
405
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') {
406
+            			$fromsource = 'vatsim';
407
+            		} elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') {
408
+				$fromsource = 'ivao';
409
+			} elseif (isset($globalVATSIM) && $globalVATSIM) {
410
+				$fromsource = 'vatsim';
411
+			} elseif (isset($globalIVAO) && $globalIVAO) {
412
+				$fromsource = 'ivao';
413
+			}
336 414
             		$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
337
-			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
415
+			if ($globalDebug && $result != 'success') {
416
+				echo '!!! ERROR : '.$result."\n";
417
+			}
338 418
 			$Spotter->db = null;
339
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
419
+			if ($globalDebugTimeElapsed) {
420
+				echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
421
+			}
340 422
 		    }
341 423
 
342 424
 /*
@@ -347,7 +429,9 @@  discard block
 block discarded – undo
347 429
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
348 430
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
349 431
   */
350
-		    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
432
+		    if (!isset($this->all_flights[$id]['id'])) {
433
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
434
+		    }
351 435
 
352 436
 		    //$putinarchive = true;
353 437
 		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
@@ -364,7 +448,9 @@  discard block
 block discarded – undo
364 448
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
365 449
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
366 450
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $line['departure_airport_icao'],'arrival_airport' => $line['arrival_airport_icao'],'route_stop' => ''));
367
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
451
+				if ($globalDebugTimeElapsed) {
452
+					echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
+				}
368 454
 
369 455
 		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
370 456
 			$timeelapsed = microtime(true);
@@ -377,7 +463,9 @@  discard block
 block discarded – undo
377 463
 				$Translation->db = null;
378 464
 			}
379 465
 			$Spotter->db = null;
380
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
466
+			if ($globalDebugTimeElapsed) {
467
+				echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
468
+			}
381 469
 
382 470
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
383 471
 			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
@@ -386,9 +474,13 @@  discard block
 block discarded – undo
386 474
 		    		$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport' => $route['fromairport_icao'],'arrival_airport' => $route['toairport_icao'],'route_stop' => $route['routestop']));
387 475
 		    	    }
388 476
 			}
389
-			if (!isset($globalFork)) $globalFork = TRUE;
477
+			if (!isset($globalFork)) {
478
+				$globalFork = TRUE;
479
+			}
390 480
 			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
391
-				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
481
+				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) {
482
+					$this->get_Schedule($id,trim($line['ident']));
483
+				}
392 484
 			}
393 485
 		    }
394 486
 		}
@@ -404,16 +496,23 @@  discard block
 block discarded – undo
404 496
 		    // use datetime
405 497
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
406 498
 			$speed = $speed*3.6;
407
-			if ($speed < 1000) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
408
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
499
+			if ($speed < 1000) {
500
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($speed)));
501
+			}
502
+  			if ($globalDebug) {
503
+  				echo "ø Calculated Speed for ".$this->all_flights[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
504
+  			}
409 505
 		    }
410 506
 		}
411 507
 
412 508
 
413 509
 
414 510
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
415
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
416
-	    	    else unset($timediff);
511
+	    	    if (isset($this->all_flights[$id]['time_last_coord'])) {
512
+	    	    	$timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
513
+	    	    } else {
514
+	    	    	unset($timediff);
515
+	    	    }
417 516
 	    	    if ($this->tmd > 5 || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM) || !isset($timediff) || $timediff > 800 || ($timediff > 10 && isset($this->all_flights[$id]['latitude']) && isset($this->all_flights[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')))) {
418 517
 			if (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude'])) {
419 518
 			    if (!$Common->checkLine($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['livedb_latitude'],$this->all_flights[$id]['livedb_longitude'],$line['latitude'],$line['longitude'])) {
@@ -421,21 +520,31 @@  discard block
 block discarded – undo
421 520
 				$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
422 521
 				$this->all_flights[$id]['putinarchive'] = true;
423 522
 				
424
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
523
+				if ($globalDebug) {
524
+					echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
525
+				}
425 526
 				$timeelapsed = microtime(true);
426 527
 				$Spotter = new Spotter($this->db);
427 528
 				$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
428
-				if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
529
+				if (!empty($all_country)) {
530
+					$this->all_flights[$id]['over_country'] = $all_country['iso2'];
531
+				}
429 532
 				$Spotter->db = null;
430
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
533
+				if ($globalDebugTimeElapsed) {
534
+					echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
535
+				}
431 536
 				$this->tmd = 0;
432
-				if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
537
+				if ($globalDebug) {
538
+					echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
539
+				}
433 540
 			    }
434 541
 			}
435 542
 
436 543
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
437 544
 			    //if (!isset($this->all_flights[$id]['latitude']) || $this->all_flights[$id]['latitude'] == '' || abs($this->all_flights[$id]['latitude']-$line['latitude']) < 3 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
438
-				if (!isset($this->all_flights[$id]['archive_latitude'])) $this->all_flights[$id]['archive_latitude'] = $line['latitude'];
545
+				if (!isset($this->all_flights[$id]['archive_latitude'])) {
546
+					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
547
+				}
439 548
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
440 549
 				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
441 550
 				    $dataFound = true;
@@ -457,9 +566,13 @@  discard block
 block discarded – undo
457 566
 			    */
458 567
 			}
459 568
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
460
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
569
+			    if ($line['longitude'] > 180) {
570
+			    	$line['longitude'] = $line['longitude'] - 360;
571
+			    }
461 572
 			    //if (!isset($this->all_flights[$id]['longitude']) || $this->all_flights[$id]['longitude'] == ''  || abs($this->all_flights[$id]['longitude']-$line['longitude']) < 2 || $line['format_source'] != 'sbs' || time() - $this->all_flights[$id]['lastupdate'] > 30) {
462
-				if (!isset($this->all_flights[$id]['archive_longitude'])) $this->all_flights[$id]['archive_longitude'] = $line['longitude'];
573
+				if (!isset($this->all_flights[$id]['archive_longitude'])) {
574
+					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
575
+				}
463 576
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs') {
464 577
 				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
465 578
 				    $dataFound = true;
@@ -490,7 +603,9 @@  discard block
 block discarded – undo
490 603
 		    }
491 604
 		}
492 605
 		if (isset($line['last_update']) && $line['last_update'] != '') {
493
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
606
+		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) {
607
+		    	$dataFound = true;
608
+		    }
494 609
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
495 610
 		}
496 611
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
@@ -512,11 +627,17 @@  discard block
 block discarded – undo
512 627
 			// Here we force archive of flight because after ground it's a new one (or should be)
513 628
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
514 629
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
515
-			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
516
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
517
-			elseif (isset($this->all_flights[$id]['ident'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
630
+			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw') && $globalDaemon) {
631
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdGi')));
632
+			} elseif (isset($line['id'])) {
633
+		        	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
634
+		        } elseif (isset($this->all_flights[$id]['ident'])) {
635
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
636
+			}
637
+		    }
638
+		    if ($line['ground'] != 1) {
639
+		    	$line['ground'] = 0;
518 640
 		    }
519
-		    if ($line['ground'] != 1) $line['ground'] = 0;
520 641
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
521 642
 		    //$dataFound = true;
522 643
 		}
@@ -524,28 +645,40 @@  discard block
 block discarded – undo
524 645
 		    if (isset($this->all_flights[$id]['squawk']) && $this->all_flights[$id]['squawk'] != '7500' && $this->all_flights[$id]['squawk'] != '7600' && $this->all_flights[$id]['squawk'] != '7700' && isset($this->all_flights[$id]['id'])) {
525 646
 			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
526 647
 			    $highlight = '';
527
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
528
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
529
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
648
+			    if ($this->all_flights[$id]['squawk'] == '7500') {
649
+			    	$highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
650
+			    }
651
+			    if ($this->all_flights[$id]['squawk'] == '7600') {
652
+			    	$highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
653
+			    }
654
+			    if ($this->all_flights[$id]['squawk'] == '7700') {
655
+			    	$highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
656
+			    }
530 657
 			    if ($highlight != '') {
531 658
 				$timeelapsed = microtime(true);
532 659
 				$Spotter = new Spotter($this->db);
533 660
 				$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
534 661
 				$Spotter->db = null;
535
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
662
+				if ($globalDebugTimeElapsed) {
663
+					echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
664
+				}
536 665
 
537 666
 				$this->all_flights[$id]['putinarchive'] = true;
538 667
 				//$putinarchive = true;
539 668
 				//$highlight = '';
540 669
 			    }
541 670
 			    
542
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
671
+		    } else {
672
+		    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
673
+		    }
543 674
 		    //$dataFound = true;
544 675
 		}
545 676
 
546 677
 		if (isset($line['altitude']) && $line['altitude'] != '') {
547 678
 		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
548
-			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) $this->all_flights[$id]['putinarchive'] = true;
679
+			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 2) {
680
+				$this->all_flights[$id]['putinarchive'] = true;
681
+			}
549 682
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
550 683
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
551 684
 			//$dataFound = true;
@@ -557,21 +690,30 @@  discard block
 block discarded – undo
557 690
 		}
558 691
 		
559 692
 		if (isset($line['heading']) && $line['heading'] != '') {
560
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) $this->all_flights[$id]['putinarchive'] = true;
693
+		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 2) {
694
+		    	$this->all_flights[$id]['putinarchive'] = true;
695
+		    }
561 696
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
562 697
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
563 698
 		    //$dataFound = true;
564 699
   		} elseif (!isset($this->all_flights[$id]['heading_fromsrc']) && isset($this->all_flights[$id]['archive_latitude']) && $this->all_flights[$id]['archive_latitude'] != $this->all_flights[$id]['latitude'] && isset($this->all_flights[$id]['archive_longitude']) && $this->all_flights[$id]['archive_longitude'] != $this->all_flights[$id]['longitude']) {
565 700
   		    $heading = $Common->getHeading($this->all_flights[$id]['archive_latitude'],$this->all_flights[$id]['archive_longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
566 701
 		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
567
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) $this->all_flights[$id]['putinarchive'] = true;
568
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
702
+		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 2) {
703
+		    	$this->all_flights[$id]['putinarchive'] = true;
704
+		    }
705
+  		    if ($globalDebug) {
706
+  		    	echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
707
+  		    }
569 708
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
570 709
   		    // If not enough messages and ACARS set heading to 0
571 710
   		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
572 711
   		}
573
-		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
574
-		elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
712
+		if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) {
713
+			$dataFound = false;
714
+		} elseif (isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) {
715
+			$dataFound = false;
716
+		}
575 717
 
576 718
 //		print_r($this->all_flights[$id]);
577 719
 		//gets the callsign from the last hour
@@ -586,23 +728,36 @@  discard block
 block discarded – undo
586 728
 			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
587 729
 			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
588 730
 			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
589
-				if ($globalDebug) echo "Check if aircraft is already in DB...";
731
+				if ($globalDebug) {
732
+					echo "Check if aircraft is already in DB...";
733
+				}
590 734
 				$timeelapsed = microtime(true);
591 735
 				$SpotterLive = new SpotterLive($this->db);
592 736
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson')) {
593 737
 				    $recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
594
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
738
+				    if ($globalDebugTimeElapsed) {
739
+				    	echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
740
+				    }
595 741
 				} elseif (isset($line['id'])) {
596 742
 				    $recent_ident = $SpotterLive->checkIdRecent($line['id']);
597
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
743
+				    if ($globalDebugTimeElapsed) {
744
+				    	echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
745
+				    }
598 746
 				} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
599 747
 				    $recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
600
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
601
-				} else $recent_ident = '';
748
+				    if ($globalDebugTimeElapsed) {
749
+				    	echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
750
+				    }
751
+				} else {
752
+					$recent_ident = '';
753
+				}
602 754
 				$SpotterLive->db=null;
603 755
 
604
-				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
605
-				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
756
+				if ($globalDebug && $recent_ident == '') {
757
+					echo " Not in DB.\n";
758
+				} elseif ($globalDebug && $recent_ident != '') {
759
+					echo " Already in DB.\n";
760
+				}
606 761
 			    } else {
607 762
 				$recent_ident = '';
608 763
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
@@ -610,7 +765,9 @@  discard block
 block discarded – undo
610 765
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
611 766
 			    if($recent_ident == "")
612 767
 			    {
613
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
768
+				if ($globalDebug) {
769
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
770
+				}
614 771
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
615 772
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
616 773
 				//adds the spotter data for the archive
@@ -654,26 +811,44 @@  discard block
 block discarded – undo
654 811
 				
655 812
 				if (!$ignoreImport) {
656 813
 				    $highlight = '';
657
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
658
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
659
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
660
-				    if (!isset($this->all_flights[$id]['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
814
+				    if ($this->all_flights[$id]['squawk'] == '7500') {
815
+				    	$highlight = 'Squawk 7500 : Hijack';
816
+				    }
817
+				    if ($this->all_flights[$id]['squawk'] == '7600') {
818
+				    	$highlight = 'Squawk 7600 : Lost Comm (radio failure)';
819
+				    }
820
+				    if ($this->all_flights[$id]['squawk'] == '7700') {
821
+				    	$highlight = 'Squawk 7700 : Emergency';
822
+				    }
823
+				    if (!isset($this->all_flights[$id]['id'])) {
824
+				    	$this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.date('YmdHi')));
825
+				    }
661 826
 				    $timeelapsed = microtime(true);
662 827
 				    $Spotter = new Spotter($this->db);
663 828
 				    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name']);
664 829
 				    $Spotter->db = null;
665
-				    if ($globalDebug && isset($result)) echo $result."\n";
666
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
830
+				    if ($globalDebug && isset($result)) {
831
+				    	echo $result."\n";
832
+				    }
833
+				    if ($globalDebugTimeElapsed) {
834
+				    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
835
+				    }
667 836
 				    
668 837
 				    // Add source stat in DB
669 838
 				    $Stats = new Stats($this->db);
670 839
 				    if (!empty($this->stats)) {
671
-					if ($globalDebug) echo 'Add source stats : ';
840
+					if ($globalDebug) {
841
+						echo 'Add source stats : ';
842
+					}
672 843
 				        foreach($this->stats as $date => $data) {
673 844
 					    foreach($data as $source => $sourced) {
674 845
 					        //print_r($sourced);
675
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
676
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
846
+				    	        if (isset($sourced['polar'])) {
847
+				    	        	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
848
+				    	        }
849
+				    	        if (isset($sourced['hist'])) {
850
+				    	        	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
851
+				    	        }
677 852
 				    		if (isset($sourced['msg'])) {
678 853
 				    		    if (time() - $sourced['msg']['date'] > 10) {
679 854
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -686,13 +861,17 @@  discard block
 block discarded – undo
686 861
 			    			unset($this->stats[$date]);
687 862
 			    		    }
688 863
 				    	}
689
-				    	if ($globalDebug) echo 'Done'."\n";
864
+				    	if ($globalDebug) {
865
+				    		echo 'Done'."\n";
866
+				    	}
690 867
 
691 868
 				    }
692 869
 				    $Stats->db = null;
693 870
 				    
694 871
 				    $this->del();
695
-				} elseif ($globalDebug) echo 'Ignore data'."\n";
872
+				} elseif ($globalDebug) {
873
+					echo 'Ignore data'."\n";
874
+				}
696 875
 				//$ignoreImport = false;
697 876
 				$this->all_flights[$id]['addedSpotter'] = 1;
698 877
 				//print_r($this->all_flights[$id]);
@@ -709,12 +888,16 @@  discard block
 block discarded – undo
709 888
 			*/
710 889
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
711 890
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
712
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
891
+				    if ($globalDebug) {
892
+				    	echo "---- Deleting Live Spotter data older than 9 hours...";
893
+				    }
713 894
 				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
714 895
 				    $SpotterLive = new SpotterLive($this->db);
715 896
 				    $SpotterLive->deleteLiveSpotterData();
716 897
 				    $SpotterLive->db=null;
717
-				    if ($globalDebug) echo " Done\n";
898
+				    if ($globalDebug) {
899
+				    	echo " Done\n";
900
+				    }
718 901
 				    $this->last_delete = time();
719 902
 				}
720 903
 			    } else {
@@ -737,11 +920,17 @@  discard block
 block discarded – undo
737 920
 		    //echo "{$line[8]} {$line[7]} - MODES:{$line[4]}  CALLSIGN:{$line[10]}   ALT:{$line[11]}   VEL:{$line[12]}   HDG:{$line[13]}   LAT:{$line[14]}   LON:{$line[15]}   VR:{$line[16]}   SQUAWK:{$line[17]}\n";
738 921
 		    if ($globalDebug) {
739 922
 			if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
740
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
741
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
923
+				if (isset($this->all_flights[$id]['source_name'])) {
924
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name'].' - Source name : '.$this->all_flights[$id]['source_name']."\n";
925
+				} else {
926
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Pilot : '.$this->all_flights[$id]['pilot_name']."\n";
927
+				}
742 928
 			} else {
743
-				if (isset($this->all_flights[$id]['source_name'])) echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
744
-				else echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
929
+				if (isset($this->all_flights[$id]['source_name'])) {
930
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time'].' - Source Name : '.$this->all_flights[$id]['source_name']."\n";
931
+				} else {
932
+					echo 'DATA : hex : '.$this->all_flights[$id]['hex'].' - ident : '.$this->all_flights[$id]['ident'].' - ICAO : '.$this->all_flights[$id]['aircraft_icao'].' - Departure Airport : '.$this->all_flights[$id]['departure_airport'].' - Arrival Airport : '.$this->all_flights[$id]['arrival_airport'].' - Latitude : '.$this->all_flights[$id]['latitude'].' - Longitude : '.$this->all_flights[$id]['longitude'].' - waypoints : '.$this->all_flights[$id]['waypoints'].' - Altitude : '.$this->all_flights[$id]['altitude'].' - Heading : '.$this->all_flights[$id]['heading'].' - Speed : '.$this->all_flights[$id]['speed'].' - Departure Airport Time : '.$this->all_flights[$id]['departure_airport_time'].' - Arrival Airport time : '.$this->all_flights[$id]['arrival_airport_time']."\n";
933
+				}
745 934
 			}
746 935
 		    }
747 936
 		    $ignoreImport = false;
@@ -787,19 +976,25 @@  discard block
 block discarded – undo
787 976
 
788 977
 		    if (!$ignoreImport) {
789 978
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
790
-				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
979
+				if ($globalDebug) {
980
+					echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
981
+				}
791 982
 				$timeelapsed = microtime(true);
792 983
 				$SpotterLive = new SpotterLive($this->db);
793 984
 				$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
794 985
 				$SpotterLive->db = null;
795
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
986
+				if ($globalDebugTimeElapsed) {
987
+					echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
988
+				}
796 989
 
797 990
 				// Put statistics in $this->stats variable
798 991
 				//if ($line['format_source'] != 'aprs') {
799 992
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
800 993
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
801 994
 					$source = $this->all_flights[$id]['source_name'];
802
-					if ($source == '') $source = $this->all_flights[$id]['format_source'];
995
+					if ($source == '') {
996
+						$source = $this->all_flights[$id]['format_source'];
997
+					}
803 998
 					if (!isset($this->source_location[$source])) {
804 999
 						$Location = new Source();
805 1000
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -820,7 +1015,9 @@  discard block
 block discarded – undo
820 1015
 					$stats_heading = round($stats_heading/22.5);
821 1016
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude']);
822 1017
 					$current_date = date('Y-m-d');
823
-					if ($stats_heading == 16) $stats_heading = 0;
1018
+					if ($stats_heading == 16) {
1019
+						$stats_heading = 0;
1020
+					}
824 1021
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
825 1022
 						for ($i=0;$i<=15;$i++) {
826 1023
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -838,7 +1035,9 @@  discard block
 block discarded – undo
838 1035
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
839 1036
 						    end($this->stats[$current_date][$source]['hist']);
840 1037
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
841
-						} else $mini = 0;
1038
+						} else {
1039
+							$mini = 0;
1040
+						}
842 1041
 						for ($i=$mini;$i<=$distance;$i+=10) {
843 1042
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
844 1043
 						}
@@ -849,20 +1048,30 @@  discard block
 block discarded – undo
849 1048
 				}
850 1049
 
851 1050
 				$this->all_flights[$id]['lastupdate'] = time();
852
-				if ($this->all_flights[$id]['putinarchive']) $send = true;
1051
+				if ($this->all_flights[$id]['putinarchive']) {
1052
+					$send = true;
1053
+				}
853 1054
 				//if ($globalDebug) echo "Distance : ".Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
854
-				if ($globalDebug) echo $result."\n";
855
-			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1055
+				if ($globalDebug) {
1056
+					echo $result."\n";
1057
+				}
1058
+			} elseif (isset($this->all_flights[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
1059
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
1060
+			}
856 1061
 			//$this->del();
857 1062
 			
858 1063
 			
859 1064
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
860
-			    if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1065
+			    if ($globalDebug) {
1066
+			    	echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1067
+			    }
861 1068
 			    $SpotterLive = new SpotterLive($this->db);
862 1069
 			    $SpotterLive->deleteLiveSpotterDataNotUpdated();
863 1070
 			    $SpotterLive->db = null;
864 1071
 			    //SpotterLive->deleteLiveSpotterData();
865
-			    if ($globalDebug) echo " Done\n";
1072
+			    if ($globalDebug) {
1073
+			    	echo " Done\n";
1074
+			    }
866 1075
 			    $this->last_delete_hourly = time();
867 1076
 			}
868 1077
 			
@@ -870,7 +1079,9 @@  discard block
 block discarded – undo
870 1079
 		    //$ignoreImport = false;
871 1080
 		}
872 1081
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
873
-		if ($send) return $this->all_flights[$id];
1082
+		if ($send) {
1083
+			return $this->all_flights[$id];
1084
+		}
874 1085
 	    }
875 1086
 	}
876 1087
     }
Please login to merge, or discard this patch.
require/class.Translation.php 2 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -58,6 +58,10 @@  discard block
 block discarded – undo
58 58
                 } else return $ident;
59 59
         }
60 60
 
61
+       /**
62
+        * @param string $correct_ident
63
+        * @param string $source
64
+        */
61 65
        public function addOperator($ident,$correct_ident,$source) {
62 66
                 $query = "INSERT INTO translation (Operator,Operator_correct,Source) VALUES (:ident,:correct_ident,:source)";
63 67
                 $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
@@ -69,6 +73,10 @@  discard block
 block discarded – undo
69 73
                 }
70 74
         }
71 75
 
76
+       /**
77
+        * @param string $correct_ident
78
+        * @param string $source
79
+        */
72 80
        public function updateOperator($ident,$correct_ident,$source) {
73 81
                 $query = "UPDATE translation SET Operator_correct = :correct_ident,Source = :source WHERE Operator = :ident";
74 82
                 $query_values = array(':ident' => $ident,':correct_ident' => $correct_ident, ':source' => $source);
Please login to merge, or discard this patch.
Braces   +20 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,16 +28,25 @@  discard block
 block discarded – undo
28 28
             } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) {
29 29
         	//$airline_icao = substr($ident, 0, 3);
30 30
         	return $ident;
31
-            } else return $ident;
32
-        } else return $ident;
31
+            } else {
32
+            	return $ident;
33
+            }
34
+        } else {
35
+        	return $ident;
36
+        }
33 37
         if ($airline_icao == 'AF') {
34
-            if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident;
35
-            else $icao = 'AFR'.ltrim(substr($ident,2),'0');
38
+            if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
39
+            	$icao = $ident;
40
+            } else {
41
+            	$icao = 'AFR'.ltrim(substr($ident,2),'0');
42
+            }
36 43
         } else {
37 44
             $identicao = $Spotter->getAllAirlineInfo($airline_icao);
38 45
             if (isset($identicao[0])) {
39 46
                 $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0');
40
-            } else $icao = $ident;
47
+            } else {
48
+            	$icao = $ident;
49
+            }
41 50
         }
42 51
         return $icao;
43 52
     }
@@ -55,7 +64,9 @@  discard block
 block discarded – undo
55 64
                 $row = $sth->fetch(PDO::FETCH_ASSOC);
56 65
                 if (count($row) > 0) {
57 66
                         return $row['operator_correct'];
58
-                } else return $ident;
67
+                } else {
68
+                	return $ident;
69
+                }
59 70
         }
60 71
 
61 72
        public function addOperator($ident,$correct_ident,$source) {
@@ -84,7 +95,9 @@  discard block
 block discarded – undo
84 95
     	    global $globalTranslationSources, $globalTranslationFetch;
85 96
     	    //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder');
86 97
     	    $globalTranslationSources = array();
87
-    	    if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE;
98
+    	    if (!isset($globalTranslationFetch)) {
99
+    	    	$globalTranslationFetch = TRUE;
100
+    	    }
88 101
     	    //echo "Check Translation for ".$ident."...";
89 102
     	    $correct = $this->getOperator($ident);
90 103
     	    if ($correct != '' && $correct != $ident) {
Please login to merge, or discard this patch.
require/libs/geoPHP/geoPHP.inc 2 patches
Doc Comments   +7 added lines patch added patch discarded remove patch
@@ -118,6 +118,9 @@  discard block
 block discarded – undo
118 118
     );
119 119
   }
120 120
 
121
+  /**
122
+   * @param boolean $force
123
+   */
121 124
   static function geosInstalled($force = NULL) {
122 125
     static $geos_installed = NULL;
123 126
     if ($force !== NULL) $geos_installed = $force;
@@ -222,6 +225,10 @@  discard block
 block discarded – undo
222 225
 
223 226
   // Detect a format given a value. This function is meant to be SPEEDY.
224 227
   // It could make a mistake in XML detection if you are mixing or using namespaces in weird ways (ie, KML inside an RSS feed)
228
+
229
+  /**
230
+   * @return string
231
+   */
225 232
   static function detectFormat(&$input) {
226 233
     $mem = fopen('php://memory', 'r+');
227 234
     fwrite($mem, $input, 11); // Write 11 bytes - we can detect the vast majority of formats in the first 11 bytes
Please login to merge, or discard this patch.
Braces   +42 added lines, -21 removed lines patch added patch discarded remove patch
@@ -52,7 +52,9 @@  discard block
 block discarded – undo
52 52
     if (!$type) {
53 53
       // If the user is trying to load a Geometry from a Geometry... Just pass it back
54 54
       if (is_object($data)) {
55
-        if ($data instanceOf Geometry) return $data;
55
+        if ($data instanceOf Geometry) {
56
+        	return $data;
57
+        }
56 58
       }
57 59
       
58 60
       $detected = geoPHP::detectFormat($data);
@@ -120,7 +122,9 @@  discard block
 block discarded – undo
120 122
 
121 123
   static function geosInstalled($force = NULL) {
122 124
     static $geos_installed = NULL;
123
-    if ($force !== NULL) $geos_installed = $force;
125
+    if ($force !== NULL) {
126
+    	$geos_installed = $force;
127
+    }
124 128
     if ($geos_installed !== NULL) {
125 129
       return $geos_installed;
126 130
     }
@@ -148,8 +152,12 @@  discard block
 block discarded – undo
148 152
   static function geometryReduce($geometry) {
149 153
     // If it's an array of one, then just parse the one
150 154
     if (is_array($geometry)) {
151
-      if (empty($geometry)) return FALSE;
152
-      if (count($geometry) == 1) return geoPHP::geometryReduce(array_shift($geometry));
155
+      if (empty($geometry)) {
156
+      	return FALSE;
157
+      }
158
+      if (count($geometry) == 1) {
159
+      	return geoPHP::geometryReduce(array_shift($geometry));
160
+      }
153 161
     }
154 162
 
155 163
     // If the geometry cannot even theoretically be reduced more, then pass it back
@@ -168,8 +176,7 @@  discard block
 block discarded – undo
168 176
         $components = $geometry->getComponents();
169 177
         if (count($components) == 1) {
170 178
           return $components[0];
171
-        }
172
-        else {
179
+        } else {
173 180
           return $geometry;
174 181
         }
175 182
       }
@@ -192,8 +199,7 @@  discard block
 block discarded – undo
192 199
             $geometries[] = $component;
193 200
             $geom_types[] = $component->geometryType();
194 201
           }
195
-        }
196
-        else {
202
+        } else {
197 203
           $geometries[] = $item;
198 204
           $geom_types[] = $item->geometryType();
199 205
         }
@@ -209,13 +215,11 @@  discard block
 block discarded – undo
209 215
     if (count($geom_types) == 1) {
210 216
       if (count($geometries) == 1) {
211 217
         return $geometries[0];
212
-      }
213
-      else {
218
+      } else {
214 219
         $class = 'Multi'.$geom_types[0];
215 220
         return new $class($geometries);
216 221
       }
217
-    }
218
-    else {
222
+    } else {
219 223
       return new GeometryCollection($geometries);
220 224
     }
221 225
   }
@@ -230,7 +234,9 @@  discard block
 block discarded – undo
230 234
     $bytes = unpack("c*", fread($mem, 11));
231 235
 
232 236
     // If bytes is empty, then we were passed empty input
233
-    if (empty($bytes)) return FALSE;
237
+    if (empty($bytes)) {
238
+    	return FALSE;
239
+    }
234 240
 
235 241
     // First char is a tab, space or carriage-return. trim it and try again
236 242
     if ($bytes[1] == 9 || $bytes[1] == 10 || $bytes[1] == 32) {
@@ -240,8 +246,11 @@  discard block
 block discarded – undo
240 246
     // Detect WKB or EWKB -- first byte is 1 (little endian indicator)
241 247
     if ($bytes[1] == 1) {
242 248
       // If SRID byte is TRUE (1), it's EWKB
243
-      if ($bytes[5]) return 'ewkb';
244
-      else return 'wkb';
249
+      if ($bytes[5]) {
250
+      	return 'ewkb';
251
+      } else {
252
+      	return 'wkb';
253
+      }
245 254
     }
246 255
 
247 256
     // Detect HEX encoded WKB or EWKB (PostGIS format) -- first byte is 48, second byte is 49 (hex '01' => first-byte = 1)
@@ -274,12 +283,24 @@  discard block
 block discarded – undo
274 283
     if ($bytes[1] == 60) {
275 284
       // grab the first 256 characters
276 285
       $string = substr($input, 0, 256);
277
-      if (strpos($string, '<kml') !== FALSE)        return 'kml';
278
-      if (strpos($string, '<coordinate') !== FALSE) return 'kml';
279
-      if (strpos($string, '<gpx') !== FALSE)        return 'gpx';
280
-      if (strpos($string, '<georss') !== FALSE)     return 'georss';
281
-      if (strpos($string, '<rss') !== FALSE)        return 'georss';
282
-      if (strpos($string, '<feed') !== FALSE)       return 'georss';
286
+      if (strpos($string, '<kml') !== FALSE) {
287
+      	return 'kml';
288
+      }
289
+      if (strpos($string, '<coordinate') !== FALSE) {
290
+      	return 'kml';
291
+      }
292
+      if (strpos($string, '<gpx') !== FALSE) {
293
+      	return 'gpx';
294
+      }
295
+      if (strpos($string, '<georss') !== FALSE) {
296
+      	return 'georss';
297
+      }
298
+      if (strpos($string, '<rss') !== FALSE) {
299
+      	return 'georss';
300
+      }
301
+      if (strpos($string, '<feed') !== FALSE) {
302
+      	return 'georss';
303
+      }
283 304
     }
284 305
 
285 306
     // We need an 8 byte string for geohash and unpacked WKB / WKT
Please login to merge, or discard this patch.
require/libs/geoPHP/lib/adapters/GeoJSON.class.php 2 patches
Doc Comments   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -113,7 +113,6 @@  discard block
 block discarded – undo
113 113
    * Serializes an object into a geojson string
114 114
    *
115 115
    *
116
-   * @param Geometry $obj The object to serialize
117 116
    *
118 117
    * @return string The GeoJSON string
119 118
    */
@@ -126,6 +125,9 @@  discard block
 block discarded – undo
126 125
     }
127 126
   }
128 127
 
128
+  /**
129
+   * @param Geometry $geometry
130
+   */
129 131
   public function getArray($geometry) {
130 132
     if ($geometry->getGeomType() == 'GeometryCollection') {
131 133
       $component_array = array();
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -120,8 +120,7 @@  discard block
 block discarded – undo
120 120
   public function write(Geometry $geometry, $return_array = FALSE) {
121 121
     if ($return_array) {
122 122
       return $this->getArray($geometry);
123
-    }
124
-    else {
123
+    } else {
125 124
       return json_encode($this->getArray($geometry));
126 125
     }
127 126
   }
@@ -139,11 +138,12 @@  discard block
 block discarded – undo
139 138
         'type'=> 'GeometryCollection',
140 139
         'geometries'=> $component_array,
141 140
       );
142
-    }
143
-    else return array(
141
+    } else {
142
+    	return array(
144 143
       'type'=> $geometry->getGeomType(),
145 144
       'coordinates'=> $geometry->asArray(),
146 145
     );
146
+    }
147 147
   }
148 148
 }
149 149
 
Please login to merge, or discard this patch.