Completed
Push — master ( e6c083...dab432 )
by Yannick
31:25
created
require/class.MarineImport.php 3 patches
Indentation   +216 added lines, -216 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,103 +105,103 @@  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'];
148
+				$this->all_tracked[$id]['ident'] = $identity['ship_name'];
149
+				$this->all_tracked[$id]['type'] = $identity['type'];
150 150
 			}
151 151
 			//print_r($identity);
152 152
 			unset($Marine);
153 153
 			//$dataFound = true;
154
-		    }
154
+			}
155 155
 		}
156 156
 		if (isset($line['type_id'])) {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
157
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
158
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
159 159
 		}
160 160
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
162
-		    if (!isset($line['type_id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
161
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
162
+			if (!isset($line['type_id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
163 163
 		}
164 164
 		if (isset($line['status']) && $line['status'] != '') {
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
165
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
166 166
 		}
167 167
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
168
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
169
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
168
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
169
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
170 170
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
171
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
171
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
172 172
 				$Marine = new Marine($this->db);
173 173
 				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
174 174
 				unset($Marine);
175
-			    }
175
+				}
176
+			}
176 177
 			}
177
-		    }
178 178
 		}
179 179
 
180 180
 
181 181
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
182
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
182
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
183 183
 		}
184 184
 		if (isset($line['imo']) && $line['imo'] != '') {
185
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
185
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
186 186
 		}
187 187
 		if (isset($line['callsign']) && $line['callsign'] != '') {
188
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
188
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
189 189
 		}
190 190
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
191
-		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
191
+			if (!isset($this->all_tracked[$id]['arrival_code'])) {
192 192
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
193 193
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
194 194
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
195
-			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
195
+				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
196 196
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
197
-				    $Marine = new Marine($this->db);
198
-				    $fromsource = NULL;
199
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
200
-				    $Marine->db = null;
197
+					$Marine = new Marine($this->db);
198
+					$fromsource = NULL;
199
+					$Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
200
+					$Marine->db = null;
201
+				}
201 202
 				}
202
-			    }
203 203
 			}
204
-		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
204
+			} elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
205 205
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
206 206
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
207 207
 			if (!isset($line['id'])) {
@@ -209,18 +209,18 @@  discard block
 block discarded – undo
209 209
 				$this->all_tracked[$id]['forcenew'] = 1;
210 210
 				$this->all_tracked[$id]['addedMarine'] = 0;
211 211
 			}
212
-		    }
212
+			}
213 213
 		}
214 214
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
215
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
215
+			if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
216 216
 		}
217 217
 
218 218
 		//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'])) {
219 219
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
221
-		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
220
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
221
+			if ($this->all_tracked[$id]['addedMarine'] == 1) {
222 222
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
223
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
223
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
224 224
 				$timeelapsed = microtime(true);
225 225
 				$Marine = new Marine($this->db);
226 226
 				$fromsource = NULL;
@@ -229,20 +229,20 @@  discard block
 block discarded – undo
229 229
 				$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']);
230 230
 				$Marine->db = null;
231 231
 				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
232
-			    }
232
+				}
233
+			}
233 234
 			}
234
-		    }
235
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
235
+			if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
236 236
 		}
237 237
 
238 238
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
239
-		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
239
+			if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
240 240
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
241
-		    } else {
241
+			} else {
242 242
 				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";
243 243
 				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";
244 244
 				return '';
245
-		    }
245
+			}
246 246
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
247 247
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
248 248
 			return '';
@@ -259,24 +259,24 @@  discard block
 block discarded – undo
259 259
 
260 260
 
261 261
 		if (isset($line['speed'])) {
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
262
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
263
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
264 264
 		} 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'])) {
265
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
266
-		    if ($distance > 1000 && $distance < 10000) {
265
+			$distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
266
+			if ($distance > 1000 && $distance < 10000) {
267 267
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
268 268
 			$speed = $speed*3.6;
269 269
 			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
270 270
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
271
-		    }
271
+			}
272 272
 		}
273 273
 
274
-	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
275
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
276
-	    	    else unset($timediff);
277
-	    	    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')))) {
274
+			if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
275
+				if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
276
+				else unset($timediff);
277
+				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')))) {
278 278
 			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'])) {
279
-			    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'])) {
279
+				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'])) {
280 280
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
281 281
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
282 282
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -284,195 +284,195 @@  discard block
 block discarded – undo
284 284
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
285 285
 				$timeelapsed = microtime(true);
286 286
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
287
-				    $Marine = new Marine($this->db);
288
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
289
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
290
-				    $Marine->db = null;
291
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
287
+					$Marine = new Marine($this->db);
288
+					$all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
289
+					if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
290
+					$Marine->db = null;
291
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
292 292
 				}
293 293
 				$this->tmd = 0;
294 294
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
295
-			    }
295
+				}
296 296
 			}
297 297
 
298 298
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
299 299
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
300 300
 				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') {
301
-				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
302
-				    $dataFound = true;
303
-				    $this->all_tracked[$id]['time_last_coord'] = time();
301
+					$this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
302
+					$dataFound = true;
303
+					$this->all_tracked[$id]['time_last_coord'] = time();
304 304
 				}
305 305
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
306 306
 			}
307 307
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
308
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
308
+				if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
309 309
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
310 310
 				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') {
311
-				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
312
-				    $dataFound = true;
313
-				    $this->all_tracked[$id]['time_last_coord'] = time();
311
+					$this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
312
+					$dataFound = true;
313
+					$this->all_tracked[$id]['time_last_coord'] = time();
314 314
 				}
315 315
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
316 316
 			}
317 317
 
318
-		    } else if ($globalDebug && $timediff > 20) {
318
+			} else if ($globalDebug && $timediff > 20) {
319 319
 			$this->tmd = $this->tmd + 1;
320 320
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
321 321
 			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
322 322
 			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
323 323
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
324
-		    }
324
+			}
325 325
 		}
326 326
 		if (isset($line['last_update']) && $line['last_update'] != '') {
327
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
328
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
327
+			if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
328
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
329 329
 		}
330 330
 		if (isset($line['format_source']) && $line['format_source'] != '') {
331
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
331
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
332 332
 		}
333 333
 		if (isset($line['source_name']) && $line['source_name'] != '') {
334
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
334
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
335 335
 		}
336 336
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
337
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
337
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
338 338
 		}
339 339
 		
340 340
 		if (isset($line['heading']) && $line['heading'] != '') {
341
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
342
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
343
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
344
-		    //$dataFound = true;
341
+			if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
342
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
343
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
344
+			//$dataFound = true;
345 345
   		} 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']) {
346
-  		    $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']);
347
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
348
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
349
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
346
+  			$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']);
347
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
348
+			if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
349
+  			if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
350 350
   		}
351 351
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
352 352
 
353 353
 
354 354
 
355 355
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
356
-		    $this->all_tracked[$id]['lastupdate'] = time();
357
-		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
358
-		        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'])) {
359
-			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
356
+			$this->all_tracked[$id]['lastupdate'] = time();
357
+			if ($this->all_tracked[$id]['addedMarine'] == 0) {
358
+				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'])) {
359
+				if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
360 360
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
361
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
362
-				    $timeelapsed = microtime(true);
363
-				    $MarineLive = new MarineLive($this->db);
364
-				    if (isset($line['id'])) {
361
+					if ($globalDebug) echo "Check if vessel is already in DB...";
362
+					$timeelapsed = microtime(true);
363
+					$MarineLive = new MarineLive($this->db);
364
+					if (isset($line['id'])) {
365 365
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
366 366
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
367
-				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
367
+					} elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
368 368
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
369 369
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
370
-				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
370
+					} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
371 371
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
372 372
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
373
-				    } else $recent_ident = '';
374
-				    $MarineLive->db=null;
375
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
376
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
373
+					} else $recent_ident = '';
374
+					$MarineLive->db=null;
375
+					if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
376
+					elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
377 377
 				} else $recent_ident = '';
378
-			    } else {
378
+				} else {
379 379
 				$recent_ident = '';
380 380
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
381
-			    }
382
-			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
383
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
384
-			    {
381
+				}
382
+				//if there was no vessel with the same callsign within the last hour and go post it into the archive
383
+				if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
384
+				{
385 385
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
386 386
 				//adds the spotter data for the archive
387
-				    $highlight = '';
388
-				    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')));
389
-				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
387
+					$highlight = '';
388
+					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')));
389
+					if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
390 390
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
391
-					    $timeelapsed = microtime(true);
392
-					    $Marine = new Marine($this->db);
393
-					    $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']);
394
-					    $Marine->db = null;
395
-					    if ($globalDebug && isset($result)) echo $result."\n";
396
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
391
+						$timeelapsed = microtime(true);
392
+						$Marine = new Marine($this->db);
393
+						$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']);
394
+						$Marine->db = null;
395
+						if ($globalDebug && isset($result)) echo $result."\n";
396
+						if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
397 397
 					}
398
-				    }
399
-				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
398
+					}
399
+					if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
400 400
 					// Add source stat in DB
401 401
 					$Stats = new Stats($this->db);
402 402
 					if (!empty($this->stats)) {
403
-					    if ($globalDebug) echo 'Add source stats : ';
404
-				    	    foreach($this->stats as $date => $data) {
403
+						if ($globalDebug) echo 'Add source stats : ';
404
+							foreach($this->stats as $date => $data) {
405 405
 						foreach($data as $source => $sourced) {
406
-					    	    //print_r($sourced);
407
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
408
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
409
-				    		    if (isset($sourced['msg'])) {
410
-				    			if (time() - $sourced['msg']['date'] > 10) {
411
-				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
412
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
413
-			    			    	    unset($this->stats[$date][$source]['msg']);
414
-			    				}
415
-			    			    }
416
-			    			}
417
-			    			if ($date != date('Y-m-d')) {
418
-			    			    unset($this->stats[$date]);
419
-			    			}
420
-				    	    }
421
-				    	    if ($globalDebug) echo 'Done'."\n";
406
+								//print_r($sourced);
407
+									if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
408
+									if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
409
+								if (isset($sourced['msg'])) {
410
+								if (time() - $sourced['msg']['date'] > 10) {
411
+										$nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
412
+										echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
413
+										unset($this->stats[$date][$source]['msg']);
414
+								}
415
+								}
416
+							}
417
+							if ($date != date('Y-m-d')) {
418
+								unset($this->stats[$date]);
419
+							}
420
+							}
421
+							if ($globalDebug) echo 'Done'."\n";
422 422
 					}
423 423
 					$Stats->db = null;
424
-				    }
424
+					}
425 425
 				    
426
-				    $this->del();
426
+					$this->del();
427 427
 				//$ignoreImport = false;
428 428
 				$this->all_tracked[$id]['addedMarine'] = 1;
429 429
 				//print_r($this->all_tracked[$id]);
430 430
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
431
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
432
-				    //MarineLive->deleteLiveMarineDataNotUpdated();
433
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
431
+					if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
432
+					//MarineLive->deleteLiveMarineDataNotUpdated();
433
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
434 434
 					$MarineLive = new MarineLive($this->db);
435 435
 					$MarineLive->deleteLiveMarineData();
436 436
 					$MarineLive->db=null;
437 437
 					if ($globalDebug) echo " Done\n";
438
-				    }
439
-				    $this->last_delete = time();
438
+					}
439
+					$this->last_delete = time();
440 440
 				}
441
-			    } elseif ($recent_ident != '') {
441
+				} elseif ($recent_ident != '') {
442 442
 				$this->all_tracked[$id]['id'] = $recent_ident;
443 443
 				$this->all_tracked[$id]['addedMarine'] = 1;
444 444
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
445
-				    if (isset($globalDaemon) && !$globalDaemon) {
445
+					if (isset($globalDaemon) && !$globalDaemon) {
446 446
 					$Marine = new Marine($this->db);
447 447
 					$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']);
448 448
 					$Marine->db = null;
449
-				    }
449
+					}
450 450
 				}
451 451
 				
452
-			    }
452
+				}
453
+			}
453 454
 			}
454
-		    }
455
-		    //adds the spotter LIVE data
456
-		    if ($globalDebug) {
455
+			//adds the spotter LIVE data
456
+			if ($globalDebug) {
457 457
 			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";
458
-		    }
459
-		    $ignoreImport = false;
458
+			}
459
+			$ignoreImport = false;
460 460
 
461
-		    if (!$ignoreImport) {
461
+			if (!$ignoreImport) {
462 462
 			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'])) {
463 463
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
464 464
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
465
-				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
465
+					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
466 466
 					$timeelapsed = microtime(true);
467 467
 					$MarineLive = new MarineLive($this->db);
468 468
 					$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']);
469 469
 					$MarineLive->db = null;
470 470
 					if ($globalDebug) echo $result."\n";
471 471
 					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
472
-				    }
472
+					}
473 473
 				}
474 474
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
475
-				    $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']);
475
+					$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']);
476 476
 				}
477 477
 				$this->all_tracked[$id]['putinarchive'] = false;
478 478
 
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
 					if ($stats_heading == 16) $stats_heading = 0;
505 505
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
506 506
 						for ($i=0;$i<=15;$i++) {
507
-						    $this->stats[$current_date][$source]['polar'][$i] = 0;
507
+							$this->stats[$current_date][$source]['polar'][$i] = 0;
508 508
 						}
509 509
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
510 510
 					} else {
@@ -517,11 +517,11 @@  discard block
 block discarded – undo
517 517
 					//var_dump($this->stats);
518 518
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
519 519
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
520
-						    end($this->stats[$current_date][$source]['hist']);
521
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
520
+							end($this->stats[$current_date][$source]['hist']);
521
+							$mini = key($this->stats[$current_date][$source]['hist'])+10;
522 522
 						} else $mini = 0;
523 523
 						for ($i=$mini;$i<=$distance;$i+=10) {
524
-						    $this->stats[$current_date][$source]['hist'][$i] = 0;
524
+							$this->stats[$current_date][$source]['hist'][$i] = 0;
525 525
 						}
526 526
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
527 527
 					} else {
@@ -537,24 +537,24 @@  discard block
 block discarded – undo
537 537
 			
538 538
 			
539 539
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
540
-			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
540
+				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
541 541
 				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
542 542
 				$MarineLive = new MarineLive($this->db);
543 543
 				$MarineLive->deleteLiveMarineDataNotUpdated();
544 544
 				$MarineLive->db = null;
545 545
 				//MarineLive->deleteLiveMarineData();
546 546
 				if ($globalDebug) echo " Done\n";
547
-			    }
548
-			    $this->last_delete_hourly = time();
547
+				}
548
+				$this->last_delete_hourly = time();
549 549
 			}
550 550
 			
551
-		    }
552
-		    //$ignoreImport = false;
551
+			}
552
+			//$ignoreImport = false;
553 553
 		}
554 554
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
555 555
 		if ($send) return $this->all_tracked[$id];
556
-	    }
556
+		}
557
+	}
557 558
 	}
558
-    }
559 559
 }
560 560
 ?>
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 		if (isset($this->all_tracked[$key]['id'])) {
60 60
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
61 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']);
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
 	}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
72 72
 	foreach ($this->all_tracked as $key => $flight) {
73 73
     	    if (isset($flight['lastupdate'])) {
74
-        	if ($flight['lastupdate'] < (time()-3000)) {
74
+        	if ($flight['lastupdate'] < (time() - 3000)) {
75 75
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76 76
             		if (isset($this->all_tracked[$key]['id'])) {
77 77
             		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             		    //$real_arrival = $this->arrival($key);
84 84
             		    $Marine = new Marine($this->db);
85 85
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
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']);
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 88
 			    }
89 89
 			    // Put in archive
@@ -97,14 +97,14 @@  discard block
 block discarded – undo
97 97
     }
98 98
 
99 99
     public function add($line) {
100
-	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
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');
103 103
 	$dataFound = false;
104 104
 	$send = false;
105 105
 	
106 106
 	// SBS format is CSV format
107
-	if(is_array($line) && isset($line['mmsi'])) {
107
+	if (is_array($line) && isset($line['mmsi'])) {
108 108
 	    //print_r($line);
109 109
   	    if (isset($line['mmsi'])) {
110 110
 
@@ -129,18 +129,18 @@  discard block
 block discarded – undo
129 129
 		
130 130
 		if (!isset($this->all_tracked[$id])) {
131 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()));
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 135
 		    if (!isset($line['id'])) {
136 136
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
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']));
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 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']));
143
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi' => $line['mmsi']));
144 144
 		    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
145 145
 			$Marine = new Marine($this->db);
146 146
 			$identity = $Marine->getIdentity($line['mmsi']);
@@ -154,23 +154,23 @@  discard block
 block discarded – undo
154 154
 		    }
155 155
 		}
156 156
 		if (isset($line['type_id'])) {
157
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $AIS->getShipType($line['type_id'])));
158
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $line['type_id']));
157
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $AIS->getShipType($line['type_id'])));
158
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $line['type_id']));
159 159
 		}
160 160
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
161
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
162
-		    if (!isset($line['type_id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
161
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
162
+		    if (!isset($line['type_id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('typeid' => $AIS->getShipTypeID($line['type'])));
163 163
 		}
164 164
 		if (isset($line['status']) && $line['status'] != '') {
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status' => $line['status']));
166 166
 		}
167 167
 		if (isset($line['status_id']) && (!isset($this->all_tracked[$id]['status_id']) || $this->all_tracked[$id]['status_id'] != $line['status_id'])) {
168
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status_id' => $line['status_id']));
168
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('status_id' => $line['status_id']));
169 169
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
170 170
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
171 171
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
172 172
 				$Marine = new Marine($this->db);
173
-				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['status_id'],$this->all_tracked[$id]['status']);
173
+				$Marine->updateStatusMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['status_id'], $this->all_tracked[$id]['status']);
174 174
 				unset($Marine);
175 175
 			    }
176 176
 			}
@@ -179,24 +179,24 @@  discard block
 block discarded – undo
179 179
 
180 180
 
181 181
 		if (isset($line['mmsi_type']) && $line['mmsi_type'] != '') {
182
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('mmsi_type' => $line['mmsi_type']));
182
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('mmsi_type' => $line['mmsi_type']));
183 183
 		}
184 184
 		if (isset($line['imo']) && $line['imo'] != '') {
185
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('imo' => $line['imo']));
185
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('imo' => $line['imo']));
186 186
 		}
187 187
 		if (isset($line['callsign']) && $line['callsign'] != '') {
188
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('callsign' => $line['callsign']));
188
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('callsign' => $line['callsign']));
189 189
 		}
190 190
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
191 191
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
192
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
192
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_code' => $line['arrival_code']));
193 193
 			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
194 194
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
195 195
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
196 196
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
197 197
 				    $Marine = new Marine($this->db);
198 198
 				    $fromsource = NULL;
199
-				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['arrival_code'],$fromsource);
199
+				    $Marine->updateArrivalPortNameMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['arrival_code'], $fromsource);
200 200
 				    $Marine->db = null;
201 201
 				}
202 202
 			    }
@@ -212,46 +212,46 @@  discard block
 block discarded – undo
212 212
 		    }
213 213
 		}
214 214
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
215
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
215
+		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('arrival_date' => $line['arrival_date']));
216 216
 		}
217 217
 
218 218
 		//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'])) {
219 219
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
220
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
220
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
221 221
 		    if ($this->all_tracked[$id]['addedMarine'] == 1) {
222 222
 			if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
223 223
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
224 224
 				$timeelapsed = microtime(true);
225 225
 				$Marine = new Marine($this->db);
226 226
 				$fromsource = NULL;
227
-				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
227
+				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
228 228
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
229
-				$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']);
229
+				$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']);
230 230
 				$Marine->db = null;
231
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
231
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
232 232
 			    }
233 233
 			}
234 234
 		    }
235
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
235
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
236 236
 		}
237 237
 
238
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
238
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 30*60 && strtotime($line['datetime']) < time() + 20*60) {
239 239
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
240
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
240
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
241 241
 		    } else {
242 242
 				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";
243 243
 				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";
244 244
 				return '';
245 245
 		    }
246
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
246
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time() - 30*60) {
247 247
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
248 248
 			return '';
249
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
249
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time() + 20*60) {
250 250
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
251 251
 			return '';
252 252
 		} elseif (!isset($line['datetime'])) {
253 253
 			date_default_timezone_set('UTC');
254
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
254
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
255 255
 		} else {
256 256
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
257 257
 			return '';
@@ -259,24 +259,24 @@  discard block
 block discarded – undo
259 259
 
260 260
 
261 261
 		if (isset($line['speed'])) {
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
264 264
 		} 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'])) {
265
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
265
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
266 266
 		    if ($distance > 1000 && $distance < 10000) {
267 267
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
268 268
 			$speed = $speed*3.6;
269
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
269
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
270 270
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
271 271
 		    }
272 272
 		}
273 273
 
274 274
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
275
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
275
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
276 276
 	    	    else unset($timediff);
277
-	    	    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')))) {
277
+	    	    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')))) {
278 278
 			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'])) {
279
-			    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'])) {
279
+			    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'])) {
280 280
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
281 281
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
282 282
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -285,10 +285,10 @@  discard block
 block discarded – undo
285 285
 				$timeelapsed = microtime(true);
286 286
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
287 287
 				    $Marine = new Marine($this->db);
288
-				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
288
+				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
289 289
 				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
290 290
 				    $Marine->db = null;
291
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
291
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
292 292
 				}
293 293
 				$this->tmd = 0;
294 294
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
@@ -297,55 +297,55 @@  discard block
 block discarded – undo
297 297
 
298 298
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
299 299
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
300
-				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') {
300
+				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') {
301 301
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
302 302
 				    $dataFound = true;
303 303
 				    $this->all_tracked[$id]['time_last_coord'] = time();
304 304
 				}
305
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
305
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
306 306
 			}
307 307
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
308 308
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
309 309
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
310
-				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') {
310
+				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') {
311 311
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
312 312
 				    $dataFound = true;
313 313
 				    $this->all_tracked[$id]['time_last_coord'] = time();
314 314
 				}
315
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
315
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
316 316
 			}
317 317
 
318 318
 		    } else if ($globalDebug && $timediff > 20) {
319 319
 			$this->tmd = $this->tmd + 1;
320 320
 			echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
321
-			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
322
-			echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
321
+			echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
322
+			echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
323 323
 			echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
324 324
 		    }
325 325
 		}
326 326
 		if (isset($line['last_update']) && $line['last_update'] != '') {
327 327
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
328
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
328
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
329 329
 		}
330 330
 		if (isset($line['format_source']) && $line['format_source'] != '') {
331
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
331
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
332 332
 		}
333 333
 		if (isset($line['source_name']) && $line['source_name'] != '') {
334
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
334
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
335 335
 		}
336 336
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
337
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
337
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
338 338
 		}
339 339
 		
340 340
 		if (isset($line['heading']) && $line['heading'] != '') {
341
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
342
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
343
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
341
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
342
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
343
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
344 344
 		    //$dataFound = true;
345 345
   		} 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']) {
346
-  		    $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']);
347
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
348
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
346
+  		    $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']);
347
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
348
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
349 349
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
350 350
   		}
351 351
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 		if ($dataFound === true && isset($this->all_tracked[$id]['mmsi'])) {
356 356
 		    $this->all_tracked[$id]['lastupdate'] = time();
357 357
 		    if ($this->all_tracked[$id]['addedMarine'] == 0) {
358
-		        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'])) {
358
+		        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'])) {
359 359
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
360 360
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
361 361
 				    if ($globalDebug) echo "Check if vessel is already in DB...";
@@ -363,37 +363,37 @@  discard block
 block discarded – undo
363 363
 				    $MarineLive = new MarineLive($this->db);
364 364
 				    if (isset($line['id'])) {
365 365
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
366
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
366
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
367 367
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
368 368
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
369
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
369
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
370 370
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
371 371
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
372
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
372
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
373 373
 				    } else $recent_ident = '';
374
-				    $MarineLive->db=null;
374
+				    $MarineLive->db = null;
375 375
 				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
376 376
 				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
377 377
 				} else $recent_ident = '';
378 378
 			    } else {
379 379
 				$recent_ident = '';
380
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
380
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
381 381
 			    }
382 382
 			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
383
-			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
383
+			    if ($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
384 384
 			    {
385 385
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
386 386
 				//adds the spotter data for the archive
387 387
 				    $highlight = '';
388
-				    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')));
388
+				    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')));
389 389
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
390 390
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
391 391
 					    $timeelapsed = microtime(true);
392 392
 					    $Marine = new Marine($this->db);
393
-					    $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']);
393
+					    $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']);
394 394
 					    $Marine->db = null;
395 395
 					    if ($globalDebug && isset($result)) echo $result."\n";
396
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
396
+					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
397 397
 					}
398 398
 				    }
399 399
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
@@ -401,15 +401,15 @@  discard block
 block discarded – undo
401 401
 					$Stats = new Stats($this->db);
402 402
 					if (!empty($this->stats)) {
403 403
 					    if ($globalDebug) echo 'Add source stats : ';
404
-				    	    foreach($this->stats as $date => $data) {
405
-						foreach($data as $source => $sourced) {
404
+				    	    foreach ($this->stats as $date => $data) {
405
+						foreach ($data as $source => $sourced) {
406 406
 					    	    //print_r($sourced);
407
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
408
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
407
+				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_marine', $date);
408
+				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_marine', $date);
409 409
 				    		    if (isset($sourced['msg'])) {
410 410
 				    			if (time() - $sourced['msg']['date'] > 10) {
411 411
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
412
-				    		    	    echo $Stats->addStatSource($nbmsg,$source,'msg_marine',$date);
412
+				    		    	    echo $Stats->addStatSource($nbmsg, $source, 'msg_marine', $date);
413 413
 			    			    	    unset($this->stats[$date][$source]['msg']);
414 414
 			    				}
415 415
 			    			    }
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
434 434
 					$MarineLive = new MarineLive($this->db);
435 435
 					$MarineLive->deleteLiveMarineData();
436
-					$MarineLive->db=null;
436
+					$MarineLive->db = null;
437 437
 					if ($globalDebug) echo " Done\n";
438 438
 				    }
439 439
 				    $this->last_delete = time();
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
445 445
 				    if (isset($globalDaemon) && !$globalDaemon) {
446 446
 					$Marine = new Marine($this->db);
447
-					$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']);
447
+					$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']);
448 448
 					$Marine->db = null;
449 449
 				    }
450 450
 				}
@@ -459,20 +459,20 @@  discard block
 block discarded – undo
459 459
 		    $ignoreImport = false;
460 460
 
461 461
 		    if (!$ignoreImport) {
462
-			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'])) {
462
+			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'])) {
463 463
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
464 464
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
465 465
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
466 466
 					$timeelapsed = microtime(true);
467 467
 					$MarineLive = new MarineLive($this->db);
468
-					$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']);
468
+					$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']);
469 469
 					$MarineLive->db = null;
470 470
 					if ($globalDebug) echo $result."\n";
471
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
471
+					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
472 472
 				    }
473 473
 				}
474 474
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
475
-				    $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']);
475
+				    $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']);
476 476
 				}
477 477
 				$this->all_tracked[$id]['putinarchive'] = false;
478 478
 
@@ -491,19 +491,19 @@  discard block
 block discarded – undo
491 491
 							$latitude = $globalCenterLatitude;
492 492
 							$longitude = $globalCenterLongitude;
493 493
 						}
494
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
494
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
495 495
 					} else {
496 496
 						$latitude = $this->source_location[$source]['latitude'];
497 497
 						$longitude = $this->source_location[$source]['longitude'];
498 498
 					}
499
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
499
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
500 500
 					//$stats_heading = $stats_heading%22.5;
501 501
 					$stats_heading = round($stats_heading/22.5);
502
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
502
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
503 503
 					$current_date = date('Y-m-d');
504 504
 					if ($stats_heading == 16) $stats_heading = 0;
505 505
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
506
-						for ($i=0;$i<=15;$i++) {
506
+						for ($i = 0; $i <= 15; $i++) {
507 507
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
508 508
 						}
509 509
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -518,9 +518,9 @@  discard block
 block discarded – undo
518 518
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
519 519
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
520 520
 						    end($this->stats[$current_date][$source]['hist']);
521
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
521
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
522 522
 						} else $mini = 0;
523
-						for ($i=$mini;$i<=$distance;$i+=10) {
523
+						for ($i = $mini; $i <= $distance; $i += 10) {
524 524
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
525 525
 						}
526 526
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -532,7 +532,7 @@  discard block
 block discarded – undo
532 532
 
533 533
 				$this->all_tracked[$id]['lastupdate'] = time();
534 534
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
535
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
535
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude'])."\n";
536 536
 			//$this->del();
537 537
 			
538 538
 			
Please login to merge, or discard this patch.
Braces   +205 added lines, -70 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 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";
57
+	    if ($globalDebug) {
58
+	    	echo "Update last seen tracked data...\n";
59
+	    }
58 60
 	    foreach ($this->all_tracked as $key => $flight) {
59 61
 		if (isset($this->all_tracked[$key]['id'])) {
60 62
 		    //echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
@@ -68,13 +70,17 @@  discard block
 block discarded – undo
68 70
     public function del() {
69 71
 	global $globalDebug, $globalNoDB, $globalNoImport;
70 72
 	// Delete old infos
71
-	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
73
+	if ($globalDebug) {
74
+		echo 'Delete old values and update latest data...'."\n";
75
+	}
72 76
 	foreach ($this->all_tracked as $key => $flight) {
73 77
     	    if (isset($flight['lastupdate'])) {
74 78
         	if ($flight['lastupdate'] < (time()-3000)) {
75 79
             	    if ((!isset($globalNoImport) || $globalNoImport !== TRUE) && (!isset($globalNoDB) || $globalNoDB !== TRUE)) {
76 80
             		if (isset($this->all_tracked[$key]['id'])) {
77
-            		    if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
81
+            		    if ($globalDebug) {
82
+            		    	echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
83
+            		    }
78 84
 			    /*
79 85
 			    $MarineLive = new MarineLive();
80 86
             		    $MarineLive->deleteLiveMarineDataById($this->all_tracked[$key]['id']);
@@ -84,7 +90,9 @@  discard block
 block discarded – undo
84 90
             		    $Marine = new Marine($this->db);
85 91
             		    if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
86 92
 				$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
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
93
+				if ($globalDebug && $result != 'success') {
94
+					echo '!!! ERROR : '.$result."\n";
95
+				}
88 96
 			    }
89 97
 			    // Put in archive
90 98
 //				$Marine->db = null;
@@ -98,7 +106,9 @@  discard block
 block discarded – undo
98 106
 
99 107
     public function add($line) {
100 108
 	global $globalFork, $globalDistanceIgnore, $globalDaemon, $globalDebug, $globalCoordMinChange, $globalDebugTimeElapsed, $globalCenterLatitude, $globalCenterLongitude, $globalBeta, $globalSourcesupdate, $globalAllTracked, $globalNoImport, $globalNoDB, $globalServerAPRS,$APRSMarine;
101
-	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') $globalCoordMinChange = '0.02';
109
+	if (!isset($globalCoordMinChange) || $globalCoordMinChange == '') {
110
+		$globalCoordMinChange = '0.02';
111
+	}
102 112
 	date_default_timezone_set('UTC');
103 113
 	$dataFound = false;
104 114
 	$send = false;
@@ -112,20 +122,30 @@  discard block
 block discarded – undo
112 122
 		// Increment message number
113 123
 		if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE) {
114 124
 		    $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'];
125
+		    if (isset($line['source_name'])) {
126
+		    	$source = $line['source_name'];
127
+		    } else {
128
+		    	$source = '';
129
+		    }
130
+		    if ($source == '' || $line['format_source'] == 'aprs') {
131
+		    	$source = $line['format_source'];
132
+		    }
118 133
 		    if (!isset($this->stats[$current_date][$source]['msg'])) {
119 134
 		    	$this->stats[$current_date][$source]['msg']['date'] = time();
120 135
 		    	$this->stats[$current_date][$source]['msg']['nb'] = 1;
121
-		    } else $this->stats[$current_date][$source]['msg']['nb'] += 1;
136
+		    } else {
137
+		    	$this->stats[$current_date][$source]['msg']['nb'] += 1;
138
+		    }
122 139
 		}
123 140
 		
124 141
 		
125 142
 		$Common = new Common();
126 143
 		$AIS = new AIS();
127
-	        if (!isset($line['id'])) $id = trim($line['mmsi']);
128
-	        else $id = trim($line['id']);
144
+	        if (!isset($line['id'])) {
145
+	        	$id = trim($line['mmsi']);
146
+	        } else {
147
+	        	$id = trim($line['id']);
148
+	        }
129 149
 		
130 150
 		if (!isset($this->all_tracked[$id])) {
131 151
 		    $this->all_tracked[$id] = array();
@@ -133,10 +153,16 @@  discard block
 block discarded – undo
133 153
 		    $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 154
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
135 155
 		    if (!isset($line['id'])) {
136
-			if (!isset($globalDaemon)) $globalDaemon = TRUE;
156
+			if (!isset($globalDaemon)) {
157
+				$globalDaemon = TRUE;
158
+			}
137 159
 			$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;
160
+		     } else {
161
+		     	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
162
+		     }
163
+		    if ($globalAllTracked !== FALSE) {
164
+		    	$dataFound = true;
165
+		    }
140 166
 		}
141 167
 		
142 168
 		if (isset($line['mmsi']) && $line['mmsi'] != '' && $line['mmsi'] != $this->all_tracked[$id]['mmsi']) {
@@ -159,7 +185,9 @@  discard block
 block discarded – undo
159 185
 		}
160 186
 		if (isset($line['type']) && $line['type'] != '' && $this->all_tracked[$id]['type'] == '') {
161 187
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
162
-		    if (!isset($line['type_id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
188
+		    if (!isset($line['type_id'])) {
189
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('typeid' => $AIS->getShipTypeID($line['type'])));
190
+		    }
163 191
 		}
164 192
 		if (isset($line['status']) && $line['status'] != '') {
165 193
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('status' => $line['status']));
@@ -190,7 +218,9 @@  discard block
 block discarded – undo
190 218
 		if (isset($line['arrival_code']) && $line['arrival_code'] != '') {
191 219
 		    if (!isset($this->all_tracked[$id]['arrival_code'])) {
192 220
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_code' => $line['arrival_code']));
193
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
221
+			if ($globalDebug) {
222
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
223
+			}
194 224
 			if ($this->all_tracked[$id]['addedMarine'] != 0) {
195 225
 			    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
196 226
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
@@ -203,7 +233,9 @@  discard block
 block discarded – undo
203 233
 			}
204 234
 		    } elseif ($this->all_tracked[$id]['arrival_code'] != $line['arrival_code']) {
205 235
 			$this->all_tracked[$id]['arrival_code'] = $line['arrival_code'];
206
-			if ($globalDebug) echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
236
+			if ($globalDebug) {
237
+				echo $this->all_tracked[$id]['id'].' => New arrival: '.$line['arrival_code']."\n";
238
+			}
207 239
 			if (!isset($line['id'])) {
208 240
 				$this->all_tracked[$id]['id'] = $id.'-'.date('YmdHi');
209 241
 				$this->all_tracked[$id]['forcenew'] = 1;
@@ -212,7 +244,9 @@  discard block
 block discarded – undo
212 244
 		    }
213 245
 		}
214 246
 		if (isset($line['arrival_date']) && $line['arrival_date'] != '') {
215
-		    if (strtotime($line['arrival_date']) > time()) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
247
+		    if (strtotime($line['arrival_date']) > time()) {
248
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('arrival_date' => $line['arrival_date']));
249
+		    }
216 250
 		}
217 251
 
218 252
 		//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'])) {
@@ -225,35 +259,50 @@  discard block
 block discarded – undo
225 259
 				$Marine = new Marine($this->db);
226 260
 				$fromsource = NULL;
227 261
 				$result = $Marine->updateIdentMarineData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
228
-				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
262
+				if ($globalDebug && $result != 'success') {
263
+					echo '!!! ERROR : '.$result."\n";
264
+				}
229 265
 				$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']);
230 266
 				$Marine->db = null;
231
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
267
+				if ($globalDebugTimeElapsed) {
268
+					echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
269
+				}
232 270
 			    }
233 271
 			}
234 272
 		    }
235
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
273
+		    if (!isset($this->all_tracked[$id]['id'])) {
274
+		    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
275
+		    }
236 276
 		}
237 277
 
238 278
 		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-30*60 && strtotime($line['datetime']) < time()+20*60) {
239 279
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime'])) {
240 280
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
241 281
 		    } else {
242
-				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";
243
-				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";
282
+				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
283
+					echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['mmsi']."\n";
284
+				} elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) {
285
+					echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['hex']." - format : ".$line['format_source']."\n";
286
+				}
244 287
 				return '';
245 288
 		    }
246 289
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) <= time()-30*60) {
247
-			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
290
+			if ($globalDebug) {
291
+				echo "!!! Date is too old ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
292
+			}
248 293
 			return '';
249 294
 		} elseif (isset($line['datetime']) && strtotime($line['datetime']) >= time()+20*60) {
250
-			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
295
+			if ($globalDebug) {
296
+				echo "!!! Date is in the future ".$this->all_tracked[$id]['mmsi']." - format : ".$line['format_source']."!!!\n";
297
+			}
251 298
 			return '';
252 299
 		} elseif (!isset($line['datetime'])) {
253 300
 			date_default_timezone_set('UTC');
254 301
 			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
255 302
 		} else {
256
-			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
303
+			if ($globalDebug) {
304
+				echo "!!! Unknow date error ".$this->all_tracked[$id]['mmsi']." date: ".$line['datetime']." - format : ".$line['format_source']."!!!\n";
305
+			}
257 306
 			return '';
258 307
 		}
259 308
 
@@ -266,14 +315,21 @@  discard block
 block discarded – undo
266 315
 		    if ($distance > 1000 && $distance < 10000) {
267 316
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
268 317
 			$speed = $speed*3.6;
269
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
270
-  			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
318
+			if ($speed < 1000) {
319
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
320
+			}
321
+  			if ($globalDebug) {
322
+  				echo "ø Calculated Speed for ".$this->all_tracked[$id]['hex']." : ".$speed." - distance : ".$distance."\n";
323
+  			}
271 324
 		    }
272 325
 		}
273 326
 
274 327
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
275
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
276
-	    	    else unset($timediff);
328
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) {
329
+	    	    	$timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
330
+	    	    } else {
331
+	    	    	unset($timediff);
332
+	    	    }
277 333
 	    	    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')))) {
278 334
 			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'])) {
279 335
 			    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'])) {
@@ -281,22 +337,32 @@  discard block
 block discarded – undo
281 337
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
282 338
 				$this->all_tracked[$id]['putinarchive'] = true;
283 339
 				
284
-				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
340
+				if ($globalDebug) {
341
+					echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
342
+				}
285 343
 				$timeelapsed = microtime(true);
286 344
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
287 345
 				    $Marine = new Marine($this->db);
288 346
 				    $all_country = $Marine->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
289
-				    if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
347
+				    if (!empty($all_country)) {
348
+				    	$this->all_tracked[$id]['over_country'] = $all_country['iso2'];
349
+				    }
290 350
 				    $Marine->db = null;
291
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
351
+				    if ($globalDebugTimeElapsed) {
352
+				    	echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
353
+				    }
292 354
 				}
293 355
 				$this->tmd = 0;
294
-				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
356
+				if ($globalDebug) {
357
+					echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
358
+				}
295 359
 			    }
296 360
 			}
297 361
 
298 362
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
299
-				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
363
+				if (!isset($this->all_tracked[$id]['archive_latitude'])) {
364
+					$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
365
+				}
300 366
 				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') {
301 367
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
302 368
 				    $dataFound = true;
@@ -305,8 +371,12 @@  discard block
 block discarded – undo
305 371
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
306 372
 			}
307 373
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
308
-			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
309
-				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
374
+			    if ($line['longitude'] > 180) {
375
+			    	$line['longitude'] = $line['longitude'] - 360;
376
+			    }
377
+				if (!isset($this->all_tracked[$id]['archive_longitude'])) {
378
+					$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
379
+				}
310 380
 				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') {
311 381
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
312 382
 				    $dataFound = true;
@@ -324,7 +394,9 @@  discard block
 block discarded – undo
324 394
 		    }
325 395
 		}
326 396
 		if (isset($line['last_update']) && $line['last_update'] != '') {
327
-		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
397
+		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) {
398
+		    	$dataFound = true;
399
+		    }
328 400
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
329 401
 		}
330 402
 		if (isset($line['format_source']) && $line['format_source'] != '') {
@@ -338,15 +410,21 @@  discard block
 block discarded – undo
338 410
 		}
339 411
 		
340 412
 		if (isset($line['heading']) && $line['heading'] != '') {
341
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
413
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) {
414
+		    	$this->all_tracked[$id]['putinarchive'] = true;
415
+		    }
342 416
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
343 417
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
344 418
 		    //$dataFound = true;
345 419
   		} 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']) {
346 420
   		    $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']);
347 421
 		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
348
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
349
-  		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
422
+		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) {
423
+		    	$this->all_tracked[$id]['putinarchive'] = true;
424
+		    }
425
+  		    if ($globalDebug) {
426
+  		    	echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
427
+  		    }
350 428
   		}
351 429
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
352 430
 
@@ -358,23 +436,38 @@  discard block
 block discarded – undo
358 436
 		        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'])) {
359 437
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
360 438
 				if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
361
-				    if ($globalDebug) echo "Check if vessel is already in DB...";
439
+				    if ($globalDebug) {
440
+				    	echo "Check if vessel is already in DB...";
441
+				    }
362 442
 				    $timeelapsed = microtime(true);
363 443
 				    $MarineLive = new MarineLive($this->db);
364 444
 				    if (isset($line['id'])) {
365 445
 					$recent_ident = $MarineLive->checkIdRecent($line['id']);
366
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
446
+					if ($globalDebugTimeElapsed) {
447
+						echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
448
+					}
367 449
 				    } elseif (isset($this->all_tracked[$id]['mmsi']) && $this->all_tracked[$id]['mmsi'] != '') {
368 450
 					$recent_ident = $MarineLive->checkMMSIRecent($this->all_tracked[$id]['mmsi']);
369
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
451
+					if ($globalDebugTimeElapsed) {
452
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
453
+					}
370 454
 				    } elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
371 455
 					$recent_ident = $MarineLive->checkIdentRecent($this->all_tracked[$id]['ident']);
372
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
373
-				    } else $recent_ident = '';
456
+					if ($globalDebugTimeElapsed) {
457
+						echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
458
+					}
459
+				    } else {
460
+				    	$recent_ident = '';
461
+				    }
374 462
 				    $MarineLive->db=null;
375
-				    if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
376
-				    elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
377
-				} else $recent_ident = '';
463
+				    if ($globalDebug && $recent_ident == '') {
464
+				    	echo " Not in DB.\n";
465
+				    } elseif ($globalDebug && $recent_ident != '') {
466
+				    	echo " Already in DB.\n";
467
+				    }
468
+				} else {
469
+					$recent_ident = '';
470
+				}
378 471
 			    } else {
379 472
 				$recent_ident = '';
380 473
 				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
@@ -382,30 +475,44 @@  discard block
 block discarded – undo
382 475
 			    //if there was no vessel with the same callsign within the last hour and go post it into the archive
383 476
 			    if($recent_ident == "" && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '')
384 477
 			    {
385
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
478
+				if ($globalDebug) {
479
+					echo "\o/ Add ".$this->all_tracked[$id]['mmsi']." in archive DB : ";
480
+				}
386 481
 				//adds the spotter data for the archive
387 482
 				    $highlight = '';
388
-				    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')));
483
+				    if (!isset($this->all_tracked[$id]['id'])) {
484
+				    	$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['mmsi'].'-'.date('YmdHi')));
485
+				    }
389 486
 				    if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
390 487
 					if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
391 488
 					    $timeelapsed = microtime(true);
392 489
 					    $Marine = new Marine($this->db);
393 490
 					    $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']);
394 491
 					    $Marine->db = null;
395
-					    if ($globalDebug && isset($result)) echo $result."\n";
396
-					    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
492
+					    if ($globalDebug && isset($result)) {
493
+					    	echo $result."\n";
494
+					    }
495
+					    if ($globalDebugTimeElapsed) {
496
+					    	echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
497
+					    }
397 498
 					}
398 499
 				    }
399 500
 				    if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
400 501
 					// Add source stat in DB
401 502
 					$Stats = new Stats($this->db);
402 503
 					if (!empty($this->stats)) {
403
-					    if ($globalDebug) echo 'Add source stats : ';
504
+					    if ($globalDebug) {
505
+					    	echo 'Add source stats : ';
506
+					    }
404 507
 				    	    foreach($this->stats as $date => $data) {
405 508
 						foreach($data as $source => $sourced) {
406 509
 					    	    //print_r($sourced);
407
-				    	    	    if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
408
-				    	    	    if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
510
+				    	    	    if (isset($sourced['polar'])) {
511
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_marine',$date);
512
+				    	    	    }
513
+				    	    	    if (isset($sourced['hist'])) {
514
+				    	    	    	echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_marine',$date);
515
+				    	    	    }
409 516
 				    		    if (isset($sourced['msg'])) {
410 517
 				    			if (time() - $sourced['msg']['date'] > 10) {
411 518
 				    		    	    $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
@@ -418,7 +525,9 @@  discard block
 block discarded – undo
418 525
 			    			    unset($this->stats[$date]);
419 526
 			    			}
420 527
 				    	    }
421
-				    	    if ($globalDebug) echo 'Done'."\n";
528
+				    	    if ($globalDebug) {
529
+				    	    	echo 'Done'."\n";
530
+				    	    }
422 531
 					}
423 532
 					$Stats->db = null;
424 533
 				    }
@@ -428,13 +537,17 @@  discard block
 block discarded – undo
428 537
 				$this->all_tracked[$id]['addedMarine'] = 1;
429 538
 				//print_r($this->all_tracked[$id]);
430 539
 				if ($this->last_delete == 0 || time() - $this->last_delete > 1800) {
431
-				    if ($globalDebug) echo "---- Deleting Live Marine data older than 9 hours...";
540
+				    if ($globalDebug) {
541
+				    	echo "---- Deleting Live Marine data older than 9 hours...";
542
+				    }
432 543
 				    //MarineLive->deleteLiveMarineDataNotUpdated();
433 544
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
434 545
 					$MarineLive = new MarineLive($this->db);
435 546
 					$MarineLive->deleteLiveMarineData();
436 547
 					$MarineLive->db=null;
437
-					if ($globalDebug) echo " Done\n";
548
+					if ($globalDebug) {
549
+						echo " Done\n";
550
+					}
438 551
 				    }
439 552
 				    $this->last_delete = time();
440 553
 				}
@@ -460,15 +573,21 @@  discard block
 block discarded – undo
460 573
 
461 574
 		    if (!$ignoreImport) {
462 575
 			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'])) {
463
-				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
576
+				if ($globalDebug) {
577
+					echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
578
+				}
464 579
 				if (!isset($globalNoImport) || $globalNoImport !== TRUE) {
465 580
 				    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
466 581
 					$timeelapsed = microtime(true);
467 582
 					$MarineLive = new MarineLive($this->db);
468 583
 					$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']);
469 584
 					$MarineLive->db = null;
470
-					if ($globalDebug) echo $result."\n";
471
-					if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
585
+					if ($globalDebug) {
586
+						echo $result."\n";
587
+					}
588
+					if ($globalDebugTimeElapsed) {
589
+						echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
590
+					}
472 591
 				    }
473 592
 				}
474 593
 				if (isset($globalServerAPRS) && $globalServerAPRS && $this->all_tracked[$id]['putinarchive']) {
@@ -480,7 +599,9 @@  discard block
 block discarded – undo
480 599
 				
481 600
 				if (isset($line['sourcestats']) && $line['sourcestats'] == TRUE && $line['format_source'] != 'aprs' && $this->all_tracked[$id]['latitude'] != '' && $this->all_tracked[$id]['longitude'] != '') {
482 601
 					$source = $this->all_tracked[$id]['source_name'];
483
-					if ($source == '') $source = $this->all_tracked[$id]['format_source'];
602
+					if ($source == '') {
603
+						$source = $this->all_tracked[$id]['format_source'];
604
+					}
484 605
 					if (!isset($this->source_location[$source])) {
485 606
 						$Location = new Source($this->db);
486 607
 						$coord = $Location->getLocationInfobySourceName($source);
@@ -501,7 +622,9 @@  discard block
 block discarded – undo
501 622
 					$stats_heading = round($stats_heading/22.5);
502 623
 					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
503 624
 					$current_date = date('Y-m-d');
504
-					if ($stats_heading == 16) $stats_heading = 0;
625
+					if ($stats_heading == 16) {
626
+						$stats_heading = 0;
627
+					}
505 628
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
506 629
 						for ($i=0;$i<=15;$i++) {
507 630
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
@@ -519,7 +642,9 @@  discard block
 block discarded – undo
519 642
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
520 643
 						    end($this->stats[$current_date][$source]['hist']);
521 644
 						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
522
-						} else $mini = 0;
645
+						} else {
646
+							$mini = 0;
647
+						}
523 648
 						for ($i=$mini;$i<=$distance;$i+=10) {
524 649
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
525 650
 						}
@@ -531,19 +656,27 @@  discard block
 block discarded – undo
531 656
 				
532 657
 
533 658
 				$this->all_tracked[$id]['lastupdate'] = time();
534
-				if ($this->all_tracked[$id]['putinarchive']) $send = true;
535
-			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
659
+				if ($this->all_tracked[$id]['putinarchive']) {
660
+					$send = true;
661
+				}
662
+			} elseif (isset($this->all_tracked[$id]['latitude']) && isset($globalDistanceIgnore['latitude']) && $globalDebug) {
663
+				echo "!! Too far -> Distance : ".$Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude'])."\n";
664
+			}
536 665
 			//$this->del();
537 666
 			
538 667
 			
539 668
 			if ($this->last_delete_hourly == 0 || time() - $this->last_delete_hourly > 900) {
540 669
 			    if (!isset($globalNoDB) || $globalNoDB !== TRUE) {
541
-				if ($globalDebug) echo "---- Deleting Live Marine data Not updated since 2 hour...";
670
+				if ($globalDebug) {
671
+					echo "---- Deleting Live Marine data Not updated since 2 hour...";
672
+				}
542 673
 				$MarineLive = new MarineLive($this->db);
543 674
 				$MarineLive->deleteLiveMarineDataNotUpdated();
544 675
 				$MarineLive->db = null;
545 676
 				//MarineLive->deleteLiveMarineData();
546
-				if ($globalDebug) echo " Done\n";
677
+				if ($globalDebug) {
678
+					echo " Done\n";
679
+				}
547 680
 			    }
548 681
 			    $this->last_delete_hourly = time();
549 682
 			}
@@ -552,7 +685,9 @@  discard block
 block discarded – undo
552 685
 		    //$ignoreImport = false;
553 686
 		}
554 687
 		//if (function_exists('pcntl_fork') && $globalFork) pcntl_signal(SIGCHLD, SIG_IGN);
555
-		if ($send) return $this->all_tracked[$id];
688
+		if ($send) {
689
+			return $this->all_tracked[$id];
690
+		}
556 691
 	    }
557 692
 	}
558 693
     }
Please login to merge, or discard this patch.
require/class.Marine.php 3 patches
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
 	}
13 13
 
14 14
 	/**
15
-	* Get SQL query part for filter used
16
-	* @param Array $filter the filter
17
-	* @return Array the SQL part
18
-	*/
15
+	 * Get SQL query part for filter used
16
+	 * @param Array $filter the filter
17
+	 * @return Array the SQL part
18
+	 */
19 19
 	
20 20
 	public function getFilter($filter = array(),$where = false,$and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	}
83 83
 
84 84
 	/**
85
-	* Executes the SQL statements to get the spotter information
86
-	*
87
-	* @param String $query the SQL query
88
-	* @param Array $params parameter of the query
89
-	* @param String $limitQuery the limit query
90
-	* @return Array the spotter information
91
-	*
92
-	*/
85
+	 * Executes the SQL statements to get the spotter information
86
+	 *
87
+	 * @param String $query the SQL query
88
+	 * @param Array $params parameter of the query
89
+	 * @param String $limitQuery the limit query
90
+	 * @return Array the spotter information
91
+	 *
92
+	 */
93 93
 	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
94 94
 	{
95 95
 		date_default_timezone_set('UTC');
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 	
221 221
 	
222 222
 	/**
223
-	* Gets all the spotter information based on the latest data entry
224
-	*
225
-	* @return Array the spotter information
226
-	*
227
-	*/
223
+	 * Gets all the spotter information based on the latest data entry
224
+	 *
225
+	 * @return Array the spotter information
226
+	 *
227
+	 */
228 228
 	public function getLatestMarineData($limit = '', $sort = '', $filter = array())
229 229
 	{
230 230
 		global $global_query;
@@ -273,11 +273,11 @@  discard block
 block discarded – undo
273 273
 	}
274 274
 
275 275
 	/**
276
-	* Gets all the spotter information based on the callsign
277
-	*
278
-	* @return Array the spotter information
279
-	*
280
-	*/
276
+	 * Gets all the spotter information based on the callsign
277
+	 *
278
+	 * @return Array the spotter information
279
+	 *
280
+	 */
281 281
 	public function getMarineDataByIdent($ident = '', $limit = '', $sort = '', $filter = array())
282 282
 	{
283 283
 		global $global_query;
@@ -329,11 +329,11 @@  discard block
 block discarded – undo
329 329
 	}
330 330
 
331 331
 	/**
332
-	* Gets all the marine information based on the type
333
-	*
334
-	* @return Array the marine information
335
-	*
336
-	*/
332
+	 * Gets all the marine information based on the type
333
+	 *
334
+	 * @return Array the marine information
335
+	 *
336
+	 */
337 337
 	public function getMarineDataByType($type = '', $limit = '', $sort = '', $filter = array())
338 338
 	{
339 339
 		global $global_query;
@@ -441,12 +441,12 @@  discard block
 block discarded – undo
441 441
 
442 442
 
443 443
 	/**
444
-	* Gets all source name
445
-	*
446
-	* @param String type format of source
447
-	* @return Array list of source name
448
-	*
449
-	*/
444
+	 * Gets all source name
445
+	 *
446
+	 * @param String type format of source
447
+	 * @return Array list of source name
448
+	 *
449
+	 */
450 450
 	public function getAllSourceName($type = '',$filters = array())
451 451
 	{
452 452
 		$filter_query = $this->getFilter($filters,true,true);
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 
477 477
 
478 478
 	/**
479
-	* Gets a list of all idents/callsigns
480
-	*
481
-	* @return Array list of ident/callsign names
482
-	*
483
-	*/
479
+	 * Gets a list of all idents/callsigns
480
+	 *
481
+	 * @return Array list of ident/callsign names
482
+	 *
483
+	 */
484 484
 	public function getAllIdents($filters = array())
485 485
 	{
486 486
 		$filter_query = $this->getFilter($filters,true,true);
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 	}
505 505
 
506 506
 	/**
507
-	* Gets all info from a mmsi
508
-	*
509
-	* @return Array ident
510
-	*
511
-	*/
507
+	 * Gets all info from a mmsi
508
+	 *
509
+	 * @return Array ident
510
+	 *
511
+	 */
512 512
 	public function getIdentity($mmsi)
513 513
 	{
514 514
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -521,9 +521,9 @@  discard block
 block discarded – undo
521 521
 	}
522 522
 
523 523
 	/**
524
-	* Add identity
525
-	*
526
-	*/
524
+	 * Add identity
525
+	 *
526
+	 */
527 527
 	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
528 528
 	{
529 529
 		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
@@ -589,13 +589,13 @@  discard block
 block discarded – undo
589 589
 	}
590 590
 
591 591
 	/**
592
-	* Update ident tracker data
593
-	*
594
-	* @param String $fammarine_id the ID
595
-	* @param String $ident the marine ident
596
-	* @return String success or false
597
-	*
598
-	*/
592
+	 * Update ident tracker data
593
+	 *
594
+	 * @param String $fammarine_id the ID
595
+	 * @param String $ident the marine ident
596
+	 * @return String success or false
597
+	 *
598
+	 */
599 599
 	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
600 600
 	{
601 601
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
 	}
611 611
 
612 612
 	/**
613
-	* Update arrival marine data
614
-	*
615
-	* @param String $fammarine_id the ID
616
-	* @param String $arrival_code the marine ident
617
-	* @return String success or false
618
-	*
619
-	*/
613
+	 * Update arrival marine data
614
+	 *
615
+	 * @param String $fammarine_id the ID
616
+	 * @param String $arrival_code the marine ident
617
+	 * @return String success or false
618
+	 *
619
+	 */
620 620
 	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
621 621
 	{
622 622
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
@@ -631,19 +631,19 @@  discard block
 block discarded – undo
631 631
 	}
632 632
 
633 633
 	/**
634
-	* Update Status data
635
-	*
636
-	* @param String $fammarine_id the ID
637
-	* @param String $status_id the marine status id
638
-	* @param String $status the marine status
639
-	* @return String success or false
640
-	*
641
-	*/
634
+	 * Update Status data
635
+	 *
636
+	 * @param String $fammarine_id the ID
637
+	 * @param String $status_id the marine status id
638
+	 * @param String $status the marine status
639
+	 * @return String success or false
640
+	 *
641
+	 */
642 642
 	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
643 643
 	{
644 644
 
645 645
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
646
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
646
+				$query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
647 647
 
648 648
 		try {
649 649
 			$sth = $this->db->prepare($query);
@@ -656,17 +656,17 @@  discard block
 block discarded – undo
656 656
 
657 657
 	}
658 658
 	/**
659
-	* Update latest marine data
660
-	*
661
-	* @param String $fammarine_id the ID
662
-	* @param String $ident the marine ident
663
-	* @return String success or false
664
-	*
665
-	*/	
659
+	 * Update latest marine data
660
+	 *
661
+	 * @param String $fammarine_id the ID
662
+	 * @param String $ident the marine ident
663
+	 * @return String success or false
664
+	 *
665
+	 */	
666 666
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
667 667
 	{
668 668
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
669
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
669
+				$query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
670 670
 
671 671
 		try {
672 672
 			$sth = $this->db->prepare($query);
@@ -680,30 +680,30 @@  discard block
 block discarded – undo
680 680
 	}
681 681
 
682 682
 	/**
683
-	* Adds a new spotter data
684
-	*
685
-	* @param String $fammarine_id the ID
686
-	* @param String $ident the marine ident
687
-	* @param String $departure_airport_icao the departure airport
688
-	* @param String $arrival_airport_icao the arrival airport
689
-	* @param String $latitude latitude of flight
690
-	* @param String $longitude latitude of flight
691
-	* @param String $waypoints waypoints of flight
692
-	* @param String $heading heading of flight
693
-	* @param String $groundspeed speed of flight
694
-	* @param String $date date of flight
695
-	* @param String $departure_airport_time departure time of flight
696
-	* @param String $arrival_airport_time arrival time of flight
697
-	* @param String $squawk squawk code of flight
698
-	* @param String $route_stop route stop of flight
699
-	* @param String $highlight highlight or not
700
-	* @param String $ModeS ModesS code of flight
701
-	* @param String $registration registration code of flight
702
-	* @param String $pilot_id pilot id of flight (for virtual airlines)
703
-	* @param String $pilot_name pilot name of flight (for virtual airlines)
704
-	* @param String $verticalrate vertival rate of flight
705
-	* @return String success or false
706
-	*/
683
+	 * Adds a new spotter data
684
+	 *
685
+	 * @param String $fammarine_id the ID
686
+	 * @param String $ident the marine ident
687
+	 * @param String $departure_airport_icao the departure airport
688
+	 * @param String $arrival_airport_icao the arrival airport
689
+	 * @param String $latitude latitude of flight
690
+	 * @param String $longitude latitude of flight
691
+	 * @param String $waypoints waypoints of flight
692
+	 * @param String $heading heading of flight
693
+	 * @param String $groundspeed speed of flight
694
+	 * @param String $date date of flight
695
+	 * @param String $departure_airport_time departure time of flight
696
+	 * @param String $arrival_airport_time arrival time of flight
697
+	 * @param String $squawk squawk code of flight
698
+	 * @param String $route_stop route stop of flight
699
+	 * @param String $highlight highlight or not
700
+	 * @param String $ModeS ModesS code of flight
701
+	 * @param String $registration registration code of flight
702
+	 * @param String $pilot_id pilot id of flight (for virtual airlines)
703
+	 * @param String $pilot_name pilot name of flight (for virtual airlines)
704
+	 * @param String $verticalrate vertival rate of flight
705
+	 * @return String success or false
706
+	 */
707 707
 	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
708 708
 	{
709 709
 		global $globalURL, $globalMarineImageFetch;
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 			$sth->execute($query_values);
819 819
 			$this->db = null;
820 820
 		} catch (PDOException $e) {
821
-		    return "error : ".$e->getMessage();
821
+			return "error : ".$e->getMessage();
822 822
 		}
823 823
 		
824 824
 		return "success";
@@ -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;
@@ -847,11 +847,11 @@  discard block
 block discarded – undo
847 847
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
848 848
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
849 849
 			$query_data = array(':ident' => $ident);
850
-    		}
850
+			}
851 851
 		
852 852
 		$sth = $this->db->prepare($query);
853 853
 		$sth->execute($query_data);
854
-    		$ident_result='';
854
+			$ident_result='';
855 855
 		while($row = $sth->fetch(PDO::FETCH_ASSOC))
856 856
 		{
857 857
 			$ident_result = $row['ident'];
@@ -862,11 +862,11 @@  discard block
 block discarded – undo
862 862
 	
863 863
 	
864 864
 	/**
865
-	* Gets the aircraft data from the last 20 seconds
866
-	*
867
-	* @return Array the spotter data
868
-	*
869
-	*/
865
+	 * Gets the aircraft data from the last 20 seconds
866
+	 *
867
+	 * @return Array the spotter data
868
+	 *
869
+	 */
870 870
 	public function getRealTimeData($q = '')
871 871
 	{
872 872
 		global $globalDBdriver;
@@ -904,11 +904,11 @@  discard block
 block discarded – undo
904 904
 	
905 905
 
906 906
 	/**
907
-	* Gets all number of flight over countries
908
-	*
909
-	* @return Array the airline country list
910
-	*
911
-	*/
907
+	 * Gets all number of flight over countries
908
+	 *
909
+	 * @return Array the airline country list
910
+	 *
911
+	 */
912 912
 
913 913
 	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
914 914
 	{
@@ -981,11 +981,11 @@  discard block
 block discarded – undo
981 981
 	
982 982
 	
983 983
 	/**
984
-	* Gets all callsigns that have flown over
985
-	*
986
-	* @return Array the callsign list
987
-	*
988
-	*/
984
+	 * Gets all callsigns that have flown over
985
+	 *
986
+	 * @return Array the callsign list
987
+	 *
988
+	 */
989 989
 	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
990 990
 	{
991 991
 		global $globalDBdriver;
@@ -1052,11 +1052,11 @@  discard block
 block discarded – undo
1052 1052
 
1053 1053
 
1054 1054
 	/**
1055
-	* Counts all dates
1056
-	*
1057
-	* @return Array the date list
1058
-	*
1059
-	*/
1055
+	 * Counts all dates
1056
+	 *
1057
+	 * @return Array the date list
1058
+	 *
1059
+	 */
1060 1060
 	public function countAllDates($filters = array())
1061 1061
 	{
1062 1062
 		global $globalTimezone, $globalDBdriver;
@@ -1102,11 +1102,11 @@  discard block
 block discarded – undo
1102 1102
 	
1103 1103
 	
1104 1104
 	/**
1105
-	* Counts all dates during the last 7 days
1106
-	*
1107
-	* @return Array the date list
1108
-	*
1109
-	*/
1105
+	 * Counts all dates during the last 7 days
1106
+	 *
1107
+	 * @return Array the date list
1108
+	 *
1109
+	 */
1110 1110
 	public function countAllDatesLast7Days($filters = array())
1111 1111
 	{
1112 1112
 		global $globalTimezone, $globalDBdriver;
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 			$query .= " GROUP BY date_name 
1129 1129
 								ORDER BY date_name ASC";
1130 1130
 			$query_data = array(':offset' => $offset);
1131
-    		}
1131
+			}
1132 1132
 		
1133 1133
 		$sth = $this->db->prepare($query);
1134 1134
 		$sth->execute($query_data);
@@ -1148,11 +1148,11 @@  discard block
 block discarded – undo
1148 1148
 	}
1149 1149
 
1150 1150
 	/**
1151
-	* Counts all dates during the last month
1152
-	*
1153
-	* @return Array the date list
1154
-	*
1155
-	*/
1151
+	 * Counts all dates during the last month
1152
+	 *
1153
+	 * @return Array the date list
1154
+	 *
1155
+	 */
1156 1156
 	public function countAllDatesLastMonth($filters = array())
1157 1157
 	{
1158 1158
 		global $globalTimezone, $globalDBdriver;
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 			$query .= " GROUP BY date_name 
1175 1175
 								ORDER BY date_name ASC";
1176 1176
 			$query_data = array(':offset' => $offset);
1177
-    		}
1177
+			}
1178 1178
 		
1179 1179
 		$sth = $this->db->prepare($query);
1180 1180
 		$sth->execute($query_data);
@@ -1196,11 +1196,11 @@  discard block
 block discarded – undo
1196 1196
 
1197 1197
 
1198 1198
 	/**
1199
-	* Counts all month
1200
-	*
1201
-	* @return Array the month list
1202
-	*
1203
-	*/
1199
+	 * Counts all month
1200
+	 *
1201
+	 * @return Array the month list
1202
+	 *
1203
+	 */
1204 1204
 	public function countAllMonths($filters = array())
1205 1205
 	{
1206 1206
 		global $globalTimezone, $globalDBdriver;
@@ -1245,11 +1245,11 @@  discard block
 block discarded – undo
1245 1245
 	
1246 1246
 
1247 1247
 	/**
1248
-	* Counts all dates during the last year
1249
-	*
1250
-	* @return Array the date list
1251
-	*
1252
-	*/
1248
+	 * Counts all dates during the last year
1249
+	 *
1250
+	 * @return Array the date list
1251
+	 *
1252
+	 */
1253 1253
 	public function countAllMonthsLastYear($filters)
1254 1254
 	{
1255 1255
 		global $globalTimezone, $globalDBdriver;
@@ -1271,7 +1271,7 @@  discard block
 block discarded – undo
1271 1271
 			$query .= " GROUP BY year_name, month_name
1272 1272
 								ORDER BY year_name, month_name ASC";
1273 1273
 			$query_data = array(':offset' => $offset);
1274
-    		}
1274
+			}
1275 1275
 		
1276 1276
 		$sth = $this->db->prepare($query);
1277 1277
 		$sth->execute($query_data);
@@ -1294,11 +1294,11 @@  discard block
 block discarded – undo
1294 1294
 	
1295 1295
 	
1296 1296
 	/**
1297
-	* Counts all hours
1298
-	*
1299
-	* @return Array the hour list
1300
-	*
1301
-	*/
1297
+	 * Counts all hours
1298
+	 *
1299
+	 * @return Array the hour list
1300
+	 *
1301
+	 */
1302 1302
 	public function countAllHours($orderby,$filters = array())
1303 1303
 	{
1304 1304
 		global $globalTimezone, $globalDBdriver;
@@ -1361,11 +1361,11 @@  discard block
 block discarded – undo
1361 1361
 	
1362 1362
 	
1363 1363
 	/**
1364
-	* Counts all hours by date
1365
-	*
1366
-	* @return Array the hour list
1367
-	*
1368
-	*/
1364
+	 * Counts all hours by date
1365
+	 *
1366
+	 * @return Array the hour list
1367
+	 *
1368
+	 */
1369 1369
 	public function countAllHoursByDate($date, $filters = array())
1370 1370
 	{
1371 1371
 		global $globalTimezone, $globalDBdriver;
@@ -1409,11 +1409,11 @@  discard block
 block discarded – undo
1409 1409
 	
1410 1410
 	
1411 1411
 	/**
1412
-	* Counts all hours by a ident/callsign
1413
-	*
1414
-	* @return Array the hour list
1415
-	*
1416
-	*/
1412
+	 * Counts all hours by a ident/callsign
1413
+	 *
1414
+	 * @return Array the hour list
1415
+	 *
1416
+	 */
1417 1417
 	public function countAllHoursByIdent($ident, $filters = array())
1418 1418
 	{
1419 1419
 		global $globalTimezone, $globalDBdriver;
@@ -1458,11 +1458,11 @@  discard block
 block discarded – undo
1458 1458
 	
1459 1459
 	
1460 1460
 	/**
1461
-	* Counts all vessels
1462
-	*
1463
-	* @return Integer the number of vessels
1464
-	*
1465
-	*/
1461
+	 * Counts all vessels
1462
+	 *
1463
+	 * @return Integer the number of vessels
1464
+	 *
1465
+	 */
1466 1466
 	public function countOverallMarine($filters = array(),$year = '',$month = '')
1467 1467
 	{
1468 1468
 		global $globalDBdriver;
@@ -1497,11 +1497,11 @@  discard block
 block discarded – undo
1497 1497
 	}
1498 1498
 	
1499 1499
 	/**
1500
-	* Counts all vessel type
1501
-	*
1502
-	* @return Integer the number of vessels
1503
-	*
1504
-	*/
1500
+	 * Counts all vessel type
1501
+	 *
1502
+	 * @return Integer the number of vessels
1503
+	 *
1504
+	 */
1505 1505
 	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1506 1506
 	{
1507 1507
 		global $globalDBdriver;
@@ -1536,11 +1536,11 @@  discard block
 block discarded – undo
1536 1536
 	
1537 1537
   
1538 1538
 	/**
1539
-	* Counts all hours of today
1540
-	*
1541
-	* @return Array the hour list
1542
-	*
1543
-	*/
1539
+	 * Counts all hours of today
1540
+	 *
1541
+	 * @return Array the hour list
1542
+	 *
1543
+	 */
1544 1544
 	public function countAllHoursFromToday($filters = array())
1545 1545
 	{
1546 1546
 		global $globalTimezone, $globalDBdriver;
@@ -1580,12 +1580,12 @@  discard block
 block discarded – undo
1580 1580
 	}
1581 1581
     
1582 1582
     
1583
-     /**
1584
-	* Gets the Barrie Spotter ID based on the FlightAware ID
1585
-	*
1586
-	* @return Integer the Barrie Spotter ID
1583
+	 /**
1584
+	  * Gets the Barrie Spotter ID based on the FlightAware ID
1585
+	  *
1586
+	  * @return Integer the Barrie Spotter ID
1587 1587
 q	*
1588
-	*/
1588
+	  */
1589 1589
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1590 1590
 	{
1591 1591
 		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
@@ -1606,13 +1606,13 @@  discard block
 block discarded – undo
1606 1606
   
1607 1607
  
1608 1608
 	/**
1609
-	* Parses a date string
1610
-	*
1611
-	* @param String $dateString the date string
1612
-	* @param String $timezone the timezone of a user
1613
-	* @return Array the time information
1614
-	*
1615
-	*/
1609
+	 * Parses a date string
1610
+	 *
1611
+	 * @param String $dateString the date string
1612
+	 * @param String $timezone the timezone of a user
1613
+	 * @return Array the time information
1614
+	 *
1615
+	 */
1616 1616
 	public function parseDateString($dateString, $timezone = '')
1617 1617
 	{
1618 1618
 		$time_array = array();
@@ -1645,12 +1645,12 @@  discard block
 block discarded – undo
1645 1645
 	}
1646 1646
 	
1647 1647
 	/**
1648
-	* Parses the direction degrees to working
1649
-	*
1650
-	* @param Float $direction the direction in degrees
1651
-	* @return Array the direction information
1652
-	*
1653
-	*/
1648
+	 * Parses the direction degrees to working
1649
+	 *
1650
+	 * @param Float $direction the direction in degrees
1651
+	 * @return Array the direction information
1652
+	 *
1653
+	 */
1654 1654
 	public function parseDirection($direction = 0)
1655 1655
 	{
1656 1656
 		if ($direction == '') $direction = 0;
@@ -1729,12 +1729,12 @@  discard block
 block discarded – undo
1729 1729
 	
1730 1730
 	
1731 1731
 	/**
1732
-	* Gets Country from latitude/longitude
1733
-	*
1734
-	* @param Float $latitude latitute of the flight
1735
-	* @param Float $longitude longitute of the flight
1736
-	* @return String the countrie
1737
-	*/
1732
+	 * Gets Country from latitude/longitude
1733
+	 *
1734
+	 * @param Float $latitude latitute of the flight
1735
+	 * @param Float $longitude longitute of the flight
1736
+	 * @return String the countrie
1737
+	 */
1738 1738
 	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1739 1739
 	{
1740 1740
 		global $globalDBdriver, $globalDebug;
@@ -1771,11 +1771,11 @@  discard block
 block discarded – undo
1771 1771
 	}
1772 1772
 
1773 1773
 	/**
1774
-	* Gets Country from iso2
1775
-	*
1776
-	* @param String $iso2 ISO2 country code
1777
-	* @return String the countrie
1778
-	*/
1774
+	 * Gets Country from iso2
1775
+	 *
1776
+	 * @param String $iso2 ISO2 country code
1777
+	 * @return String the countrie
1778
+	 */
1779 1779
 	public function getCountryFromISO2($iso2)
1780 1780
 	{
1781 1781
 		global $globalDBdriver, $globalDebug;
@@ -1804,12 +1804,12 @@  discard block
 block discarded – undo
1804 1804
 
1805 1805
 	
1806 1806
 	/**
1807
-	* Gets the short url from bit.ly
1808
-	*
1809
-	* @param String $url the full url
1810
-	* @return String the bit.ly url
1811
-	*
1812
-	*/
1807
+	 * Gets the short url from bit.ly
1808
+	 *
1809
+	 * @param String $url the full url
1810
+	 * @return String the bit.ly url
1811
+	 *
1812
+	 */
1813 1813
 	public function getBitlyURL($url)
1814 1814
 	{
1815 1815
 		global $globalBitlyAccessToken;
@@ -1836,11 +1836,11 @@  discard block
 block discarded – undo
1836 1836
 
1837 1837
 	
1838 1838
 	/**
1839
-	* Gets all vessels types that have flown over
1840
-	*
1841
-	* @return Array the vessel type list
1842
-	*
1843
-	*/
1839
+	 * Gets all vessels types that have flown over
1840
+	 *
1841
+	 * @return Array the vessel type list
1842
+	 *
1843
+	 */
1844 1844
 	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1845 1845
 	{
1846 1846
 		global $globalDBdriver;
@@ -1906,11 +1906,11 @@  discard block
 block discarded – undo
1906 1906
 	}
1907 1907
 
1908 1908
 	/**
1909
-	* Gets all the tracker information
1910
-	*
1911
-	* @return Array the tracker information
1912
-	*
1913
-	*/
1909
+	 * Gets all the tracker information
1910
+	 *
1911
+	 * @return Array the tracker information
1912
+	 *
1913
+	 */
1914 1914
 	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1915 1915
 	{
1916 1916
 		global $globalTimezone, $globalDBdriver;
Please login to merge, or discard this patch.
Spacing   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 require_once(dirname(__FILE__).'/class.Image.php');
3 3
 $global_query = "SELECT marine_output.* FROM marine_output";
4 4
 
5
-class Marine{
5
+class Marine {
6 6
 	public $db;
7 7
 	
8 8
 	public function __construct($dbc = null) {
@@ -17,33 +17,33 @@  discard block
 block discarded – undo
17 17
 	* @return Array the SQL part
18 18
 	*/
19 19
 	
20
-	public function getFilter($filter = array(),$where = false,$and = false) {
20
+	public function getFilter($filter = array(), $where = false, $and = false) {
21 21
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
22 22
 		$filters = array();
23 23
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
24 24
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
25 25
 				$filters = $globalStatsFilters[$globalFilterName];
26 26
 			} else {
27
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
27
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
28 28
 			}
29 29
 		}
30 30
 		if (isset($filter[0]['source'])) {
31
-			$filters = array_merge($filters,$filter);
31
+			$filters = array_merge($filters, $filter);
32 32
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
33
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
34 34
 		$filter_query_join = '';
35 35
 		$filter_query_where = '';
36
-		foreach($filters as $flt) {
36
+		foreach ($filters as $flt) {
37 37
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
38 38
 				if (isset($flt['source'])) {
39
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."') AND spotter_output.format_source IN ('".implode("','",$flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
39
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."') AND spotter_output.format_source IN ('".implode("','", $flt['source'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
40 40
 				} else {
41
-					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','",$flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
41
+					$filter_query_join .= " INNER JOIN (SELECT fammarine_id FROM marine_output WHERE marine_output.ident IN ('".implode("','", $flt['idents'])."')) spfi ON spfi.fammarine_id = marine_output.fammarine_id";
42 42
 				}
43 43
 			}
44 44
 		}
45 45
 		if (isset($filter['source']) && !empty($filter['source'])) {
46
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
46
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
47 47
 		}
48 48
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
49 49
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76 76
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
77 77
 		if ($filter_query_where != '') {
78
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
78
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
79 79
 		}
80 80
 		$filter_query = $filter_query_join.$filter_query_where;
81 81
 		return $filter_query;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	* @return Array the spotter information
91 91
 	*
92 92
 	*/
93
-	public function getDataFromDB($query, $params = array(), $limitQuery = '',$schedules = false)
93
+	public function getDataFromDB($query, $params = array(), $limitQuery = '', $schedules = false)
94 94
 	{
95 95
 		date_default_timezone_set('UTC');
96 96
 		if (!is_string($query))
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 			$sth = $this->db->prepare($query.$limitQuery);
111 111
 			$sth->execute($params);
112 112
 		} catch (PDOException $e) {
113
-			printf("Invalid query : %s\nWhole query: %s\n",$e->getMessage(), $query.$limitQuery);
113
+			printf("Invalid query : %s\nWhole query: %s\n", $e->getMessage(), $query.$limitQuery);
114 114
 			exit();
115 115
 		}
116 116
 		
117 117
 		$num_rows = 0;
118 118
 		$spotter_array = array();
119
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
119
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
120 120
 		{
121 121
 			$num_rows++;
122 122
 			$temp_array = array();
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 			}
152 152
 			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
153 153
 
154
-			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
154
+			if (isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
155 155
 			{
156 156
 				$Image = new Image($this->db);
157
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
157
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'], '', $temp_array['ident']);
158 158
 				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
159 159
 				unset($Image);
160 160
 				if (count($image_array) > 0) {
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
 				{
191 191
 					$temp_array['date'] = "about ".$dateArray['hours']." hours ago";
192 192
 				} else {
193
-					$temp_array['date'] = date("M j Y, g:i a",strtotime($row['date']." UTC"));
193
+					$temp_array['date'] = date("M j Y, g:i a", strtotime($row['date']." UTC"));
194 194
 				}
195 195
 				$temp_array['date_minutes_past'] = $dateArray['minutes'];
196
-				$temp_array['date_iso_8601'] = date("c",strtotime($row['date']." UTC"));
197
-				$temp_array['date_rfc_2822'] = date("r",strtotime($row['date']." UTC"));
196
+				$temp_array['date_iso_8601'] = date("c", strtotime($row['date']." UTC"));
197
+				$temp_array['date_rfc_2822'] = date("r", strtotime($row['date']." UTC"));
198 198
 				$temp_array['date_unix'] = strtotime($row['date']." UTC");
199 199
 				if (isset($row['last_seen']) && $row['last_seen'] != '') {
200 200
 					if (strtotime($row['last_seen']) > strtotime($row['date'])) {
201 201
 						$temp_array['duration'] = strtotime($row['last_seen']) - strtotime($row['date']);
202
-						$temp_array['last_seen_date_iso_8601'] = date("c",strtotime($row['last_seen']." UTC"));
203
-						$temp_array['last_seen_date_rfc_2822'] = date("r",strtotime($row['last_seen']." UTC"));
202
+						$temp_array['last_seen_date_iso_8601'] = date("c", strtotime($row['last_seen']." UTC"));
203
+						$temp_array['last_seen_date_rfc_2822'] = date("r", strtotime($row['last_seen']." UTC"));
204 204
 						$temp_array['last_seen_date_unix'] = strtotime($row['last_seen']." UTC");
205 205
 					}
206 206
 				}
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 		if ($limit != "")
234 234
 		{
235 235
 			$limit_array = explode(",", $limit);
236
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
237
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
236
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
237
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
238 238
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
239 239
 			{
240 240
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 		} else {
249 249
 			$orderby_query = " ORDER BY marine_output.date DESC";
250 250
 		}
251
-		$query  = $global_query.$filter_query." ".$orderby_query;
252
-		$spotter_array = $this->getDataFromDB($query, array(),$limit_query,true);
251
+		$query = $global_query.$filter_query." ".$orderby_query;
252
+		$spotter_array = $this->getDataFromDB($query, array(), $limit_query, true);
253 253
 		return $spotter_array;
254 254
 	}
255 255
     
@@ -267,8 +267,8 @@  discard block
 block discarded – undo
267 267
 		if ($id == '') return array();
268 268
 		$additional_query = "marine_output.fammarine_id = :id";
269 269
 		$query_values = array(':id' => $id);
270
-		$query  = $global_query." WHERE ".$additional_query." ";
271
-		$spotter_array = $this->getDataFromDB($query,$query_values);
270
+		$query = $global_query." WHERE ".$additional_query." ";
271
+		$spotter_array = $this->getDataFromDB($query, $query_values);
272 272
 		return $spotter_array;
273 273
 	}
274 274
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 		$query_values = array();
288 288
 		$limit_query = '';
289 289
 		$additional_query = '';
290
-		$filter_query = $this->getFilter($filter,true,true);
290
+		$filter_query = $this->getFilter($filter, true, true);
291 291
 		if ($ident != "")
292 292
 		{
293 293
 			if (!is_string($ident))
@@ -303,8 +303,8 @@  discard block
 block discarded – undo
303 303
 		{
304 304
 			$limit_array = explode(",", $limit);
305 305
 			
306
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
307
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
306
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
307
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
308 308
 			
309 309
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
310 310
 			{
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 		$query_values = array();
344 344
 		$limit_query = '';
345 345
 		$additional_query = '';
346
-		$filter_query = $this->getFilter($filter,true,true);
346
+		$filter_query = $this->getFilter($filter, true, true);
347 347
 		if (!is_string($type))
348 348
 		{
349 349
 			return false;
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 		{
357 357
 			$limit_array = explode(",", $limit);
358 358
 			
359
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
360
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
359
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
360
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
361 361
 			
362 362
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
363 363
 			{
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 		return $spotter_array;
382 382
 	}
383 383
 	
384
-	public function getMarineDataByDate($date = '', $limit = '', $sort = '',$filter = array())
384
+	public function getMarineDataByDate($date = '', $limit = '', $sort = '', $filter = array())
385 385
 	{
386 386
 		global $global_query, $globalTimezone, $globalDBdriver;
387 387
 		
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 		$limit_query = '';
390 390
 		$additional_query = '';
391 391
 
392
-		$filter_query = $this->getFilter($filter,true,true);
392
+		$filter_query = $this->getFilter($filter, true, true);
393 393
 		
394 394
 		if ($date != "")
395 395
 		{
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 		{
416 416
 			$limit_array = explode(",", $limit);
417 417
 			
418
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
419
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
418
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
419
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
420 420
 			
421 421
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
422 422
 			{
@@ -447,11 +447,11 @@  discard block
 block discarded – undo
447 447
 	* @return Array list of source name
448 448
 	*
449 449
 	*/
450
-	public function getAllSourceName($type = '',$filters = array())
450
+	public function getAllSourceName($type = '', $filters = array())
451 451
 	{
452
-		$filter_query = $this->getFilter($filters,true,true);
452
+		$filter_query = $this->getFilter($filters, true, true);
453 453
 		$query_values = array();
454
-		$query  = "SELECT DISTINCT marine_output.source_name 
454
+		$query = "SELECT DISTINCT marine_output.source_name 
455 455
 				FROM marine_output".$filter_query." marine_output.source_name <> ''";
456 456
 		if ($type != '') {
457 457
 			$query_values = array(':type' => $type);
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 		$source_array = array();
467 467
 		$temp_array = array();
468 468
 		
469
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
469
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
470 470
 		{
471 471
 			$temp_array['source_name'] = $row['source_name'];
472 472
 			$source_array[] = $temp_array;
@@ -483,8 +483,8 @@  discard block
 block discarded – undo
483 483
 	*/
484 484
 	public function getAllIdents($filters = array())
485 485
 	{
486
-		$filter_query = $this->getFilter($filters,true,true);
487
-		$query  = "SELECT DISTINCT marine_output.ident
486
+		$filter_query = $this->getFilter($filters, true, true);
487
+		$query = "SELECT DISTINCT marine_output.ident
488 488
 								FROM marine_output".$filter_query." marine_output.ident <> '' 
489 489
 								ORDER BY marine_output.date ASC LIMIT 700 OFFSET 0";
490 490
 
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		$ident_array = array();
495 495
 		$temp_array = array();
496 496
 		
497
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
497
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
498 498
 		{
499 499
 			$temp_array['ident'] = $row['ident'];
500 500
 			$ident_array[] = $temp_array;
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 	*/
512 512
 	public function getIdentity($mmsi)
513 513
 	{
514
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
514
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
515 515
 		$query  = "SELECT * FROM marine_identity WHERE mmsi = :mmsi LIMIT 1";
516 516
 		$sth = $this->db->prepare($query);
517 517
 		$sth->execute(array(':mmsi' => $mmsi));
@@ -524,23 +524,23 @@  discard block
 block discarded – undo
524 524
 	* Add identity
525 525
 	*
526 526
 	*/
527
-	public function addIdentity($mmsi,$imo,$ident,$callsign,$type)
527
+	public function addIdentity($mmsi, $imo, $ident, $callsign, $type)
528 528
 	{
529
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_NUMBER_INT);
529
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_NUMBER_INT);
530 530
 		if ($mmsi != '') {
531
-			$imo = filter_var($imo,FILTER_SANITIZE_NUMBER_INT);
532
-			$ident = filter_var($ident,FILTER_SANITIZE_STRING);
533
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
534
-			$type = filter_var($type,FILTER_SANITIZE_STRING);
531
+			$imo = filter_var($imo, FILTER_SANITIZE_NUMBER_INT);
532
+			$ident = filter_var($ident, FILTER_SANITIZE_STRING);
533
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
534
+			$type = filter_var($type, FILTER_SANITIZE_STRING);
535 535
 			$identinfo = $this->getIdentity($mmsi);
536 536
 			if (empty($identinfo)) {
537
-				$query  = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
537
+				$query = "INSERT INTO marine_identity (mmsi,imo,call_sign,ship_name,type) VALUES (:mmsi,:imo,:call_sign,:ship_name,:type)";
538 538
 				$sth = $this->db->prepare($query);
539
-				$sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':call_sign' => $callsign,':ship_name' => $ident,':type' => $type));
539
+				$sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':call_sign' => $callsign, ':ship_name' => $ident, ':type' => $type));
540 540
 			} elseif ($ident != '' && $identinfo['ship_name'] != $ident) {
541
-				$query  = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
541
+				$query = "UPDATE marine_identity SET ship_name = :ship_name,type = :type WHERE mmsi = :mmsi";
542 542
 				$sth = $this->db->prepare($query);
543
-				$sth->execute(array(':mmsi' => $mmsi,':ship_name' => $ident,':type' => $type));
543
+				$sth->execute(array(':mmsi' => $mmsi, ':ship_name' => $ident, ':type' => $type));
544 544
 			}
545 545
 		}
546 546
 	}
@@ -561,12 +561,12 @@  discard block
 block discarded – undo
561 561
 		} else $offset = '+00:00';
562 562
 
563 563
 		if ($globalDBdriver == 'mysql') {
564
-			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
564
+			$query = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
565 565
 								FROM marine_output
566 566
 								WHERE marine_output.date <> '' 
567 567
 								ORDER BY marine_output.date ASC LIMIT 0,100";
568 568
 		} else {
569
-			$query  = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
569
+			$query = "SELECT DISTINCT to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') as date
570 570
 								FROM marine_output
571 571
 								WHERE marine_output.date <> '' 
572 572
 								ORDER BY marine_output.date ASC LIMIT 0,100";
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 		$date_array = array();
579 579
 		$temp_array = array();
580 580
 		
581
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
581
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
582 582
 		{
583 583
 			$temp_array['date'] = $row['date'];
584 584
 
@@ -596,10 +596,10 @@  discard block
 block discarded – undo
596 596
 	* @return String success or false
597 597
 	*
598 598
 	*/
599
-	public function updateIdentMarineData($fammarine_id = '', $ident = '',$fromsource = NULL)
599
+	public function updateIdentMarineData($fammarine_id = '', $ident = '', $fromsource = NULL)
600 600
 	{
601 601
 		$query = 'UPDATE marine_output SET ident = :ident WHERE fammarine_id = :fammarine_id';
602
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident);
602
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident);
603 603
 		try {
604 604
 			$sth = $this->db->prepare($query);
605 605
 			$sth->execute($query_values);
@@ -617,10 +617,10 @@  discard block
 block discarded – undo
617 617
 	* @return String success or false
618 618
 	*
619 619
 	*/
620
-	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '',$fromsource = NULL)
620
+	public function updateArrivalPortNameMarineData($fammarine_id = '', $arrival_code = '', $fromsource = NULL)
621 621
 	{
622 622
 		$query = 'UPDATE marine_output SET arrival_port_name = :arrival_code WHERE fammarine_id = :fammarine_id';
623
-		$query_values = array(':fammarine_id' => $fammarine_id,':arrival_code' => $arrival_code);
623
+		$query_values = array(':fammarine_id' => $fammarine_id, ':arrival_code' => $arrival_code);
624 624
 		try {
625 625
 			$sth = $this->db->prepare($query);
626 626
 			$sth->execute($query_values);
@@ -639,11 +639,11 @@  discard block
 block discarded – undo
639 639
 	* @return String success or false
640 640
 	*
641 641
 	*/
642
-	public function updateStatusMarineData($fammarine_id = '', $status_id = '',$status = '')
642
+	public function updateStatusMarineData($fammarine_id = '', $status_id = '', $status = '')
643 643
 	{
644 644
 
645 645
 		$query = 'UPDATE marine_output SET status = :status, status_id = :status_id WHERE fammarine_id = :fammarine_id';
646
-                $query_values = array(':fammarine_id' => $fammarine_id,':status' => $status,':status_id' => $status_id);
646
+                $query_values = array(':fammarine_id' => $fammarine_id, ':status' => $status, ':status_id' => $status_id);
647 647
 
648 648
 		try {
649 649
 			$sth = $this->db->prepare($query);
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 	public function updateLatestMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $groundspeed = NULL, $date = '')
667 667
 	{
668 668
 		$query = 'UPDATE marine_output SET ident = :ident, last_latitude = :last_latitude, last_longitude = :last_longitude, last_seen = :last_seen, last_ground_speed = :last_ground_speed WHERE fammarine_id = :fammarine_id';
669
-                $query_values = array(':fammarine_id' => $fammarine_id,':last_latitude' => $latitude,':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed,':last_seen' => $date,':ident' => $ident);
669
+                $query_values = array(':fammarine_id' => $fammarine_id, ':last_latitude' => $latitude, ':last_longitude' => $longitude, ':last_ground_speed' => $groundspeed, ':last_seen' => $date, ':ident' => $ident);
670 670
 
671 671
 		try {
672 672
 			$sth = $this->db->prepare($query);
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 	* @param String $verticalrate vertival rate of flight
705 705
 	* @return String success or false
706 706
 	*/
707
-	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '',$type = '',$typeid = '',$imo = '',$callsign = '',$arrival_code = '',$arrival_date = '',$status = '',$statusid = '',$format_source = '', $source_name = '')
707
+	public function addMarineData($fammarine_id = '', $ident = '', $latitude = '', $longitude = '', $heading = '', $groundspeed = '', $date = '', $mmsi = '', $type = '', $typeid = '', $imo = '', $callsign = '', $arrival_code = '', $arrival_date = '', $status = '', $statusid = '', $format_source = '', $source_name = '')
708 708
 	{
709 709
 		global $globalURL, $globalMarineImageFetch;
710 710
 		
@@ -771,32 +771,32 @@  discard block
 block discarded – undo
771 771
 		}
772 772
 
773 773
     
774
-		if ($date == "" || strtotime($date) < time()-20*60)
774
+		if ($date == "" || strtotime($date) < time() - 20*60)
775 775
 		{
776 776
 			$date = date("Y-m-d H:i:s", time());
777 777
 		}
778 778
 
779
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
780
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
781
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
782
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
783
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
784
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
785
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
786
-		$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
787
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
788
-		$status = filter_var($status,FILTER_SANITIZE_STRING);
789
-		$type_id = filter_var($typeid,FILTER_SANITIZE_NUMBER_INT);
790
-		$status_id = filter_var($statusid,FILTER_SANITIZE_NUMBER_INT);
791
-		$imo = filter_var($imo,FILTER_SANITIZE_STRING);
792
-		$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
793
-		$arrival_code = filter_var($arrival_code,FILTER_SANITIZE_STRING);
794
-		$arrival_date = filter_var($arrival_date,FILTER_SANITIZE_STRING);
779
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
780
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
781
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
782
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
783
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
784
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
785
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
786
+		$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
787
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
788
+		$status = filter_var($status, FILTER_SANITIZE_STRING);
789
+		$type_id = filter_var($typeid, FILTER_SANITIZE_NUMBER_INT);
790
+		$status_id = filter_var($statusid, FILTER_SANITIZE_NUMBER_INT);
791
+		$imo = filter_var($imo, FILTER_SANITIZE_STRING);
792
+		$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
793
+		$arrival_code = filter_var($arrival_code, FILTER_SANITIZE_STRING);
794
+		$arrival_date = filter_var($arrival_date, FILTER_SANITIZE_STRING);
795 795
 		if (isset($globalMarineImageFetch) && $globalMarineImageFetch === TRUE) {
796 796
 			$Image = new Image($this->db);
797
-			$image_array = $Image->getMarineImage($mmsi,$imo,$ident);
797
+			$image_array = $Image->getMarineImage($mmsi, $imo, $ident);
798 798
 			if (!isset($image_array[0]['mmsi'])) {
799
-				$Image->addMarineImage($mmsi,$imo,$ident);
799
+				$Image->addMarineImage($mmsi, $imo, $ident);
800 800
 			}
801 801
 			unset($Image);
802 802
 		}
@@ -809,10 +809,10 @@  discard block
 block discarded – undo
809 809
 		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
810 810
 		if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
811 811
 		if ($arrival_date == '') $arrival_date = NULL;
812
-		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date) 
812
+		$query = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date) 
813 813
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date)";
814 814
 
815
-		$query_values = array(':fammarine_id' => $fammarine_id,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':heading' => $heading,':speed' => $groundspeed,':date' => $date,':format_source' => $format_source, ':source_name' => $source_name,':mmsi' => $mmsi,':type' => $type,':type_id' => $type_id,':status' => $status,':status_id' => $status_id,':imo' => $imo,':arrival_port_name' => $arrival_code,':arrival_port_date' => $arrival_date);
815
+		$query_values = array(':fammarine_id' => $fammarine_id, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':heading' => $heading, ':speed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':mmsi' => $mmsi, ':type' => $type, ':type_id' => $type_id, ':status' => $status, ':status_id' => $status_id, ':imo' => $imo, ':arrival_port_name' => $arrival_code, ':arrival_port_date' => $arrival_date);
816 816
 		try {
817 817
 			$sth = $this->db->prepare($query);
818 818
 			$sth->execute($query_values);
@@ -836,13 +836,13 @@  discard block
 block discarded – undo
836 836
 	{
837 837
 		global $globalDBdriver, $globalTimezone;
838 838
 		if ($globalDBdriver == 'mysql') {
839
-			$query  = "SELECT marine_output.ident FROM marine_output 
839
+			$query = "SELECT marine_output.ident FROM marine_output 
840 840
 								WHERE marine_output.ident = :ident 
841 841
 								AND marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
842 842
 								AND marine_output.date < UTC_TIMESTAMP()";
843 843
 			$query_data = array(':ident' => $ident);
844 844
 		} else {
845
-			$query  = "SELECT marine_output.ident FROM marine_output 
845
+			$query = "SELECT marine_output.ident FROM marine_output 
846 846
 								WHERE marine_output.ident = :ident 
847 847
 								AND marine_output.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
848 848
 								AND marine_output.date < now() AT TIME ZONE 'UTC'";
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
 		
852 852
 		$sth = $this->db->prepare($query);
853 853
 		$sth->execute($query_data);
854
-    		$ident_result='';
855
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
854
+    		$ident_result = '';
855
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
856 856
 		{
857 857
 			$ident_result = $row['ident'];
858 858
 		}
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 				return false;
879 879
 			} else {
880 880
 				$q_array = explode(" ", $q);
881
-				foreach ($q_array as $q_item){
882
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
881
+				foreach ($q_array as $q_item) {
882
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
883 883
 					$additional_query .= " AND (";
884 884
 					$additional_query .= "(marine_output.ident like '%".$q_item."%')";
885 885
 					$additional_query .= ")";
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
 			}
888 888
 		}
889 889
 		if ($globalDBdriver == 'mysql') {
890
-			$query  = "SELECT marine_output.* FROM marine_output 
890
+			$query = "SELECT marine_output.* FROM marine_output 
891 891
 				WHERE marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 20 SECOND) ".$additional_query." 
892 892
 				AND marine_output.date < UTC_TIMESTAMP()";
893 893
 		} else {
894
-			$query  = "SELECT marine_output.* FROM marine_output 
894
+			$query = "SELECT marine_output.* FROM marine_output 
895 895
 				WHERE marine_output.date::timestamp >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '20 SECONDS' ".$additional_query." 
896 896
 				AND marine_output.date::timestamp < CURRENT_TIMESTAMP AT TIME ZONE 'UTC'";
897 897
 		}
@@ -910,16 +910,16 @@  discard block
 block discarded – undo
910 910
 	*
911 911
 	*/
912 912
 
913
-	public function countAllMarineOverCountries($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array())
913
+	public function countAllMarineOverCountries($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array())
914 914
 	{
915 915
 		global $globalDBdriver, $globalArchive;
916 916
 		//$filter_query = $this->getFilter($filters,true,true);
917
-		$Connection= new Connection($this->db);
917
+		$Connection = new Connection($this->db);
918 918
 		if (!$Connection->tableExists('countries')) return array();
919 919
 		require_once('class.SpotterLive.php');
920 920
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
921 921
 			$MarineLive = new MarineLive($this->db);
922
-			$filter_query = $MarineLive->getFilter($filters,true,true);
922
+			$filter_query = $MarineLive->getFilter($filters, true, true);
923 923
 			$filter_query .= " over_country IS NOT NULL AND over_country <> ''";
924 924
 			if ($olderthanmonths > 0) {
925 925
 				if ($globalDBdriver == 'mysql') {
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 		} else {
940 940
 			require_once(dirname(__FILE__)."/class.MarineArchive.php");
941 941
 			$MarineArchive = new MarineArchive($this->db);
942
-			$filter_query = $MarineArchive->getFilter($filters,true,true);
942
+			$filter_query = $MarineArchive->getFilter($filters, true, true);
943 943
 			$filter_query .= " over_country <> ''";
944 944
 			if ($olderthanmonths > 0) {
945 945
 				if ($globalDBdriver == 'mysql') {
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 		$flight_array = array();
968 968
 		$temp_array = array();
969 969
         
970
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
970
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
971 971
 		{
972 972
 			$temp_array['marine_count'] = $row['nb'];
973 973
 			$temp_array['marine_country'] = $row['name'];
@@ -986,11 +986,11 @@  discard block
 block discarded – undo
986 986
 	* @return Array the callsign list
987 987
 	*
988 988
 	*/
989
-	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '',$filters = array(),$year = '', $month = '', $day = '')
989
+	public function countAllCallsigns($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
990 990
 	{
991 991
 		global $globalDBdriver;
992
-		$filter_query = $this->getFilter($filters,true,true);
993
-		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
992
+		$filter_query = $this->getFilter($filters, true, true);
993
+		$query = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
994 994
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
995 995
 		 if ($olderthanmonths > 0) {
996 996
 			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
@@ -1004,28 +1004,28 @@  discard block
 block discarded – undo
1004 1004
 		if ($year != '') {
1005 1005
 			if ($globalDBdriver == 'mysql') {
1006 1006
 				$query .= " AND YEAR(marine_output.date) = :year";
1007
-				$query_values = array_merge($query_values,array(':year' => $year));
1007
+				$query_values = array_merge($query_values, array(':year' => $year));
1008 1008
 			} else {
1009 1009
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1010
-				$query_values = array_merge($query_values,array(':year' => $year));
1010
+				$query_values = array_merge($query_values, array(':year' => $year));
1011 1011
 			}
1012 1012
 		}
1013 1013
 		if ($month != '') {
1014 1014
 			if ($globalDBdriver == 'mysql') {
1015 1015
 				$query .= " AND MONTH(marine_output.date) = :month";
1016
-				$query_values = array_merge($query_values,array(':month' => $month));
1016
+				$query_values = array_merge($query_values, array(':month' => $month));
1017 1017
 			} else {
1018 1018
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1019
-				$query_values = array_merge($query_values,array(':month' => $month));
1019
+				$query_values = array_merge($query_values, array(':month' => $month));
1020 1020
 			}
1021 1021
 		}
1022 1022
 		if ($day != '') {
1023 1023
 			if ($globalDBdriver == 'mysql') {
1024 1024
 				$query .= " AND DAY(marine_output.date) = :day";
1025
-				$query_values = array_merge($query_values,array(':day' => $day));
1025
+				$query_values = array_merge($query_values, array(':day' => $day));
1026 1026
 			} else {
1027 1027
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1028
-				$query_values = array_merge($query_values,array(':day' => $day));
1028
+				$query_values = array_merge($query_values, array(':day' => $day));
1029 1029
 			}
1030 1030
 		}
1031 1031
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 		$callsign_array = array();
1038 1038
 		$temp_array = array();
1039 1039
         
1040
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1040
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1041 1041
 		{
1042 1042
 			$temp_array['callsign_icao'] = $row['ident'];
1043 1043
 			$temp_array['airline_name'] = $row['airline_name'];
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 		$date_array = array();
1090 1090
 		$temp_array = array();
1091 1091
         
1092
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1092
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1093 1093
 		{
1094 1094
 			$temp_array['date_name'] = $row['date_name'];
1095 1095
 			$temp_array['date_count'] = $row['date_count'];
@@ -1115,7 +1115,7 @@  discard block
 block discarded – undo
1115 1115
 			$datetime = new DateTime();
1116 1116
 			$offset = $datetime->format('P');
1117 1117
 		} else $offset = '+00:00';
1118
-		$filter_query = $this->getFilter($filters,true,true);
1118
+		$filter_query = $this->getFilter($filters, true, true);
1119 1119
 		if ($globalDBdriver == 'mysql') {
1120 1120
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1121 1121
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 7 DAY)";
@@ -1136,7 +1136,7 @@  discard block
 block discarded – undo
1136 1136
 		$date_array = array();
1137 1137
 		$temp_array = array();
1138 1138
         
1139
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1139
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1140 1140
 		{
1141 1141
 			$temp_array['date_name'] = $row['date_name'];
1142 1142
 			$temp_array['date_count'] = $row['date_count'];
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 			$datetime = new DateTime();
1162 1162
 			$offset = $datetime->format('P');
1163 1163
 		} else $offset = '+00:00';
1164
-		$filter_query = $this->getFilter($filters,true,true);
1164
+		$filter_query = $this->getFilter($filters, true, true);
1165 1165
 		if ($globalDBdriver == 'mysql') {
1166 1166
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
1167 1167
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MONTH)";
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 		$date_array = array();
1183 1183
 		$temp_array = array();
1184 1184
         
1185
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1185
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1186 1186
 		{
1187 1187
 			$temp_array['date_name'] = $row['date_name'];
1188 1188
 			$temp_array['date_count'] = $row['date_count'];
@@ -1229,7 +1229,7 @@  discard block
 block discarded – undo
1229 1229
 		$date_array = array();
1230 1230
 		$temp_array = array();
1231 1231
         
1232
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1232
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1233 1233
 		{
1234 1234
 			$temp_array['month_name'] = $row['month_name'];
1235 1235
 			$temp_array['year_name'] = $row['year_name'];
@@ -1258,7 +1258,7 @@  discard block
 block discarded – undo
1258 1258
 			$datetime = new DateTime();
1259 1259
 			$offset = $datetime->format('P');
1260 1260
 		} else $offset = '+00:00';
1261
-		$filter_query = $this->getFilter($filters,true,true);
1261
+		$filter_query = $this->getFilter($filters, true, true);
1262 1262
 		if ($globalDBdriver == 'mysql') {
1263 1263
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
1264 1264
 								FROM marine_output".$filter_query." marine_output.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 YEAR)";
@@ -1279,7 +1279,7 @@  discard block
 block discarded – undo
1279 1279
 		$date_array = array();
1280 1280
 		$temp_array = array();
1281 1281
         
1282
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1282
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1283 1283
 		{
1284 1284
 			$temp_array['year_name'] = $row['year_name'];
1285 1285
 			$temp_array['month_name'] = $row['month_name'];
@@ -1299,7 +1299,7 @@  discard block
 block discarded – undo
1299 1299
 	* @return Array the hour list
1300 1300
 	*
1301 1301
 	*/
1302
-	public function countAllHours($orderby,$filters = array())
1302
+	public function countAllHours($orderby, $filters = array())
1303 1303
 	{
1304 1304
 		global $globalTimezone, $globalDBdriver;
1305 1305
 		if ($globalTimezone != '') {
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 		$hour_array = array();
1348 1348
 		$temp_array = array();
1349 1349
         
1350
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1350
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1351 1351
 		{
1352 1352
 			$temp_array['hour_name'] = $row['hour_name'];
1353 1353
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1369,8 +1369,8 @@  discard block
 block discarded – undo
1369 1369
 	public function countAllHoursByDate($date, $filters = array())
1370 1370
 	{
1371 1371
 		global $globalTimezone, $globalDBdriver;
1372
-		$filter_query = $this->getFilter($filters,true,true);
1373
-		$date = filter_var($date,FILTER_SANITIZE_STRING);
1372
+		$filter_query = $this->getFilter($filters, true, true);
1373
+		$date = filter_var($date, FILTER_SANITIZE_STRING);
1374 1374
 		if ($globalTimezone != '') {
1375 1375
 			date_default_timezone_set($globalTimezone);
1376 1376
 			$datetime = new DateTime($date);
@@ -1378,12 +1378,12 @@  discard block
 block discarded – undo
1378 1378
 		} else $offset = '+00:00';
1379 1379
 
1380 1380
 		if ($globalDBdriver == 'mysql') {
1381
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1381
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1382 1382
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = :date
1383 1383
 								GROUP BY hour_name 
1384 1384
 								ORDER BY hour_name ASC";
1385 1385
 		} else {
1386
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1386
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1387 1387
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset, 'YYYY-mm-dd') = :date
1388 1388
 								GROUP BY hour_name 
1389 1389
 								ORDER BY hour_name ASC";
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
 		$hour_array = array();
1396 1396
 		$temp_array = array();
1397 1397
         
1398
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1398
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1399 1399
 		{
1400 1400
 			$temp_array['hour_name'] = $row['hour_name'];
1401 1401
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1417,8 +1417,8 @@  discard block
 block discarded – undo
1417 1417
 	public function countAllHoursByIdent($ident, $filters = array())
1418 1418
 	{
1419 1419
 		global $globalTimezone, $globalDBdriver;
1420
-		$filter_query = $this->getFilter($filters,true,true);
1421
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
1420
+		$filter_query = $this->getFilter($filters, true, true);
1421
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
1422 1422
 		if ($globalTimezone != '') {
1423 1423
 			date_default_timezone_set($globalTimezone);
1424 1424
 			$datetime = new DateTime();
@@ -1426,12 +1426,12 @@  discard block
 block discarded – undo
1426 1426
 		} else $offset = '+00:00';
1427 1427
 
1428 1428
 		if ($globalDBdriver == 'mysql') {
1429
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1429
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1430 1430
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1431 1431
 								GROUP BY hour_name 
1432 1432
 								ORDER BY hour_name ASC";
1433 1433
 		} else {
1434
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1434
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1435 1435
 								FROM marine_output".$filter_query." marine_output.ident = :ident 
1436 1436
 								GROUP BY hour_name 
1437 1437
 								ORDER BY hour_name ASC";
@@ -1439,12 +1439,12 @@  discard block
 block discarded – undo
1439 1439
       
1440 1440
 		
1441 1441
 		$sth = $this->db->prepare($query);
1442
-		$sth->execute(array(':ident' => $ident,':offset' => $offset));
1442
+		$sth->execute(array(':ident' => $ident, ':offset' => $offset));
1443 1443
       
1444 1444
 		$hour_array = array();
1445 1445
 		$temp_array = array();
1446 1446
         
1447
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1447
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1448 1448
 		{
1449 1449
 			$temp_array['hour_name'] = $row['hour_name'];
1450 1450
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1463,33 +1463,33 @@  discard block
 block discarded – undo
1463 1463
 	* @return Integer the number of vessels
1464 1464
 	*
1465 1465
 	*/
1466
-	public function countOverallMarine($filters = array(),$year = '',$month = '')
1466
+	public function countOverallMarine($filters = array(), $year = '', $month = '')
1467 1467
 	{
1468 1468
 		global $globalDBdriver;
1469 1469
 		//$queryi  = "SELECT COUNT(marine_output.marine_id) AS flight_count FROM marine_output";
1470
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1470
+		$queryi = "SELECT COUNT(DISTINCT marine_output.mmsi) AS flight_count FROM marine_output";
1471 1471
 		$query_values = array();
1472 1472
 		$query = '';
1473 1473
 		if ($year != '') {
1474 1474
 			if ($globalDBdriver == 'mysql') {
1475 1475
 				$query .= " AND YEAR(marine_output.date) = :year";
1476
-				$query_values = array_merge($query_values,array(':year' => $year));
1476
+				$query_values = array_merge($query_values, array(':year' => $year));
1477 1477
 			} else {
1478 1478
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1479
-				$query_values = array_merge($query_values,array(':year' => $year));
1479
+				$query_values = array_merge($query_values, array(':year' => $year));
1480 1480
 			}
1481 1481
 		}
1482 1482
 		if ($month != '') {
1483 1483
 			if ($globalDBdriver == 'mysql') {
1484 1484
 				$query .= " AND MONTH(marine_output.date) = :month";
1485
-				$query_values = array_merge($query_values,array(':month' => $month));
1485
+				$query_values = array_merge($query_values, array(':month' => $month));
1486 1486
 			} else {
1487 1487
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1488
-				$query_values = array_merge($query_values,array(':month' => $month));
1488
+				$query_values = array_merge($query_values, array(':month' => $month));
1489 1489
 			}
1490 1490
 		}
1491 1491
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1492
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1492
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1493 1493
 		
1494 1494
 		$sth = $this->db->prepare($queryi);
1495 1495
 		$sth->execute($query_values);
@@ -1502,32 +1502,32 @@  discard block
 block discarded – undo
1502 1502
 	* @return Integer the number of vessels
1503 1503
 	*
1504 1504
 	*/
1505
-	public function countOverallMarineTypes($filters = array(),$year = '',$month = '')
1505
+	public function countOverallMarineTypes($filters = array(), $year = '', $month = '')
1506 1506
 	{
1507 1507
 		global $globalDBdriver;
1508
-		$queryi  = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1508
+		$queryi = "SELECT COUNT(DISTINCT marine_output.type) AS marine_count FROM marine_output";
1509 1509
 		$query_values = array();
1510 1510
 		$query = '';
1511 1511
 		if ($year != '') {
1512 1512
 			if ($globalDBdriver == 'mysql') {
1513 1513
 				$query .= " AND YEAR(marine_output.date) = :year";
1514
-				$query_values = array_merge($query_values,array(':year' => $year));
1514
+				$query_values = array_merge($query_values, array(':year' => $year));
1515 1515
 			} else {
1516 1516
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1517
-				$query_values = array_merge($query_values,array(':year' => $year));
1517
+				$query_values = array_merge($query_values, array(':year' => $year));
1518 1518
 			}
1519 1519
 		}
1520 1520
 		if ($month != '') {
1521 1521
 			if ($globalDBdriver == 'mysql') {
1522 1522
 				$query .= " AND MONTH(marine_output.date) = :month";
1523
-				$query_values = array_merge($query_values,array(':month' => $month));
1523
+				$query_values = array_merge($query_values, array(':month' => $month));
1524 1524
 			} else {
1525 1525
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1526
-				$query_values = array_merge($query_values,array(':month' => $month));
1526
+				$query_values = array_merge($query_values, array(':month' => $month));
1527 1527
 			}
1528 1528
 		}
1529 1529
 		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1530
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1530
+		else $queryi .= $this->getFilter($filters, true, true).substr($query, 4);
1531 1531
 		
1532 1532
 		$sth = $this->db->prepare($queryi);
1533 1533
 		$sth->execute($query_values);
@@ -1544,7 +1544,7 @@  discard block
 block discarded – undo
1544 1544
 	public function countAllHoursFromToday($filters = array())
1545 1545
 	{
1546 1546
 		global $globalTimezone, $globalDBdriver;
1547
-		$filter_query = $this->getFilter($filters,true,true);
1547
+		$filter_query = $this->getFilter($filters, true, true);
1548 1548
 		if ($globalTimezone != '') {
1549 1549
 			date_default_timezone_set($globalTimezone);
1550 1550
 			$datetime = new DateTime();
@@ -1552,12 +1552,12 @@  discard block
 block discarded – undo
1552 1552
 		} else $offset = '+00:00';
1553 1553
 
1554 1554
 		if ($globalDBdriver == 'mysql') {
1555
-			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1555
+			$query = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
1556 1556
 								FROM marine_output".$filter_query." DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) = CURDATE()
1557 1557
 								GROUP BY hour_name 
1558 1558
 								ORDER BY hour_name ASC";
1559 1559
 		} else {
1560
-			$query  = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1560
+			$query = "SELECT EXTRACT(HOUR FROM marine_output.date AT TIME ZONE INTERVAL :offset) AS hour_name, count(*) as hour_count
1561 1561
 								FROM marine_output".$filter_query." to_char(marine_output.date AT TIME ZONE INTERVAL :offset,'YYYY-mm-dd') = CAST(NOW() AS date)
1562 1562
 								GROUP BY hour_name 
1563 1563
 								ORDER BY hour_name ASC";
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
 		$hour_array = array();
1570 1570
 		$temp_array = array();
1571 1571
         
1572
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1572
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1573 1573
 		{
1574 1574
 			$temp_array['hour_name'] = $row['hour_name'];
1575 1575
 			$temp_array['hour_count'] = $row['hour_count'];
@@ -1588,9 +1588,9 @@  discard block
 block discarded – undo
1588 1588
 	*/
1589 1589
 	public function getMarineIDBasedOnFamMarineID($fammarine_id)
1590 1590
 	{
1591
-		$fammarine_id = filter_var($fammarine_id,FILTER_SANITIZE_STRING);
1591
+		$fammarine_id = filter_var($fammarine_id, FILTER_SANITIZE_STRING);
1592 1592
 
1593
-		$query  = "SELECT marine_output.marine_id
1593
+		$query = "SELECT marine_output.marine_id
1594 1594
 				FROM marine_output 
1595 1595
 				WHERE marine_output.fammarine_id = '".$fammarine_id."'";
1596 1596
         
@@ -1598,7 +1598,7 @@  discard block
 block discarded – undo
1598 1598
 		$sth = $this->db->prepare($query);
1599 1599
 		$sth->execute();
1600 1600
 
1601
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1601
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1602 1602
 		{
1603 1603
 			return $row['marine_id'];
1604 1604
 		}
@@ -1623,23 +1623,23 @@  discard block
 block discarded – undo
1623 1623
 		}
1624 1624
 		
1625 1625
 		$current_date = date("Y-m-d H:i:s");
1626
-		$date = date("Y-m-d H:i:s",strtotime($dateString." UTC"));
1626
+		$date = date("Y-m-d H:i:s", strtotime($dateString." UTC"));
1627 1627
 		
1628 1628
 		$diff = abs(strtotime($current_date) - strtotime($date));
1629 1629
 
1630
-		$time_array['years'] = floor($diff / (365*60*60*24)); 
1630
+		$time_array['years'] = floor($diff/(365*60*60*24)); 
1631 1631
 		$years = $time_array['years'];
1632 1632
 		
1633
-		$time_array['months'] = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
1633
+		$time_array['months'] = floor(($diff - $years*365*60*60*24)/(30*60*60*24));
1634 1634
 		$months = $time_array['months'];
1635 1635
 		
1636
-		$time_array['days'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
1636
+		$time_array['days'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24)/(60*60*24));
1637 1637
 		$days = $time_array['days'];
1638
-		$time_array['hours'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/ (60*60));
1638
+		$time_array['hours'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24)/(60*60));
1639 1639
 		$hours = $time_array['hours'];
1640
-		$time_array['minutes'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/ 60);
1640
+		$time_array['minutes'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60)/60);
1641 1641
 		$minutes = $time_array['minutes'];
1642
-		$time_array['seconds'] = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1642
+		$time_array['seconds'] = floor(($diff - $years*365*60*60*24 - $months*30*60*60*24 - $days*60*60*24 - $hours*60*60 - $minutes*60));  
1643 1643
 		
1644 1644
 		return $time_array;
1645 1645
 	}
@@ -1662,63 +1662,63 @@  discard block
 block discarded – undo
1662 1662
 			$temp_array['direction_degree'] = $direction;
1663 1663
 			$temp_array['direction_shortname'] = "N";
1664 1664
 			$temp_array['direction_fullname'] = "North";
1665
-		} elseif ($direction >= 22.5 && $direction < 45){
1665
+		} elseif ($direction >= 22.5 && $direction < 45) {
1666 1666
 			$temp_array['direction_degree'] = $direction;
1667 1667
 			$temp_array['direction_shortname'] = "NNE";
1668 1668
 			$temp_array['direction_fullname'] = "North-Northeast";
1669
-		} elseif ($direction >= 45 && $direction < 67.5){
1669
+		} elseif ($direction >= 45 && $direction < 67.5) {
1670 1670
 			$temp_array['direction_degree'] = $direction;
1671 1671
 			$temp_array['direction_shortname'] = "NE";
1672 1672
 			$temp_array['direction_fullname'] = "Northeast";
1673
-		} elseif ($direction >= 67.5 && $direction < 90){
1673
+		} elseif ($direction >= 67.5 && $direction < 90) {
1674 1674
 			$temp_array['direction_degree'] = $direction;
1675 1675
 			$temp_array['direction_shortname'] = "ENE";
1676 1676
 			$temp_array['direction_fullname'] = "East-Northeast";
1677
-		} elseif ($direction >= 90 && $direction < 112.5){
1677
+		} elseif ($direction >= 90 && $direction < 112.5) {
1678 1678
 			$temp_array['direction_degree'] = $direction;
1679 1679
 			$temp_array['direction_shortname'] = "E";
1680 1680
 			$temp_array['direction_fullname'] = "East";
1681
-		} elseif ($direction >= 112.5 && $direction < 135){
1681
+		} elseif ($direction >= 112.5 && $direction < 135) {
1682 1682
 			$temp_array['direction_degree'] = $direction;
1683 1683
 			$temp_array['direction_shortname'] = "ESE";
1684 1684
 			$temp_array['direction_fullname'] = "East-Southeast";
1685
-		} elseif ($direction >= 135 && $direction < 157.5){
1685
+		} elseif ($direction >= 135 && $direction < 157.5) {
1686 1686
 			$temp_array['direction_degree'] = $direction;
1687 1687
 			$temp_array['direction_shortname'] = "SE";
1688 1688
 			$temp_array['direction_fullname'] = "Southeast";
1689
-		} elseif ($direction >= 157.5 && $direction < 180){
1689
+		} elseif ($direction >= 157.5 && $direction < 180) {
1690 1690
 			$temp_array['direction_degree'] = $direction;
1691 1691
 			$temp_array['direction_shortname'] = "SSE";
1692 1692
 			$temp_array['direction_fullname'] = "South-Southeast";
1693
-		} elseif ($direction >= 180 && $direction < 202.5){
1693
+		} elseif ($direction >= 180 && $direction < 202.5) {
1694 1694
 			$temp_array['direction_degree'] = $direction;
1695 1695
 			$temp_array['direction_shortname'] = "S";
1696 1696
 			$temp_array['direction_fullname'] = "South";
1697
-		} elseif ($direction >= 202.5 && $direction < 225){
1697
+		} elseif ($direction >= 202.5 && $direction < 225) {
1698 1698
 			$temp_array['direction_degree'] = $direction;
1699 1699
 			$temp_array['direction_shortname'] = "SSW";
1700 1700
 			$temp_array['direction_fullname'] = "South-Southwest";
1701
-		} elseif ($direction >= 225 && $direction < 247.5){
1701
+		} elseif ($direction >= 225 && $direction < 247.5) {
1702 1702
 			$temp_array['direction_degree'] = $direction;
1703 1703
 			$temp_array['direction_shortname'] = "SW";
1704 1704
 			$temp_array['direction_fullname'] = "Southwest";
1705
-		} elseif ($direction >= 247.5 && $direction < 270){
1705
+		} elseif ($direction >= 247.5 && $direction < 270) {
1706 1706
 			$temp_array['direction_degree'] = $direction;
1707 1707
 			$temp_array['direction_shortname'] = "WSW";
1708 1708
 			$temp_array['direction_fullname'] = "West-Southwest";
1709
-		} elseif ($direction >= 270 && $direction < 292.5){
1709
+		} elseif ($direction >= 270 && $direction < 292.5) {
1710 1710
 			$temp_array['direction_degree'] = $direction;
1711 1711
 			$temp_array['direction_shortname'] = "W";
1712 1712
 			$temp_array['direction_fullname'] = "West";
1713
-		} elseif ($direction >= 292.5 && $direction < 315){
1713
+		} elseif ($direction >= 292.5 && $direction < 315) {
1714 1714
 			$temp_array['direction_degree'] = $direction;
1715 1715
 			$temp_array['direction_shortname'] = "WNW";
1716 1716
 			$temp_array['direction_fullname'] = "West-Northwest";
1717
-		} elseif ($direction >= 315 && $direction < 337.5){
1717
+		} elseif ($direction >= 315 && $direction < 337.5) {
1718 1718
 			$temp_array['direction_degree'] = $direction;
1719 1719
 			$temp_array['direction_shortname'] = "NW";
1720 1720
 			$temp_array['direction_fullname'] = "Northwest";
1721
-		} elseif ($direction >= 337.5 && $direction < 360){
1721
+		} elseif ($direction >= 337.5 && $direction < 360) {
1722 1722
 			$temp_array['direction_degree'] = $direction;
1723 1723
 			$temp_array['direction_shortname'] = "NNW";
1724 1724
 			$temp_array['direction_fullname'] = "North-Northwest";
@@ -1735,11 +1735,11 @@  discard block
 block discarded – undo
1735 1735
 	* @param Float $longitude longitute of the flight
1736 1736
 	* @return String the countrie
1737 1737
 	*/
1738
-	public function getCountryFromLatitudeLongitude($latitude,$longitude)
1738
+	public function getCountryFromLatitudeLongitude($latitude, $longitude)
1739 1739
 	{
1740 1740
 		global $globalDBdriver, $globalDebug;
1741
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1742
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1741
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1742
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
1743 1743
 	
1744 1744
 		$Connection = new Connection($this->db);
1745 1745
 		if (!$Connection->tableExists('countries')) return '';
@@ -1779,7 +1779,7 @@  discard block
 block discarded – undo
1779 1779
 	public function getCountryFromISO2($iso2)
1780 1780
 	{
1781 1781
 		global $globalDBdriver, $globalDebug;
1782
-		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1782
+		$iso2 = filter_var($iso2, FILTER_SANITIZE_STRING);
1783 1783
 	
1784 1784
 		$Connection = new Connection($this->db);
1785 1785
 		if (!$Connection->tableExists('countries')) return '';
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
 		
1828 1828
 		$bitly_data = json_decode($bitly_data);
1829 1829
 		$bitly_url = '';
1830
-		if ($bitly_data->status_txt = "OK"){
1830
+		if ($bitly_data->status_txt = "OK") {
1831 1831
 			$bitly_url = $bitly_data->data->url;
1832 1832
 		}
1833 1833
 
@@ -1841,11 +1841,11 @@  discard block
 block discarded – undo
1841 1841
 	* @return Array the vessel type list
1842 1842
 	*
1843 1843
 	*/
1844
-	public function countAllMarineTypes($limit = true,$olderthanmonths = 0,$sincedate = '',$filters = array(),$year = '',$month = '',$day = '')
1844
+	public function countAllMarineTypes($limit = true, $olderthanmonths = 0, $sincedate = '', $filters = array(), $year = '', $month = '', $day = '')
1845 1845
 	{
1846 1846
 		global $globalDBdriver;
1847
-		$filter_query = $this->getFilter($filters,true,true);
1848
-		$query  = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
1847
+		$filter_query = $this->getFilter($filters, true, true);
1848
+		$query = "SELECT marine_output.type AS marine_type, COUNT(marine_output.type) AS marine_type_count, marine_output.type_id AS marine_type_id 
1849 1849
 		    FROM marine_output ".$filter_query." marine_output.type <> '' AND marine_output.type_id IS NOT NULL";
1850 1850
 		if ($olderthanmonths > 0) {
1851 1851
 			if ($globalDBdriver == 'mysql') {
@@ -1865,28 +1865,28 @@  discard block
 block discarded – undo
1865 1865
 		if ($year != '') {
1866 1866
 			if ($globalDBdriver == 'mysql') {
1867 1867
 				$query .= " AND YEAR(marine_output.date) = :year";
1868
-				$query_values = array_merge($query_values,array(':year' => $year));
1868
+				$query_values = array_merge($query_values, array(':year' => $year));
1869 1869
 			} else {
1870 1870
 				$query .= " AND EXTRACT(YEAR FROM marine_output.date) = :year";
1871
-				$query_values = array_merge($query_values,array(':year' => $year));
1871
+				$query_values = array_merge($query_values, array(':year' => $year));
1872 1872
 			}
1873 1873
 		}
1874 1874
 		if ($month != '') {
1875 1875
 			if ($globalDBdriver == 'mysql') {
1876 1876
 				$query .= " AND MONTH(marine_output.date) = :month";
1877
-				$query_values = array_merge($query_values,array(':month' => $month));
1877
+				$query_values = array_merge($query_values, array(':month' => $month));
1878 1878
 			} else {
1879 1879
 				$query .= " AND EXTRACT(MONTH FROM marine_output.date) = :month";
1880
-				$query_values = array_merge($query_values,array(':month' => $month));
1880
+				$query_values = array_merge($query_values, array(':month' => $month));
1881 1881
 			}
1882 1882
 		}
1883 1883
 		if ($day != '') {
1884 1884
 			if ($globalDBdriver == 'mysql') {
1885 1885
 				$query .= " AND DAY(marine_output.date) = :day";
1886
-				$query_values = array_merge($query_values,array(':day' => $day));
1886
+				$query_values = array_merge($query_values, array(':day' => $day));
1887 1887
 			} else {
1888 1888
 				$query .= " AND EXTRACT(DAY FROM marine_output.date) = :day";
1889
-				$query_values = array_merge($query_values,array(':day' => $day));
1889
+				$query_values = array_merge($query_values, array(':day' => $day));
1890 1890
 			}
1891 1891
 		}
1892 1892
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
@@ -1895,7 +1895,7 @@  discard block
 block discarded – undo
1895 1895
 		$sth->execute($query_values);
1896 1896
 		$marine_array = array();
1897 1897
 		$temp_array = array();
1898
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
1898
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
1899 1899
 		{
1900 1900
 			$temp_array['marine_type'] = $row['marine_type'];
1901 1901
 			$temp_array['marine_type_id'] = $row['marine_type_id'];
@@ -1911,13 +1911,13 @@  discard block
 block discarded – undo
1911 1911
 	* @return Array the tracker information
1912 1912
 	*
1913 1913
 	*/
1914
-	public function searchMarineData($q = '', $callsign = '',$mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '',$origLat = '',$origLon = '',$dist = '',$filters = array())
1914
+	public function searchMarineData($q = '', $callsign = '', $mmsi = '', $imo = '', $date_posted = '', $limit = '', $sort = '', $includegeodata = '', $origLat = '', $origLon = '', $dist = '', $filters = array())
1915 1915
 	{
1916 1916
 		global $globalTimezone, $globalDBdriver;
1917 1917
 		date_default_timezone_set('UTC');
1918 1918
 		$query_values = array();
1919 1919
 		$additional_query = '';
1920
-		$filter_query = $this->getFilter($filters,true,true);
1920
+		$filter_query = $this->getFilter($filters, true, true);
1921 1921
 		if ($q != "")
1922 1922
 		{
1923 1923
 			if (!is_string($q))
@@ -1925,8 +1925,8 @@  discard block
 block discarded – undo
1925 1925
 				return false;
1926 1926
 			} else {
1927 1927
 				$q_array = explode(" ", $q);
1928
-				foreach ($q_array as $q_item){
1929
-					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1928
+				foreach ($q_array as $q_item) {
1929
+					$q_item = filter_var($q_item, FILTER_SANITIZE_STRING);
1930 1930
 					$additional_query .= " AND (";
1931 1931
 					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1932 1932
 					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
@@ -1938,42 +1938,42 @@  discard block
 block discarded – undo
1938 1938
 		}
1939 1939
 		if ($callsign != "")
1940 1940
 		{
1941
-			$callsign = filter_var($callsign,FILTER_SANITIZE_STRING);
1941
+			$callsign = filter_var($callsign, FILTER_SANITIZE_STRING);
1942 1942
 			if (!is_string($callsign))
1943 1943
 			{
1944 1944
 				return false;
1945 1945
 			} else {
1946 1946
 				$additional_query .= " AND marine_output.ident = :callsign";
1947
-				$query_values = array_merge($query_values,array(':callsign' => $callsign));
1947
+				$query_values = array_merge($query_values, array(':callsign' => $callsign));
1948 1948
 			}
1949 1949
 		}
1950 1950
 		if ($mmsi != "")
1951 1951
 		{
1952
-			$mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING);
1952
+			$mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING);
1953 1953
 			if (!is_numeric($mmsi))
1954 1954
 			{
1955 1955
 				return false;
1956 1956
 			} else {
1957 1957
 				$additional_query .= " AND marine_output.mmsi = :mmsi";
1958
-				$query_values = array_merge($query_values,array(':mmsi' => $mmsi));
1958
+				$query_values = array_merge($query_values, array(':mmsi' => $mmsi));
1959 1959
 			}
1960 1960
 		}
1961 1961
 		if ($imo != "")
1962 1962
 		{
1963
-			$imo = filter_var($imo,FILTER_SANITIZE_STRING);
1963
+			$imo = filter_var($imo, FILTER_SANITIZE_STRING);
1964 1964
 			if (!is_numeric($imo))
1965 1965
 			{
1966 1966
 				return false;
1967 1967
 			} else {
1968 1968
 				$additional_query .= " AND marine_output.imo = :imo";
1969
-				$query_values = array_merge($query_values,array(':imo' => $imo));
1969
+				$query_values = array_merge($query_values, array(':imo' => $imo));
1970 1970
 			}
1971 1971
 		}
1972 1972
 		if ($date_posted != "")
1973 1973
 		{
1974 1974
 			$date_array = explode(",", $date_posted);
1975
-			$date_array[0] = filter_var($date_array[0],FILTER_SANITIZE_STRING);
1976
-			$date_array[1] = filter_var($date_array[1],FILTER_SANITIZE_STRING);
1975
+			$date_array[0] = filter_var($date_array[0], FILTER_SANITIZE_STRING);
1976
+			$date_array[1] = filter_var($date_array[1], FILTER_SANITIZE_STRING);
1977 1977
 			if ($globalTimezone != '') {
1978 1978
 				date_default_timezone_set($globalTimezone);
1979 1979
 				$datetime = new DateTime();
@@ -2000,8 +2000,8 @@  discard block
 block discarded – undo
2000 2000
 		if ($limit != "")
2001 2001
 		{
2002 2002
 			$limit_array = explode(",", $limit);
2003
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
2004
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
2003
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
2004
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
2005 2005
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2006 2006
 			{
2007 2007
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
@@ -2019,28 +2019,28 @@  discard block
 block discarded – undo
2019 2019
 			}
2020 2020
 		}
2021 2021
 		if ($origLat != "" && $origLon != "" && $dist != "") {
2022
-			$dist = number_format($dist*0.621371,2,'.',''); // convert km to mile
2022
+			$dist = number_format($dist*0.621371, 2, '.', ''); // convert km to mile
2023 2023
 			if ($globalDBdriver == 'mysql') {
2024
-				$query="SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
2024
+				$query = "SELECT marine_output.*, 1.60935*3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2))) as distance 
2025 2025
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND marine_archive.longitude between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat)*69)) and marine_archive.latitude between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
2026 2026
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - marine_archive.latitude)*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(marine_archive.latitude*pi()/180)*POWER(SIN(($origLon-marine_archive.longitude)*pi()/180/2),2)))) < $dist".$orderby_query;
2027 2027
 			} else {
2028
-				$query="SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
2028
+				$query = "SELECT marine_output.*, 1.60935 * 3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2))) as distance 
2029 2029
 				    FROM marine_archive,marine_output".$filter_query." marine_output.fammarine_id = marine_archive.fammarine_id AND marine_output.ident <> '' ".$additional_query."AND CAST(marine_archive.longitude as double precision) between ($origLon-$dist/cos(radians($origLat))*69) and ($origLon+$dist/cos(radians($origLat))*69) and CAST(marine_archive.latitude as double precision) between ($origLat-($dist/69)) and ($origLat+($dist/69)) 
2030 2030
 				    AND (3956 * 2 * ASIN(SQRT( POWER(SIN(($origLat - CAST(marine_archive.latitude as double precision))*pi()/180/2),2)+COS( $origLat *pi()/180)*COS(CAST(marine_archive.latitude as double precision)*pi()/180)*POWER(SIN(($origLon-CAST(marine_archive.longitude as double precision))*pi()/180/2),2)))) < $dist".$filter_query.$orderby_query;
2031 2031
 			}
2032 2032
 		} else {
2033
-			$query  = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2033
+			$query = "SELECT marine_output.* FROM marine_output".$filter_query." marine_output.ident <> '' 
2034 2034
 			    ".$additional_query."
2035 2035
 			    ".$orderby_query;
2036 2036
 		}
2037
-		$marine_array = $this->getDataFromDB($query, $query_values,$limit_query);
2037
+		$marine_array = $this->getDataFromDB($query, $query_values, $limit_query);
2038 2038
 		return $marine_array;
2039 2039
 	}
2040 2040
 
2041 2041
 	public function getOrderBy()
2042 2042
 	{
2043
-		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"),"distance_asc" => array("key" => "distance_asc","value" => "Distance - ASC","sql" => "ORDER BY distance ASC"),"distance_desc" => array("key" => "distance_desc","value" => "Distance - DESC","sql" => "ORDER BY distance DESC"));
2043
+		$orderby = array("type_asc" => array("key" => "type_asc", "value" => "Type - ASC", "sql" => "ORDER BY marine_output.type ASC"), "type_desc" => array("key" => "type_desc", "value" => "Type - DESC", "sql" => "ORDER BY marine_output.type DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY marine_output.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY marine_output.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY marine_output.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY marine_output.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY marine_output.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY marine_output.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY marine_output.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY marine_output.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY marine_output.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY marine_output.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY marine_output.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY marine_output.date DESC"), "distance_asc" => array("key" => "distance_asc", "value" => "Distance - ASC", "sql" => "ORDER BY distance ASC"), "distance_desc" => array("key" => "distance_desc", "value" => "Distance - DESC", "sql" => "ORDER BY distance DESC"));
2044 2044
 		
2045 2045
 		return $orderby;
2046 2046
 		
Please login to merge, or discard this patch.
Braces   +206 added lines, -73 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@  discard block
 block discarded – undo
8 8
 	public function __construct($dbc = null) {
9 9
 		$Connection = new Connection($dbc);
10 10
 		$this->db = $Connection->db();
11
-		if ($this->db === null) die('Error: No DB connection. (Marine)');
11
+		if ($this->db === null) {
12
+			die('Error: No DB connection. (Marine)');
13
+		}
12 14
 	}
13 15
 
14 16
 	/**
@@ -30,7 +32,9 @@  discard block
 block discarded – undo
30 32
 		if (isset($filter[0]['source'])) {
31 33
 			$filters = array_merge($filters,$filter);
32 34
 		}
33
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
35
+		if (is_array($globalFilter)) {
36
+			$filter = array_merge($filter,$globalFilter);
37
+		}
34 38
 		$filter_query_join = '';
35 39
 		$filter_query_where = '';
36 40
 		foreach($filters as $flt) {
@@ -72,8 +76,11 @@  discard block
 block discarded – undo
72 76
 				$filter_query_where .= " AND EXTRACT(DAY FROM marine_output.date) = '".$filter['day']."'";
73 77
 			}
74 78
 		}
75
-		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
76
-		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
79
+		if ($filter_query_where == '' && $where) {
80
+			$filter_query_where = ' WHERE';
81
+		} elseif ($filter_query_where != '' && $and) {
82
+			$filter_query_where .= ' AND';
83
+		}
77 84
 		if ($filter_query_where != '') {
78 85
 			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
79 86
 		}
@@ -127,35 +134,63 @@  discard block
 block discarded – undo
127 134
 				$temp_array['spotter_id'] = $row['spotter_archive_id'];
128 135
 			} elseif (isset($row['spotter_archive_output_id'])) {
129 136
 				$temp_array['spotter_id'] = $row['spotter_archive_output_id'];
130
-			*/} 
131
-			elseif (isset($row['marineid'])) {
137
+			*/} elseif (isset($row['marineid'])) {
132 138
 				$temp_array['marine_id'] = $row['marineid'];
133 139
 			} else {
134 140
 				$temp_array['marine_id'] = '';
135 141
 			}
136
-			if (isset($row['fammarine_id'])) $temp_array['fammarine_id'] = $row['fammarine_id'];
137
-			if (isset($row['mmsi'])) $temp_array['mmsi'] = $row['mmsi'];
138
-			if (isset($row['type'])) $temp_array['type'] = $row['type'];
139
-			if (isset($row['type_id'])) $temp_array['type_id'] = $row['type_id'];
140
-			if (isset($row['status'])) $temp_array['status'] = $row['status'];
141
-			if (isset($row['status_id'])) $temp_array['status_id'] = $row['status_id'];
142
-			if (isset($row['ident'])) $temp_array['ident'] = $row['ident'];
143
-			if (isset($row['arrival_port_name'])) $temp_array['arrival_port_name'] = $row['arrival_port_name'];
144
-			if (isset($row['latitude'])) $temp_array['latitude'] = $row['latitude'];
145
-			if (isset($row['longitude'])) $temp_array['longitude'] = $row['longitude'];
146
-			if (isset($row['format_source'])) $temp_array['format_source'] = $row['format_source'];
142
+			if (isset($row['fammarine_id'])) {
143
+				$temp_array['fammarine_id'] = $row['fammarine_id'];
144
+			}
145
+			if (isset($row['mmsi'])) {
146
+				$temp_array['mmsi'] = $row['mmsi'];
147
+			}
148
+			if (isset($row['type'])) {
149
+				$temp_array['type'] = $row['type'];
150
+			}
151
+			if (isset($row['type_id'])) {
152
+				$temp_array['type_id'] = $row['type_id'];
153
+			}
154
+			if (isset($row['status'])) {
155
+				$temp_array['status'] = $row['status'];
156
+			}
157
+			if (isset($row['status_id'])) {
158
+				$temp_array['status_id'] = $row['status_id'];
159
+			}
160
+			if (isset($row['ident'])) {
161
+				$temp_array['ident'] = $row['ident'];
162
+			}
163
+			if (isset($row['arrival_port_name'])) {
164
+				$temp_array['arrival_port_name'] = $row['arrival_port_name'];
165
+			}
166
+			if (isset($row['latitude'])) {
167
+				$temp_array['latitude'] = $row['latitude'];
168
+			}
169
+			if (isset($row['longitude'])) {
170
+				$temp_array['longitude'] = $row['longitude'];
171
+			}
172
+			if (isset($row['format_source'])) {
173
+				$temp_array['format_source'] = $row['format_source'];
174
+			}
147 175
 			if (isset($row['heading'])) {
148 176
 				$temp_array['heading'] = $row['heading'];
149 177
 				$heading_direction = $this->parseDirection($row['heading']);
150
-				if (isset($heading_direction[0]['direction_fullname'])) $temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
178
+				if (isset($heading_direction[0]['direction_fullname'])) {
179
+					$temp_array['heading_name'] = $heading_direction[0]['direction_fullname'];
180
+				}
181
+			}
182
+			if (isset($row['ground_speed'])) {
183
+				$temp_array['ground_speed'] = $row['ground_speed'];
151 184
 			}
152
-			if (isset($row['ground_speed'])) $temp_array['ground_speed'] = $row['ground_speed'];
153 185
 
154 186
 			if(isset($temp_array['mmsi']) && $temp_array['mmsi'] != "")
155 187
 			{
156 188
 				$Image = new Image($this->db);
157
-				if (isset($temp_array['ident']) && $temp_array['ident'] != '') $image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
158
-				else $image_array = $Image->getMarineImage($temp_array['mmsi']);
189
+				if (isset($temp_array['ident']) && $temp_array['ident'] != '') {
190
+					$image_array = $Image->getMarineImage($temp_array['mmsi'],'',$temp_array['ident']);
191
+				} else {
192
+					$image_array = $Image->getMarineImage($temp_array['mmsi']);
193
+				}
159 194
 				unset($Image);
160 195
 				if (count($image_array) > 0) {
161 196
 					$temp_array['image'] = $image_array[0]['image'];
@@ -207,13 +242,21 @@  discard block
 block discarded – undo
207 242
 			}
208 243
 			
209 244
 			$fromsource = NULL;
210
-			if (isset($row['source_name']) && $row['source_name'] != '') $temp_array['source_name'] = $row['source_name'];
211
-			if (isset($row['over_country']) && $row['over_country'] != '') $temp_array['over_country'] = $row['over_country'];
212
-			if (isset($row['distance']) && $row['distance'] != '') $temp_array['distance'] = $row['distance'];
245
+			if (isset($row['source_name']) && $row['source_name'] != '') {
246
+				$temp_array['source_name'] = $row['source_name'];
247
+			}
248
+			if (isset($row['over_country']) && $row['over_country'] != '') {
249
+				$temp_array['over_country'] = $row['over_country'];
250
+			}
251
+			if (isset($row['distance']) && $row['distance'] != '') {
252
+				$temp_array['distance'] = $row['distance'];
253
+			}
213 254
 			$temp_array['query_number_rows'] = $num_rows;
214 255
 			$spotter_array[] = $temp_array;
215 256
 		}
216
-		if ($num_rows == 0) return array();
257
+		if ($num_rows == 0) {
258
+			return array();
259
+		}
217 260
 		$spotter_array[0]['query_number_rows'] = $num_rows;
218 261
 		return $spotter_array;
219 262
 	}	
@@ -239,8 +282,12 @@  discard block
 block discarded – undo
239 282
 			{
240 283
 				//$limit_query = " LIMIT ".$limit_array[0].",".$limit_array[1];
241 284
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
242
-			} else $limit_query = "";
243
-		} else $limit_query = "";
285
+			} else {
286
+				$limit_query = "";
287
+			}
288
+		} else {
289
+			$limit_query = "";
290
+		}
244 291
 		if ($sort != "")
245 292
 		{
246 293
 			$search_orderby_array = $this->getOrderBy();
@@ -264,7 +311,9 @@  discard block
 block discarded – undo
264 311
 		global $global_query;
265 312
 		
266 313
 		date_default_timezone_set('UTC');
267
-		if ($id == '') return array();
314
+		if ($id == '') {
315
+			return array();
316
+		}
268 317
 		$additional_query = "marine_output.fammarine_id = :id";
269 318
 		$query_values = array(':id' => $id);
270 319
 		$query  = $global_query." WHERE ".$additional_query." ";
@@ -460,8 +509,11 @@  discard block
 block discarded – undo
460 509
 		$query .= " ORDER BY marine_output.source_name ASC";
461 510
 
462 511
 		$sth = $this->db->prepare($query);
463
-		if (!empty($query_values)) $sth->execute($query_values);
464
-		else $sth->execute();
512
+		if (!empty($query_values)) {
513
+			$sth->execute($query_values);
514
+		} else {
515
+			$sth->execute();
516
+		}
465 517
 
466 518
 		$source_array = array();
467 519
 		$temp_array = array();
@@ -516,8 +568,11 @@  discard block
 block discarded – undo
516 568
 		$sth = $this->db->prepare($query);
517 569
 		$sth->execute(array(':mmsi' => $mmsi));
518 570
 		$result = $sth->fetchAll(PDO::FETCH_ASSOC);
519
-		if (isset($result[0])) return $result[0];
520
-		else return array();
571
+		if (isset($result[0])) {
572
+			return $result[0];
573
+		} else {
574
+			return array();
575
+		}
521 576
 	}
522 577
 
523 578
 	/**
@@ -558,7 +613,9 @@  discard block
 block discarded – undo
558 613
 			date_default_timezone_set($globalTimezone);
559 614
 			$datetime = new DateTime();
560 615
 			$offset = $datetime->format('P');
561
-		} else $offset = '+00:00';
616
+		} else {
617
+			$offset = '+00:00';
618
+		}
562 619
 
563 620
 		if ($globalDBdriver == 'mysql') {
564 621
 			$query  = "SELECT DISTINCT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) as date
@@ -804,11 +861,21 @@  discard block
 block discarded – undo
804 861
 			$latitude = 0;
805 862
 			$longitude = 0;
806 863
 		}
807
-		if ($type_id == '') $type_id = NULL;
808
-		if ($status_id == '') $status_id = NULL;
809
-		if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
810
-		if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
811
-		if ($arrival_date == '') $arrival_date = NULL;
864
+		if ($type_id == '') {
865
+			$type_id = NULL;
866
+		}
867
+		if ($status_id == '') {
868
+			$status_id = NULL;
869
+		}
870
+		if ($heading == '' || $Common->isInteger($heading) === false) {
871
+			$heading = 0;
872
+		}
873
+		if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) {
874
+			$groundspeed = 0;
875
+		}
876
+		if ($arrival_date == '') {
877
+			$arrival_date = NULL;
878
+		}
812 879
 		$query  = "INSERT INTO marine_output (fammarine_id, ident, latitude, longitude, heading, ground_speed, date, format_source, source_name, mmsi, type, type_id, status,status_id,imo,arrival_port_name,arrival_port_date) 
813 880
 		    VALUES (:fammarine_id,:ident,:latitude,:longitude,:heading,:speed,:date,:format_source, :source_name,:mmsi,:type,:type_id,:status,:status_id,:imo,:arrival_port_name,:arrival_port_date)";
814 881
 
@@ -915,7 +982,9 @@  discard block
 block discarded – undo
915 982
 		global $globalDBdriver, $globalArchive;
916 983
 		//$filter_query = $this->getFilter($filters,true,true);
917 984
 		$Connection= new Connection($this->db);
918
-		if (!$Connection->tableExists('countries')) return array();
985
+		if (!$Connection->tableExists('countries')) {
986
+			return array();
987
+		}
919 988
 		require_once('class.SpotterLive.php');
920 989
 		if (!isset($globalArchive) || $globalArchive !== TRUE) {
921 990
 			$MarineLive = new MarineLive($this->db);
@@ -959,7 +1028,9 @@  discard block
 block discarded – undo
959 1028
 			$query = "SELECT c.name, c.iso3, c.iso2, count(c.name) as nb FROM countries c INNER JOIN (SELECT DISTINCT fammarine_id,over_country FROM marine_archive".$filter_query.") l ON c.iso2 = l.over_country ";
960 1029
 		}
961 1030
 		$query .= "GROUP BY c.name,c.iso3,c.iso2 ORDER BY nb DESC";
962
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1031
+		if ($limit) {
1032
+			$query .= " LIMIT 10 OFFSET 0";
1033
+		}
963 1034
 
964 1035
 		$sth = $this->db->prepare($query);
965 1036
 		$sth->execute();
@@ -993,12 +1064,18 @@  discard block
 block discarded – undo
993 1064
 		$query  = "SELECT DISTINCT marine_output.ident, COUNT(marine_output.ident) AS callsign_icao_count 
994 1065
                     FROM marine_output".$filter_query." marine_output.ident <> ''";
995 1066
 		 if ($olderthanmonths > 0) {
996
-			if ($globalDBdriver == 'mysql') $query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
997
-			else $query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1067
+			if ($globalDBdriver == 'mysql') {
1068
+				$query .= ' AND date < DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$olderthanmonths.' MONTH)';
1069
+			} else {
1070
+				$query .= " AND marine_output.date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'";
1071
+			}
998 1072
 		}
999 1073
 		if ($sincedate != '') {
1000
-			if ($globalDBdriver == 'mysql') $query .= " AND marine_output.date > '".$sincedate."'";
1001
-			else $query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1074
+			if ($globalDBdriver == 'mysql') {
1075
+				$query .= " AND marine_output.date > '".$sincedate."'";
1076
+			} else {
1077
+				$query .= " AND marine_output.date > CAST('".$sincedate."' AS TIMESTAMP)";
1078
+			}
1002 1079
 		}
1003 1080
 		$query_values = array();
1004 1081
 		if ($year != '') {
@@ -1029,7 +1106,9 @@  discard block
 block discarded – undo
1029 1106
 			}
1030 1107
 		}
1031 1108
 		$query .= " GROUP BY marine_output.ident ORDER BY callsign_icao_count DESC";
1032
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
1109
+		if ($limit) {
1110
+			$query .= " LIMIT 10 OFFSET 0";
1111
+		}
1033 1112
       		
1034 1113
 		$sth = $this->db->prepare($query);
1035 1114
 		$sth->execute($query_values);
@@ -1064,7 +1143,9 @@  discard block
 block discarded – undo
1064 1143
 			date_default_timezone_set($globalTimezone);
1065 1144
 			$datetime = new DateTime();
1066 1145
 			$offset = $datetime->format('P');
1067
-		} else $offset = '+00:00';
1146
+		} else {
1147
+			$offset = '+00:00';
1148
+		}
1068 1149
 
1069 1150
 		if ($globalDBdriver == 'mysql') {
1070 1151
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1114,7 +1195,9 @@  discard block
 block discarded – undo
1114 1195
 			date_default_timezone_set($globalTimezone);
1115 1196
 			$datetime = new DateTime();
1116 1197
 			$offset = $datetime->format('P');
1117
-		} else $offset = '+00:00';
1198
+		} else {
1199
+			$offset = '+00:00';
1200
+		}
1118 1201
 		$filter_query = $this->getFilter($filters,true,true);
1119 1202
 		if ($globalDBdriver == 'mysql') {
1120 1203
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1160,7 +1243,9 @@  discard block
 block discarded – undo
1160 1243
 			date_default_timezone_set($globalTimezone);
1161 1244
 			$datetime = new DateTime();
1162 1245
 			$offset = $datetime->format('P');
1163
-		} else $offset = '+00:00';
1246
+		} else {
1247
+			$offset = '+00:00';
1248
+		}
1164 1249
 		$filter_query = $this->getFilter($filters,true,true);
1165 1250
 		if ($globalDBdriver == 'mysql') {
1166 1251
 			$query  = "SELECT DATE(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS date_name, count(*) as date_count
@@ -1208,7 +1293,9 @@  discard block
 block discarded – undo
1208 1293
 			date_default_timezone_set($globalTimezone);
1209 1294
 			$datetime = new DateTime();
1210 1295
 			$offset = $datetime->format('P');
1211
-		} else $offset = '+00:00';
1296
+		} else {
1297
+			$offset = '+00:00';
1298
+		}
1212 1299
 
1213 1300
 		if ($globalDBdriver == 'mysql') {
1214 1301
 			$query  = "SELECT YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name,MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, count(*) as date_count
@@ -1257,7 +1344,9 @@  discard block
 block discarded – undo
1257 1344
 			date_default_timezone_set($globalTimezone);
1258 1345
 			$datetime = new DateTime();
1259 1346
 			$offset = $datetime->format('P');
1260
-		} else $offset = '+00:00';
1347
+		} else {
1348
+			$offset = '+00:00';
1349
+		}
1261 1350
 		$filter_query = $this->getFilter($filters,true,true);
1262 1351
 		if ($globalDBdriver == 'mysql') {
1263 1352
 			$query  = "SELECT MONTH(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS month_name, YEAR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS year_name, count(*) as date_count
@@ -1306,7 +1395,9 @@  discard block
 block discarded – undo
1306 1395
 			date_default_timezone_set($globalTimezone);
1307 1396
 			$datetime = new DateTime();
1308 1397
 			$offset = $datetime->format('P');
1309
-		} else $offset = '+00:00';
1398
+		} else {
1399
+			$offset = '+00:00';
1400
+		}
1310 1401
 
1311 1402
 		$orderby_sql = '';
1312 1403
 		if ($orderby == "hour")
@@ -1375,7 +1466,9 @@  discard block
 block discarded – undo
1375 1466
 			date_default_timezone_set($globalTimezone);
1376 1467
 			$datetime = new DateTime($date);
1377 1468
 			$offset = $datetime->format('P');
1378
-		} else $offset = '+00:00';
1469
+		} else {
1470
+			$offset = '+00:00';
1471
+		}
1379 1472
 
1380 1473
 		if ($globalDBdriver == 'mysql') {
1381 1474
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1423,7 +1516,9 @@  discard block
 block discarded – undo
1423 1516
 			date_default_timezone_set($globalTimezone);
1424 1517
 			$datetime = new DateTime();
1425 1518
 			$offset = $datetime->format('P');
1426
-		} else $offset = '+00:00';
1519
+		} else {
1520
+			$offset = '+00:00';
1521
+		}
1427 1522
 
1428 1523
 		if ($globalDBdriver == 'mysql') {
1429 1524
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1488,8 +1583,11 @@  discard block
 block discarded – undo
1488 1583
 				$query_values = array_merge($query_values,array(':month' => $month));
1489 1584
 			}
1490 1585
 		}
1491
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1492
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1586
+		if (empty($query_values)) {
1587
+			$queryi .= $this->getFilter($filters);
1588
+		} else {
1589
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1590
+		}
1493 1591
 		
1494 1592
 		$sth = $this->db->prepare($queryi);
1495 1593
 		$sth->execute($query_values);
@@ -1526,8 +1624,11 @@  discard block
 block discarded – undo
1526 1624
 				$query_values = array_merge($query_values,array(':month' => $month));
1527 1625
 			}
1528 1626
 		}
1529
-		if (empty($query_values)) $queryi .= $this->getFilter($filters);
1530
-		else $queryi .= $this->getFilter($filters,true,true).substr($query,4);
1627
+		if (empty($query_values)) {
1628
+			$queryi .= $this->getFilter($filters);
1629
+		} else {
1630
+			$queryi .= $this->getFilter($filters,true,true).substr($query,4);
1631
+		}
1531 1632
 		
1532 1633
 		$sth = $this->db->prepare($queryi);
1533 1634
 		$sth->execute($query_values);
@@ -1549,7 +1650,9 @@  discard block
 block discarded – undo
1549 1650
 			date_default_timezone_set($globalTimezone);
1550 1651
 			$datetime = new DateTime();
1551 1652
 			$offset = $datetime->format('P');
1552
-		} else $offset = '+00:00';
1653
+		} else {
1654
+			$offset = '+00:00';
1655
+		}
1553 1656
 
1554 1657
 		if ($globalDBdriver == 'mysql') {
1555 1658
 			$query  = "SELECT HOUR(CONVERT_TZ(marine_output.date,'+00:00', :offset)) AS hour_name, count(*) as hour_count
@@ -1653,7 +1756,9 @@  discard block
 block discarded – undo
1653 1756
 	*/
1654 1757
 	public function parseDirection($direction = 0)
1655 1758
 	{
1656
-		if ($direction == '') $direction = 0;
1759
+		if ($direction == '') {
1760
+			$direction = 0;
1761
+		}
1657 1762
 		$direction_array = array();
1658 1763
 		$temp_array = array();
1659 1764
 
@@ -1742,7 +1847,9 @@  discard block
 block discarded – undo
1742 1847
 		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
1743 1848
 	
1744 1849
 		$Connection = new Connection($this->db);
1745
-		if (!$Connection->tableExists('countries')) return '';
1850
+		if (!$Connection->tableExists('countries')) {
1851
+			return '';
1852
+		}
1746 1853
 	
1747 1854
 		try {
1748 1855
 			/*
@@ -1762,9 +1869,13 @@  discard block
 block discarded – undo
1762 1869
 			$sth->closeCursor();
1763 1870
 			if (count($row) > 0) {
1764 1871
 				return $row;
1765
-			} else return '';
1872
+			} else {
1873
+				return '';
1874
+			}
1766 1875
 		} catch (PDOException $e) {
1767
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1876
+			if (isset($globalDebug) && $globalDebug) {
1877
+				echo 'Error : '.$e->getMessage()."\n";
1878
+			}
1768 1879
 			return '';
1769 1880
 		}
1770 1881
 	
@@ -1782,7 +1893,9 @@  discard block
 block discarded – undo
1782 1893
 		$iso2 = filter_var($iso2,FILTER_SANITIZE_STRING);
1783 1894
 	
1784 1895
 		$Connection = new Connection($this->db);
1785
-		if (!$Connection->tableExists('countries')) return '';
1896
+		if (!$Connection->tableExists('countries')) {
1897
+			return '';
1898
+		}
1786 1899
 	
1787 1900
 		try {
1788 1901
 			$query = "SELECT name,iso2,iso3 FROM countries WHERE iso2 = :iso2 LIMIT 1";
@@ -1794,9 +1907,13 @@  discard block
 block discarded – undo
1794 1907
 			$sth->closeCursor();
1795 1908
 			if (count($row) > 0) {
1796 1909
 				return $row;
1797
-			} else return '';
1910
+			} else {
1911
+				return '';
1912
+			}
1798 1913
 		} catch (PDOException $e) {
1799
-			if (isset($globalDebug) && $globalDebug) echo 'Error : '.$e->getMessage()."\n";
1914
+			if (isset($globalDebug) && $globalDebug) {
1915
+				echo 'Error : '.$e->getMessage()."\n";
1916
+			}
1800 1917
 			return '';
1801 1918
 		}
1802 1919
 	
@@ -1814,7 +1931,9 @@  discard block
 block discarded – undo
1814 1931
 	{
1815 1932
 		global $globalBitlyAccessToken;
1816 1933
 		
1817
-		if ($globalBitlyAccessToken == '') return $url;
1934
+		if ($globalBitlyAccessToken == '') {
1935
+			return $url;
1936
+		}
1818 1937
         
1819 1938
 		$google_url = 'https://api-ssl.bitly.com/v3/shorten?access_token='.$globalBitlyAccessToken.'&longUrl='.$url;
1820 1939
 		
@@ -1890,7 +2009,9 @@  discard block
 block discarded – undo
1890 2009
 			}
1891 2010
 		}
1892 2011
 		$query .= " GROUP BY marine_output.type, marine_output.type_id ORDER BY marine_type_count DESC";
1893
-		if ($limit) $query .= " LIMIT 10 OFFSET 0";
2012
+		if ($limit) {
2013
+			$query .= " LIMIT 10 OFFSET 0";
2014
+		}
1894 2015
 		$sth = $this->db->prepare($query);
1895 2016
 		$sth->execute($query_values);
1896 2017
 		$marine_array = array();
@@ -1928,9 +2049,15 @@  discard block
 block discarded – undo
1928 2049
 				foreach ($q_array as $q_item){
1929 2050
 					$q_item = filter_var($q_item,FILTER_SANITIZE_STRING);
1930 2051
 					$additional_query .= " AND (";
1931
-					if (is_int($q_item)) $additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
1932
-					if (is_int($q_item)) $additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
1933
-					if (is_int($q_item)) $additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2052
+					if (is_int($q_item)) {
2053
+						$additional_query .= "(marine_output.marine_id = '".$q_item."') OR ";
2054
+					}
2055
+					if (is_int($q_item)) {
2056
+						$additional_query .= "(marine_output.mmsi = '".$q_item."') OR ";
2057
+					}
2058
+					if (is_int($q_item)) {
2059
+						$additional_query .= "(marine_output.imo = '".$q_item."') OR ";
2060
+					}
1934 2061
 					$additional_query .= "(marine_output.ident like '%".$q_item."%') OR ";
1935 2062
 					$additional_query .= ")";
1936 2063
 				}
@@ -1978,7 +2105,9 @@  discard block
 block discarded – undo
1978 2105
 				date_default_timezone_set($globalTimezone);
1979 2106
 				$datetime = new DateTime();
1980 2107
 				$offset = $datetime->format('P');
1981
-			} else $offset = '+00:00';
2108
+			} else {
2109
+				$offset = '+00:00';
2110
+			}
1982 2111
 			if ($date_array[1] != "")
1983 2112
 			{
1984 2113
 				$date_array[0] = date("Y-m-d H:i:s", strtotime($date_array[0]));
@@ -2005,8 +2134,12 @@  discard block
 block discarded – undo
2005 2134
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
2006 2135
 			{
2007 2136
 				$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0];
2008
-			} else $limit_query = "";
2009
-		} else $limit_query = "";
2137
+			} else {
2138
+				$limit_query = "";
2139
+			}
2140
+		} else {
2141
+			$limit_query = "";
2142
+		}
2010 2143
 		if ($sort != "")
2011 2144
 		{
2012 2145
 			$search_orderby_array = $this->getOrderBy();
Please login to merge, or discard this patch.
aircraft-statistics-time.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -8,15 +8,15 @@  discard block
 block discarded – undo
8 8
         die();
9 9
 }
10 10
 
11
-$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING);
11
+$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING);
12 12
 
13 13
 $Spotter = new Spotter();
14
-$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1","");
14
+$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", "");
15 15
 
16 16
 
17 17
 if (!empty($spotter_array))
18 18
 {
19
-	$title = sprintf(_("Most Common Time of Day from %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']);
19
+	$title = sprintf(_("Most Common Time of Day from %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']);
20 20
 	require_once('header.php');
21 21
 	print '<div class="select-item">';
22 22
 	print '<form action="'.$globalURL.'/aircraft" method="get">';
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	$Stats = new Stats();
26 26
 	$aircraft_types = $Stats->getAllAircraftTypes();
27 27
 	if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
28
-	foreach($aircraft_types as $aircrafttype)
28
+	foreach ($aircraft_types as $aircrafttype)
29 29
 	{
30
-		if($aircraft_type == $aircrafttype['aircraft_icao'])
30
+		if ($aircraft_type == $aircrafttype['aircraft_icao'])
31 31
 		{
32 32
 			print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
33 33
 		} else {
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	include('aircraft-sub-menu.php');
54 54
 	print '<div class="column">';
55 55
 	print '<h2>'._("Most Common Time of Day").'</h2>';
56
-	print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
56
+	print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>';
57 57
 
58 58
 	$hour_array = $Spotter->countAllHoursByAircraft($aircraft_type);
59 59
 	print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
 	$hour_data = '';
64 64
 	$hour_cnt = '';
65 65
 	$last = 0;
66
-	foreach($hour_array as $hour_item)
66
+	foreach ($hour_array as $hour_item)
67 67
 	{
68
-		while($last != $hour_item['hour_name']) {
68
+		while ($last != $hour_item['hour_name']) {
69 69
 			$hour_data .= '"'.$last.':00",';
70 70
 			$hour_cnt .= '0,';
71 71
 			$last++;
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 		$hour_cnt .= $hour_item['hour_count'].',';
76 76
 	}
77 77
 	$hour_data = "[".substr($hour_data, 0, -1)."]";
78
-	$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
78
+	$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]";
79 79
 	print 'c3.generate({
80 80
 	    bindto: "#chartHour",
81 81
 	    data: {
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 		print '</thead>';
99 99
 		print '<tbody>';
100 100
 		$i = 1;
101
-		foreach($hour_array as $hour_item)
101
+		foreach ($hour_array as $hour_item)
102 102
 		{
103 103
 			print '<tr>';
104 104
 			print '<td>'.$hour_item['hour_name'].':00</td>';
Please login to merge, or discard this patch.
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.
aircraft-statistics-arrival-airport.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,15 +9,15 @@  discard block
 block discarded – undo
9 9
         die();
10 10
 }
11 11
 
12
-$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING);
12
+$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING);
13 13
 
14 14
 $Spotter = new Spotter();
15
-$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1","");
15
+$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", "");
16 16
 
17 17
 
18 18
 if (!empty($spotter_array))
19 19
 {
20
-	$title = sprintf(_("Most Common Arrival Airports for %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']);
20
+	$title = sprintf(_("Most Common Arrival Airports for %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']);
21 21
 	require_once('header.php');
22 22
 	print '<div class="select-item">';
23 23
 	print '<form action="'.$globalURL.'/aircraft" method="get">';
@@ -26,9 +26,9 @@  discard block
 block discarded – undo
26 26
 	$Stats = new Stats();
27 27
 	$aircraft_types = $Stats->getAllAircraftTypes();
28 28
 	if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
29
-	foreach($aircraft_types as $aircrafttype)
29
+	foreach ($aircraft_types as $aircrafttype)
30 30
 	{
31
-		if($aircraft_type == $aircrafttype['aircraft_icao'])
31
+		if ($aircraft_type == $aircrafttype['aircraft_icao'])
32 32
 		{
33 33
 			print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
34 34
 		} else {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 	include('aircraft-sub-menu.php');
56 56
 	print '<div class="column">';
57 57
 	print '<h2>'._("Most Common Arrival Airports").'</h2>';
58
-	print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
58
+	print '<p>'.sprintf(_("The statistic below shows all arrival airports of flights from <strong>%s (%s)</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>';
59 59
 	$airport_airport_array = $Spotter->countAllArrivalAirportsByAircraft($aircraft_type);
60 60
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
61 61
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	print '<script>';
65 65
 	print 'var series = [';
66 66
 	$airport_data = '';
67
-	foreach($airport_airport_array as $airport_item)
67
+	foreach ($airport_airport_array as $airport_item)
68 68
 	{
69 69
 		$airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_name'].' ('.$airport_item['airport_arrival_icao'].')",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],';
70 70
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	print '</thead>';
120 120
 	print '<tbody>';
121 121
 	$i = 1;
122
-	foreach($airport_airport_array as $airport_item)
122
+	foreach ($airport_airport_array as $airport_item)
123 123
 	{
124 124
 		print '<tr>';
125 125
 		print '<td><strong>'.$i.'</strong></td>';
Please login to merge, or discard this patch.
aircraft-statistics-departure-airport-country.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -7,14 +7,14 @@  discard block
 block discarded – undo
7 7
         header('Location: '.$globalURL.'/aircraft');
8 8
         die();
9 9
 }
10
-$aircraft_type = filter_input(INPUT_GET,'aircraft_type',FILTER_SANITIZE_STRING);
10
+$aircraft_type = filter_input(INPUT_GET, 'aircraft_type', FILTER_SANITIZE_STRING);
11 11
 $Spotter = new Spotter();
12
-$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type,"0,1","");
12
+$spotter_array = $Spotter->getSpotterDataByAircraft($aircraft_type, "0,1", "");
13 13
 
14 14
 
15 15
 if (!empty($spotter_array))
16 16
 {
17
-	$title = sprintf(_("Most Common Departure Airports by Country for %s (%s)"),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']);
17
+	$title = sprintf(_("Most Common Departure Airports by Country for %s (%s)"), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']);
18 18
 	require_once('header.php');
19 19
 	print '<div class="select-item">';
20 20
 	print '<form action="'.$globalURL.'/aircraft" method="get">';
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	$Stats = new Stats();
24 24
 	$aircraft_types = $Stats->getAllAircraftTypes();
25 25
 	if (empty($aircraft_types)) $aircraft_types = $Spotter->getAllAircraftTypes();
26
-	foreach($aircraft_types as $aircrafttype)
26
+	foreach ($aircraft_types as $aircrafttype)
27 27
 	{
28
-		if($aircraft_type == $aircrafttype['aircraft_icao'])
28
+		if ($aircraft_type == $aircrafttype['aircraft_icao'])
29 29
 		{
30 30
 			print '<option value="'.$aircrafttype['aircraft_icao'].'" selected="selected">'.$aircrafttype['aircraft_name'].' ('.$aircrafttype['aircraft_icao'].')</option>';
31 31
 		} else {
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	include('aircraft-sub-menu.php');
52 52
 	print '<div class="column">';
53 53
 	print '<h2>'._("Most Common Departure Airports by Country").'</h2>';
54
-	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s (%s)</strong>."),$spotter_array[0]['aircraft_name'],$spotter_array[0]['aircraft_type']).'</p>';
54
+	print '<p>'.sprintf(_("The statistic below shows all departure airports by Country of origin of flights from <strong>%s (%s)</strong>."), $spotter_array[0]['aircraft_name'], $spotter_array[0]['aircraft_type']).'</p>';
55 55
 	$airport_country_array = $Spotter->countAllDepartureAirportCountriesByAircraft($aircraft_type);
56 56
 	print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
57 57
 	print '<script type="text/javascript" src="'.$globalURL.'/js/topojson.v2.min.js"></script>';
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	print '<div id="chartCountry" class="chart" width="100%"></div><script>';
60 60
 	print 'var series = [';
61 61
 	$country_data = '';
62
-	foreach($airport_country_array as $airport_item)
62
+	foreach ($airport_country_array as $airport_item)
63 63
 	{
64 64
 		$country_data .= '[ "'.$airport_item['departure_airport_country_iso3'].'",'.$airport_item['airport_departure_country_count'].'],';
65 65
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 		print '</thead>';
108 108
 		print '<tbody>';
109 109
 		$i = 1;
110
-		foreach($airport_country_array as $airport_item)
110
+		foreach ($airport_country_array as $airport_item)
111 111
 		{
112 112
 			print '<tr>';
113 113
 			print '<td><strong>'.$i.'</strong></td>';
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; ?>/marine/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.