Completed
Push — master ( 55ae08...b8e332 )
by Yannick
29:04
created
aircraft-detailed.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 		print '<div class="select-item">';
43 43
 		print '<form action="'.$globalURL.'/aircraft" method="get">';
44 44
 		print '<select name="aircraft_type" class="selectpicker" data-live-search="true">';
45
-    		print '<option></option>';
46
-    		$Stats = new Stats();
45
+			print '<option></option>';
46
+			$Stats = new Stats();
47 47
 		$aircraft_types = $Stats->getAllAircraftTypes();
48 48
 		if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
49 49
 		foreach($aircraft_types as $aircrafttype)
@@ -54,20 +54,20 @@  discard block
 block discarded – undo
54 54
 			} else {
55 55
 				print '<option value="'.$aircrafttype['aircraft_icao'].'">'.$aircrafttype['aircraft_manufacturer'].' '.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
56 56
 			}
57
-    		}
58
-    		print '</select>';
59
-	    	print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
57
+			}
58
+			print '</select>';
59
+			print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
60 60
 	  	print '</form>';
61 61
 	  	print '</div>';
62 62
 	    
63 63
 		if ($aircraft_type != "NA")
64 64
 		{
65
-	    		print '<div class="info column">';
66
-	      		print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>';
67
-	      		print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['aircraft_name'].'</div>';
68
-	      		print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['aircraft_type'].'</div>'; 
69
-	      		if (isset($spotter_array[0]['aircraft_manufacturer'])) print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>';
70
-	    		print '</div>';
65
+				print '<div class="info column">';
66
+		  		print '<h1>'.$spotter_array[0]['aircraft_name'].' ('.$spotter_array[0]['aircraft_type'].')</h1>';
67
+		  		print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['aircraft_name'].'</div>';
68
+		  		print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['aircraft_type'].'</div>'; 
69
+		  		if (isset($spotter_array[0]['aircraft_manufacturer'])) print '<div><span class="label">'._("Manufacturer").'</span><a href="'.$globalURL.'/manufacturer/'.strtolower(str_replace(" ", "-", $spotter_array[0]['aircraft_manufacturer'])).'">'.$spotter_array[0]['aircraft_manufacturer'].'</a></div>';
70
+				print '</div>';
71 71
 		} else {
72 72
 			print '<div class="alert alert-warning">'._("This special aircraft profile shows all flights in where the aircraft type is unknown.").'</div>';
73 73
 		}
Please login to merge, or discard this patch.
require/class.MarineImport.php 1 patch
Indentation   +223 added lines, -223 removed lines patch added patch discarded remove patch
@@ -9,25 +9,25 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Stats.php');
10 10
 require_once(dirname(__FILE__).'/class.Source.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class MarineImport {
16
-    private $all_tracked = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_tracked = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSMarine, $globalNoDB;
27 27
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
28
-	    $Connection = new Connection($dbc);
29
-	    $this->db = $Connection->db();
30
-	    date_default_timezone_set('UTC');
28
+		$Connection = new Connection($dbc);
29
+		$this->db = $Connection->db();
30
+		date_default_timezone_set('UTC');
31 31
 	}
32 32
 	// Get previous source stats
33 33
 	/*
@@ -46,57 +46,57 @@  discard block
 block discarded – undo
46 46
 	}
47 47
 	*/
48 48
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
49
-	    $APRSMarine = new APRSMarine();
50
-	    //$APRSSpotter->connect();
49
+		$APRSMarine = new APRSMarine();
50
+		//$APRSSpotter->connect();
51
+	}
51 52
 	}
52
-    }
53 53
 
54
-    public function checkAll() {
54
+	public function checkAll() {
55 55
 	global $globalDebug, $globalNoDB;
56 56
 	if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
57
-	    if ($globalDebug) echo "Update last seen tracked data...\n";
58
-	    foreach ($this->all_tracked as $key => $flight) {
57
+		if ($globalDebug) echo "Update last seen tracked data...\n";
58
+		foreach ($this->all_tracked as $key => $flight) {
59 59
 		if (isset($this->all_tracked[$key]['id'])) {
60
-		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
61
-    		    $Marine = new Marine($this->db);
62
-    		    $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
60
+			//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
61
+				$Marine = new Marine($this->db);
62
+				$Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
63
+		}
63 64
 		}
64
-	    }
65 65
 	}
66
-    }
66
+	}
67 67
 
68
-    public function del() {
68
+	public function del() {
69 69
 	global $globalDebug, $globalNoDB, $globalNoImport;
70 70
 	// Delete old infos
71 71
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
72 72
 	foreach ($this->all_tracked as $key => $flight) {
73
-    	    if (isset($flight['lastupdate'])) {
74
-        	if ($flight['lastupdate'] < (time()-3000)) {
75
-            	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76
-            		if (isset($this->all_tracked[$key]['id'])) {
77
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
78
-			    /*
73
+			if (isset($flight['lastupdate'])) {
74
+			if ($flight['lastupdate'] < (time()-3000)) {
75
+					if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76
+					if (isset($this->all_tracked[$key]['id'])) {
77
+						if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
78
+				/*
79 79
 			    $MarineLive = new MarineLive();
80 80
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
81 81
 			    $MarineLive->db = null;
82 82
 			    */
83
-            		    //$real_arrival = $this->arrival($key);
84
-            		    $Marine = new Marine($this->db);
85
-            		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
83
+						//$real_arrival = $this->arrival($key);
84
+						$Marine = new Marine($this->db);
85
+						if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
86 86
 				$result = $Marine->updateLatestMarineData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
87 87
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
88
-			    }
89
-			    // Put in archive
88
+				}
89
+				// Put in archive
90 90
 //				$Marine->db = null;
91 91
 			}
92
-            	    }
93
-            	    unset($this->all_tracked[$key]);
94
-    	        }
95
-	    }
96
-        }
97
-    }
92
+					}
93
+					unset($this->all_tracked[$key]);
94
+				}
95
+		}
96
+		}
97
+	}
98 98
 
99
-    public function add($line) {
99
+	public function add($line) {
100 100
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
101 101
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
102 102
 	date_default_timezone_set('UTC');
@@ -105,104 +105,104 @@  discard block
 block discarded – undo
105 105
 	
106 106
 	// SBS format is CSV format
107 107
 	if(is_array($line) && isset($line['mmsi'])) {
108
-	    //print_r($line);
109
-  	    if (isset($line['mmsi'])) {
108
+		//print_r($line);
109
+  		if (isset($line['mmsi'])) {
110 110
 
111 111
 		
112 112
 		// Increment message number
113 113
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
114
-		    $current_date = date('Y-m-d');
115
-		    if (isset($line['source_name'])) $source = $line['source_name'];
116
-		    else $source = '';
117
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
118
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
119
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
120
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
114
+			$current_date = date('Y-m-d');
115
+			if (isset($line['source_name'])) $source = $line['source_name'];
116
+			else $source = '';
117
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
118
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
119
+				$this->stats[$current_date][$source]['msg']['date'] = time();
120
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
122 122
 		}
123 123
 		
124 124
 		
125 125
 		$Common = new Common();
126 126
 		$AIS = new AIS();
127
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
128
-	        else $id = trim($line['id']);
127
+			if (!isset($line['id'])) $id = trim($line['mmsi']);
128
+			else $id = trim($line['id']);
129 129
 		
130 130
 		if (!isset($this->all_tracked[$id])) {
131
-		    $this->all_tracked[$id] = array();
132
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
133
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
134
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135
-		    if (!isset($line['id'])) {
131
+			$this->all_tracked[$id] = array();
132
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedMarine' => 0));
133
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '0', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','typeid' => '','noarchive' => false,'putinarchive' => true,'over_country' => '','mmsi' => '','status' => '','status_id' => '','imo' => '','callsign' => '','arrival_code' => '','arrival_date' => '','mmsi_type' => ''));
134
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135
+			if (!isset($line['id'])) {
136 136
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
137 137
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
138
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
139
-		    if ($globalAllTracked !== FALSE) $dataFound = true;
138
+			 } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
139
+			if ($globalAllTracked !== FALSE) $dataFound = true;
140 140
 		}
141 141
 		
142 142
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
143
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
144
-		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
143
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi' => $line['mmsi']));
144
+			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
145 145
 			$Marine = new Marine($this->db);
146 146
 			$identity = $Marine->getIdentity($line['mmsi']);
147 147
 			if (!empty($identity)) {
148
-			    $this->all_tracked[$id]['ident'] = $identity['ship_name'];
149
-			    $this->all_tracked[$id]['type'] = $identity['type'];
150
-			    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
148
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
149
+				$this->all_tracked[$id]['type'] = $identity['type'];
150
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($identity['type'])));
151 151
 			}
152 152
 			//print_r($identity);
153 153
 			unset($Marine);
154 154
 			//$dataFound = true;
155
-		    }
155
+			}
156 156
 		}
157 157
 		if (isset($line['type_id'])) {
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
159
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
158
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
159
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
160 160
 		}
161 161
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
162
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
163
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
162
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
163
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
164 164
 		}
165 165
 		if (isset($line['status']) && $line['status'] != '') {
166
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
166
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
167 167
 		}
168 168
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
169
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
170
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
169
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
170
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
171 171
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
172
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
172
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
173 173
 				$Marine = new Marine($this->db);
174 174
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
175 175
 				unset($Marine);
176
-			    }
176
+				}
177
+			}
177 178
 			}
178
-		    }
179 179
 		}
180 180
 
181 181
 
182 182
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
183
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
183
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
184 184
 		}
185 185
 		if (isset($line['imo']) && $line['imo'] != '') {
186
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
186
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
187 187
 		}
188 188
 		if (isset($line['callsign']) && $line['callsign'] != '') {
189
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
189
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
190 190
 		}
191 191
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
192
-		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
192
+			if (!isset($this->all_tracked[$id]['arrival_code'])) {
193 193
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
194 194
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
195 195
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
196
-			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
196
+				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
197 197
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
198
-				    $Marine = new Marine($this->db);
199
-				    $fromsource = NULL;
200
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
201
-				    $Marine->db = null;
198
+					$Marine = new Marine($this->db);
199
+					$fromsource = NULL;
200
+					$Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
201
+					$Marine->db = null;
202
+				}
202 203
 				}
203
-			    }
204 204
 			}
205
-		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
205
+			} elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
206 206
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
207 207
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
208 208
 			if (!isset($line['id'])) {
@@ -210,26 +210,26 @@  discard block
 block discarded – undo
210 210
 				$this->all_tracked[$id]['forcenew'] = 1;
211 211
 				$this->all_tracked[$id]['addedMarine'] = 0;
212 212
 			}
213
-		    }
213
+			}
214 214
 		}
215 215
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
216
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
216
+			if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
217 217
 		}
218 218
 
219 219
 		//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'])) {
220 220
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
221
-		    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
221
+			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
222 222
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
223
-			    $timeelapsed = microtime(true);
224
-			    $Marine = new Marine($this->db);
225
-			    $Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
226
-			    $Marine->db = null;
223
+				$timeelapsed = microtime(true);
224
+				$Marine = new Marine($this->db);
225
+				$Marine->addIdentity($this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['type']);
226
+				$Marine->db = null;
227
+			}
227 228
 			}
228
-		    }
229
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
230
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
229
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
230
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
231 231
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
232
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
232
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
233 233
 				$timeelapsed = microtime(true);
234 234
 				$Marine = new Marine($this->db);
235 235
 				$fromsource = NULL;
@@ -237,20 +237,20 @@  discard block
 block discarded – undo
237 237
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
238 238
 				$Marine->db = null;
239 239
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
240
-			    }
240
+				}
241
+			}
241 242
 			}
242
-		    }
243
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
243
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
244 244
 		}
245 245
 
246 246
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
247
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
247
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
248 248
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
249
-		    } else {
249
+			} else {
250 250
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
251 251
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
252 252
 				return '';
253
-		    }
253
+			}
254 254
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
255 255
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
256 256
 			return '';
@@ -267,24 +267,24 @@  discard block
 block discarded – undo
267 267
 
268 268
 
269 269
 		if (isset($line['speed'])) {
270
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
271
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
270
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
271
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
272 272
 		} 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'])) {
273
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
274
-		    if ($distance > 1000 && $distance < 10000) {
273
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
274
+			if ($distance > 1000 && $distance < 10000) {
275 275
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
276 276
 			$speed = $speed*3.6;
277 277
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
278 278
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
279
-		    }
279
+			}
280 280
 		}
281 281
 
282
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
283
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
284
-	    	    else unset($timediff);
285
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
282
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
283
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
284
+				else unset($timediff);
285
+				if ($this->tmd > 5 || !isset($timediff) || $timediff > 2000 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
286 286
 			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'])) {
287
-			    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'])) {
287
+				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'])) {
288 288
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
289 289
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
290 290
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -292,195 +292,195 @@  discard block
 block discarded – undo
292 292
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
293 293
 				$timeelapsed = microtime(true);
294 294
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
295
-				    $Marine = new Marine($this->db);
296
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
297
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
298
-				    $Marine->db = null;
299
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
295
+					$Marine = new Marine($this->db);
296
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
297
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
298
+					$Marine->db = null;
299
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
300 300
 				}
301 301
 				$this->tmd = 0;
302 302
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
303
-			    }
303
+				}
304 304
 			}
305 305
 
306 306
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
307 307
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
308 308
 				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
309
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
310
-				    $dataFound = true;
311
-				    $this->all_tracked[$id]['time_last_coord'] = time();
309
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
310
+					$dataFound = true;
311
+					$this->all_tracked[$id]['time_last_coord'] = time();
312 312
 				}
313 313
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
314 314
 			}
315 315
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
316
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
316
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
317 317
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
318 318
 				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_tracked[$id]['format_source'] == 'aprs') {
319
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
320
-				    $dataFound = true;
321
-				    $this->all_tracked[$id]['time_last_coord'] = time();
319
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
320
+					$dataFound = true;
321
+					$this->all_tracked[$id]['time_last_coord'] = time();
322 322
 				}
323 323
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
324 324
 			}
325 325
 
326
-		    } else if ($globalDebug && $timediff > 20) {
326
+			} else if ($globalDebug && $timediff > 20) {
327 327
 			$this->tmd = $this->tmd + 1;
328 328
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
329 329
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
330 330
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
331 331
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
332
-		    }
332
+			}
333 333
 		}
334 334
 		if (isset($line['last_update']) && $line['last_update'] != '') {
335
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
336
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
335
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
336
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
337 337
 		}
338 338
 		if (isset($line['format_source']) && $line['format_source'] != '') {
339
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
339
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
340 340
 		}
341 341
 		if (isset($line['source_name']) && $line['source_name'] != '') {
342
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
342
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
343 343
 		}
344 344
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
345
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
345
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
346 346
 		}
347 347
 		
348 348
 		if (isset($line['heading']) && $line['heading'] != '') {
349
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
350
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
351
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
352
-		    //$dataFound = true;
349
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
350
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
351
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
352
+			//$dataFound = true;
353 353
   		} 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']) {
354
-  		    $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']);
355
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
356
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
357
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
354
+  			$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']);
355
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
356
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
357
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
358 358
   		}
359 359
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
360 360
 
361 361
 
362 362
 
363 363
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
364
-		    $this->all_tracked[$id]['lastupdate'] = time();
365
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
366
-		        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'])) {
367
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
364
+			$this->all_tracked[$id]['lastupdate'] = time();
365
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
366
+				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'])) {
367
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
368 368
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
369
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
370
-				    $timeelapsed = microtime(true);
371
-				    $MarineLive = new MarineLive($this->db);
372
-				    if (isset($line['id'])) {
369
+					if ($globalDebug) echo "Check if vessel is already in DB...";
370
+					$timeelapsed = microtime(true);
371
+					$MarineLive = new MarineLive($this->db);
372
+					if (isset($line['id'])) {
373 373
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
374 374
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
375
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
375
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
376 376
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
377 377
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
378
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
378
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
379 379
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
380 380
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
381
-				    } else $recent_ident = '';
382
-				    $MarineLive->db=null;
383
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
384
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
381
+					} else $recent_ident = '';
382
+					$MarineLive->db=null;
383
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
384
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
385 385
 				} else $recent_ident = '';
386
-			    } else {
386
+				} else {
387 387
 				$recent_ident = '';
388 388
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
389
-			    }
390
-			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
391
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
392
-			    {
389
+				}
390
+				//if there was no vessel with the same callsign within the last hour and go post it into the archive
391
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
392
+				{
393 393
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
394 394
 				//adds the spotter data for the archive
395
-				    $highlight = '';
396
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
397
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
395
+					$highlight = '';
396
+					if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
397
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
398 398
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
399
-					    $timeelapsed = microtime(true);
400
-					    $Marine = new Marine($this->db);
401
-					    $result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
402
-					    $Marine->db = null;
403
-					    if ($globalDebug && isset($result)) echo $result."\n";
404
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
399
+						$timeelapsed = microtime(true);
400
+						$Marine = new Marine($this->db);
401
+						$result = $Marine->addMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['mmsi'], $this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'], $this->all_tracked[$id]['status'], $this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
402
+						$Marine->db = null;
403
+						if ($globalDebug && isset($result)) echo $result."\n";
404
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
405
+					}
405 406
 					}
406
-				    }
407
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
407
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
408 408
 					// Add source stat in DB
409 409
 					$Stats = new Stats($this->db);
410 410
 					if (!empty($this->stats)) {
411
-					    if ($globalDebug) echo 'Add source stats : ';
412
-				    	    foreach($this->stats as $date => $data) {
411
+						if ($globalDebug) echo 'Add source stats : ';
412
+							foreach($this->stats as $date => $data) {
413 413
 						foreach($data as $source => $sourced) {
414
-					    	    //print_r($sourced);
415
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
416
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
417
-				    		    if (isset($sourced['msg'])) {
418
-				    			if (time() - $sourced['msg']['date'] > 10) {
419
-				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
420
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
421
-			    			    	    unset($this->stats[$date][$source]['msg']);
422
-			    				}
423
-			    			    }
424
-			    			}
425
-			    			if ($date != date('Y-m-d')) {
426
-			    			    unset($this->stats[$date]);
427
-			    			}
428
-				    	    }
429
-				    	    if ($globalDebug) echo 'Done'."\n";
414
+								//print_r($sourced);
415
+									if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
416
+									if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
417
+								if (isset($sourced['msg'])) {
418
+								if (time() - $sourced['msg']['date'] > 10) {
419
+										$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
420
+										echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
421
+										unset($this->stats[$date][$source]['msg']);
422
+								}
423
+								}
424
+							}
425
+							if ($date != date('Y-m-d')) {
426
+								unset($this->stats[$date]);
427
+							}
428
+							}
429
+							if ($globalDebug) echo 'Done'."\n";
430 430
 					}
431 431
 					$Stats->db = null;
432
-				    }
432
+					}
433 433
 				    
434
-				    $this->del();
434
+					$this->del();
435 435
 				//$ignoreImport = false;
436 436
 				$this->all_tracked[$id]['addedMarine'] = 1;
437 437
 				//print_r($this->all_tracked[$id]);
438 438
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
439
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
440
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
441
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
439
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
440
+					//MarineLive->deleteLiveMarineDataNotUpdated();
441
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
442 442
 					$MarineLive = new MarineLive($this->db);
443 443
 					$MarineLive->deleteLiveMarineData();
444 444
 					$MarineLive->db=null;
445 445
 					if ($globalDebug) echo " Done\n";
446
-				    }
447
-				    $this->last_delete = time();
446
+					}
447
+					$this->last_delete = time();
448 448
 				}
449
-			    } elseif ($recent_ident != '') {
449
+				} elseif ($recent_ident != '') {
450 450
 				$this->all_tracked[$id]['id'] = $recent_ident;
451 451
 				$this->all_tracked[$id]['addedMarine'] = 1;
452 452
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
453
-				    if (isset($globalDaemon) && !$globalDaemon) {
453
+					if (isset($globalDaemon) && !$globalDaemon) {
454 454
 					$Marine = new Marine($this->db);
455 455
 					$Marine->updateLatestMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
456 456
 					$Marine->db = null;
457
-				    }
457
+					}
458 458
 				}
459 459
 				
460
-			    }
460
+				}
461 461
 			}
462
-		    }
463
-		    //adds the spotter LIVE data
464
-		    if ($globalDebug) {
462
+			}
463
+			//adds the spotter LIVE data
464
+			if ($globalDebug) {
465 465
 			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'].' - Heading : '.$this->all_tracked[$id]['heading'].' - Speed : '.$this->all_tracked[$id]['speed']."\n";
466
-		    }
467
-		    $ignoreImport = false;
466
+			}
467
+			$ignoreImport = false;
468 468
 
469
-		    if (!$ignoreImport) {
469
+			if (!$ignoreImport) {
470 470
 			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'])) {
471 471
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
472 472
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
473
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
473
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
474 474
 					$timeelapsed = microtime(true);
475 475
 					$MarineLive = new MarineLive($this->db);
476 476
 					$result = $MarineLive->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
477 477
 					$MarineLive->db = null;
478 478
 					if ($globalDebug) echo $result."\n";
479 479
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
480
-				    }
480
+					}
481 481
 				}
482 482
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
483
-				    $APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
483
+					$APRSMarine->addLiveMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['mmsi'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['typeid'],$this->all_tracked[$id]['imo'],$this->all_tracked[$id]['callsign'],$this->all_tracked[$id]['arrival_code'],$this->all_tracked[$id]['arrival_date'],$this->all_tracked[$id]['status'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
484 484
 				}
485 485
 				$this->all_tracked[$id]['putinarchive'] = false;
486 486
 
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 					if ($stats_heading == 16) $stats_heading = 0;
513 513
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
514 514
 						for ($i=0;$i<=15;$i++) {
515
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
515
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
516 516
 						}
517 517
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
518 518
 					} else {
@@ -525,11 +525,11 @@  discard block
 block discarded – undo
525 525
 					//var_dump($this->stats);
526 526
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
527 527
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
528
-						    end($this->stats[$current_date][$source]['hist']);
529
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
528
+							end($this->stats[$current_date][$source]['hist']);
529
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
530 530
 						} else $mini = 0;
531 531
 						for ($i=$mini;$i<=$distance;$i+=10) {
532
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
532
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
533 533
 						}
534 534
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
535 535
 					} else {
@@ -545,24 +545,24 @@  discard block
 block discarded – undo
545 545
 			
546 546
 			
547 547
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
548
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
548
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
549 549
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
550 550
 				$MarineLive = new MarineLive($this->db);
551 551
 				$MarineLive->deleteLiveMarineDataNotUpdated();
552 552
 				$MarineLive->db = null;
553 553
 				//MarineLive->deleteLiveMarineData();
554 554
 				if ($globalDebug) echo " Done\n";
555
-			    }
556
-			    $this->last_delete_hourly = time();
555
+				}
556
+				$this->last_delete_hourly = time();
557 557
 			}
558 558
 			
559
-		    }
560
-		    //$ignoreImport = false;
559
+			}
560
+			//$ignoreImport = false;
561 561
 		}
562 562
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
563 563
 		if ($send) return $this->all_tracked[$id];
564
-	    }
564
+		}
565
+	}
565 566
 	}
566
-    }
567 567
 }
568 568
 ?>
Please login to merge, or discard this patch.
require/class.SpotterLive.php 1 patch
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 	/**
16
-	* Get SQL query part for filter used
17
-	* @param Array $filter the filter
18
-	* @return Array the SQL part
19
-	*/
16
+	 * Get SQL query part for filter used
17
+	 * @param Array $filter the filter
18
+	 * @return Array the SQL part
19
+	 */
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
@@ -133,11 +133,11 @@  discard block
 block discarded – undo
133 133
 	}
134 134
 
135 135
 	/**
136
-	* Gets all the spotter information based on the latest data entry
137
-	*
138
-	* @return Array the spotter information
139
-	*
140
-	*/
136
+	 * Gets all the spotter information based on the latest data entry
137
+	 *
138
+	 * @return Array the spotter information
139
+	 *
140
+	 */
141 141
 	public function getLiveSpotterData($limit = '', $sort = '', $filter = array())
142 142
 	{
143 143
 		global $globalDBdriver, $globalLiveInterval;
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	/**
183
-	* Gets Minimal Live Spotter data
184
-	*
185
-	* @return Array the spotter information
186
-	*
187
-	*/
183
+	 * Gets Minimal Live Spotter data
184
+	 *
185
+	 * @return Array the spotter information
186
+	 *
187
+	 */
188 188
 	public function getMinLiveSpotterData($filter = array())
189 189
 	{
190 190
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
 	}
222 222
 
223 223
 	/**
224
-	* Gets Minimal Live Spotter data since xx seconds
225
-	*
226
-	* @return Array the spotter information
227
-	*
228
-	*/
224
+	 * Gets Minimal Live Spotter data since xx seconds
225
+	 *
226
+	 * @return Array the spotter information
227
+	 *
228
+	 */
229 229
 	public function getMinLastLiveSpotterData($coord = array(),$filter = array(), $limit = false)
230 230
 	{
231 231
 		global $globalDBdriver, $globalLiveInterval, $globalArchive, $globalMap3DAircraftsLimit;
@@ -308,11 +308,11 @@  discard block
 block discarded – undo
308 308
 	}
309 309
 
310 310
 	/**
311
-	* Gets number of latest data entry
312
-	*
313
-	* @return String number of entry
314
-	*
315
-	*/
311
+	 * Gets number of latest data entry
312
+	 *
313
+	 * @return String number of entry
314
+	 *
315
+	 */
316 316
 	public function getLiveSpotterCount($filter = array())
317 317
 	{
318 318
 		global $globalDBdriver, $globalLiveInterval;
@@ -339,11 +339,11 @@  discard block
 block discarded – undo
339 339
 	}
340 340
 
341 341
 	/**
342
-	* Gets all the spotter information based on the latest data entry and coord
343
-	*
344
-	* @return Array the spotter information
345
-	*
346
-	*/
342
+	 * Gets all the spotter information based on the latest data entry and coord
343
+	 *
344
+	 * @return Array the spotter information
345
+	 *
346
+	 */
347 347
 	public function getLiveSpotterDatabyCoord($coord, $filter = array())
348 348
 	{
349 349
 		global $globalDBdriver, $globalLiveInterval;
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
 	}
369 369
 
370 370
 	/**
371
-	* Gets all the spotter information based on the latest data entry and coord
372
-	*
373
-	* @return Array the spotter information
374
-	*
375
-	*/
371
+	 * Gets all the spotter information based on the latest data entry and coord
372
+	 *
373
+	 * @return Array the spotter information
374
+	 *
375
+	 */
376 376
 	public function getMinLiveSpotterDatabyCoord($coord, $filter = array())
377 377
 	{
378 378
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 	}
438 438
 
439 439
 	/**
440
-	* Gets all the spotter information based on a user's latitude and longitude
441
-	*
442
-	* @return Array the spotter information
443
-	*
444
-	*/
440
+	 * Gets all the spotter information based on a user's latitude and longitude
441
+	 *
442
+	 * @return Array the spotter information
443
+	 *
444
+	 */
445 445
 	public function getLatestSpotterForLayar($lat, $lng, $radius, $interval)
446 446
 	{
447 447
 		$Spotter = new Spotter($this->db);
@@ -451,98 +451,98 @@  discard block
 block discarded – undo
451 451
 				return false;
452 452
 			}
453 453
 		}
454
-        if ($lng != '')
455
-                {
456
-                        if (!is_numeric($lng))
457
-                        {
458
-                                return false;
459
-                        }
460
-                }
461
-
462
-                if ($radius != '')
463
-                {
464
-                        if (!is_numeric($radius))
465
-                        {
466
-                                return false;
467
-                        }
468
-                }
454
+		if ($lng != '')
455
+				{
456
+						if (!is_numeric($lng))
457
+						{
458
+								return false;
459
+						}
460
+				}
461
+
462
+				if ($radius != '')
463
+				{
464
+						if (!is_numeric($radius))
465
+						{
466
+								return false;
467
+						}
468
+				}
469 469
 		$additional_query = '';
470
-        if ($interval != '')
471
-                {
472
-                        if (!is_string($interval))
473
-                        {
474
-                                //$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
475
-			        return false;
476
-                        } else {
477
-                if ($interval == '1m')
478
-                {
479
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
480
-                } else if ($interval == '15m'){
481
-                    $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
482
-                } 
483
-            }
484
-                } else {
485
-         $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
486
-        }
487
-
488
-                $query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
470
+		if ($interval != '')
471
+				{
472
+						if (!is_string($interval))
473
+						{
474
+								//$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
475
+					return false;
476
+						} else {
477
+				if ($interval == '1m')
478
+				{
479
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';
480
+				} else if ($interval == '15m'){
481
+					$additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= spotter_live.date ';
482
+				} 
483
+			}
484
+				} else {
485
+		 $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= spotter_live.date ';   
486
+		}
487
+
488
+				$query  = "SELECT spotter_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM spotter_live 
489 489
                    WHERE spotter_live.latitude <> '' 
490 490
                                    AND spotter_live.longitude <> '' 
491 491
                    ".$additional_query."
492 492
                    HAVING distance < :radius  
493 493
                                    ORDER BY distance";
494 494
 
495
-                $spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
495
+				$spotter_array = $Spotter->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
496 496
 
497
-                return $spotter_array;
498
-        }
497
+				return $spotter_array;
498
+		}
499 499
 
500 500
     
501
-        /**
502
-	* Gets all the spotter information based on a particular callsign
503
-	*
504
-	* @return Array the spotter information
505
-	*
506
-	*/
501
+		/**
502
+		 * Gets all the spotter information based on a particular callsign
503
+		 *
504
+		 * @return Array the spotter information
505
+		 *
506
+		 */
507 507
 	public function getLastLiveSpotterDataByIdent($ident)
508 508
 	{
509 509
 		$Spotter = new Spotter($this->db);
510 510
 		date_default_timezone_set('UTC');
511 511
 
512 512
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
513
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
513
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
514 514
 
515 515
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident),'',true);
516 516
 
517 517
 		return $spotter_array;
518 518
 	}
519 519
 
520
-        /**
521
-	* Gets all the spotter information based on a particular callsign
522
-	*
523
-	* @return Array the spotter information
524
-	*
525
-	*/
520
+		/**
521
+		 * Gets all the spotter information based on a particular callsign
522
+		 *
523
+		 * @return Array the spotter information
524
+		 *
525
+		 */
526 526
 	public function getDateLiveSpotterDataByIdent($ident,$date)
527 527
 	{
528 528
 		$Spotter = new Spotter($this->db);
529 529
 		date_default_timezone_set('UTC');
530 530
 
531 531
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
532
-                $query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
532
+				$query  = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate ORDER BY spotter_live.date DESC';
533 533
 
534
-                $date = date('c',$date);
534
+				$date = date('c',$date);
535 535
 		$spotter_array = $Spotter->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
536 536
 
537 537
 		return $spotter_array;
538 538
 	}
539 539
 
540
-        /**
541
-	* Gets last spotter information based on a particular callsign
542
-	*
543
-	* @return Array the spotter information
544
-	*
545
-	*/
540
+		/**
541
+		 * Gets last spotter information based on a particular callsign
542
+		 *
543
+		 * @return Array the spotter information
544
+		 *
545
+		 */
546 546
 	public function getLastLiveSpotterDataById($id)
547 547
 	{
548 548
 		$Spotter = new Spotter($this->db);
@@ -553,12 +553,12 @@  discard block
 block discarded – undo
553 553
 		return $spotter_array;
554 554
 	}
555 555
 
556
-        /**
557
-	* Gets last spotter information based on a particular callsign
558
-	*
559
-	* @return Array the spotter information
560
-	*
561
-	*/
556
+		/**
557
+		 * Gets last spotter information based on a particular callsign
558
+		 *
559
+		 * @return Array the spotter information
560
+		 *
561
+		 */
562 562
 	public function getDateLiveSpotterDataById($id,$date)
563 563
 	{
564 564
 		$Spotter = new Spotter($this->db);
@@ -571,21 +571,21 @@  discard block
 block discarded – undo
571 571
 		return $spotter_array;
572 572
 	}
573 573
 
574
-        /**
575
-	* Gets altitude information based on a particular callsign
576
-	*
577
-	* @return Array the spotter information
578
-	*
579
-	*/
574
+		/**
575
+		 * Gets altitude information based on a particular callsign
576
+		 *
577
+		 * @return Array the spotter information
578
+		 *
579
+		 */
580 580
 	public function getAltitudeLiveSpotterDataByIdent($ident)
581 581
 	{
582 582
 
583 583
 		date_default_timezone_set('UTC');
584 584
 
585 585
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
586
-                $query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
586
+				$query  = 'SELECT spotter_live.altitude, spotter_live.date FROM spotter_live WHERE spotter_live.ident = :ident';
587 587
 
588
-    		try {
588
+			try {
589 589
 			
590 590
 			$sth = $this->db->prepare($query);
591 591
 			$sth->execute(array(':ident' => $ident));
@@ -598,12 +598,12 @@  discard block
 block discarded – undo
598 598
 		return $spotter_array;
599 599
 	}
600 600
 
601
-        /**
602
-	* Gets all the spotter information based on a particular id
603
-	*
604
-	* @return Array the spotter information
605
-	*
606
-	*/
601
+		/**
602
+		 * Gets all the spotter information based on a particular id
603
+		 *
604
+		 * @return Array the spotter information
605
+		 *
606
+		 */
607 607
 	public function getAllLiveSpotterDataById($id,$liveinterval = false)
608 608
 	{
609 609
 		global $globalDBdriver, $globalLiveInterval;
@@ -631,18 +631,18 @@  discard block
 block discarded – undo
631 631
 		return $spotter_array;
632 632
 	}
633 633
 
634
-        /**
635
-	* Gets all the spotter information based on a particular ident
636
-	*
637
-	* @return Array the spotter information
638
-	*
639
-	*/
634
+		/**
635
+		 * Gets all the spotter information based on a particular ident
636
+		 *
637
+		 * @return Array the spotter information
638
+		 *
639
+		 */
640 640
 	public function getAllLiveSpotterDataByIdent($ident)
641 641
 	{
642 642
 		date_default_timezone_set('UTC');
643 643
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
644 644
 		$query  = self::$global_query.' WHERE spotter_live.ident = :ident';
645
-    		try {
645
+			try {
646 646
 			
647 647
 			$sth = $this->db->prepare($query);
648 648
 			$sth->execute(array(':ident' => $ident));
@@ -656,23 +656,23 @@  discard block
 block discarded – undo
656 656
 
657 657
 
658 658
 	/**
659
-	* Deletes all info in the table
660
-	*
661
-	* @return String success or false
662
-	*
663
-	*/
659
+	 * Deletes all info in the table
660
+	 *
661
+	 * @return String success or false
662
+	 *
663
+	 */
664 664
 	public function deleteLiveSpotterData()
665 665
 	{
666 666
 		global $globalDBdriver;
667 667
 		if ($globalDBdriver == 'mysql') {
668 668
 			//$query  = "DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE) >= spotter_live.date";
669 669
 			$query  = 'DELETE FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 9 HOUR) >= spotter_live.date';
670
-            		//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
670
+					//$query  = "DELETE FROM spotter_live WHERE spotter_live.id IN (SELECT spotter_live.id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= spotter_live.date)";
671 671
 		} else {
672 672
 			$query  = "DELETE FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date";
673 673
 		}
674 674
         
675
-    		try {
675
+			try {
676 676
 			
677 677
 			$sth = $this->db->prepare($query);
678 678
 			$sth->execute();
@@ -684,18 +684,18 @@  discard block
 block discarded – undo
684 684
 	}
685 685
 
686 686
 	/**
687
-	* Deletes all info in the table for aircraft not seen since 2 HOUR
688
-	*
689
-	* @return String success or false
690
-	*
691
-	*/
687
+	 * Deletes all info in the table for aircraft not seen since 2 HOUR
688
+	 *
689
+	 * @return String success or false
690
+	 *
691
+	 */
692 692
 	public function deleteLiveSpotterDataNotUpdated()
693 693
 	{
694 694
 		global $globalDBdriver, $globalDebug;
695 695
 		if ($globalDBdriver == 'mysql') {
696 696
 			//$query = 'SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(), INTERVAL 1 HOUR) < spotter_live.date) LIMIT 800 OFFSET 0';
697
-    			$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
698
-    			try {
697
+				$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND DATE_SUB(UTC_TIMESTAMP(), INTERVAL 2 HOUR) >= s.max_date LIMIT 2000 OFFSET 0";
698
+				try {
699 699
 				
700 700
 				$sth = $this->db->prepare($query);
701 701
 				$sth->execute();
@@ -703,8 +703,8 @@  discard block
 block discarded – undo
703 703
 				return "error";
704 704
 			}
705 705
 			$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
706
-                        $i = 0;
707
-                        $j =0;
706
+						$i = 0;
707
+						$j =0;
708 708
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
709 709
 			foreach($all as $row)
710 710
 			{
@@ -712,20 +712,20 @@  discard block
 block discarded – undo
712 712
 				$j++;
713 713
 				if ($j == 30) {
714 714
 					if ($globalDebug) echo ".";
715
-				    	try {
715
+						try {
716 716
 						
717 717
 						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
718 718
 						$sth->execute();
719 719
 					} catch(PDOException $e) {
720 720
 						return "error";
721 721
 					}
722
-                                	$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
723
-                                	$j = 0;
722
+									$query_delete = 'DELETE FROM spotter_live WHERE flightaware_id IN (';
723
+									$j = 0;
724 724
 				}
725 725
 				$query_delete .= "'".$row['flightaware_id']."',";
726 726
 			}
727 727
 			if ($i > 0) {
728
-    				try {
728
+					try {
729 729
 					
730 730
 					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
731 731
 					$sth->execute();
@@ -736,9 +736,9 @@  discard block
 block discarded – undo
736 736
 			return "success";
737 737
 		} elseif ($globalDBdriver == 'pgsql') {
738 738
 			//$query = "SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' >= spotter_live.date AND spotter_live.flightaware_id NOT IN (SELECT flightaware_id FROM spotter_live WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '9 HOURS' < spotter_live.date) LIMIT 800 OFFSET 0";
739
-    			//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
740
-    			$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
741
-    			try {
739
+				//$query = "SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 800 OFFSET 0";
740
+				$query = "DELETE FROM spotter_live WHERE flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT flightaware_id,MAX(date) as max_date FROM spotter_live GROUP BY flightaware_id) s ON s.flightaware_id = spotter_live.flightaware_id AND NOW() AT TIME ZONE 'UTC' - INTERVAL '2 HOURS' >= s.max_date LIMIT 2000 OFFSET 0)";
741
+				try {
742 742
 				
743 743
 				$sth = $this->db->prepare($query);
744 744
 				$sth->execute();
@@ -782,17 +782,17 @@  discard block
 block discarded – undo
782 782
 	}
783 783
 
784 784
 	/**
785
-	* Deletes all info in the table for an ident
786
-	*
787
-	* @return String success or false
788
-	*
789
-	*/
785
+	 * Deletes all info in the table for an ident
786
+	 *
787
+	 * @return String success or false
788
+	 *
789
+	 */
790 790
 	public function deleteLiveSpotterDataByIdent($ident)
791 791
 	{
792 792
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
793 793
 		$query  = 'DELETE FROM spotter_live WHERE ident = :ident';
794 794
         
795
-    		try {
795
+			try {
796 796
 			
797 797
 			$sth = $this->db->prepare($query);
798 798
 			$sth->execute(array(':ident' => $ident));
@@ -804,17 +804,17 @@  discard block
 block discarded – undo
804 804
 	}
805 805
 
806 806
 	/**
807
-	* Deletes all info in the table for an id
808
-	*
809
-	* @return String success or false
810
-	*
811
-	*/
807
+	 * Deletes all info in the table for an id
808
+	 *
809
+	 * @return String success or false
810
+	 *
811
+	 */
812 812
 	public function deleteLiveSpotterDataById($id)
813 813
 	{
814 814
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
815 815
 		$query  = 'DELETE FROM spotter_live WHERE flightaware_id = :id';
816 816
         
817
-    		try {
817
+			try {
818 818
 			
819 819
 			$sth = $this->db->prepare($query);
820 820
 			$sth->execute(array(':id' => $id));
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 
828 828
 
829 829
 	/**
830
-	* Gets the aircraft ident within the last hour
831
-	*
832
-	* @return String the ident
833
-	*
834
-	*/
830
+	 * Gets the aircraft ident within the last hour
831
+	 *
832
+	 * @return String the ident
833
+	 *
834
+	 */
835 835
 	public function getIdentFromLastHour($ident)
836 836
 	{
837 837
 		global $globalDBdriver, $globalTimezone;
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
 			$ident_result = $row['ident'];
858 858
 		}
859 859
 		return $ident_result;
860
-        }
860
+		}
861 861
 
862 862
 	/**
863
-	* Check recent aircraft
864
-	*
865
-	* @return String the ident
866
-	*
867
-	*/
863
+	 * Check recent aircraft
864
+	 *
865
+	 * @return String the ident
866
+	 *
867
+	 */
868 868
 	public function checkIdentRecent($ident)
869 869
 	{
870 870
 		global $globalDBdriver, $globalTimezone;
@@ -890,14 +890,14 @@  discard block
 block discarded – undo
890 890
 			$ident_result = $row['flightaware_id'];
891 891
 		}
892 892
 		return $ident_result;
893
-        }
893
+		}
894 894
 
895 895
 	/**
896
-	* Check recent aircraft by id
897
-	*
898
-	* @return String the ident
899
-	*
900
-	*/
896
+	 * Check recent aircraft by id
897
+	 *
898
+	 * @return String the ident
899
+	 *
900
+	 */
901 901
 	public function checkIdRecent($id)
902 902
 	{
903 903
 		global $globalDBdriver, $globalTimezone;
@@ -923,14 +923,14 @@  discard block
 block discarded – undo
923 923
 			$ident_result = $row['flightaware_id'];
924 924
 		}
925 925
 		return $ident_result;
926
-        }
926
+		}
927 927
 
928 928
 	/**
929
-	* Check recent aircraft by ModeS
930
-	*
931
-	* @return String the ModeS
932
-	*
933
-	*/
929
+	 * Check recent aircraft by ModeS
930
+	 *
931
+	 * @return String the ModeS
932
+	 *
933
+	 */
934 934
 	public function checkModeSRecent($modes)
935 935
 	{
936 936
 		global $globalDBdriver, $globalTimezone;
@@ -960,11 +960,11 @@  discard block
 block discarded – undo
960 960
 	}
961 961
 
962 962
 	/**
963
-	* Gets the aircraft data from the last 20 seconds
964
-	*
965
-	* @return Array the spotter data
966
-	*
967
-	*/
963
+	 * Gets the aircraft data from the last 20 seconds
964
+	 *
965
+	 * @return Array the spotter data
966
+	 *
967
+	 */
968 968
 	public function getRealTimeData($q = '')
969 969
 	{
970 970
 		global $globalDBdriver;
@@ -1006,16 +1006,16 @@  discard block
 block discarded – undo
1006 1006
 	}
1007 1007
 
1008 1008
 	/**
1009
-	* Adds a new spotter data
1010
-	*
1011
-	* @param String $flightaware_id the ID from flightaware
1012
-	* @param String $ident the flight ident
1013
-	* @param String $aircraft_icao the aircraft type
1014
-	* @param String $departure_airport_icao the departure airport
1015
-	* @param String $arrival_airport_icao the arrival airport
1016
-	* @return String success or false
1017
-	*
1018
-	*/
1009
+	 * Adds a new spotter data
1010
+	 *
1011
+	 * @param String $flightaware_id the ID from flightaware
1012
+	 * @param String $ident the flight ident
1013
+	 * @param String $aircraft_icao the aircraft type
1014
+	 * @param String $departure_airport_icao the departure airport
1015
+	 * @param String $arrival_airport_icao the arrival airport
1016
+	 * @return String success or false
1017
+	 *
1018
+	 */
1019 1019
 	public function addLiveSpotterData($flightaware_id = '', $ident = '', $aircraft_icao = '', $departure_airport_icao = '', $arrival_airport_icao = '', $latitude = '', $longitude = '', $waypoints = '', $altitude = '', $altitude_real = '',$heading = '', $groundspeed = '', $date = '',$departure_airport_time = '', $arrival_airport_time = '', $squawk = '', $route_stop = '', $ModeS = '', $putinarchive = false,$registration = '',$pilot_id = '', $pilot_name = '', $verticalrate = '', $noarchive = false, $ground = false,$format_source = '', $source_name = '', $over_country = '')
1020 1020
 	{
1021 1021
 		global $globalURL, $globalArchive, $globalDebug;
@@ -1158,10 +1158,10 @@  discard block
 block discarded – undo
1158 1158
 		$arrival_airport_country = '';
1159 1159
 		
1160 1160
             	
1161
-            	if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1162
-            	if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1163
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1164
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1161
+				if ($squawk == '' || $Common->isInteger($squawk) === false ) $squawk = NULL;
1162
+				if ($verticalrate == '' || $Common->isInteger($verticalrate) === false ) $verticalrate = NULL;
1163
+				if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
1164
+				if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
1165 1165
 		
1166 1166
 		$query = '';
1167 1167
 		if ($globalArchive) {
@@ -1182,10 +1182,10 @@  discard block
 block discarded – undo
1182 1182
 			return "error : ".$e->getMessage();
1183 1183
 		}
1184 1184
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
1185
-		    if ($globalDebug) echo '(Add to SBS archive : ';
1186
-		    $SpotterArchive = new SpotterArchive($this->db);
1187
-		    $result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1188
-		    if ($globalDebug) echo $result.')';
1185
+			if ($globalDebug) echo '(Add to SBS archive : ';
1186
+			$SpotterArchive = new SpotterArchive($this->db);
1187
+			$result =  $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $altitude_real,$heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country);
1188
+			if ($globalDebug) echo $result.')';
1189 1189
 		} elseif ($globalDebug && $putinarchive !== true) {
1190 1190
 			echo '(Not adding to archive)';
1191 1191
 		} elseif ($globalDebug && $noarchive === true) {
Please login to merge, or discard this patch.
require/libs/SimplePie.compiled.php 1 patch
Indentation   +281 added lines, -282 removed lines patch added patch discarded remove patch
@@ -868,7 +868,6 @@  discard block
 block discarded – undo
868 868
 	 * This tells SimplePie to ignore any file errors and fall back to cache
869 869
 	 * instead. This only works if caching is enabled and cached content
870 870
 	 * still exists.
871
-
872 871
 	 * @param bool $enable Force use of cache on fail.
873 872
 	 */
874 873
 	public function force_cache_fallback($enable = false)
@@ -1663,7 +1662,7 @@  discard block
 block discarded – undo
1663 1662
 					// Now also do feed discovery, but if microformats were found don't
1664 1663
 					// overwrite the current value of file.
1665 1664
 					$discovered = $locate->find($this->autodiscovery,
1666
-					                            $this->all_discovered_feeds);
1665
+												$this->all_discovered_feeds);
1667 1666
 					if ($microformats)
1668 1667
 					{
1669 1668
 						if ($hub = $locate->get_rel_link('hub'))
@@ -1928,8 +1927,8 @@  discard block
 block discarded – undo
1928 1927
 			{
1929 1928
 				// sanitize encodes ampersands which are required when used in a url.
1930 1929
 				return str_replace('&amp;', '&',
1931
-				                   $this->sanitize($this->permanent_url,
1932
-				                                   SIMPLEPIE_CONSTRUCT_IRI));
1930
+								   $this->sanitize($this->permanent_url,
1931
+												   SIMPLEPIE_CONSTRUCT_IRI));
1933 1932
 			}
1934 1933
 		}
1935 1934
 		else
@@ -1937,8 +1936,8 @@  discard block
 block discarded – undo
1937 1936
 			if ($this->feed_url !== null)
1938 1937
 			{
1939 1938
 				return str_replace('&amp;', '&',
1940
-				                   $this->sanitize($this->feed_url,
1941
-				                                   SIMPLEPIE_CONSTRUCT_IRI));
1939
+								   $this->sanitize($this->feed_url,
1940
+												   SIMPLEPIE_CONSTRUCT_IRI));
1942 1941
 			}
1943 1942
 		}
1944 1943
 		return null;
@@ -2597,8 +2596,8 @@  discard block
 block discarded – undo
2597 2596
 		}
2598 2597
 
2599 2598
 		if (isset($this->data['headers']['link']) &&
2600
-		    preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/',
2601
-		               $this->data['headers']['link'], $match))
2599
+			preg_match('/<([^>]+)>; rel='.preg_quote($rel).'/',
2600
+					   $this->data['headers']['link'], $match))
2602 2601
 		{
2603 2602
 			return array($match[1]);
2604 2603
 		}
@@ -3937,112 +3936,112 @@  discard block
 block discarded – undo
3937 3936
  */
3938 3937
 class SimplePie_Cache_Memcached implements SimplePie_Cache_Base
3939 3938
 {
3940
-    /**
3941
-     * Memcached instance
3942
-     * @var Memcached
3943
-     */
3944
-    protected $cache;
3945
-
3946
-    /**
3947
-     * Options
3948
-     * @var array
3949
-     */
3950
-    protected $options;
3951
-
3952
-    /**
3953
-     * Cache name
3954
-     * @var string
3955
-     */
3956
-    protected $name;
3957
-
3958
-    /**
3959
-     * Create a new cache object
3960
-     * @param string $location Location string (from SimplePie::$cache_location)
3961
-     * @param string $name     Unique ID for the cache
3962
-     * @param string $type     Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
3963
-     */
3964
-    public function __construct($location, $name, $type) {
3965
-        $this->options = array(
3966
-            'host'   => '127.0.0.1',
3967
-            'port'   => 11211,
3968
-            'extras' => array(
3969
-                'timeout' => 3600, // one hour
3970
-                'prefix'  => 'simplepie_',
3971
-            ),
3972
-        );
3973
-        $this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
3974
-
3975
-        $this->name = $this->options['extras']['prefix'] . md5("$name:$type");
3976
-
3977
-        $this->cache = new Memcached();
3978
-        $this->cache->addServer($this->options['host'], (int)$this->options['port']);
3979
-    }
3980
-
3981
-    /**
3982
-     * Save data to the cache
3983
-     * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
3984
-     * @return bool Successfulness
3985
-     */
3986
-    public function save($data) {
3987
-        if ($data instanceof SimplePie) {
3988
-            $data = $data->data;
3989
-        }
3990
-
3991
-        return $this->setData(serialize($data));
3992
-    }
3993
-
3994
-    /**
3995
-     * Retrieve the data saved to the cache
3996
-     * @return array Data for SimplePie::$data
3997
-     */
3998
-    public function load() {
3999
-        $data = $this->cache->get($this->name);
4000
-
4001
-        if ($data !== false) {
4002
-            return unserialize($data);
4003
-        }
4004
-        return false;
4005
-    }
4006
-
4007
-    /**
4008
-     * Retrieve the last modified time for the cache
4009
-     * @return int Timestamp
4010
-     */
4011
-    public function mtime() {
4012
-        $data = $this->cache->get($this->name . '_mtime');
4013
-        return (int) $data;
4014
-    }
4015
-
4016
-    /**
4017
-     * Set the last modified time to the current time
4018
-     * @return bool Success status
4019
-     */
4020
-    public function touch() {
4021
-        $data = $this->cache->get($this->name);
4022
-        return $this->setData($data);
4023
-    }
4024
-
4025
-    /**
4026
-     * Remove the cache
4027
-     * @return bool Success status
4028
-     */
4029
-    public function unlink() {
4030
-        return $this->cache->delete($this->name, 0);
4031
-    }
4032
-
4033
-    /**
4034
-     * Set the last modified time and data to Memcached
4035
-     * @return bool Success status
4036
-     */
4037
-    private function setData($data) {
4038
-
4039
-        if ($data !== false) {
4040
-            $this->cache->set($this->name . '_mtime', time(), (int)$this->options['extras']['timeout']);
4041
-            return $this->cache->set($this->name, $data, (int)$this->options['extras']['timeout']);
4042
-        }
4043
-
4044
-        return false;
4045
-    }
3939
+	/**
3940
+	 * Memcached instance
3941
+	 * @var Memcached
3942
+	 */
3943
+	protected $cache;
3944
+
3945
+	/**
3946
+	 * Options
3947
+	 * @var array
3948
+	 */
3949
+	protected $options;
3950
+
3951
+	/**
3952
+	 * Cache name
3953
+	 * @var string
3954
+	 */
3955
+	protected $name;
3956
+
3957
+	/**
3958
+	 * Create a new cache object
3959
+	 * @param string $location Location string (from SimplePie::$cache_location)
3960
+	 * @param string $name     Unique ID for the cache
3961
+	 * @param string $type     Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
3962
+	 */
3963
+	public function __construct($location, $name, $type) {
3964
+		$this->options = array(
3965
+			'host'   => '127.0.0.1',
3966
+			'port'   => 11211,
3967
+			'extras' => array(
3968
+				'timeout' => 3600, // one hour
3969
+				'prefix'  => 'simplepie_',
3970
+			),
3971
+		);
3972
+		$this->options = SimplePie_Misc::array_merge_recursive($this->options, SimplePie_Cache::parse_URL($location));
3973
+
3974
+		$this->name = $this->options['extras']['prefix'] . md5("$name:$type");
3975
+
3976
+		$this->cache = new Memcached();
3977
+		$this->cache->addServer($this->options['host'], (int)$this->options['port']);
3978
+	}
3979
+
3980
+	/**
3981
+	 * Save data to the cache
3982
+	 * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
3983
+	 * @return bool Successfulness
3984
+	 */
3985
+	public function save($data) {
3986
+		if ($data instanceof SimplePie) {
3987
+			$data = $data->data;
3988
+		}
3989
+
3990
+		return $this->setData(serialize($data));
3991
+	}
3992
+
3993
+	/**
3994
+	 * Retrieve the data saved to the cache
3995
+	 * @return array Data for SimplePie::$data
3996
+	 */
3997
+	public function load() {
3998
+		$data = $this->cache->get($this->name);
3999
+
4000
+		if ($data !== false) {
4001
+			return unserialize($data);
4002
+		}
4003
+		return false;
4004
+	}
4005
+
4006
+	/**
4007
+	 * Retrieve the last modified time for the cache
4008
+	 * @return int Timestamp
4009
+	 */
4010
+	public function mtime() {
4011
+		$data = $this->cache->get($this->name . '_mtime');
4012
+		return (int) $data;
4013
+	}
4014
+
4015
+	/**
4016
+	 * Set the last modified time to the current time
4017
+	 * @return bool Success status
4018
+	 */
4019
+	public function touch() {
4020
+		$data = $this->cache->get($this->name);
4021
+		return $this->setData($data);
4022
+	}
4023
+
4024
+	/**
4025
+	 * Remove the cache
4026
+	 * @return bool Success status
4027
+	 */
4028
+	public function unlink() {
4029
+		return $this->cache->delete($this->name, 0);
4030
+	}
4031
+
4032
+	/**
4033
+	 * Set the last modified time and data to Memcached
4034
+	 * @return bool Success status
4035
+	 */
4036
+	private function setData($data) {
4037
+
4038
+		if ($data !== false) {
4039
+			$this->cache->set($this->name . '_mtime', time(), (int)$this->options['extras']['timeout']);
4040
+			return $this->cache->set($this->name, $data, (int)$this->options['extras']['timeout']);
4041
+		}
4042
+
4043
+		return false;
4044
+	}
4046 4045
 }
4047 4046
 
4048 4047
 /**
@@ -4471,143 +4470,143 @@  discard block
 block discarded – undo
4471 4470
  * @uses Redis
4472 4471
  */
4473 4472
 class SimplePie_Cache_Redis implements SimplePie_Cache_Base {
4474
-    /**
4475
-     * Redis instance
4476
-     *
4477
-     * @var \Redis
4478
-     */
4479
-    protected $cache;
4480
-
4481
-    /**
4482
-     * Options
4483
-     *
4484
-     * @var array
4485
-     */
4486
-    protected $options;
4487
-
4488
-    /**
4489
-     * Cache name
4490
-     *
4491
-     * @var string
4492
-     */
4493
-    protected $name;
4494
-
4495
-    /**
4496
-     * Cache Data
4497
-     *
4498
-     * @var type
4499
-     */
4500
-    protected $data;
4501
-
4502
-    /**
4503
-     * Create a new cache object
4504
-     *
4505
-     * @param string $location Location string (from SimplePie::$cache_location)
4506
-     * @param string $name Unique ID for the cache
4507
-     * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
4508
-     */
4509
-    public function __construct($location, $name, $options = null) {
4510
-        //$this->cache = \flow\simple\cache\Redis::getRedisClientInstance();
4511
-        $parsed = SimplePie_Cache::parse_URL($location);
4512
-        $redis = new Redis();
4513
-        $redis->connect($parsed['host'], $parsed['port']);
4514
-        $this->cache = $redis;
4515
-
4516
-        if (!is_null($options) && is_array($options)) {
4517
-            $this->options = $options;
4518
-        } else {
4519
-            $this->options = array (
4520
-                'prefix' => 'rss:simple_primary:',
4521
-                'expire' => 0,
4522
-            );
4523
-        }
4524
-
4525
-        $this->name = $this->options['prefix'] . $name;
4526
-    }
4527
-
4528
-    /**
4529
-     * @param \Redis $cache
4530
-     */
4531
-    public function setRedisClient(\Redis $cache) {
4532
-        $this->cache = $cache;
4533
-    }
4534
-
4535
-    /**
4536
-     * Save data to the cache
4537
-     *
4538
-     * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
4539
-     * @return bool Successfulness
4540
-     */
4541
-    public function save($data) {
4542
-        if ($data instanceof SimplePie) {
4543
-            $data = $data->data;
4544
-        }
4545
-        $response = $this->cache->set($this->name, serialize($data));
4546
-        if ($this->options['expire']) {
4547
-            $this->cache->expire($this->name, $this->options['expire']);
4548
-        }
4549
-
4550
-        return $response;
4551
-    }
4552
-
4553
-    /**
4554
-     * Retrieve the data saved to the cache
4555
-     *
4556
-     * @return array Data for SimplePie::$data
4557
-     */
4558
-    public function load() {
4559
-        $data = $this->cache->get($this->name);
4560
-
4561
-        if ($data !== false) {
4562
-            return unserialize($data);
4563
-        }
4564
-        return false;
4565
-    }
4566
-
4567
-    /**
4568
-     * Retrieve the last modified time for the cache
4569
-     *
4570
-     * @return int Timestamp
4571
-     */
4572
-    public function mtime() {
4573
-
4574
-        $data = $this->cache->get($this->name);
4575
-
4576
-        if ($data !== false) {
4577
-            return time();
4578
-        }
4579
-
4580
-        return false;
4581
-    }
4582
-
4583
-    /**
4584
-     * Set the last modified time to the current time
4585
-     *
4586
-     * @return bool Success status
4587
-     */
4588
-    public function touch() {
4589
-
4590
-        $data = $this->cache->get($this->name);
4591
-
4592
-        if ($data !== false) {
4593
-            $return = $this->cache->set($this->name, $data);
4594
-            if ($this->options['expire']) {
4595
-                return $this->cache->expire($this->name, $this->ttl);
4596
-            }
4597
-            return $return;
4598
-        }
4599
-
4600
-        return false;
4601
-    }
4602
-
4603
-    /**
4604
-     * Remove the cache
4605
-     *
4606
-     * @return bool Success status
4607
-     */
4608
-    public function unlink() {
4609
-        return $this->cache->set($this->name, null);
4610
-    }
4473
+	/**
4474
+	 * Redis instance
4475
+	 *
4476
+	 * @var \Redis
4477
+	 */
4478
+	protected $cache;
4479
+
4480
+	/**
4481
+	 * Options
4482
+	 *
4483
+	 * @var array
4484
+	 */
4485
+	protected $options;
4486
+
4487
+	/**
4488
+	 * Cache name
4489
+	 *
4490
+	 * @var string
4491
+	 */
4492
+	protected $name;
4493
+
4494
+	/**
4495
+	 * Cache Data
4496
+	 *
4497
+	 * @var type
4498
+	 */
4499
+	protected $data;
4500
+
4501
+	/**
4502
+	 * Create a new cache object
4503
+	 *
4504
+	 * @param string $location Location string (from SimplePie::$cache_location)
4505
+	 * @param string $name Unique ID for the cache
4506
+	 * @param string $type Either TYPE_FEED for SimplePie data, or TYPE_IMAGE for image data
4507
+	 */
4508
+	public function __construct($location, $name, $options = null) {
4509
+		//$this->cache = \flow\simple\cache\Redis::getRedisClientInstance();
4510
+		$parsed = SimplePie_Cache::parse_URL($location);
4511
+		$redis = new Redis();
4512
+		$redis->connect($parsed['host'], $parsed['port']);
4513
+		$this->cache = $redis;
4514
+
4515
+		if (!is_null($options) && is_array($options)) {
4516
+			$this->options = $options;
4517
+		} else {
4518
+			$this->options = array (
4519
+				'prefix' => 'rss:simple_primary:',
4520
+				'expire' => 0,
4521
+			);
4522
+		}
4523
+
4524
+		$this->name = $this->options['prefix'] . $name;
4525
+	}
4526
+
4527
+	/**
4528
+	 * @param \Redis $cache
4529
+	 */
4530
+	public function setRedisClient(\Redis $cache) {
4531
+		$this->cache = $cache;
4532
+	}
4533
+
4534
+	/**
4535
+	 * Save data to the cache
4536
+	 *
4537
+	 * @param array|SimplePie $data Data to store in the cache. If passed a SimplePie object, only cache the $data property
4538
+	 * @return bool Successfulness
4539
+	 */
4540
+	public function save($data) {
4541
+		if ($data instanceof SimplePie) {
4542
+			$data = $data->data;
4543
+		}
4544
+		$response = $this->cache->set($this->name, serialize($data));
4545
+		if ($this->options['expire']) {
4546
+			$this->cache->expire($this->name, $this->options['expire']);
4547
+		}
4548
+
4549
+		return $response;
4550
+	}
4551
+
4552
+	/**
4553
+	 * Retrieve the data saved to the cache
4554
+	 *
4555
+	 * @return array Data for SimplePie::$data
4556
+	 */
4557
+	public function load() {
4558
+		$data = $this->cache->get($this->name);
4559
+
4560
+		if ($data !== false) {
4561
+			return unserialize($data);
4562
+		}
4563
+		return false;
4564
+	}
4565
+
4566
+	/**
4567
+	 * Retrieve the last modified time for the cache
4568
+	 *
4569
+	 * @return int Timestamp
4570
+	 */
4571
+	public function mtime() {
4572
+
4573
+		$data = $this->cache->get($this->name);
4574
+
4575
+		if ($data !== false) {
4576
+			return time();
4577
+		}
4578
+
4579
+		return false;
4580
+	}
4581
+
4582
+	/**
4583
+	 * Set the last modified time to the current time
4584
+	 *
4585
+	 * @return bool Success status
4586
+	 */
4587
+	public function touch() {
4588
+
4589
+		$data = $this->cache->get($this->name);
4590
+
4591
+		if ($data !== false) {
4592
+			$return = $this->cache->set($this->name, $data);
4593
+			if ($this->options['expire']) {
4594
+				return $this->cache->expire($this->name, $this->ttl);
4595
+			}
4596
+			return $return;
4597
+		}
4598
+
4599
+		return false;
4600
+	}
4601
+
4602
+	/**
4603
+	 * Remove the cache
4604
+	 *
4605
+	 * @return bool Success status
4606
+	 */
4607
+	public function unlink() {
4608
+		return $this->cache->set($this->name, null);
4609
+	}
4611 4610
 
4612 4611
 }
4613 4612
 
@@ -8269,9 +8268,9 @@  discard block
 block discarded – undo
8269 8268
 	 * Clean up
8270 8269
 	 */
8271 8270
 	public function __destruct() {
8272
-	    $this->set_iri(null, true);
8273
-	    $this->set_path(null, true);
8274
-	    $this->set_authority(null, true);
8271
+		$this->set_iri(null, true);
8272
+		$this->set_path(null, true);
8273
+		$this->set_authority(null, true);
8275 8274
 	}
8276 8275
 
8277 8276
 	/**
@@ -8794,9 +8793,9 @@  discard block
 block discarded – undo
8794 8793
 		// Relative urls cannot have a colon in the first path segment (and the
8795 8794
 		// slashes themselves are not included so skip the first character).
8796 8795
 		if (!$this->scheme && !$isauthority &&
8797
-		    strpos($this->ipath, ':') !== false &&
8798
-		    strpos($this->ipath, '/', 1) !== false &&
8799
-		    strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false;
8796
+			strpos($this->ipath, ':') !== false &&
8797
+			strpos($this->ipath, '/', 1) !== false &&
8798
+			strpos($this->ipath, ':') < strpos($this->ipath, '/', 1)) return false;
8800 8799
 
8801 8800
 		return true;
8802 8801
 	}
@@ -9469,7 +9468,7 @@  discard block
 block discarded – undo
9469 9468
 			$fn = 'md5';
9470 9469
 		}
9471 9470
 		return call_user_func($fn,
9472
-		       $this->get_permalink().$this->get_title().$this->get_content());
9471
+			   $this->get_permalink().$this->get_title().$this->get_content());
9473 9472
 	}
9474 9473
 
9475 9474
 	/**
@@ -9538,47 +9537,47 @@  discard block
 block discarded – undo
9538 9537
 	public function get_description($description_only = false)
9539 9538
 	{
9540 9539
 		if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'summary')) &&
9541
-		    ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
9540
+			($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
9542 9541
 		{
9543 9542
 			return $return;
9544 9543
 		}
9545 9544
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'summary')) &&
9546
-		        ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
9545
+				($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
9547 9546
 		{
9548 9547
 			return $return;
9549 9548
 		}
9550 9549
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'description')) &&
9551
-		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0]))))
9550
+				($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_MAYBE_HTML, $this->get_base($tags[0]))))
9552 9551
 		{
9553 9552
 			return $return;
9554 9553
 		}
9555 9554
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'description')) &&
9556
-		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
9555
+				($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
9557 9556
 		{
9558 9557
 			return $return;
9559 9558
 		}
9560 9559
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'description')) &&
9561
-		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
9560
+				($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
9562 9561
 		{
9563 9562
 			return $return;
9564 9563
 		}
9565 9564
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'description')) &&
9566
-		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
9565
+				($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
9567 9566
 		{
9568 9567
 			return $return;
9569 9568
 		}
9570 9569
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'summary')) &&
9571
-		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
9570
+				($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
9572 9571
 		{
9573 9572
 			return $return;
9574 9573
 		}
9575 9574
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'subtitle')) &&
9576
-		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
9575
+				($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)))
9577 9576
 		{
9578 9577
 			return $return;
9579 9578
 		}
9580 9579
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'description')) &&
9581
-		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML)))
9580
+				($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML)))
9582 9581
 		{
9583 9582
 			return $return;
9584 9583
 		}
@@ -9610,17 +9609,17 @@  discard block
 block discarded – undo
9610 9609
 	public function get_content($content_only = false)
9611 9610
 	{
9612 9611
 		if (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'content')) &&
9613
-		    ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
9612
+			($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_10_content_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
9614 9613
 		{
9615 9614
 			return $return;
9616 9615
 		}
9617 9616
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'content')) &&
9618
-		        ($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
9617
+				($return = $this->sanitize($tags[0]['data'], $this->registry->call('Misc', 'atom_03_construct_type', array($tags[0]['attribs'])), $this->get_base($tags[0]))))
9619 9618
 		{
9620 9619
 			return $return;
9621 9620
 		}
9622 9621
 		elseif (($tags = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_10_MODULES_CONTENT, 'encoded')) &&
9623
-		        ($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
9622
+				($return = $this->sanitize($tags[0]['data'], SIMPLEPIE_CONSTRUCT_HTML, $this->get_base($tags[0]))))
9624 9623
 		{
9625 9624
 			return $return;
9626 9625
 		}
@@ -12335,8 +12334,8 @@  discard block
 block discarded – undo
12335 12334
 			$sniffer = $this->registry->create('Content_Type_Sniffer', array($file));
12336 12335
 			$sniffed = $sniffer->get_type();
12337 12336
 			$mime_types = array('application/rss+xml', 'application/rdf+xml',
12338
-			                    'text/rdf', 'application/atom+xml', 'text/xml',
12339
-			                    'application/xml', 'application/x-rss+xml');
12337
+								'text/rdf', 'application/atom+xml', 'text/xml',
12338
+								'application/xml', 'application/x-rss+xml');
12340 12339
 			if ($check_html)
12341 12340
 			{
12342 12341
 				$mime_types[] = 'text/html';
@@ -12510,12 +12509,12 @@  discard block
 block discarded – undo
12510 12509
 		if ($this->dom === null)
12511 12510
 		{
12512 12511
 			throw new SimplePie_Exception('DOMDocument not found, unable to use '.
12513
-			                              'locator');
12512
+										  'locator');
12514 12513
 		}
12515 12514
 		if (!class_exists('DOMXpath'))
12516 12515
 		{
12517 12516
 			throw new SimplePie_Exception('DOMXpath not found, unable to use '.
12518
-			                              'get_rel_link');
12517
+										  'get_rel_link');
12519 12518
 		}
12520 12519
 
12521 12520
 		$xpath = new DOMXpath($this->dom);
@@ -12525,22 +12524,22 @@  discard block
 block discarded – undo
12525 12524
 			$href = trim($link->getAttribute('href'));
12526 12525
 			$parsed = $this->registry->call('Misc', 'parse_url', array($href));
12527 12526
 			if ($parsed['scheme'] === '' ||
12528
-			    preg_match('/^https?$/i', $parsed['scheme']))
12527
+				preg_match('/^https?$/i', $parsed['scheme']))
12529 12528
 			{
12530 12529
 				if (method_exists($link, 'getLineNo') &&
12531
-				    $this->base_location < $link->getLineNo())
12530
+					$this->base_location < $link->getLineNo())
12532 12531
 				{
12533 12532
 					$href =
12534 12533
 						$this->registry->call('Misc', 'absolutize_url',
12535
-						                      array(trim($link->getAttribute('href')),
12536
-						                            $this->base));
12534
+											  array(trim($link->getAttribute('href')),
12535
+													$this->base));
12537 12536
 				}
12538 12537
 				else
12539 12538
 				{
12540 12539
 					$href =
12541 12540
 						$this->registry->call('Misc', 'absolutize_url',
12542
-						                      array(trim($link->getAttribute('href')),
12543
-						                            $this->http_base));
12541
+											  array(trim($link->getAttribute('href')),
12542
+													$this->http_base));
12544 12543
 				}
12545 12544
 				if ($href === false)
12546 12545
 				{
@@ -16630,9 +16629,9 @@  discard block
 block discarded – undo
16630 16629
 		}
16631 16630
 		$channel = array('channel' => array(array('child' => array('' =>
16632 16631
 			array('link' => $link, 'image' => $image, 'title' => $feed_title,
16633
-			      'item' => $items)))));
16632
+				  'item' => $items)))));
16634 16633
 		$rss = array(array('attribs' => array('' => array('version' => '2.0')),
16635
-		                   'child' => array('' => $channel)));
16634
+						   'child' => array('' => $channel)));
16636 16635
 		$this->data = array('child' => array('' => array('rss' => $rss)));
16637 16636
 		return true;
16638 16637
 	}
Please login to merge, or discard this patch.
install/index.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -345,14 +345,14 @@  discard block
 block discarded – undo
345 345
 				</tr>
346 346
 				<!--
347 347
 		<?php
348
-		    if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
349
-			    require_once(dirname(__FILE__).'/../require/class.Connection.php');
350
-			    $Connection = new Connection();
348
+			if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
349
+				require_once(dirname(__FILE__).'/../require/class.Connection.php');
350
+				$Connection = new Connection();
351 351
 		?>
352 352
 			-->
353 353
 		<?php
354 354
 			if ($Connection->db != NULL) {
355
-			    if ($Connection->tableExists('source_location')) {
355
+				if ($Connection->tableExists('source_location')) {
356 356
 				require_once(dirname(__FILE__).'/../require/class.Source.php');
357 357
 				$Source = new Source();
358 358
 				//$alllocations = $Source->getAllLocationInfo();
@@ -372,9 +372,9 @@  discard block
 block discarded – undo
372 372
 		
373 373
 		<?php
374 374
 				}
375
-			    }
375
+				}
376
+			}
376 377
 			}
377
-		    }
378 378
 		?>
379 379
 
380 380
 				<tr>
@@ -484,12 +484,12 @@  discard block
 block discarded – undo
484 484
 ?>
485 485
 							<tr>
486 486
 								<?php
487
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
487
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
488 488
 								?>
489 489
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
490 490
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
491 491
 								<?php
492
-								    } else {
492
+									} else {
493 493
 									$hostport = explode(':',$source['host']);
494 494
 									if (isset($hostport[1])) {
495 495
 										$host = $hostport[0];
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
503 503
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td>
504 504
 								<?php
505
-								    }
505
+									}
506 506
 								?>
507 507
 								<td>
508 508
 									<select name="format[]" id="format">
@@ -639,9 +639,9 @@  discard block
 block discarded – undo
639 639
 			    </thead>
640 640
 			    <tbody>
641 641
 				<?php
642
-				    if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
642
+					if (isset($globalNewsFeeds) && !empty($globalNewsFeeds)) {
643 643
 					foreach ($globalNewsFeeds as $type => $feedslng) {
644
-					    foreach ($feedslng as $lng => $feeds) {
644
+						foreach ($feedslng as $lng => $feeds) {
645 645
 						foreach ($feeds as $feed) {
646 646
 				?>
647 647
 				<tr>
@@ -666,9 +666,9 @@  discard block
 block discarded – undo
666 666
 				
667 667
 				<?php
668 668
 						}
669
-					    }
669
+						}
670
+					}
670 671
 					}
671
-				    }
672 672
 				?>
673 673
 				<tr>
674 674
 				    <td><input type="url" name="newsurl[]" /></td>
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
 			<br />
1010 1010
 			<p>
1011 1011
 			<?php 
1012
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
1012
+				if (extension_loaded('gd') && function_exists('gd_info')) {
1013 1013
 			?>
1014 1014
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
1015 1015
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -1019,11 +1019,11 @@  discard block
 block discarded – undo
1019 1019
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
1020 1020
 			<?php
1021 1021
 				}
1022
-			    } else {
1022
+				} else {
1023 1023
 			?>
1024 1024
 				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
1025 1025
 			<?php
1026
-			    }
1026
+				}
1027 1027
 			?>
1028 1028
 			</p>
1029 1029
 			<br />
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 	</p>
1048 1048
 <?php
1049 1049
 	require('../footer.php');
1050
-        exit;
1050
+		exit;
1051 1051
 }
1052 1052
 // '	
1053 1053
 $settings = array();
@@ -1138,8 +1138,8 @@  discard block
 block discarded – undo
1138 1138
 	
1139 1139
 	$sources = array();
1140 1140
 	foreach ($source_name as $keys => $name) {
1141
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1142
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1141
+		if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1142
+		else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1143 1143
 	}
1144 1144
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1145 1145
 
@@ -1149,13 +1149,13 @@  discard block
 block discarded – undo
1149 1149
 	
1150 1150
 	$newsfeeds = array();
1151 1151
 	foreach($newsurl as $newskey => $url) {
1152
-	    if ($url != '') {
1152
+		if ($url != '') {
1153 1153
 		$type = $newstype[$newskey];
1154 1154
 		$lng = $newslng[$newskey];
1155 1155
 		if (isset($newsfeeds[$type][$lng])) {
1156
-		    $newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1156
+			$newsfeeds[$type][$lng] = array_merge($newsfeeds[$type][$lng],array($url));
1157 1157
 		} else $newsfeeds[$type][$lng] = array($url);
1158
-	    }
1158
+		}
1159 1159
 	}
1160 1160
 	$settings = array_merge($settings,array('globalNewsFeeds' => $newsfeeds));
1161 1161
 
@@ -1567,14 +1567,14 @@  discard block
 block discarded – undo
1567 1567
 
1568 1568
 	// Set some defaults values...
1569 1569
 	if (!isset($globalAircraftImageSources)) {
1570
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1571
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1570
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1571
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1572 1572
 	}
1573 1573
 
1574 1574
 	if (!isset($globalSchedulesSources)) {
1575
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1576
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1577
-    	}
1575
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1576
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1577
+		}
1578 1578
 
1579 1579
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1580 1580
 
@@ -1622,21 +1622,21 @@  discard block
 block discarded – undo
1622 1622
 	$popi = false;
1623 1623
 	$popw = false;
1624 1624
 	foreach ($_SESSION['done'] as $done) {
1625
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1626
-	    if ($done == 'Create database') $pop = true;
1627
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1628
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1629
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1625
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1626
+		if ($done == 'Create database') $pop = true;
1627
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1628
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1629
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1630 1630
 	}
1631 1631
 	if ($pop) {
1632
-	    sleep(5);
1633
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1632
+		sleep(5);
1633
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1634 1634
 	} else if ($popi) {
1635
-	    sleep(5);
1636
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1635
+		sleep(5);
1636
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1637 1637
 	} else if ($popw) {
1638
-	    sleep(5);
1639
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1638
+		sleep(5);
1639
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1640 1640
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1641 1641
 	print '</div></ul>';
1642 1642
 	print '<div id="error"></div>';
@@ -1702,7 +1702,7 @@  discard block
 block discarded – undo
1702 1702
 	unset($_COOKIE['install']);
1703 1703
 	print '<div class="info column"><ul>';
1704 1704
 	foreach ($_SESSION['done'] as $done) {
1705
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1705
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1706 1706
 	}
1707 1707
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1708 1708
 	print '</ul></div>';
Please login to merge, or discard this patch.
statistics.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
                 <div class="more">
255 255
             	    <?php
256 256
             	    
257
-            		if ($year != '' && $month != '') {
258
-            	    ?>
257
+					if ($year != '' && $month != '') {
258
+					?>
259 259
             	    <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 260
             	    <?php
261
-            		} else {
262
-            	    ?>
261
+					} else {
262
+					?>
263 263
             	    <a href="<?php print $globalURL; ?>/marine/statistics/type" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
264 264
             	    <?php
265
-            		}
266
-            	    ?>
265
+					}
266
+					?>
267 267
                 </div>
268 268
             </div>
269 269
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 ?>
298 298
                 <div class="more">
299 299
             	    <?php
300
-            	    /*
300
+					/*
301 301
             		if ($year != '' && $month != '') {
302 302
             	    ?>
303 303
             	    <a href="<?php print $globalURL; ?>/tracker/statistics/type/<?php echo $year; ?>/<?php echo $month ?>/" class="btn btn-default btn" role="button"><?php echo _("See full statistic"); ?>&raquo;</a>
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
             	    <?php
309 309
             		}
310 310
             		*/
311
-            	    ?>
311
+					?>
312 312
                 </div>
313 313
             </div>
314 314
     <!-- <?php print 'Time elapsed : '.(microtime(true)-$beginpage).'s' ?> -->
Please login to merge, or discard this patch.
owner-sub-menu.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 	</form>
8 8
 </div>
9 9
 <?php
10
-    if (isset($owner)) {
10
+	if (isset($owner)) {
11 11
 ?>
12 12
 <div class="sub-menu sub-menu-container">
13 13
 	<ul class="nav nav-pills">
@@ -38,5 +38,5 @@  discard block
 block discarded – undo
38 38
 	</ul>
39 39
 </div>
40 40
 <?php
41
-    }
41
+	}
42 42
 ?>
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
tsk-geojson.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
 		$id = $spotter_item['Waypoint']['@attributes']['id'];
24 24
 		if ($id == 0 || !is_numeric($id)) $id = $j;
25 25
 		$output .= '{"type": "Feature",';
26
-		    $output .= '"id": '.$id.',';
27
-		    $output .= '"properties": {';
26
+			$output .= '"id": '.$id.',';
27
+			$output .= '"properties": {';
28 28
 			$output .= '"type": "'.$spotter_item['@attributes']['type'].'",';
29 29
 			//$output .= '"id": "'.$spotter_item['Waypoint']['@attributes']['id'].'",';
30 30
 			$output .= '"name": "'.$spotter_item['Waypoint']['@attributes']['name'].'",';
@@ -35,31 +35,31 @@  discard block
 block discarded – undo
35 35
 			} elseif ($spotter_item['@attributes']['type'] == 'Finish') {
36 36
 				$output .= '"icon": "/images/tsk/tsk-finish.png"';
37 37
 			} else $output .= '"icon": "/images/tsk/number_'.$id.'.png"';
38
-		    $output .= '},';
39
-		    $output .= '"geometry": {';
38
+			$output .= '},';
39
+			$output .= '"geometry": {';
40 40
 			$output .= '"type": "Point",';
41 41
 			$output .= '"coordinates": [';
42
-			    $output .= $spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'];
42
+				$output .= $spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'];
43 43
 			$output .= ']';
44
-		    $output .= '}';
44
+			$output .= '}';
45 45
 		$output .= '},';
46 46
 		$j++;
47 47
 	}
48 48
 	// Lines
49 49
 	$output .= '{"type": "Feature",';
50
-	    $output .= '"properties": {';
50
+		$output .= '"properties": {';
51 51
 		$output .= '"type": "'.$spotter_array['@attributes']['type'].'"';
52
-	    $output .= '},';
53
-	    $output .= '"geometry": {';
52
+		$output .= '},';
53
+		$output .= '"geometry": {';
54 54
 		$output .= '"type": "LineString",';
55 55
 		$output .= '"coordinates": [';
56 56
 	foreach($spotter_array['Point'] as $spotter_item)
57 57
 	{
58
-			    $output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],';
58
+				$output .= '['.$spotter_item['Waypoint']['Location']['@attributes']['longitude'].', '.$spotter_item['Waypoint']['Location']['@attributes']['latitude'].'],';
59 59
 	}
60 60
 	$output  = substr($output, 0, -1);
61 61
 		$output .= ']';
62
-	    $output .= '}';
62
+		$output .= '}';
63 63
 	$output .= '},';
64 64
 	$output  = substr($output, 0, -1);
65 65
 }
Please login to merge, or discard this patch.
require/class.SpotterImport.php 1 patch
Indentation   +423 added lines, -423 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 require_once(dirname(__FILE__).'/class.Source.php');
10 10
 require_once(dirname(__FILE__).'/class.GeoidHeight.php');
11 11
 if (isset($globalServerAPRS) && $globalServerAPRS) {
12
-    require_once(dirname(__FILE__).'/class.APRS.php');
12
+	require_once(dirname(__FILE__).'/class.APRS.php');
13 13
 }
14 14
 
15 15
 class SpotterImport {
16
-    private $all_flights = array();
17
-    private $last_delete_hourly = 0;
18
-    private $last_delete = 0;
19
-    private $stats = array();
20
-    private $tmd = 0;
21
-    private $source_location = array();
22
-    public $db = null;
23
-    public $nb = 0;
16
+	private $all_flights = array();
17
+	private $last_delete_hourly = 0;
18
+	private $last_delete = 0;
19
+	private $stats = array();
20
+	private $tmd = 0;
21
+	private $source_location = array();
22
+	public $db = null;
23
+	public $nb = 0;
24 24
 
25
-    public function __construct($dbc = null) {
25
+	public function __construct($dbc = null) {
26 26
 	global $globalBeta, $globalServerAPRS, $APRSSpotter, $globalNoDB, $GeoidClass, $globalDebug, $globalGeoid;
27 27
 	if (!(isset($globalNoDB) && $globalNoDB)) {
28 28
 		$Connection = new Connection($dbc);
@@ -34,14 +34,14 @@  discard block
 block discarded – undo
34 34
 		$currentdate = date('Y-m-d');
35 35
 		$sourcestat = $Stats->getStatsSource($currentdate);
36 36
 		if (!empty($sourcestat)) {
37
-		    foreach($sourcestat as $srcst) {
38
-		    	$type = $srcst['stats_type'];
37
+			foreach($sourcestat as $srcst) {
38
+				$type = $srcst['stats_type'];
39 39
 			if ($type == 'polar' || $type == 'hist') {
40
-			    $source = $srcst['source_name'];
41
-			    $data = $srcst['source_data'];
42
-			    $this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
-	    		}
44
-		    }
40
+				$source = $srcst['source_name'];
41
+				$data = $srcst['source_data'];
42
+				$this->stats[$currentdate][$source][$type] = json_decode($data,true);
43
+				}
44
+			}
45 45
 		}
46 46
 	}
47 47
 	if (isset($globalServerAPRS) && $globalServerAPRS) {
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 			$GeoidClass = FALSE;
57 57
 		}
58 58
 	}
59
-    }
59
+	}
60 60
 
61
-    public function get_Schedule($id,$ident) {
61
+	public function get_Schedule($id,$ident) {
62 62
 	global $globalDebug, $globalFork, $globalSchedulesFetch;
63 63
 	// Get schedule here, so it's done only one time
64 64
 	
@@ -78,42 +78,42 @@  discard block
 block discarded – undo
78 78
 	$operator = $Spotter->getOperator($ident);
79 79
 	$scheduleexist = false;
80 80
 	if ($Schedule->checkSchedule($operator) == 0) {
81
-	    $operator = $Translation->checkTranslation($ident);
82
-	    if ($Schedule->checkSchedule($operator) == 0) {
81
+		$operator = $Translation->checkTranslation($ident);
82
+		if ($Schedule->checkSchedule($operator) == 0) {
83 83
 		$schedule = $Schedule->fetchSchedule($operator);
84 84
 		if (count($schedule) > 0 && isset($schedule['DepartureTime']) && isset($schedule['ArrivalTime'])) {
85
-		    if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
-		    // Should also check if route schedule = route from DB
89
-		    if ($schedule['DepartureAirportIATA'] != '') {
85
+			if ($globalDebug) echo "-> Schedule info for ".$operator." (".$ident.")\n";
86
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $schedule['DepartureTime']));
87
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $schedule['ArrivalTime']));
88
+			// Should also check if route schedule = route from DB
89
+			if ($schedule['DepartureAirportIATA'] != '') {
90 90
 			if ($this->all_flights[$id]['departure_airport'] != $Spotter->getAirportIcao($schedule['DepartureAirportIATA'])) {
91
-			    $airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
-			    if (trim($airport_icao) != '') {
91
+				$airport_icao = $Spotter->getAirportIcao($schedule['DepartureAirportIATA']);
92
+				if (trim($airport_icao) != '') {
93 93
 				$this->all_flights[$id]['departure_airport'] = $airport_icao;
94 94
 				if ($globalDebug) echo "-> Change departure airport to ".$airport_icao." for ".$ident."\n";
95
-			    }
95
+				}
96
+			}
96 97
 			}
97
-		    }
98
-		    if ($schedule['ArrivalAirportIATA'] != '') {
98
+			if ($schedule['ArrivalAirportIATA'] != '') {
99 99
 			if ($this->all_flights[$id]['arrival_airport'] != $Spotter->getAirportIcao($schedule['ArrivalAirportIATA'])) {
100
-			    $airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
-			    if (trim($airport_icao) != '') {
100
+				$airport_icao = $Spotter->getAirportIcao($schedule['ArrivalAirportIATA']);
101
+				if (trim($airport_icao) != '') {
102 102
 				$this->all_flights[$id]['arrival_airport'] = $airport_icao;
103 103
 				if ($globalDebug) echo "-> Change arrival airport to ".$airport_icao." for ".$ident."\n";
104
-			    }
104
+				}
105 105
 			}
106
-		    }
107
-		    $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']);
106
+			}
107
+			$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']);
108 108
 		}
109
-	    } else $scheduleexist = true;
109
+		} else $scheduleexist = true;
110 110
 	} else $scheduleexist = true;
111 111
 	// close connection, at least one way will work ?
112
-       if ($scheduleexist) {
112
+	   if ($scheduleexist) {
113 113
 		if ($globalDebug) echo "-> get arrival/departure airport info for ".$ident."\n";
114
-    		$sch = $Schedule->getSchedule($operator);
114
+			$sch = $Schedule->getSchedule($operator);
115 115
 		$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']));
116
-       }
116
+	   }
117 117
 	$Spotter->db = null;
118 118
 	$Schedule->db = null;
119 119
 	$Translation->db = null;
@@ -128,78 +128,78 @@  discard block
 block discarded – undo
128 128
 	}
129 129
 	  */
130 130
 	}
131
-    }
131
+	}
132 132
 
133
-    public function checkAll() {
133
+	public function checkAll() {
134 134
 	global $globalDebug, $globalNoImport;
135 135
 	if ($globalDebug) echo "Update last seen flights data...\n";
136 136
 	if (!isset($globalNoImport) || $globalNoImport === FALSE) {
137
-	    foreach ($this->all_flights as $key => $flight) {
137
+		foreach ($this->all_flights as $key => $flight) {
138 138
 		if (isset($this->all_flights[$key]['id'])) {
139
-		    //echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140
-    		    $Spotter = new Spotter($this->db);
141
-        	    $real_arrival = $this->arrival($key);
142
-        	    if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']);
143
-        	}
144
-	    }
139
+			//echo $this->all_flights[$key]['id'].' - '.$this->all_flights[$key]['latitude'].'  '.$this->all_flights[$key]['longitude']."\n";
140
+				$Spotter = new Spotter($this->db);
141
+				$real_arrival = $this->arrival($key);
142
+				if (isset($this->all_flights[$key]['altitude']) && isset($this->all_flights[$key]['datetime'])) $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']);
143
+			}
144
+		}
145
+	}
145 146
 	}
146
-    }
147 147
 
148
-    public function arrival($key) {
148
+	public function arrival($key) {
149 149
 	global $globalClosestMinDist, $globalDebug;
150 150
 	if ($globalDebug) echo 'Update arrival...'."\n";
151 151
 	$Spotter = new Spotter($this->db);
152
-        $airport_icao = '';
153
-        $airport_time = '';
154
-        if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
152
+		$airport_icao = '';
153
+		$airport_time = '';
154
+		if (!isset($globalClosestMinDist) || $globalClosestMinDist == '') $globalClosestMinDist = 50;
155 155
 	if ($this->all_flights[$key]['latitude'] != '' && $this->all_flights[$key]['longitude'] != '') {
156
-	    $closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
-    	    if (isset($closestAirports[0])) {
158
-        	if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159
-        	    $airport_icao = $closestAirports[0]['icao'];
160
-        	    $airport_time = $this->all_flights[$key]['datetime'];
161
-        	    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
162
-        	} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163
-        	    foreach ($closestAirports as $airport) {
164
-        		if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165
-        		    $airport_icao = $airport['icao'];
166
-        		    $airport_time = $this->all_flights[$key]['datetime'];
167
-        		    if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
168
-        		    break;
169
-        		}
170
-        	    }
171
-        	} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
172
-        		$airport_icao = $closestAirports[0]['icao'];
173
-        		$airport_time = $this->all_flights[$key]['datetime'];
174
-        	} else {
175
-        		if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
176
-        	}
177
-    	    } else {
178
-    		    if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
179
-    	    }
156
+		$closestAirports = $Spotter->closestAirports($this->all_flights[$key]['latitude'],$this->all_flights[$key]['longitude'],$globalClosestMinDist);
157
+			if (isset($closestAirports[0])) {
158
+			if (isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] == $closestAirports[0]['icao']) {
159
+				$airport_icao = $closestAirports[0]['icao'];
160
+				$airport_time = $this->all_flights[$key]['datetime'];
161
+				if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
162
+			} elseif (count($closestAirports > 1) && isset($this->all_flights[$key]['arrival_airport']) && $this->all_flights[$key]['arrival_airport'] != '') {
163
+				foreach ($closestAirports as $airport) {
164
+				if ($this->all_flights[$key]['arrival_airport'] == $airport['icao']) {
165
+					$airport_icao = $airport['icao'];
166
+					$airport_time = $this->all_flights[$key]['datetime'];
167
+					if ($globalDebug) echo "---++ Find arrival airport. airport_icao : ".$airport_icao."\n";
168
+					break;
169
+				}
170
+				}
171
+			} elseif ($this->all_flights[$key]['altitude'] == 0 || ($this->all_flights[$key]['altitude_real'] != '' && ($closestAirports[0]['altitude'] < $this->all_flights[$key]['altitude_real'] && $this->all_flights[$key]['altitude_real'] < $closestAirports[0]['altitude']+5000))) {
172
+				$airport_icao = $closestAirports[0]['icao'];
173
+				$airport_time = $this->all_flights[$key]['datetime'];
174
+			} else {
175
+				if ($globalDebug) echo "----- Can't find arrival airport. Airport altitude : ".$closestAirports[0]['altitude'].' - flight altitude : '.$this->all_flights[$key]['altitude_real']."\n";
176
+			}
177
+			} else {
178
+				if ($globalDebug) echo "----- No Airport near last coord. Latitude : ".$this->all_flights[$key]['latitude'].' - Longitude : '.$this->all_flights[$key]['longitude'].' - MinDist : '.$globalClosestMinDist."\n";
179
+			}
180 180
 
181
-        } else {
182
-        	if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183
-        }
184
-        return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
-    }
181
+		} else {
182
+			if ($globalDebug) echo "---- No latitude or longitude. Ident : ".$this->all_flights[$key]['ident']."\n";
183
+		}
184
+		return array('airport_icao' => $airport_icao,'airport_time' => $airport_time);
185
+	}
186 186
 
187 187
 
188 188
 
189
-    public function del() {
189
+	public function del() {
190 190
 	global $globalDebug, $globalNoImport, $globalNoDB;
191 191
 	// Delete old infos
192 192
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
193 193
 	foreach ($this->all_flights as $key => $flight) {
194
-	    if (isset($flight['lastupdate'])) {
194
+		if (isset($flight['lastupdate'])) {
195 195
 		if ($flight['lastupdate'] < (time()-1800)) {
196
-		    $this->delKey($key);
196
+			$this->delKey($key);
197 197
 		}
198
-	    }
198
+		}
199
+	}
199 200
 	}
200
-    }
201 201
 
202
-    public function delKey($key) {
202
+	public function delKey($key) {
203 203
 	global $globalDebug, $globalNoImport, $globalNoDB;
204 204
 	// Delete old infos
205 205
 	if (isset($this->all_flights[$key]['id'])) {
@@ -214,9 +214,9 @@  discard block
 block discarded – undo
214 214
 		}
215 215
 	}
216 216
 	unset($this->all_flights[$key]);
217
-    }
217
+	}
218 218
 
219
-    public function add($line) {
219
+	public function add($line) {
220 220
 	global $globalPilotIdAccept, $globalAirportAccept, $globalAirlineAccept, $globalAirlineIgnore, $globalAirportIgnore, $globalFork, $globalDistanceIgnore, $globalDaemon, $globalSBS1update, $globalDebug, $globalIVAO, $globalVATSIM, $globalphpVMS, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAirlinesSource, $globalVAM, $globalAllFlights, $globalServerAPRS, $APRSSpotter, $globalNoImport, $globalNoDB, $globalVA, $globalAircraftMaxUpdate, $globalAircraftMinUpdate, $globalLiveInterval, $GeoidClass, $globalArchive;
221 221
 	//if (!isset($globalDebugTimeElapsed) || $globalDebugTimeElapsed == '') $globalDebugTimeElapsed = FALSE;
222 222
 	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.01';
@@ -242,20 +242,20 @@  discard block
 block discarded – undo
242 242
 	
243 243
 	// SBS format is CSV format
244 244
 	if(is_array($line) && (isset($line['hex']) || isset($line['id']))) {
245
-	    //print_r($line);
246
-	    if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247
-  	    if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
245
+		//print_r($line);
246
+		if (isset($line['hex'])) $line['hex'] = strtoupper($line['hex']);
247
+  		if (isset($line['id']) || (isset($line['hex']) && $line['hex'] != '' && $line['hex'] != '00000' && $line['hex'] != '000000' && $line['hex'] != '111111' && ctype_xdigit($line['hex']) && strlen($line['hex']) === 6)) {
248 248
 
249 249
 		// Increment message number
250 250
 		if (isset($line['sourcestats']) && $line['sourcestats'] === TRUE) {
251
-		    $current_date = date('Y-m-d');
252
-		    if (isset($line['source_name'])) $source = $line['source_name'];
253
-		    else $source = '';
254
-		    if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
255
-		    if (!isset($this->stats[$current_date][$source]['msg'])) {
256
-		    	$this->stats[$current_date][$source]['msg']['date'] = time();
257
-		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
251
+			$current_date = date('Y-m-d');
252
+			if (isset($line['source_name'])) $source = $line['source_name'];
253
+			else $source = '';
254
+			if ($source == '' || $line['format_source'] == 'aprs') $source = $line['format_source'];
255
+			if (!isset($this->stats[$current_date][$source]['msg'])) {
256
+				$this->stats[$current_date][$source]['msg']['date'] = time();
257
+				$this->stats[$current_date][$source]['msg']['nb'] = 1;
258
+			} else $this->stats[$current_date][$source]['msg']['nb'] += 1;
259 259
 		}
260 260
 		
261 261
 		/*
@@ -271,54 +271,54 @@  discard block
 block discarded – undo
271 271
 		//$this->db = $dbc;
272 272
 
273 273
 		//$hex = trim($line['hex']);
274
-	        if (!isset($line['id'])) $id = trim($line['hex']);
275
-	        else $id = trim($line['id']);
274
+			if (!isset($line['id'])) $id = trim($line['hex']);
275
+			else $id = trim($line['id']);
276 276
 		
277 277
 		if (!isset($this->all_flights[$id])) {
278
-		    if ($globalDebug) echo 'New flight...'."\n";
279
-		    $this->all_flights[$id] = array();
280
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
282
-		    if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
283
-		    if (!isset($line['id'])) {
278
+			if ($globalDebug) echo 'New flight...'."\n";
279
+			$this->all_flights[$id] = array();
280
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
281
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => '','departure_airport' => '', 'arrival_airport' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '','altitude_real' => '','altitude_previous' => '', 'heading' => '','departure_airport_time' => '','arrival_airport_time' => '','squawk' => '','route_stop' => '','registration' => '','pilot_id' => '','pilot_name' => '','waypoints' => '','ground' => '0', 'format_source' => '','source_name' => '','over_country' => '','verticalrate' => '','noarchive' => false,'putinarchive' => true,'source_type' => ''));
282
+			if (isset($globalDaemon) && $globalDaemon === FALSE) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('lastupdate' => time()));
283
+			if (!isset($line['id'])) {
284 284
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
285 285
 //			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')));
286 286
 //			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')));
287 287
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
288
-		        //else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
-		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
288
+				//else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
289
+			 } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
290
+			if ($globalAllFlights !== FALSE) $dataFound = true;
291 291
 		}
292 292
 		if (isset($line['source_type']) && $line['source_type'] != '') {
293
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
293
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_type' => $line['source_type']));
294 294
 		}
295 295
 		
296 296
 		//print_r($this->all_flights);
297 297
 		if (isset($line['hex']) && !isset($this->all_flights[$id]['hex']) && ctype_xdigit($line['hex'])) {
298
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
299
-		    //if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
298
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => trim($line['hex'])));
299
+			//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
300 300
 			//$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
301
-		    //} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
302
-		    if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
301
+			//} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => date('Y-m-d H:i:s')));
302
+			if (!isset($line['aircraft_name']) && (!isset($line['aircraft_icao']) || $line['aircraft_icao'] == '????') && $line['format_source'] != 'whazzup' && $line['format_source'] != 'vatsimtxt' && $line['format_source'] != 'pireps' && $line['format_source'] != 'phpvmacars' && $line['format_source'] != 'vam' && $line['format_source'] != 'flightgearsp' && $line['format_source'] != 'flightgearmp') {
303 303
 			$timeelapsed = microtime(true);
304 304
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
305
-			    $Spotter = new Spotter($this->db);
306
-			    if (isset($this->all_flights[$id]['source_type'])) {
305
+				$Spotter = new Spotter($this->db);
306
+				if (isset($this->all_flights[$id]['source_type'])) {
307 307
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']),$this->all_flights[$id]['source_type']);
308
-			    } else {
308
+				} else {
309 309
 				$aircraft_icao = $Spotter->getAllAircraftType(trim($line['hex']));
310
-			    }
311
-			    $Spotter->db = null;
312
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
-			    if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
310
+				}
311
+				$Spotter->db = null;
312
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getallaircrattype : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
313
+				if ($aircraft_icao != '') $this->all_flights[$id] = array_merge($this->all_flights[$id],array('aircraft_icao' => $aircraft_icao));
314 314
 			}
315
-		    }
316
-		    if ($globalAllFlights !== FALSE) $dataFound = true;
317
-		    if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
315
+			}
316
+			if ($globalAllFlights !== FALSE) $dataFound = true;
317
+			if ($globalDebug) echo "*********** New aircraft hex : ".$line['hex']." ***********\n";
318 318
 		}
319
-	        if (isset($line['id']) && !isset($line['hex'])) {
320
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
321
-	        }
319
+			if (isset($line['id']) && !isset($line['hex'])) {
320
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('hex' => ''));
321
+			}
322 322
 		if (isset($line['aircraft_icao']) && $line['aircraft_icao'] != '') {
323 323
 			$icao = $line['aircraft_icao'];
324 324
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 		}
350 350
 		//if (isset($line['datetime']) && preg_match('/^(\d{4}(?:\-\d{2}){2} \d{2}(?:\:\d{2}){2})$/',$line['datetime'])) {
351 351
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
352
-		    if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
352
+			if (!isset($this->all_flights[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_flights[$id]['datetime'])) {
353 353
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('datetime' => $line['datetime']));
354
-		    } else {
354
+			} else {
355 355
 				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";
356 356
 				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";
357 357
 				/*
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 				print_r($line);
361 361
 				*/
362 362
 				return '';
363
-		    }
363
+			}
364 364
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
365 365
 			if ($globalDebug) echo "!!! Date is too old ".$line['datetime']." for ".$this->all_flights[$id]['hex']." - format : ".$line['format_source']."!!!\n";
366 366
 			return '';
@@ -376,21 +376,21 @@  discard block
 block discarded – undo
376 376
 		}
377 377
 
378 378
 		if (isset($line['registration']) && $line['registration'] != '' && $line['registration'] != 'z.NO-REG' && $line['registration'] != 'NA') {
379
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
379
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('registration' => $line['registration']));
380 380
 		}
381 381
 		if (isset($line['waypoints']) && $line['waypoints'] != '') {
382
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
382
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('waypoints' => $line['waypoints']));
383 383
 		}
384 384
 		if (isset($line['pilot_id']) && $line['pilot_id'] != '') {
385
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
385
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_id' => trim($line['pilot_id'])));
386 386
 		}
387 387
 		if (isset($line['pilot_name']) && $line['pilot_name'] != '') {
388
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
388
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('pilot_name' => trim($line['pilot_name'])));
389 389
 		}
390 390
  
391 391
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_flights[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9]+$/', $line['ident'])) {
392 392
 
393
-		    if ($this->all_flights[$id]['addedSpotter'] == 1) {
393
+			if ($this->all_flights[$id]['addedSpotter'] == 1) {
394 394
 			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
395 395
 				if ($globalDebug) echo '---!!!! New ident, reset aircraft data...'."\n";
396 396
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -399,23 +399,23 @@  discard block
 block discarded – undo
399 399
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
400 400
 				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']));
401 401
 			} else {
402
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
403
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
402
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
403
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
404 404
 				$timeelapsed = microtime(true);
405
-            			$Spotter = new Spotter($this->db);
406
-            			$fromsource = NULL;
407
-            			if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
408
-            			elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
405
+						$Spotter = new Spotter($this->db);
406
+						$fromsource = NULL;
407
+						if (isset($globalAirlinesSource) && $globalAirlinesSource != '') $fromsource = $globalAirlinesSource;
408
+						elseif (isset($line['format_source']) && $line['format_source'] == 'vatsimtxt') $fromsource = 'vatsim';
409 409
 				elseif (isset($line['format_source']) && $line['format_source'] == 'whazzup') $fromsource = 'ivao';
410 410
 				elseif (isset($globalVATSIM) && $globalVATSIM) $fromsource = 'vatsim';
411 411
 				elseif (isset($globalIVAO) && $globalIVAO) $fromsource = 'ivao';
412
-            			$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
412
+						$result = $Spotter->updateIdentSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$fromsource);
413 413
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
414 414
 				$Spotter->db = null;
415 415
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
416
-			    }
416
+				}
417 417
 			}
418
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
418
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ident' => trim($line['ident'])));
419 419
 		    
420 420
 /*
421 421
 		    if (!isset($line['id'])) {
@@ -425,63 +425,63 @@  discard block
 block discarded – undo
425 425
 		        else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $this->all_flights[$id]['hex'].'-'.$this->all_flights[$id]['ident']));
426 426
 		     } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
427 427
   */
428
-		    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']));
428
+			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']));
429 429
 
430
-		    //$putinarchive = true;
431
-		    if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
430
+			//$putinarchive = true;
431
+			if (isset($line['departure_airport_time']) && $line['departure_airport_time'] != 0) {
432 432
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('departure_airport_time' => $line['departure_airport_time']));
433
-		    }
434
-		    if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
433
+			}
434
+			if (isset($line['arrival_airport_time']) && $line['arrival_airport_time'] != 0) {
435 435
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('arrival_airport_time' => $line['arrival_airport_time']));
436
-		    }
437
-		    if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
438
-		    		$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' => ''));
439
-		    } elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
436
+			}
437
+			if (isset($line['departure_airport_icao']) && isset($line['arrival_airport_icao'])) {
438
+					$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' => ''));
439
+			} elseif (isset($line['departure_airport_iata']) && isset($line['arrival_airport_iata'])) {
440 440
 			$timeelapsed = microtime(true);
441 441
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
442 442
 				$Spotter = new Spotter($this->db);
443 443
 				$line['departure_airport_icao'] = $Spotter->getAirportIcao($line['departure_airport_iata']);
444 444
 				$line['arrival_airport_icao'] = $Spotter->getAirportIcao($line['arrival_airport_iata']);
445
-		    		$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' => ''));
445
+					$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' => ''));
446 446
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getAirportICAO : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
447
-                        }
448
-		    } elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
447
+						}
448
+			} elseif (!isset($line['format_source']) || $line['format_source'] != 'aprs') {
449 449
 			$timeelapsed = microtime(true);
450 450
 			if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
451
-			    $Spotter = new Spotter($this->db);
452
-			    $route = $Spotter->getRouteInfo(trim($line['ident']));
453
-			    if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
451
+				$Spotter = new Spotter($this->db);
452
+				$route = $Spotter->getRouteInfo(trim($line['ident']));
453
+				if (!isset($route['fromairport_icao']) && !isset($route['toairport_icao'])) {
454 454
 				$Translation = new Translation($this->db);
455 455
 				$ident = $Translation->checkTranslation(trim($line['ident']));
456 456
 				$route = $Spotter->getRouteInfo($ident);
457 457
 				$Translation->db = null;
458
-			    }
459
-			    $Spotter->db = null;
460
-			    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
461
-                    	}
458
+				}
459
+				$Spotter->db = null;
460
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getrouteinfo : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
461
+						}
462 462
 			if (isset($route['fromairport_icao']) && isset($route['toairport_icao'])) {
463
-			    //if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
464
-			    if ($route['fromairport_icao'] != $route['toairport_icao']) {
463
+				//if ($route['FromAirport_ICAO'] != $route['ToAirport_ICAO']) {
464
+				if ($route['fromairport_icao'] != $route['toairport_icao']) {
465 465
 				//    $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']));
466
-		    		$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']));
467
-		    	    }
466
+					$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']));
467
+					}
468 468
 			}
469 469
 			if (!isset($globalFork)) $globalFork = TRUE;
470 470
 			if (!$globalVA && !$globalIVAO && !$globalVATSIM && !$globalphpVMS && !$globalVAM && (!isset($line['format_source']) || $line['format_source'] != 'aprs')) {
471 471
 				if (!isset($this->all_flights[$id]['schedule_check']) || $this->all_flights[$id]['schedule_check'] === false) $this->get_Schedule($id,trim($line['ident']));
472 472
 			}
473
-		    }
473
+			}
474 474
 		}
475 475
 
476 476
 		if (isset($line['speed']) && $line['speed'] != '' && $line['speed'] != 0) {
477 477
 		//    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => $line[12]));
478
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
479
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
480
-		    //$dataFound = true;
478
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed' => round($line['speed'])));
479
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('speed_fromsrc' => true));
480
+			//$dataFound = true;
481 481
 		} else if (!isset($this->all_flights[$id]['speed_fromsrc']) && isset($this->all_flights[$id]['time_last_coord']) && $this->all_flights[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
482
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
483
-		    if ($distance > 1000 && $distance < 10000) {
484
-		    // use datetime
482
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m');
483
+			if ($distance > 1000 && $distance < 10000) {
484
+			// use datetime
485 485
 			$speed = $distance/(time() - $this->all_flights[$id]['time_last_coord']);
486 486
 			$speed = $speed*3.6;
487 487
 			if ($speed < 1000) {
@@ -490,49 +490,49 @@  discard block
 block discarded – undo
490 490
 	  		} else {
491 491
 	  			if ($globalDebug) echo "ø IGNORED : Calculated Speed for ".$this->all_flights[$id]['hex']." : ".round($speed)." - distance : ".$distance."\n";
492 492
 	  		}
493
-		    }
493
+			}
494 494
 		}
495 495
 
496 496
 
497 497
 
498
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
499
-	    	    if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
500
-	    	    	if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
501
-	    	    	return false;
502
-	    	    }
503
-	    	    if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
504
-	    	    else unset($timediff);
505
-	    	    if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
506
-	    	    else unset($timediff_archive);
507
-	    	    if ($this->tmd > 5
508
-	    	        || (isset($line['format_source']) 
509
-	    	    	    && $line['format_source'] == 'airwhere' 
510
-	    	    	    && ((!isset($this->all_flights[$id]['latitude']) 
511
-	    	    		|| !isset($this->all_flights[$id]['longitude'])) 
512
-	    	    		|| (isset($this->all_flights[$id]['latitude']) 
513
-	    	    		    && isset($this->all_flights[$id]['longitude']) 
514
-	    	    		    && $this->all_flights[$id]['latitude'] != $line['latitude'] 
515
-	    	    		    && $this->all_flights[$id]['longitude'] != $line['longitude']
516
-	    	    		)
517
-	    	    	    )
518
-	    	    	)
519
-	    		|| (isset($globalVA) && $globalVA) 
520
-	    	    	|| (isset($globalIVAO) && $globalIVAO)
521
-	    	    	|| (isset($globalVATSIM) && $globalVATSIM)
522
-	    	    	|| (isset($globalphpVMS) && $globalphpVMS)
523
-	    	    	|| (isset($globalVAM) && $globalVAM)
524
-	    	    	|| !isset($timediff)
525
-	    	    	|| $timediff > $globalLiveInterval
526
-	    	    	|| $globalArchive
527
-	    	    	|| ($timediff > 30 
528
-	    	    	    && isset($this->all_flights[$id]['latitude']) 
529
-	    	    	    && isset($this->all_flights[$id]['longitude']) 
530
-	    	    	    && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
531
-	    	    	    )
532
-	    	    	) {
498
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
499
+				if (ctype_digit(strval($line['latitude'])) || ctype_digit(strval($line['longitude']))) {
500
+					if ($globalDebug) echo "/!\ Invalid latitude or/and longitude data : lat: ".$line['latitude']." - lng: ".$line['longitude']."\n";
501
+					return false;
502
+				}
503
+				if (isset($this->all_flights[$id]['time_last_coord'])) $timediff = round(time()-$this->all_flights[$id]['time_last_coord']);
504
+				else unset($timediff);
505
+				if (isset($this->all_flights[$id]['time_last_archive_coord'])) $timediff_archive = round(time()-$this->all_flights[$id]['time_last_archive_coord']);
506
+				else unset($timediff_archive);
507
+				if ($this->tmd > 5
508
+					|| (isset($line['format_source']) 
509
+						&& $line['format_source'] == 'airwhere' 
510
+						&& ((!isset($this->all_flights[$id]['latitude']) 
511
+						|| !isset($this->all_flights[$id]['longitude'])) 
512
+						|| (isset($this->all_flights[$id]['latitude']) 
513
+							&& isset($this->all_flights[$id]['longitude']) 
514
+							&& $this->all_flights[$id]['latitude'] != $line['latitude'] 
515
+							&& $this->all_flights[$id]['longitude'] != $line['longitude']
516
+						)
517
+						)
518
+					)
519
+				|| (isset($globalVA) && $globalVA) 
520
+					|| (isset($globalIVAO) && $globalIVAO)
521
+					|| (isset($globalVATSIM) && $globalVATSIM)
522
+					|| (isset($globalphpVMS) && $globalphpVMS)
523
+					|| (isset($globalVAM) && $globalVAM)
524
+					|| !isset($timediff)
525
+					|| $timediff > $globalLiveInterval
526
+					|| $globalArchive
527
+					|| ($timediff > 30 
528
+						&& isset($this->all_flights[$id]['latitude']) 
529
+						&& isset($this->all_flights[$id]['longitude']) 
530
+						&& $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m'))
531
+						)
532
+					) {
533 533
 
534 534
 			if ((isset($timediff) && !isset($timediff_archive)) || (isset($this->all_flights[$id]['archive_latitude']) && isset($this->all_flights[$id]['archive_longitude']) && isset($this->all_flights[$id]['livedb_latitude']) && isset($this->all_flights[$id]['livedb_longitude']))) {
535
-			    if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
535
+				if ((isset($timediff_archive) && $timediff_archive > $globalAircraftMaxUpdate)
536 536
 				|| (isset($line['format_source']) && $line['format_source'] == 'airwhere') 
537 537
 				|| !$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'])) {
538 538
 				$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
@@ -540,9 +540,9 @@  discard block
 block discarded – undo
540 540
 				$this->all_flights[$id]['putinarchive'] = true;
541 541
 				$this->tmd = 0;
542 542
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
543
-				    if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
544
-				    $timeelapsed = microtime(true);
545
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
543
+					if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_flights[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
544
+					$timeelapsed = microtime(true);
545
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
546 546
 					$Spotter = new Spotter($this->db);
547 547
 					$all_country = $Spotter->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
548 548
 					if (!empty($all_country)) $this->all_flights[$id]['over_country'] = $all_country['iso2'];
@@ -550,11 +550,11 @@  discard block
 block discarded – undo
550 550
 					$Spotter->db = null;
551 551
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
552 552
 					if ($globalDebug) echo 'FOUND : '.$this->all_flights[$id]['over_country'].' ---------------'."\n";
553
-				    }
553
+					}
554 554
 				}
555 555
 				$this->all_flights[$id]['time_last_archive_coord'] = time();
556
-			    } 
557
-			    /*
556
+				} 
557
+				/*
558 558
 			    else {
559 559
 				if (!isset($timediff)) echo 'NO TIMEDIFF';
560 560
 				else {
@@ -568,16 +568,16 @@  discard block
 block discarded – undo
568 568
 			}
569 569
 
570 570
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
571
-			    //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) {
571
+				//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) {
572 572
 				if (!isset($this->all_flights[$id]['archive_latitude'])) {
573 573
 					$this->all_flights[$id]['archive_latitude'] = $line['latitude'];
574 574
 					$this->all_flights[$id]['time_last_coord'] = time();
575 575
 				}
576 576
 				//if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
577 577
 				if (!isset($this->all_flights[$id]['livedb_latitude']) || abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_latitude']-$line['latitude']) > 0.0001)) {
578
-				    $this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
579
-				    $dataFound = true;
580
-				    $this->all_flights[$id]['time_last_coord'] = time();
578
+					$this->all_flights[$id]['livedb_latitude'] = $line['latitude'];
579
+					$dataFound = true;
580
+					$this->all_flights[$id]['time_last_coord'] = time();
581 581
 				}
582 582
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
583 583
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('latitude' => $line['latitude']));
@@ -588,24 +588,24 @@  discard block
 block discarded – undo
588 588
 				    //$putinarchive = true;
589 589
 				}
590 590
 				*/
591
-			    /*
591
+				/*
592 592
 			    } elseif (isset($this->all_flights[$id]['latitude'])) {
593 593
 				if ($globalDebug) echo '!!! Strange latitude value - diff : '.abs($this->all_flights[$id]['latitude']-$line['latitude']).'- previous lat : '.$this->all_flights[$id]['latitude'].'- new lat : '.$line['latitude']."\n";
594 594
 			    }
595 595
 			    */
596 596
 			}
597 597
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
598
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
599
-			    //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) {
598
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
599
+				//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) {
600 600
 				if (!isset($this->all_flights[$id]['archive_longitude'])) {
601 601
 					$this->all_flights[$id]['archive_longitude'] = $line['longitude'];
602 602
 					$this->all_flights[$id]['time_last_coord'] = time();
603 603
 				}
604 604
 				//if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || $this->all_flights[$id]['format_source'] == 'aprs' || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
605 605
 				if (!isset($this->all_flights[$id]['livedb_longitude']) || abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChange || ($this->all_flights[$id]['format_source'] == 'airwhere' && abs($this->all_flights[$id]['livedb_longitude']-$line['longitude']) > 0.0001)) {
606
-				    $this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
607
-				    $dataFound = true;
608
-				    $this->all_flights[$id]['time_last_coord'] = time();
606
+					$this->all_flights[$id]['livedb_longitude'] = $line['longitude'];
607
+					$dataFound = true;
608
+					$this->all_flights[$id]['time_last_coord'] = time();
609 609
 				}
610 610
 				// elseif ($globalDebug) echo '!*!*! Ignore data, too close to previous one'."\n";
611 611
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('longitude' => $line['longitude']));
@@ -623,67 +623,67 @@  discard block
 block discarded – undo
623 623
 			    */
624 624
 			}
625 625
 
626
-		    } else if ($globalDebug && $timediff > 30) {
626
+			} else if ($globalDebug && $timediff > 30) {
627 627
 			$this->tmd = $this->tmd + 1;
628 628
 			echo '!!! Too much distance in short time... for '.$this->all_flights[$id]['ident']."\n";
629 629
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')."m -";
630 630
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
631 631
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_flights[$id]['latitude'].' - prev long : '.$this->all_flights[$id]['longitude']." \n";
632
-		    }
632
+			}
633 633
 		}
634 634
 		if (isset($line['last_update']) && $line['last_update'] != '') {
635
-		    if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
636
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
635
+			if (isset($this->all_flights[$id]['last_update']) && $this->all_flights[$id]['last_update'] != $line['last_update']) $dataFound = true;
636
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('last_update' => $line['last_update']));
637 637
 		}
638 638
 		if (isset($line['verticalrate']) && $line['verticalrate'] != '') {
639
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
640
-		    //$dataFound = true;
639
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('verticalrate' => $line['verticalrate']));
640
+			//$dataFound = true;
641 641
 		}
642 642
 		if (isset($line['format_source']) && $line['format_source'] != '') {
643
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
643
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('format_source' => $line['format_source']));
644 644
 		}
645 645
 		if (isset($line['source_name']) && $line['source_name'] != '') {
646
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
646
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('source_name' => $line['source_name']));
647 647
 		}
648 648
 		if (isset($line['emergency']) && $line['emergency'] != '') {
649
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
650
-		    //$dataFound = true;
649
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('emergency' => $line['emergency']));
650
+			//$dataFound = true;
651 651
 		}
652 652
 		if (isset($line['ground']) && $line['ground'] != '') {
653
-		    if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
653
+			if (isset($this->all_flights[$id]['ground']) && $this->all_flights[$id]['ground'] == 1 && $line['ground'] == 0) {
654 654
 			// Here we force archive of flight because after ground it's a new one (or should be)
655 655
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
656 656
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 1));
657 657
 			if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $id.'-'.date('YmdHi')));
658
-		        elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
658
+				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
659 659
 			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']));
660
-		    }
661
-		    if ($line['ground'] != 1) $line['ground'] = 0;
662
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
663
-		    //$dataFound = true;
660
+			}
661
+			if ($line['ground'] != 1) $line['ground'] = 0;
662
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('ground' => $line['ground']));
663
+			//$dataFound = true;
664 664
 		}
665 665
 		if (isset($line['squawk']) && $line['squawk'] != '') {
666
-		    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'])) {
667
-			    if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
668
-			    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
669
-			    $highlight = '';
670
-			    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
671
-			    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
672
-			    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
673
-			    if ($highlight != '') {
666
+			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'])) {
667
+				if ($this->all_flights[$id]['squawk'] != $line['squawk']) $this->all_flights[$id]['putinarchive'] = true;
668
+				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
669
+				$highlight = '';
670
+				if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack at '.date('Y-m-d G:i').' UTC';
671
+				if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure) at '.date('Y-m-d G:i').' UTC';
672
+				if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency at '.date('Y-m-d G:i').' UTC';
673
+				if ($highlight != '') {
674 674
 				$timeelapsed = microtime(true);
675 675
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
676
-				    $Spotter = new Spotter($this->db);
677
-				    $Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
678
-				    $Spotter->db = null;
679
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
676
+					$Spotter = new Spotter($this->db);
677
+					$Spotter->setHighlightFlight($this->all_flights[$id]['id'],$highlight);
678
+					$Spotter->db = null;
679
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update sethighlightflight : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
680 680
 				}
681 681
 				//$putinarchive = true;
682 682
 				//$highlight = '';
683
-			    }
683
+				}
684 684
 			    
685
-		    } else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
686
-		    //$dataFound = true;
685
+			} else $this->all_flights[$id] = array_merge($this->all_flights[$id],array('squawk' => $line['squawk']));
686
+			//$dataFound = true;
687 687
 		}
688 688
 
689 689
 		if (isset($line['altitude']) && $line['altitude'] != '') {
@@ -694,13 +694,13 @@  discard block
 block discarded – undo
694 694
 					$line['altitude'] = $line['altitude'] - $geoid;
695 695
 				}
696 696
 			}
697
-		    //if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
697
+			//if (!isset($this->all_flights[$id]['altitude']) || $this->all_flights[$id]['altitude'] == '' || ($this->all_flights[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
698 698
 			if (is_int($this->all_flights[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_flights[$id]['altitude']) > 3) $this->all_flights[$id]['putinarchive'] = true;
699 699
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude' => round($line['altitude']/100)));
700 700
 			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_real' => $line['altitude']));
701 701
 			//$dataFound = true;
702
-		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
703
-		    if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
702
+			//} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
703
+			if ($globalVA !== TRUE && $globalIVAO !== TRUE && $globalVATSIM !== TRUE && $globalphpVMS !== TRUE && $globalVAM !== TRUE) {
704 704
 			if (isset($this->all_flights[$id]['over_country']) && $this->all_flights[$id]['over_country'] != '' && isset($this->all_flights[$id]['altitude_previous']) && $this->all_flights[$id]['altitude_previous'] != '' && $this->all_flights[$id]['altitude_previous'] < $this->all_flights[$id]['altitude_real'] && isset($this->all_flights[$id]['lastupdate']) && $this->all_flights[$id]['lastupdate'] < time() - 1600) {
705 705
 				if ($globalDebug) echo '--- Reset because of altitude'."\n";
706 706
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('addedSpotter' => 0));
@@ -709,27 +709,27 @@  discard block
 block discarded – undo
709 709
 				elseif (isset($line['id'])) $this->all_flights[$id] = array_merge($this->all_flights[$id],array('id' => $line['id']));
710 710
 				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']));
711 711
 			}
712
-		    }
713
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
712
+			}
713
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('altitude_previous' => $line['altitude']));
714 714
 		}
715 715
 
716 716
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
717
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
717
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('noarchive' => true));
718 718
 		}
719 719
 		
720 720
 		if (isset($line['heading']) && $line['heading'] != '') {
721
-		    if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
722
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
723
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
724
-		    //$dataFound = true;
721
+			if (is_int($this->all_flights[$id]['heading']) && abs($this->all_flights[$id]['heading']-round($line['heading'])) > 10) $this->all_flights[$id]['putinarchive'] = true;
722
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($line['heading'])));
723
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading_fromsrc' => true));
724
+			//$dataFound = true;
725 725
   		} 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']) {
726
-  		    $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']);
727
-		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
728
-		    if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
729
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
726
+  			$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']);
727
+			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => round($heading)));
728
+			if (abs($this->all_flights[$id]['heading']-round($heading)) > 10) $this->all_flights[$id]['putinarchive'] = true;
729
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_flights[$id]['hex']." : ".$heading."\n";
730 730
   		} elseif (isset($this->all_flights[$id]['format_source']) && $this->all_flights[$id]['format_source'] == 'ACARS') {
731
-  		    // If not enough messages and ACARS set heading to 0
732
-  		    $this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
731
+  			// If not enough messages and ACARS set heading to 0
732
+  			$this->all_flights[$id] = array_merge($this->all_flights[$id],array('heading' => 0));
733 733
   		}
734 734
 		if ($globalDaemon === TRUE && isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
735 735
 		elseif ($globalDaemon === TRUE && isset($globalSBS1update) && $globalSBS1update != '' && isset($this->all_flights[$id]['lastupdate']) && time()-$this->all_flights[$id]['lastupdate'] < $globalSBS1update) $dataFound = false;
@@ -742,125 +742,125 @@  discard block
 block discarded – undo
742 742
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex']) && $this->all_flights[$id]['heading'] != '' && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
743 743
 		//if ($dataFound === true && isset($this->all_flights[$id]['hex'])) {
744 744
 		if ($dataFound === true && isset($this->all_flights[$id]['id'])) {
745
-		    $this->all_flights[$id]['lastupdate'] = time();
746
-		    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
747
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
748
-			    //print_r($this->all_flights);
749
-			    //echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
750
-			    //$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
751
-			    if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
745
+			$this->all_flights[$id]['lastupdate'] = time();
746
+			if ((!isset($globalNoImport) || $globalNoImport === FALSE) && $this->all_flights[$id]['addedSpotter'] == 0) {
747
+				if (!isset($globalDistanceIgnore['latitude']) || $this->all_flights[$id]['longitude'] == ''  || $this->all_flights[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
748
+				//print_r($this->all_flights);
749
+				//echo $this->all_flights[$id]['id'].' - '.$this->all_flights[$id]['addedSpotter']."\n";
750
+				//$last_hour_ident = Spotter->getIdentFromLastHour($this->all_flights[$id]['ident']);
751
+				if (!isset($this->all_flights[$id]['forcenew']) || $this->all_flights[$id]['forcenew'] == 0) {
752 752
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
753
-				    if ($globalDebug) echo "Check if aircraft is already in DB...";
754
-				    $timeelapsed = microtime(true);
755
-				    $SpotterLive = new SpotterLive($this->db);
756
-				    if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
753
+					if ($globalDebug) echo "Check if aircraft is already in DB...";
754
+					$timeelapsed = microtime(true);
755
+					$SpotterLive = new SpotterLive($this->db);
756
+					if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt' || $line['format_source'] === 'planeupdatefaa' || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'radarvirtueljson' || $line['format_source'] === 'famaprs')) {
757 757
 					$recent_ident = $SpotterLive->checkModeSRecent($this->all_flights[$id]['hex']);
758 758
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkModeSRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
759
-				    } elseif (isset($line['id'])) {
759
+					} elseif (isset($line['id'])) {
760 760
 					$recent_ident = $SpotterLive->checkIdRecent($line['id']);
761 761
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
762
-				    } elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
762
+					} elseif (isset($this->all_flights[$id]['ident']) && $this->all_flights[$id]['ident'] != '') {
763 763
 					$recent_ident = $SpotterLive->checkIdentRecent($this->all_flights[$id]['ident']);
764 764
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
765
-				    } else $recent_ident = '';
766
-				    $SpotterLive->db=null;
767
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
768
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
765
+					} else $recent_ident = '';
766
+					$SpotterLive->db=null;
767
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
768
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
769 769
 				} else $recent_ident = '';
770
-			    } else {
770
+				} else {
771 771
 				$recent_ident = '';
772 772
 				$this->all_flights[$id] = array_merge($this->all_flights[$id],array('forcenew' => 0));
773
-			    }
774
-			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
775
-			    if($recent_ident == "")
776
-			    {
773
+				}
774
+				//if there was no aircraft with the same callsign within the last hour and go post it into the archive
775
+				if($recent_ident == "")
776
+				{
777 777
 				if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." in archive DB : ";
778 778
 				if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
779 779
 				if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
780 780
 				//adds the spotter data for the archive
781 781
 				$ignoreImport = false;
782 782
 				foreach($globalAirportIgnore as $airportIgnore) {
783
-				    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
783
+					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
784 784
 					$ignoreImport = true;
785
-				    }
785
+					}
786 786
 				}
787 787
 				if (count($globalAirportAccept) > 0) {
788
-				    $ignoreImport = true;
789
-				    foreach($globalAirportIgnore as $airportIgnore) {
788
+					$ignoreImport = true;
789
+					foreach($globalAirportIgnore as $airportIgnore) {
790 790
 					if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
791
-					    $ignoreImport = false;
791
+						$ignoreImport = false;
792
+					}
792 793
 					}
793
-				    }
794 794
 				}
795 795
 				if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
796
-				    foreach($globalAirlineIgnore as $airlineIgnore) {
796
+					foreach($globalAirlineIgnore as $airlineIgnore) {
797 797
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
798
-					    $ignoreImport = true;
798
+						$ignoreImport = true;
799
+					}
799 800
 					}
800
-				    }
801 801
 				}
802 802
 				if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
803
-				    $ignoreImport = true;
804
-				    foreach($globalAirlineAccept as $airlineAccept) {
803
+					$ignoreImport = true;
804
+					foreach($globalAirlineAccept as $airlineAccept) {
805 805
 					if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
806
-					    $ignoreImport = false;
806
+						$ignoreImport = false;
807
+					}
807 808
 					}
808
-				    }
809 809
 				}
810 810
 				if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
811
-				    $ignoreImport = true;
812
-				    foreach($globalPilotIdAccept as $pilotIdAccept) {
811
+					$ignoreImport = true;
812
+					foreach($globalPilotIdAccept as $pilotIdAccept) {
813 813
 					if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
814
-					    $ignoreImport = false;
814
+						$ignoreImport = false;
815
+					}
815 816
 					}
816
-				    }
817 817
 				}
818 818
 				
819 819
 				if (!$ignoreImport) {
820
-				    $highlight = '';
821
-				    if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
822
-				    if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
823
-				    if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
824
-				    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')));
825
-				    $timeelapsed = microtime(true);
826
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
820
+					$highlight = '';
821
+					if ($this->all_flights[$id]['squawk'] == '7500') $highlight = 'Squawk 7500 : Hijack';
822
+					if ($this->all_flights[$id]['squawk'] == '7600') $highlight = 'Squawk 7600 : Lost Comm (radio failure)';
823
+					if ($this->all_flights[$id]['squawk'] == '7700') $highlight = 'Squawk 7700 : Emergency';
824
+					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')));
825
+					$timeelapsed = microtime(true);
826
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
827 827
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
828
-					    $Spotter = new Spotter($this->db);
829
-					    $result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
830
-					    $Spotter->db = null;
831
-					    if ($globalDebug && isset($result)) echo $result."\n";
828
+						$Spotter = new Spotter($this->db);
829
+						$result = $Spotter->addSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'], $this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'],$this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$highlight,$this->all_flights[$id]['hex'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'],$this->all_flights[$id]['verticalrate'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['source_type']);
830
+						$Spotter->db = null;
831
+						if ($globalDebug && isset($result)) echo $result."\n";
832 832
 					}
833
-				    }
834
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
835
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
833
+					}
834
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
835
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
836 836
 
837
-				    // Add source stat in DB
838
-				    $Stats = new Stats($this->db);
839
-				    if (!empty($this->stats)) {
837
+					// Add source stat in DB
838
+					$Stats = new Stats($this->db);
839
+					if (!empty($this->stats)) {
840 840
 					if ($globalDebug) echo 'Add source stats : ';
841
-				        foreach($this->stats as $date => $data) {
842
-					    foreach($data as $source => $sourced) {
843
-					        //print_r($sourced);
844
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
845
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
846
-				    		if (isset($sourced['msg'])) {
847
-				    		    if (time() - $sourced['msg']['date'] > 10) {
848
-				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
849
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
850
-			    			        unset($this->stats[$date][$source]['msg']);
851
-			    			    }
852
-			    			}
853
-			    		    }
854
-			    		    if ($date != date('Y-m-d')) {
855
-			    			unset($this->stats[$date]);
856
-			    		    }
857
-				    	}
858
-				    	if ($globalDebug) echo 'Done'."\n";
841
+						foreach($this->stats as $date => $data) {
842
+						foreach($data as $source => $sourced) {
843
+							//print_r($sourced);
844
+								if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar',$date);
845
+								if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist',$date);
846
+							if (isset($sourced['msg'])) {
847
+								if (time() - $sourced['msg']['date'] > 10) {
848
+									$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
849
+									echo $Stats->addStatSource($nbmsg,$source,'msg',$date);
850
+									unset($this->stats[$date][$source]['msg']);
851
+								}
852
+							}
853
+							}
854
+							if ($date != date('Y-m-d')) {
855
+							unset($this->stats[$date]);
856
+							}
857
+						}
858
+						if ($globalDebug) echo 'Done'."\n";
859 859
 
860
-				    }
861
-				    $Stats->db = null;
862
-				    }
863
-				    $this->del();
860
+					}
861
+					$Stats->db = null;
862
+					}
863
+					$this->del();
864 864
 				} elseif ($globalDebug) echo 'Ignore data'."\n";
865 865
 				//$ignoreImport = false;
866 866
 				$this->all_flights[$id]['addedSpotter'] = 1;
@@ -878,41 +878,41 @@  discard block
 block discarded – undo
878 878
 			*/
879 879
 			//SpotterLive->deleteLiveSpotterDataByIdent($this->all_flights[$id]['ident']);
880 880
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
881
-				    if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
882
-				    //SpotterLive->deleteLiveSpotterDataNotUpdated();
883
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
881
+					if ($globalDebug) echo "---- Deleting Live Spotter data older than 9 hours...";
882
+					//SpotterLive->deleteLiveSpotterDataNotUpdated();
883
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
884 884
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
885
-					    $SpotterLive = new SpotterLive($this->db);
886
-					    $SpotterLive->deleteLiveSpotterData();
887
-					    $SpotterLive->db=null;
885
+						$SpotterLive = new SpotterLive($this->db);
886
+						$SpotterLive->deleteLiveSpotterData();
887
+						$SpotterLive->db=null;
888 888
 					}
889
-				    }
890
-				    if ($globalDebug) echo " Done\n";
891
-				    $this->last_delete = time();
889
+					}
890
+					if ($globalDebug) echo " Done\n";
891
+					$this->last_delete = time();
892 892
 				}
893
-			    } else {
893
+				} else {
894 894
 				if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt'|| $line['format_source'] === 'planeupdatefaa'  || $line['format_source'] === 'aprs' || $line['format_source'] === 'aircraftlistjson' || $line['format_source'] === 'famaprs' || $line['format_source'] === 'airwhere')) {
895
-				    $this->all_flights[$id]['id'] = $recent_ident;
896
-				    $this->all_flights[$id]['addedSpotter'] = 1;
895
+					$this->all_flights[$id]['id'] = $recent_ident;
896
+					$this->all_flights[$id]['addedSpotter'] = 1;
897 897
 				}
898 898
 				if (isset($globalDaemon) && !$globalDaemon) {
899
-				    if (!isset($globalNoImport) || $globalNoImport === FALSE) {
899
+					if (!isset($globalNoImport) || $globalNoImport === FALSE) {
900 900
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
901
-					    $Spotter = new Spotter($this->db);
902
-					    $Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
903
-					    $Spotter->db = null;
901
+						$Spotter = new Spotter($this->db);
902
+						$Spotter->updateLatestSpotterData($this->all_flights[$id]['id'],$this->all_flights[$id]['ident'],$this->all_flights[$id]['latitude'],$this->all_flights[$id]['longitude'],$this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'],$this->all_flights[$id]['ground'],$this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'],$this->all_flights[$id]['arrival_airport'],$this->all_flights[$id]['arrival_airport_time']);
903
+						$Spotter->db = null;
904
+					}
904 905
 					}
905
-				    }
906 906
 				}
907 907
 				
908
-			    }
908
+				}
909 909
 			}
910
-		    }
911
-		    //adds the spotter LIVE data
912
-		    //SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
913
-		    //echo "\nAdd in Live !! \n";
914
-		    //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";
915
-		    if ($globalDebug) {
910
+			}
911
+			//adds the spotter LIVE data
912
+			//SpotterLive->addLiveSpotterData($flightaware_id, $ident, $aircraft_type, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed);
913
+			//echo "\nAdd in Live !! \n";
914
+			//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";
915
+			if ($globalDebug) {
916 916
 			if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS) || (isset($globalVAM) && $globalVAM)) {
917 917
 				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";
918 918
 				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";
@@ -920,60 +920,60 @@  discard block
 block discarded – undo
920 920
 				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";
921 921
 				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";
922 922
 			}
923
-		    }
924
-		    $ignoreImport = false;
925
-		    if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
926
-		    if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
923
+			}
924
+			$ignoreImport = false;
925
+			if ($this->all_flights[$id]['departure_airport'] == "") { $this->all_flights[$id]['departure_airport'] = "NA"; }
926
+			if ($this->all_flights[$id]['arrival_airport'] == "") { $this->all_flights[$id]['arrival_airport'] = "NA"; }
927 927
 
928
-		    foreach($globalAirportIgnore as $airportIgnore) {
929
-		        if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
930
-			    $ignoreImport = true;
928
+			foreach($globalAirportIgnore as $airportIgnore) {
929
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
930
+				$ignoreImport = true;
931
+			}
931 932
 			}
932
-		    }
933
-		    if (count($globalAirportAccept) > 0) {
934
-		        $ignoreImport = true;
935
-		        foreach($globalAirportIgnore as $airportIgnore) {
936
-			    if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
933
+			if (count($globalAirportAccept) > 0) {
934
+				$ignoreImport = true;
935
+				foreach($globalAirportIgnore as $airportIgnore) {
936
+				if (($this->all_flights[$id]['departure_airport'] == $airportIgnore) || ($this->all_flights[$id]['arrival_airport'] == $airportIgnore)) {
937 937
 				$ignoreImport = false;
938
-			    }
938
+				}
939 939
 			}
940
-		    }
941
-		    if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
940
+			}
941
+			if (isset($globalAirlineIgnore) && is_array($globalAirlineIgnore)) {
942 942
 			foreach($globalAirlineIgnore as $airlineIgnore) {
943
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
943
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineIgnore) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineIgnore)) {
944 944
 				$ignoreImport = true;
945
-			    }
945
+				}
946 946
 			}
947
-		    }
948
-		    if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
947
+			}
948
+			if (isset($globalAirlineAccept) && count($globalAirlineAccept) > 0) {
949 949
 			$ignoreImport = true;
950 950
 			foreach($globalAirlineAccept as $airlineAccept) {
951
-			    if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
951
+				if ((is_numeric(substr(substr($this->all_flights[$id]['ident'],0,4),-1,1)) && substr($this->all_flights[$id]['ident'],0,3) == $airlineAccept) || (is_numeric(substr(substr($this->all_flights[$id]['ident'],0,3),-1,1)) && substr($this->all_flights[$id]['ident'],0,2) == $airlineAccept)) {
952 952
 				$ignoreImport = false;
953
-			    }
953
+				}
954
+			}
954 955
 			}
955
-		    }
956
-		    if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
956
+			if (isset($globalPilotIdAccept) && count($globalPilotIdAccept) > 0) {
957 957
 			$ignoreImport = true;
958 958
 			foreach($globalPilotIdAccept as $pilotIdAccept) {
959
-			    if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
960
-			        $ignoreImport = false;
961
-			    }
959
+				if ($this->all_flights[$id]['pilot_id'] == $pilotIdAccept) {
960
+					$ignoreImport = false;
961
+				}
962
+			}
962 963
 			}
963
-		    }
964 964
 
965
-		    if (!$ignoreImport) {
965
+			if (!$ignoreImport) {
966 966
 			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'])) {
967 967
 				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')));
968 968
 				$timeelapsed = microtime(true);
969 969
 				if (!isset($globalNoImport) || $globalNoImport === FALSE) {
970
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
970
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
971 971
 					if ($globalDebug) echo "\o/ Add ".$this->all_flights[$id]['ident']." from ".$this->all_flights[$id]['format_source']." in Live DB : ";
972 972
 					$SpotterLive = new SpotterLive($this->db);
973 973
 					$result = $SpotterLive->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'],$this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
974 974
 					$SpotterLive->db = null;
975 975
 					if ($globalDebug) echo $result."\n";
976
-				    }
976
+					}
977 977
 				}
978 978
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_flights[$id]['putinarchive']) {
979 979
 					$APRSSpotter->addLiveSpotterData($this->all_flights[$id]['id'], $this->all_flights[$id]['ident'], $this->all_flights[$id]['aircraft_icao'], $this->all_flights[$id]['departure_airport'], $this->all_flights[$id]['arrival_airport'], $this->all_flights[$id]['latitude'], $this->all_flights[$id]['longitude'], $this->all_flights[$id]['waypoints'], $this->all_flights[$id]['altitude'], $this->all_flights[$id]['altitude_real'], $this->all_flights[$id]['heading'], $this->all_flights[$id]['speed'],$this->all_flights[$id]['datetime'], $this->all_flights[$id]['departure_airport_time'], $this->all_flights[$id]['arrival_airport_time'], $this->all_flights[$id]['squawk'],$this->all_flights[$id]['route_stop'],$this->all_flights[$id]['hex'],$this->all_flights[$id]['putinarchive'],$this->all_flights[$id]['registration'],$this->all_flights[$id]['pilot_id'],$this->all_flights[$id]['pilot_name'], $this->all_flights[$id]['verticalrate'], $this->all_flights[$id]['noarchive'], $this->all_flights[$id]['ground'],$this->all_flights[$id]['format_source'],$this->all_flights[$id]['source_name'],$this->all_flights[$id]['over_country']);
@@ -985,7 +985,7 @@  discard block
 block discarded – undo
985 985
 				//if ($line['format_source'] != 'aprs') {
986 986
 				//if (isset($line['format_source']) && ($line['format_source'] === 'sbs' || $line['format_source'] === 'tsv' || $line['format_source'] === 'raw' || $line['format_source'] === 'deltadbtxt')) {
987 987
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
988
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
988
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_flights[$id]['latitude'] != '' && $this->all_flights[$id]['longitude'] != '') {
989 989
 					$source = $this->all_flights[$id]['source_name'];
990 990
 					if ($source == '') $source = $this->all_flights[$id]['format_source'];
991 991
 					if (!isset($this->source_location[$source])) {
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 					if ($stats_heading == 16) $stats_heading = 0;
1012 1012
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
1013 1013
 						for ($i=0;$i<=15;$i++) {
1014
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
1014
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
1015 1015
 						}
1016 1016
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
1017 1017
 					} else {
@@ -1024,17 +1024,17 @@  discard block
 block discarded – undo
1024 1024
 					//var_dump($this->stats);
1025 1025
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
1026 1026
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
1027
-						    end($this->stats[$current_date][$source]['hist']);
1028
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
1027
+							end($this->stats[$current_date][$source]['hist']);
1028
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
1029 1029
 						} else $mini = 0;
1030 1030
 						for ($i=$mini;$i<=$distance;$i+=10) {
1031
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
1031
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
1032 1032
 						}
1033 1033
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
1034 1034
 					} else {
1035 1035
 						$this->stats[$current_date][$source]['hist'][$distance] += 1;
1036 1036
 					}
1037
-				    }
1037
+					}
1038 1038
 				}
1039 1039
 
1040 1040
 				$this->all_flights[$id]['lastupdate'] = time();
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 			//$this->del();
1045 1045
 			
1046 1046
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
1047
-			    if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1047
+				if ((!isset($globalNoImport) || $globalNoImport === FALSE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
1048 1048
 				if ($globalDebug) echo "---- Deleting Live Spotter data Not updated since 2 hour...";
1049 1049
 				$SpotterLive = new SpotterLive($this->db);
1050 1050
 				$SpotterLive->deleteLiveSpotterDataNotUpdated();
@@ -1052,19 +1052,19 @@  discard block
 block discarded – undo
1052 1052
 				//SpotterLive->deleteLiveSpotterData();
1053 1053
 				if ($globalDebug) echo " Done\n";
1054 1054
 				$this->last_delete_hourly = time();
1055
-			    } else {
1055
+				} else {
1056 1056
 				$this->del();
1057 1057
 				$this->last_delete_hourly = time();
1058
-			    }
1058
+				}
1059 1059
 			}
1060 1060
 			
1061
-		    }
1062
-		    //$ignoreImport = false;
1061
+			}
1062
+			//$ignoreImport = false;
1063 1063
 		}
1064 1064
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
1065 1065
 		if ($send) return $this->all_flights[$id];
1066
-	    }
1066
+		}
1067
+	}
1067 1068
 	}
1068
-    }
1069 1069
 }
1070 1070
 ?>
Please login to merge, or discard this patch.