Completed
Push — master ( 491897...dd0fde )
by Yannick
29:49
created
country-statistics-time.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 require_once('require/class.Spotter.php');
4 4
 require_once('require/class.Language.php');
5 5
 if (!isset($_GET['country'])) {
6
-        header('Location: '.$globalURL.'/country');
7
-        die();
6
+		header('Location: '.$globalURL.'/country');
7
+		die();
8 8
 }
9 9
 $Spotter = new Spotter();
10 10
 $country = ucwords(str_replace("-", " ", filter_input(INPUT_GET,'country',FILTER_SANITIZE_STRING)));
Please login to merge, or discard this patch.
js/map.2d.js.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 setInterval(function(){update_locationsLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
386 386
 
387 387
 <?php
388
-    // Add support for custom json via $globalMapJson
389
-    if (isset($globalMapJson) && is_array($globalMapJson)) {
388
+	// Add support for custom json via $globalMapJson
389
+	if (isset($globalMapJson) && is_array($globalMapJson)) {
390 390
 	foreach ($globalMapJson as $json) {
391
-	    if (isset($json['url'])) {
391
+		if (isset($json['url'])) {
392 392
 ?>
393 393
 update_genLayer('<?php print $json['url']; ?>');
394 394
 <?php
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 setInterval(function(){update_genLayer('<?php print $json['url']; ?>')}, <?php print $json['refresh']; ?>);
398 398
 <?php
399 399
 		}
400
-	    }
400
+		}
401
+	}
401 402
 	}
402
-    }
403 403
 
404 404
 ?>
405 405
 //adds the bootstrap tooltip to the map icons
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Indentation   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -7,16 +7,16 @@  discard block
 block discarded – undo
7 7
 require_once(dirname(__FILE__).'/class.Source.php');
8 8
 
9 9
 class TrackerImport {
10
-    private $all_tracked = array();
11
-    private $last_delete_hourly = 0;
12
-    private $last_delete = 0;
13
-    private $stats = array();
14
-    private $tmd = 0;
15
-    private $source_location = array();
16
-    public $db = null;
17
-    public $nb = 0;
10
+	private $all_tracked = array();
11
+	private $last_delete_hourly = 0;
12
+	private $last_delete = 0;
13
+	private $stats = array();
14
+	private $tmd = 0;
15
+	private $source_location = array();
16
+	public $db = null;
17
+	public $nb = 0;
18 18
 
19
-    public function __construct($dbc = null) {
19
+	public function __construct($dbc = null) {
20 20
 	global $globalBeta;
21 21
 	$Connection = new Connection($dbc);
22 22
 	$this->db = $Connection->db();
@@ -38,50 +38,50 @@  discard block
 block discarded – undo
38 38
 	    }
39 39
 	}
40 40
 	*/
41
-    }
41
+	}
42 42
 
43
-    public function checkAll() {
43
+	public function checkAll() {
44 44
 	global $globalDebug;
45 45
 	if ($globalDebug) echo "Update last seen tracked data...\n";
46 46
 	foreach ($this->all_tracked as $key => $flight) {
47
-	    if (isset($this->all_tracked[$key]['id'])) {
47
+		if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49
-    		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
-            }
49
+			$Tracker = new Tracker($this->db);
50
+			$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
51
+			}
52
+	}
52 53
 	}
53
-    }
54 54
 
55
-    public function del() {
55
+	public function del() {
56 56
 	global $globalDebug;
57 57
 	// Delete old infos
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60
-    	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
62
-            	    if (isset($this->all_tracked[$key]['id'])) {
63
-            		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
60
+			if (isset($flight['lastupdate'])) {
61
+			if ($flight['lastupdate'] < (time()-3000)) {
62
+					if (isset($this->all_tracked[$key]['id'])) {
63
+					if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
65 65
 			$TrackerLive = new TrackerLive();
66 66
             		$TrackerLive->deleteLiveTrackerDataById($this->all_tracked[$key]['id']);
67 67
 			$TrackerLive->db = null;
68 68
 			*/
69
-            		//$real_arrival = $this->arrival($key);
70
-            		$Tracker = new Tracker($this->db);
71
-            		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
69
+					//$real_arrival = $this->arrival($key);
70
+					$Tracker = new Tracker($this->db);
71
+					if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72 72
 				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
76 76
 //			$Tracker->db = null;
77
-            	    }
78
-            	    unset($this->all_tracked[$key]);
79
-    	        }
80
-	    }
81
-        }
82
-    }
77
+					}
78
+					unset($this->all_tracked[$key]);
79
+				}
80
+		}
81
+		}
82
+	}
83 83
 
84
-    public function add($line) {
84
+	public function add($line) {
85 85
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChangeTracker, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked;
86 86
 	if (!isset($globalCoordMinChangeTracker) || $globalCoordMinChangeTracker == '') $globalCoordMinChangeTracker = '0.015';
87 87
 	date_default_timezone_set('UTC');
@@ -90,47 +90,47 @@  discard block
 block discarded – undo
90 90
 	
91 91
 	// SBS format is CSV format
92 92
 	if(is_array($line) && isset($line['ident'])) {
93
-	    //print_r($line);
94
-  	    if (isset($line['ident'])) {
93
+		//print_r($line);
94
+  		if (isset($line['ident'])) {
95 95
 
96 96
 		
97 97
 		// Increment message number
98 98
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
99
-		    $current_date = date('Y-m-d');
100
-		    if (isset($line['source_name'])) $source = $line['source_name'];
101
-		    else $source = '';
102
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
104
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
105
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
99
+			$current_date = date('Y-m-d');
100
+			if (isset($line['source_name'])) $source = $line['source_name'];
101
+			else $source = '';
102
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
103
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
104
+				$this->stats[$current_date][$source]['msg']['date'] = time();
105
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
106
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
107 107
 		}
108 108
 		
109 109
 		
110 110
 		$Common = new Common();
111
-	        if (!isset($line['id'])) $id = trim($line['ident']);
112
-	        else $id = trim($line['id']);
111
+			if (!isset($line['id'])) $id = trim($line['ident']);
112
+			else $id = trim($line['id']);
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115
-		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
-		    if (!isset($line['id'])) {
115
+			$this->all_tracked[$id] = array();
116
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
119
+			if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121 121
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
122
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
123
+			if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126 126
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
127
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
127
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128 128
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
129
-		    } else {
129
+			} else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133
-		    }
133
+			}
134 134
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
-		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
150
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
151
+			if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153
-            		$Tracker = new Tracker($this->db);
154
-            		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
153
+					$Tracker = new Tracker($this->db);
154
+					$fromsource = NULL;
155
+					$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158 158
 			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
159
-		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
159
+			}
160
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
-		    if ($distance > 100 && $distance < 10000) {
167
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
168
+			if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171 171
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173
-		    }
173
+			}
174 174
 		}
175 175
 
176
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
-	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
176
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
178
+				else unset($timediff);
179
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) {
181
+				if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -192,30 +192,30 @@  discard block
 block discarded – undo
192 192
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195
-			    }
195
+				}
196 196
 			}
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200 200
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
-				    $dataFound = true;
203
-				    $this->all_tracked[$id]['time_last_coord'] = time();
201
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202
+					$dataFound = true;
203
+					$this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205 205
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
208
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210 210
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
-				    $dataFound = true;
213
-				    $this->all_tracked[$id]['time_last_coord'] = time();
211
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212
+					$dataFound = true;
213
+					$this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215 215
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218
-		    } else if ($globalDebug && $timediff > 20) {
218
+			} else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
@@ -223,131 +223,131 @@  discard block
 block discarded – undo
223 223
 				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226
-		    }
226
+			}
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
229
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
-		    //$dataFound = true;
239
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
240
+			//$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
-		    //$dataFound = true;
243
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
244
+			//$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248
-		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
248
+			//if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249 249
 			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250 250
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251 251
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
253
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
-		    //$dataFound = true;
261
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
264
+			//$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
266
+  			$heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
272 272
 
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274
-		    $this->all_tracked[$id]['lastupdate'] = time();
275
-		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
274
+			$this->all_tracked[$id]['lastupdate'] = time();
275
+			if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282
-				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
282
+					$recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285
-				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
285
+					$recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287 287
 				} else $recent_ident = '';
288 288
 				$TrackerLive->db=null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292
-			    } else {
292
+				} else {
293 293
 				$recent_ident = '';
294 294
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
295
-			    }
296
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
298
-			    {
295
+				}
296
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
+				if($recent_ident == "")
298
+				{
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301
-				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
-				    $timeelapsed = microtime(true);
304
-				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
-				    $Tracker->db = null;
307
-				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
301
+					$highlight = '';
302
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303
+					$timeelapsed = microtime(true);
304
+					$Tracker = new Tracker($this->db);
305
+					$result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
306
+					$Tracker->db = null;
307
+					if ($globalDebug && isset($result)) echo $result."\n";
308
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
309 309
 				    
310 310
 				    
311
-				    // Add source stat in DB
312
-				    $Stats = new Stats($this->db);
313
-				    if (!empty($this->stats)) {
311
+					// Add source stat in DB
312
+					$Stats = new Stats($this->db);
313
+					if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
317
-					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
-				    		if (isset($sourced['msg'])) {
321
-				    		    if (time() - $sourced['msg']['date'] > 10) {
322
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
-			    			        unset($this->stats[$date][$source]['msg']);
325
-			    			    }
326
-			    			}
327
-			    		    }
328
-			    		    if ($date != date('Y-m-d')) {
329
-			    			unset($this->stats[$date]);
330
-			    		    }
331
-				    	}
332
-				    	if ($globalDebug) echo 'Done'."\n";
315
+						foreach($this->stats as $date => $data) {
316
+						foreach($data as $source => $sourced) {
317
+							//print_r($sourced);
318
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
320
+							if (isset($sourced['msg'])) {
321
+								if (time() - $sourced['msg']['date'] > 10) {
322
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
+									echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
324
+									unset($this->stats[$date][$source]['msg']);
325
+								}
326
+							}
327
+							}
328
+							if ($date != date('Y-m-d')) {
329
+							unset($this->stats[$date]);
330
+							}
331
+						}
332
+						if ($globalDebug) echo 'Done'."\n";
333 333
 
334
-				    }
335
-				    $Stats->db = null;
334
+					}
335
+					$Stats->db = null;
336 336
 				    
337
-				    $this->del();
337
+					$this->del();
338 338
 				//$ignoreImport = false;
339 339
 				$this->all_tracked[$id]['addedTracker'] = 1;
340 340
 				//print_r($this->all_tracked[$id]);
341 341
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
342
-				    if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
-				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344
-				    $TrackerLive = new TrackerLive($this->db);
345
-				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
347
-				    if ($globalDebug) echo " Done\n";
348
-				    $this->last_delete = time();
342
+					if ($globalDebug) echo "---- Deleting Live Tracker data older than 9 hours...";
343
+					//TrackerLive->deleteLiveTrackerDataNotUpdated();
344
+					$TrackerLive = new TrackerLive($this->db);
345
+					$TrackerLive->deleteLiveTrackerData();
346
+					$TrackerLive->db=null;
347
+					if ($globalDebug) echo " Done\n";
348
+					$this->last_delete = time();
349 349
 				}
350
-			    } else {
350
+				} else {
351 351
 				$this->all_tracked[$id]['id'] = $recent_ident;
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
@@ -356,16 +356,16 @@  discard block
 block discarded – undo
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
359
-			    }
359
+				}
360 360
 			}
361
-		    }
362
-		    //adds the spotter LIVE data
363
-		    if ($globalDebug) {
361
+			}
362
+			//adds the spotter LIVE data
363
+			if ($globalDebug) {
364 364
 			echo 'DATA : ident : '.$this->all_tracked[$id]['ident'].' - type : '.$this->all_tracked[$id]['type'].' - Latitude : '.$this->all_tracked[$id]['latitude'].' - Longitude : '.$this->all_tracked[$id]['longitude'].' - Altitude : '.$this->all_tracked[$id]['altitude'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
365
-		    }
366
-		    $ignoreImport = false;
365
+			}
366
+			$ignoreImport = false;
367 367
 
368
-		    if (!$ignoreImport) {
368
+			if (!$ignoreImport) {
369 369
 			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405 405
 						for ($i=0;$i<=15;$i++) {
406
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
406
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
409 409
 					} else {
@@ -416,11 +416,11 @@  discard block
 block discarded – undo
416 416
 					//var_dump($this->stats);
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419
-						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
419
+							end($this->stats[$current_date][$source]['hist']);
420
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
421 421
 						} else $mini = 0;
422 422
 						for ($i=$mini;$i<=$distance;$i+=10) {
423
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
423
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
426 426
 					} else {
@@ -436,22 +436,22 @@  discard block
 block discarded – undo
436 436
 			
437 437
 			
438 438
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
439
-			    if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
-			    $TrackerLive = new TrackerLive($this->db);
441
-			    $TrackerLive->deleteLiveTrackerDataNotUpdated();
442
-			    $TrackerLive->db = null;
443
-			    //TrackerLive->deleteLiveTrackerData();
444
-			    if ($globalDebug) echo " Done\n";
445
-			    $this->last_delete_hourly = time();
439
+				if ($globalDebug) echo "---- Deleting Live Tracker data Not updated since 2 hour...";
440
+				$TrackerLive = new TrackerLive($this->db);
441
+				$TrackerLive->deleteLiveTrackerDataNotUpdated();
442
+				$TrackerLive->db = null;
443
+				//TrackerLive->deleteLiveTrackerData();
444
+				if ($globalDebug) echo " Done\n";
445
+				$this->last_delete_hourly = time();
446 446
 			}
447 447
 			
448
-		    }
449
-		    //$ignoreImport = false;
448
+			}
449
+			//$ignoreImport = false;
450 450
 		}
451 451
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
452 452
 		if ($send) return $this->all_tracked[$id];
453
-	    }
453
+		}
454
+	}
454 455
 	}
455
-    }
456 456
 }
457 457
 ?>
Please login to merge, or discard this patch.
require/class.APRS.php 1 patch
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -3,10 +3,10 @@  discard block
 block discarded – undo
3 3
 require_once(dirname(__FILE__).'/class.Common.php');
4 4
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
5 5
 class aprs {
6
-    private $socket;
7
-    private $connected = false;
6
+	private $socket;
7
+	private $connected = false;
8 8
 
9
-    protected $symbols = array('/!' => 'Police',
9
+	protected $symbols = array('/!' => 'Police',
10 10
 	'/#' => 'DIGI',
11 11
 	'/$' => 'Phone',
12 12
 	'/%' => 'DX Cluster',
@@ -166,13 +166,13 @@  discard block
 block discarded – undo
166 166
 	'\~' => 'TNC Stream SW');
167 167
 	
168 168
 
169
-    private function urshift($n, $s) {
169
+	private function urshift($n, $s) {
170 170
 	return ($n >= 0) ? ($n >> $s) :
171
-	    (($n & 0x7fffffff) >> $s) | 
171
+		(($n & 0x7fffffff) >> $s) | 
172 172
 		(0x40000000 >> ($s - 1));
173
-    }
173
+	}
174 174
 
175
-    public function parse($input) {
175
+	public function parse($input) {
176 176
 	global $globalDebug;
177 177
 	$debug = false;
178 178
 	$result = array();
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	
185 185
 	/* Check that end was found and body has at least one byte. */
186 186
 	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) {
187
-	    if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
188
-	    return false;
187
+		if ($globalDebug) echo '!!! APRS invalid : '.$input."\n";
188
+		return false;
189 189
 	}
190 190
 	
191 191
 	if ($debug) echo 'input : '.$input."\n";
@@ -199,34 +199,34 @@  discard block
 block discarded – undo
199 199
 	/* Parse source, target and path. */
200 200
 	//FLRDF0A52>APRS,qAS,LSTB
201 201
 	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) {
202
-	    $ident = $matches[1];
203
-	    $all_elements = $matches[2];
204
-	    if ($ident == 'AIRCRAFT') {
202
+		$ident = $matches[1];
203
+		$all_elements = $matches[2];
204
+		if ($ident == 'AIRCRAFT') {
205 205
 		$result['format_source'] = 'famaprs';
206 206
 		$result['source_type'] = 'modes';
207
-	    } elseif ($ident == 'MARINE') {
207
+		} elseif ($ident == 'MARINE') {
208 208
 		$result['format_source'] = 'famaprs';
209 209
 		$result['source_type'] = 'ais';
210
-	    } else {
210
+		} else {
211 211
 		if ($debug) echo 'ident : '.$ident."\n";
212 212
 		$result['ident'] = $ident;
213
-	    }
213
+		}
214 214
 	} else {
215
-	    if ($debug) 'No ident'."\n";
216
-	    return false;
215
+		if ($debug) 'No ident'."\n";
216
+		return false;
217 217
 	}
218 218
 	$elements = explode(',',$all_elements);
219 219
 	$source = end($elements);
220 220
 	$result['source'] = $source;
221 221
 	foreach ($elements as $element) {
222
-	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
223
-	        //echo "ok";
224
-	        //if ($element == 'TCPIP*') return false;
225
-	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
222
+		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) {
223
+			//echo "ok";
224
+			//if ($element == 'TCPIP*') return false;
225
+		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) {
226 226
 		if ($debug) echo 'element : '.$element."\n";
227 227
 		return false;
228
-	    }
229
-	    /*
228
+		}
229
+		/*
230 230
 	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) {
231 231
 		//echo "ok";
232 232
 	    } else {
@@ -253,48 +253,48 @@  discard block
 block discarded – undo
253 253
 	$body_parse = substr($body,1);
254 254
 	//echo 'Body : '.$body."\n";
255 255
 	if (preg_match('/^;(.){9}\*/',$body,$matches)) {
256
-	    $body_parse = substr($body_parse,10);
257
-	    $find = true;
258
-	    //echo $body_parse."\n";
256
+		$body_parse = substr($body_parse,10);
257
+		$find = true;
258
+		//echo $body_parse."\n";
259 259
 	}
260 260
 	if (preg_match('/^`(.*)\//',$body,$matches)) {
261
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
262
-	    $find = true;
263
-	    //echo $body_parse."\n";
261
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
262
+		$find = true;
263
+		//echo $body_parse."\n";
264 264
 	}
265 265
 	if (preg_match("/^'(.*)\//",$body,$matches)) {
266
-	    $body_parse = substr($body_parse,strlen($matches[1])-1);
267
-	    $find = true;
268
-	    //echo $body_parse."\n";
266
+		$body_parse = substr($body_parse,strlen($matches[1])-1);
267
+		$find = true;
268
+		//echo $body_parse."\n";
269 269
 	}
270 270
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) {
271
-	    $find = true;
272
-	    //print_r($matches);
273
-	    $timestamp = $matches[0];
274
-	    if ($matches[4] == 'h') {
271
+		$find = true;
272
+		//print_r($matches);
273
+		$timestamp = $matches[0];
274
+		if ($matches[4] == 'h') {
275 275
 		$timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]);
276 276
 		//echo 'timestamp : '.$timestamp.' - now : '.time()."\n";
277 277
 		/*
278 278
 		if (time() + 3900 < $timestamp) $timestamp -= 86400;
279 279
 		elseif (time() - 82500 > $timestamp) $timestamp += 86400;
280 280
 		*/
281
-	    } elseif ($matches[4] == 'z' || $matches[4] == '/') {
281
+		} elseif ($matches[4] == 'z' || $matches[4] == '/') {
282 282
 		// This work or not ?
283 283
 		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]);
284
-	    }
285
-	    $body_parse = substr($body_parse,7);
286
-	    $result['timestamp'] = $timestamp;
287
-	    //echo date('Ymd H:i:s',$timestamp);
284
+		}
285
+		$body_parse = substr($body_parse,7);
286
+		$result['timestamp'] = $timestamp;
287
+		//echo date('Ymd H:i:s',$timestamp);
288 288
 	}
289 289
 	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) {
290
-	    $find = true;
291
-	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
-	    $body_parse = substr($body_parse,8);
293
-	    $result['timestamp'] = $timestamp;
294
-	    //echo date('Ymd H:i:s',$timestamp);
290
+		$find = true;
291
+		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]);
292
+		$body_parse = substr($body_parse,8);
293
+		$result['timestamp'] = $timestamp;
294
+		//echo date('Ymd H:i:s',$timestamp);
295 295
 	}
296 296
 	//if (strlen($body_parse) > 19) {
297
-	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
297
+		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) {
298 298
 		$find = true;
299 299
 		// 4658.70N/00707.78Ez
300 300
 		//print_r(str_split($body_parse));
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		$lon = intval($lon_deg);
314 314
 		if ($lat > 89 || $lon > 179) return false;
315 315
 	    
316
-	    /*
316
+		/*
317 317
 	    $tmp_5b = str_replace('.','',$lat_min);
318 318
 	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) {
319 319
 	        print_r($matches);
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 		$result['longitude'] = $longitude;
328 328
 		$body_parse = substr($body_parse,18);
329 329
 		$body_parse_len = strlen($body_parse);
330
-	    }
331
-	    $body_parse_len = strlen($body_parse);
332
-	    if ($body_parse_len > 0) {
330
+		}
331
+		$body_parse_len = strlen($body_parse);
332
+		if ($body_parse_len > 0) {
333 333
 		/*
334 334
 		if (!isset($result['timestamp']) && !isset($result['latitude'])) {
335 335
 			$body_split = str_split($body);
@@ -363,95 +363,95 @@  discard block
 block discarded – undo
363 363
 			if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code];
364 364
 			if ($symbol_code != '_') {
365 365
 			}
366
-		    //$body_parse = substr($body_parse,1);
367
-		    //$body_parse = trim($body_parse);
368
-		    //$body_parse_len = strlen($body_parse);
369
-		    if ($body_parse_len >= 7) {
366
+			//$body_parse = substr($body_parse,1);
367
+			//$body_parse = trim($body_parse);
368
+			//$body_parse_len = strlen($body_parse);
369
+			if ($body_parse_len >= 7) {
370 370
 			
371
-		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
-		    	    $course = substr($body_parse,0,3);
373
-		    	    $tmp_s = intval($course);
374
-		    	    if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
-		    	    $speed = substr($body_parse,4,3);
376
-		    	    if ($speed != '...') {
377
-		    		//$result['speed'] = round($speed*1.852);
378
-		    		$result['speed'] = intval($speed);
379
-		    	    }
380
-		    	    $body_parse = substr($body_parse,7);
381
-		        }
382
-		        // Check PHGR, PHG, RNG
383
-		    } 
384
-		    /*
371
+				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) {
372
+					$course = substr($body_parse,0,3);
373
+					$tmp_s = intval($course);
374
+					if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course);
375
+					$speed = substr($body_parse,4,3);
376
+					if ($speed != '...') {
377
+					//$result['speed'] = round($speed*1.852);
378
+					$result['speed'] = intval($speed);
379
+					}
380
+					$body_parse = substr($body_parse,7);
381
+				}
382
+				// Check PHGR, PHG, RNG
383
+			} 
384
+			/*
385 385
 		    else if ($body_parse_len > 0) {
386 386
 			$rest = $body_parse;
387 387
 		    }
388 388
 		    */
389
-		    if (strlen($body_parse) > 0) {
390
-		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
391
-		            $altitude = intval($matches[1]);
392
-		            //$result['altitude'] = round($altitude*0.3048);
393
-		            $result['altitude'] = $altitude;
394
-		            //$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
-		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
396
-		        }
397
-		    }
389
+			if (strlen($body_parse) > 0) {
390
+				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) {
391
+					$altitude = intval($matches[1]);
392
+					//$result['altitude'] = round($altitude*0.3048);
393
+					$result['altitude'] = $altitude;
394
+					//$body_parse = trim(substr($body_parse,strlen($matches[0])));
395
+					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse));
396
+				}
397
+			}
398 398
 		    
399
-		    // Telemetry
400
-		    /*
399
+			// Telemetry
400
+			/*
401 401
 		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) {
402 402
 		        // Nothing yet...
403 403
 		    }
404 404
 		    */
405
-		    // DAO
405
+			// DAO
406 406
 		    
407
-		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
407
+			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) {
408 408
 			    
409
-			    $dao = $matches[1];
410
-			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
409
+				$dao = $matches[1];
410
+				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) {
411 411
 				$dao_split = str_split($dao);
412
-			        $lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
-			        $lon_off = (($dao_split[2])-48.0)*0.001/60.0;
412
+					$lat_off = (($dao_split[1])-48.0)*0.001/60.0;
413
+					$lon_off = (($dao_split[2])-48.0)*0.001/60.0;
414 414
 			    
415 415
 				if ($result['latitude'] < 0) $result['latitude'] -= $lat_off;
416 416
 				else $result['latitude'] += $lat_off;
417 417
 				if ($result['longitude'] < 0) $result['longitude'] -= $lon_off;
418 418
 				else $result['longitude'] += $lon_off;
419
-			    }
419
+				}
420 420
 			    
421
-		            $body_parse = substr($body_parse,6);
422
-		    }
421
+					$body_parse = substr($body_parse,6);
422
+			}
423 423
 		    
424
-		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
424
+			if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) {
425 425
 			$result['ident'] = str_replace('_',' ',$matches[1]);
426
-		    }
427
-		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
426
+			}
427
+			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) {
428 428
 			$result['squawk'] = $matches[1];
429
-		    }
430
-		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
429
+			}
430
+			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) {
431 431
 			$result['aircraft_icao'] = $matches[1];
432
-		    }
433
-		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
432
+			}
433
+			if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) {
434 434
 			$result['verticalrate'] = $matches[1];
435
-		    }
436
-		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
435
+			}
436
+			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) {
437 437
 			$result['typeid'] = $matches[1];
438
-		    }
439
-		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
438
+			}
439
+			if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) {
440 440
 			$result['statusid'] = $matches[1];
441
-		    }
442
-		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
441
+			}
442
+			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) {
443 443
 			$result['imo'] = $matches[1];
444
-		    }
445
-		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
444
+			}
445
+			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) {
446 446
 			$result['arrival_date'] = $matches[1];
447
-		    }
448
-		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
447
+			}
448
+			if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) {
449 449
 			$result['arrival_code'] = str_replace('_',' ',$matches[1]);
450
-		    }
451
-		    // OGN comment
450
+			}
451
+			// OGN comment
452 452
 		   // echo "Before OGN : ".$body_parse."\n";
453
-		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
-		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
453
+			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) {
454
+			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) {
455 455
 			$id = $matches[1];
456 456
 			//$mode = substr($id,0,2);
457 457
 			$address = substr($id,2);
@@ -481,42 +481,42 @@  discard block
 block discarded – undo
481 481
 			$stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0;
482 482
 			$result['stealth'] = $stealth;
483 483
 			$result['address'] = $address;
484
-		    }
484
+			}
485 485
 		    
486
-		    //Comment
487
-		    $result['comment'] = trim($body_parse);
486
+			//Comment
487
+			$result['comment'] = trim($body_parse);
488 488
 		//} else {
489
-		    // parse weather
490
-		    //$body_parse = substr($body_parse,1);
491
-		    //$body_parse_len = strlen($body_parse);
492
-		    //echo 'weather'."\n";
493
-		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
-			    $result['wind_dir'] = intval($matches[1]);
495
-			    $result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
-			    $result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
-			    $result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
-		    	    $body_parse = substr($body_parse,strlen($matches[0])+1);
499
-		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
489
+			// parse weather
490
+			//$body_parse = substr($body_parse,1);
491
+			//$body_parse_len = strlen($body_parse);
492
+			//echo 'weather'."\n";
493
+			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
494
+				$result['wind_dir'] = intval($matches[1]);
495
+				$result['wind_speed'] = round(intval($matches[2])*1.60934,1);
496
+				$result['wind_gust'] = round(intval($matches[3])*1.60934,1);
497
+				$result['temp'] = round(5/9*((intval($matches[4]))-32),1);
498
+					$body_parse = substr($body_parse,strlen($matches[0])+1);
499
+			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
500 500
 			$result['wind_dir'] = intval($matches[1]);
501 501
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
502 502
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
503 503
 			$result['temp'] = round(5/9*(($matches[4])-32),1);
504
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
505
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
504
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
505
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) {
506 506
 			$result['wind_dir'] = intval($matches[1]);
507 507
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
508 508
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
509
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
510
-		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
509
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
510
+			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) {
511 511
 			$result['wind_dir'] = intval($matches[1]);
512 512
 			$result['wind_speed'] = round($matches[2]*1.60934,1);
513 513
 			$result['wind_gust'] = round($matches[3]*1.60934,1);
514
-		        $body_parse = substr($body_parse,strlen($matches[0])+1);
515
-		    }
516
-		    //if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517
-		    //g012t088r000p000P000h38b10110
518
-		    //g011t086r000p000P000h29b10198
519
-		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
514
+				$body_parse = substr($body_parse,strlen($matches[0])+1);
515
+			}
516
+			//if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) {
517
+			//g012t088r000p000P000h38b10110
518
+			//g011t086r000p000P000h29b10198
519
+			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
520 520
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
521 521
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
522 522
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
525 525
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
526 526
 			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
527
-		        $body_parse = substr($body_parse,strlen($matches[0]));
528
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
527
+				$body_parse = substr($body_parse,strlen($matches[0]));
528
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3,4})r([0-9 \\.]{3})P([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2,3})b([0-9 \\.]{5})/',$body_parse,$matches)) {
529 529
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
530 530
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
531 531
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -533,8 +533,8 @@  discard block
 block discarded – undo
533 533
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
534 534
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
535 535
 			if ($matches[7] != '...') $result['pressure'] = round((intval($matches[7])/10),1);
536
-		        $body_parse = substr($body_parse,strlen($matches[0]));
537
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
536
+				$body_parse = substr($body_parse,strlen($matches[0]));
537
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
538 538
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
539 539
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
540 540
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
@@ -542,58 +542,58 @@  discard block
 block discarded – undo
542 542
 			if ($matches[5] != '...') $result['precipitation24h'] = round((intval($matches[5])/100)*25.1,1);
543 543
 			if ($matches[7] != '...') $result['humidity'] = intval($matches[7]);
544 544
 			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
545
-		        $body_parse = substr($body_parse,strlen($matches[0]));
546
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
545
+				$body_parse = substr($body_parse,strlen($matches[0]));
546
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})P([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
547 547
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
548 548
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
549 549
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
550 550
 			if ($matches[4] != '...') $result['precipitation24h'] = round((intval($matches[4])/100)*25.1,1);
551 551
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
552 552
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
553
-		        $body_parse = substr($body_parse,strlen($matches[0]));
554
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
553
+				$body_parse = substr($body_parse,strlen($matches[0]));
554
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})b([0-9 \\.]{5})h([0-9 \\.]{2})/',$body_parse,$matches)) {
555 555
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
556 556
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
557 557
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
558 558
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
559 559
 			if ($matches[6] != '...') $result['humidity'] = intval($matches[6]);
560 560
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
561
-		        $body_parse = substr($body_parse,strlen($matches[0]));
562
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
561
+				$body_parse = substr($body_parse,strlen($matches[0]));
562
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{3})p([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
563 563
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
564 564
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
565 565
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
566 566
 			if ($matches[4] != '...') $result['precipitation'] = round((intval($matches[4])/100)*25.1,1);
567 567
 			if ($matches[5] != '...') $result['humidity'] = intval($matches[5]);
568 568
 			if ($matches[6] != '...') $result['pressure'] = round((intval($matches[6])/10),1);
569
-		        $body_parse = substr($body_parse,strlen($matches[0]));
570
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
569
+				$body_parse = substr($body_parse,strlen($matches[0]));
570
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
571 571
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
572 572
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
573 573
 			if ($matches[2] != '...') $result['humidity'] = intval($matches[3]);
574 574
 			if ($matches[4] != '...') $result['pressure'] = round((intval($matches[4])/10),1);
575
-		        $body_parse = substr($body_parse,strlen($matches[0]));
576
-		    } elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
575
+				$body_parse = substr($body_parse,strlen($matches[0]));
576
+			} elseif (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9 \\.]{3})t([0-9 \\.]{3})r([0-9 \\.]{2,3})h([0-9 \\.]{2})b([0-9 \\.]{5})/',$body_parse,$matches)) {
577 577
 			if ($matches[1] != '...') $result['wind_gust'] = round($matches[1]*1.60934,1);
578 578
 			if ($matches[2] != '...') $result['temp'] = round(5/9*((intval($matches[2]))-32),1);
579 579
 			if ($matches[3] != '...') $result['rain'] = round((intval($matches[3])/100)*25.1,1);
580 580
 			if ($matches[4] != '...') $result['humidity'] = intval($matches[4]);
581 581
 			if ($matches[5] != '...') $result['pressure'] = round((intval($matches[5])/10),1);
582
-		        $body_parse = substr($body_parse,strlen($matches[0]));
583
-		    }
584
-		    $result['comment'] = trim($body_parse);
582
+				$body_parse = substr($body_parse,strlen($matches[0]));
583
+			}
584
+			$result['comment'] = trim($body_parse);
585 585
 		}
586 586
 		} else $result['comment'] = trim($body_parse);
587 587
 
588
-	    }
588
+		}
589 589
 	//}
590 590
 	if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4);
591 591
 	if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4);
592 592
 	if ($debug) print_r($result);
593 593
 	return $result;
594
-    }
594
+	}
595 595
     
596
-    public function connect() {
596
+	public function connect() {
597 597
 	global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport;
598 598
 	$aprs_connect = 0;
599 599
 	$aprs_keep = 120;
@@ -617,24 +617,24 @@  discard block
 block discarded – undo
617 617
 		socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1);
618 618
 		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) {
619 619
 			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) {
620
-			    echo 'APRS user verified !'."\n";
621
-			    $this->connected = true;
622
-			    return true;
623
-			    break;
620
+				echo 'APRS user verified !'."\n";
621
+				$this->connected = true;
622
+				return true;
623
+				break;
624 624
 			}
625 625
 			if (time()-$authstart > 5) {
626
-			    echo 'APRS timeout'."\n";
627
-			    break;
626
+				echo 'APRS timeout'."\n";
627
+				break;
628 628
 			}
629 629
 		}
630 630
 	}
631
-    }
631
+	}
632 632
 
633
-    public function disconnect() {
633
+	public function disconnect() {
634 634
 	socket_close($this->socket);
635
-    }
635
+	}
636 636
     
637
-    public function send($data) {
637
+	public function send($data) {
638 638
 	global $globalDebug;
639 639
 	if ($this->connected === false) $this->connect();
640 640
 	$send = socket_send( $this->socket  , $data , strlen($data),0);
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 		socket_close($this->socket);
644 644
 		$this->connect();
645 645
 	}
646
-    }
646
+	}
647 647
 }
648 648
 
649 649
 class APRSSpotter extends APRS {
Please login to merge, or discard this patch.
require/class.Language.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -68,10 +68,10 @@  discard block
 block discarded – undo
68 68
 			);
69 69
 
70 70
 	/**
71
-	* Returns list of available locales
72
-	*
73
-	* @return array
74
-	*/
71
+	 * Returns list of available locales
72
+	 *
73
+	 * @return array
74
+	 */
75 75
 	public function listLocaleDir()
76 76
 	{
77 77
 		$result = array('en_GB');
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	/**
99
-	* Returns list of available languages
100
-	*
101
-	* @return array
99
+	 * Returns list of available languages
100
+	 *
101
+	 * @return array
102 102
 	 */
103 103
 	public function getLanguages()
104 104
 	{
Please login to merge, or discard this patch.
require/class.Translation.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@
 block discarded – undo
15 15
 
16 16
 
17 17
 	/**
18
-	* Change IATA to ICAO value for ident
19
-	* 
20
-	* @param String $ident ident
21
-	* @return String the icao
22
-	*/
18
+	 * Change IATA to ICAO value for ident
19
+	 * 
20
+	 * @param String $ident ident
21
+	 * @return String the icao
22
+	 */
23 23
 	public function ident2icao($ident) {
24 24
 		$Spotter = new Spotter();
25 25
 		if (!is_numeric(substr($ident, 0, 3))) {
Please login to merge, or discard this patch.
search-php.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -90,40 +90,40 @@
 block discarded – undo
90 90
 if (!empty($spotter_array)) {
91 91
 	foreach($spotter_array as $spotter_item) {
92 92
 		array_push($flights, array(
93
-		    "id" => $spotter_item['spotter_id'], 
94
-		    "ident" => $spotter_item['ident'], 
95
-		    "registration" => $spotter_item['registration'], 
96
-		    "aircraft_icao" => $spotter_item['aircraft_type'], 
97
-		    "aircraft_name" => $spotter_item['aircraft_name'], 
98
-		    "aircraft_manufacturer" => $spotter_item['aircraft_manufacturer'],
99
-		    "airline_name" => $spotter_item['airline_name'], 
100
-		    "airline_icao" => $spotter_item['airline_icao'], 
101
-		    "airline_iata" => $spotter_item['airline_iata'], 
102
-		    "airline_country" => $spotter_item['airline_country'], 
103
-		    "airline_callsign" => $spotter_item['airline_callsign'], 
104
-		    "airline_type" => $spotter_item['airline_type'],
105
-		    "departure_airport_city" => $spotter_item['departure_airport_city'], 
106
-		    "departure_airport_country" => $spotter_item['departure_airport_country'], 
107
-		    "departure_airport_iata" => $spotter_item['departure_airport_iata'], 
108
-		    "departure_airport_icao" => $spotter_item['departure_airport_icao'], 
109
-		    "departure_airport_latitude" => $spotter_item['departure_airport_latitude'], 
110
-		    "departure_airport_longitude" => $spotter_item['departure_airport_longitude'], 
111
-		    "departure_airport_altitude" => $spotter_item['departure_airport_altitude'], 
112
-		    "arrival_airport_city" => $spotter_item['arrival_airport_city'], 
113
-		    "arrival_airport_country" => $spotter_item['arrival_airport_country'], 
114
-		    "arrival_airport_iata" => $spotter_item['arrival_airport_iata'], 
115
-		    "arrival_airport_icao" => $spotter_item['arrival_airport_icao'], 
116
-		    "arrival_airport_latitude" => $spotter_item['arrival_airport_latitude'], 
117
-		    "arrival_airport_longitude" => $spotter_item['arrival_airport_longitude'], 
118
-		    "arrival_airport_altitude" => $spotter_item['arrival_airport_altitude'],
119
-		    "latitude" => $spotter_item['latitude'], 
120
-		    "longitude" => $spotter_item['longitude'], 
121
-		    "altitude" => $spotter_item['altitude'], 
122
-		    "ground_speed" => $spotter_item['ground_speed'], 
123
-		    "heading" => $spotter_item['heading'], 
124
-		    "heading_name" => $spotter_item['heading_name'], 
125
-		    "waypoints" => $spotter_item['waypoints'],
126
-		    "date" => date("c", strtotime($spotter_item['date_iso_8601']))
93
+			"id" => $spotter_item['spotter_id'], 
94
+			"ident" => $spotter_item['ident'], 
95
+			"registration" => $spotter_item['registration'], 
96
+			"aircraft_icao" => $spotter_item['aircraft_type'], 
97
+			"aircraft_name" => $spotter_item['aircraft_name'], 
98
+			"aircraft_manufacturer" => $spotter_item['aircraft_manufacturer'],
99
+			"airline_name" => $spotter_item['airline_name'], 
100
+			"airline_icao" => $spotter_item['airline_icao'], 
101
+			"airline_iata" => $spotter_item['airline_iata'], 
102
+			"airline_country" => $spotter_item['airline_country'], 
103
+			"airline_callsign" => $spotter_item['airline_callsign'], 
104
+			"airline_type" => $spotter_item['airline_type'],
105
+			"departure_airport_city" => $spotter_item['departure_airport_city'], 
106
+			"departure_airport_country" => $spotter_item['departure_airport_country'], 
107
+			"departure_airport_iata" => $spotter_item['departure_airport_iata'], 
108
+			"departure_airport_icao" => $spotter_item['departure_airport_icao'], 
109
+			"departure_airport_latitude" => $spotter_item['departure_airport_latitude'], 
110
+			"departure_airport_longitude" => $spotter_item['departure_airport_longitude'], 
111
+			"departure_airport_altitude" => $spotter_item['departure_airport_altitude'], 
112
+			"arrival_airport_city" => $spotter_item['arrival_airport_city'], 
113
+			"arrival_airport_country" => $spotter_item['arrival_airport_country'], 
114
+			"arrival_airport_iata" => $spotter_item['arrival_airport_iata'], 
115
+			"arrival_airport_icao" => $spotter_item['arrival_airport_icao'], 
116
+			"arrival_airport_latitude" => $spotter_item['arrival_airport_latitude'], 
117
+			"arrival_airport_longitude" => $spotter_item['arrival_airport_longitude'], 
118
+			"arrival_airport_altitude" => $spotter_item['arrival_airport_altitude'],
119
+			"latitude" => $spotter_item['latitude'], 
120
+			"longitude" => $spotter_item['longitude'], 
121
+			"altitude" => $spotter_item['altitude'], 
122
+			"ground_speed" => $spotter_item['ground_speed'], 
123
+			"heading" => $spotter_item['heading'], 
124
+			"heading_name" => $spotter_item['heading_name'], 
125
+			"waypoints" => $spotter_item['waypoints'],
126
+			"date" => date("c", strtotime($spotter_item['date_iso_8601']))
127 127
 		));
128 128
 	}
129 129
 }
Please login to merge, or discard this patch.
archive-geojson.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 				}
91 91
 
92 92
 				//waypoint plotting
93
-                /*
93
+				/*
94 94
 				$output .= '{';
95 95
 					$output .= '"type": "Feature",';
96 96
 						$output .= '"properties": {';
@@ -269,8 +269,8 @@  discard block
 block discarded – undo
269 269
 					$output_time .= (strtotime($spotter_history['date'])*1000).',';
270 270
 				}
271 271
 				if (isset($output_time)) {
272
-				    $output_time  = substr($output_time, 0, -1);
273
-				    $output .= '"time": ['.$output_time.'],';
272
+					$output_time  = substr($output_time, 0, -1);
273
+					$output .= '"time": ['.$output_time.'],';
274 274
 				}
275 275
 
276 276
 
@@ -284,8 +284,8 @@  discard block
 block discarded – undo
284 284
 						$output .= '"coordinates": [';
285 285
 						
286 286
 				if (isset($output_history)) {
287
-				    $output_history  = substr($output_history, 0, -1);
288
-				    $output .= $output_history;
287
+					$output_history  = substr($output_history, 0, -1);
288
+					$output .= $output_history;
289 289
 				}
290 290
 				
291 291
 						$output .= ']';
Please login to merge, or discard this patch.
statistics.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 ?>
250 250
                 <div class="more">
251 251
             	    <?php
252
-            	    /*
252
+					/*
253 253
             		if ($year != '' && $month != '') {
254 254
             	    ?>
255 255
             	    <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
             	    <?php
261 261
             		}
262 262
             		*/
263
-            	    ?>
263
+					?>
264 264
                 </div>
265 265
             </div>
266 266
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
 ?>
295 295
                 <div class="more">
296 296
             	    <?php
297
-            	    /*
297
+					/*
298 298
             		if ($year != '' && $month != '') {
299 299
             	    ?>
300 300
             	    <a href="<?php print $globalURL; ?>/marine/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
             	    <?php
306 306
             		}
307 307
             		*/
308
-            	    ?>
308
+					?>
309 309
                 </div>
310 310
             </div>
311 311
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
Please login to merge, or discard this patch.