Completed
Push — master ( 4b9f50...005bcb )
by Yannick
28:37
created
live-czml.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
     $s3 = sin($bank/2);
49 49
     $c1c2 = $c1*$c2;
50 50
     $s1s2 = $s1*$s2;
51
-    $w =$c1c2*$c3 - $s1s2*$s3;
52
-    $x =$c1c2*$s3 + $s1s2*$c3;
53
-    $y =$s1*$c2*$c3 + $c1*$s2*$s3;
54
-    $z =$c1*$s2*$c3 - $s1*$c2*$s3;
55
-    return array('x' => $x,'y' => $y,'z' => $z,'w' => $w);
51
+    $w = $c1c2*$c3 - $s1s2*$s3;
52
+    $x = $c1c2*$s3 + $s1s2*$c3;
53
+    $y = $s1*$c2*$c3 + $c1*$s2*$s3;
54
+    $z = $c1*$s2*$c3 - $s1*$c2*$s3;
55
+    return array('x' => $x, 'y' => $y, 'z' => $z, 'w' => $w);
56 56
 //    return array('x' => '0.0','y' => '-0.931','z' => '0.0','w' => '0.365');
57 57
 
58 58
 }
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 $min = false;
74 74
 $allhistory = false;
75 75
 $filter['source'] = array();
76
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt'));
77
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup'));
78
-if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars'));
79
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs','famaprs'));
80
-if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs'));
81
-if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'],FILTER_SANITIZE_STRING);
82
-if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',',$_COOKIE['filter_Airlines']),FILTER_SANITIZE_STRING);
83
-if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',',$_COOKIE['filter_Sources']),FILTER_SANITIZE_STRING);
84
-if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'],FILTER_SANITIZE_STRING);
85
-if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'],FILTER_SANITIZE_STRING);
76
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['filter_ShowVATSIM']) && $_COOKIE['filter_ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'], array('vatsimtxt'));
77
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['filter_ShowIVAO']) && $_COOKIE['filter_ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'], array('whazzup'));
78
+if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['filter_ShowVMS']) && $_COOKIE['filter_ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'], array('phpvmacars'));
79
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['filter_ShowSBS1']) && $_COOKIE['filter_ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'], array('sbs', 'famaprs'));
80
+if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['filter_ShowAPRS']) && $_COOKIE['filter_ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'], array('aprs'));
81
+if (isset($_COOKIE['filter_ident']) && $_COOKIE['filter_ident'] != '') $filter['ident'] = filter_var($_COOKIE['filter_ident'], FILTER_SANITIZE_STRING);
82
+if (isset($_COOKIE['filter_Airlines']) && $_COOKIE['filter_Airlines'] != '') $filter['airlines'] = filter_var_array(explode(',', $_COOKIE['filter_Airlines']), FILTER_SANITIZE_STRING);
83
+if (isset($_COOKIE['filter_Sources']) && $_COOKIE['filter_Sources'] != '') $filter['source_aprs'] = filter_var_array(explode(',', $_COOKIE['filter_Sources']), FILTER_SANITIZE_STRING);
84
+if (isset($_COOKIE['filter_airlinestype']) && $_COOKIE['filter_airlinestype'] != 'all') $filter['airlinestype'] = filter_var($_COOKIE['filter_airlinestype'], FILTER_SANITIZE_STRING);
85
+if (isset($_COOKIE['filter_alliance']) && $_COOKIE['filter_alliance'] != 'all') $filter['alliance'] = filter_var($_COOKIE['filter_alliance'], FILTER_SANITIZE_STRING);
86 86
 /*
87 87
 if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) {
88 88
 	$min = true;
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 	$from_archive = true;
130 130
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
131 131
 //	$enddate = filter_input(INPUT_GET,'enddate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
132
-	$begindate = filter_input(INPUT_GET,'begindate',FILTER_SANITIZE_NUMBER_INT);
133
-	$enddate = filter_input(INPUT_GET,'enddate',FILTER_SANITIZE_NUMBER_INT);
134
-	$archivespeed = filter_input(INPUT_GET,'speed',FILTER_SANITIZE_NUMBER_INT);
135
-	$begindate = date('Y-m-d H:i:s',$begindate);
136
-	$enddate = date('Y-m-d H:i:s',$enddate);
137
-	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate,$enddate,$filter);
132
+	$begindate = filter_input(INPUT_GET, 'begindate', FILTER_SANITIZE_NUMBER_INT);
133
+	$enddate = filter_input(INPUT_GET, 'enddate', FILTER_SANITIZE_NUMBER_INT);
134
+	$archivespeed = filter_input(INPUT_GET, 'speed', FILTER_SANITIZE_NUMBER_INT);
135
+	$begindate = date('Y-m-d H:i:s', $begindate);
136
+	$enddate = date('Y-m-d H:i:s', $enddate);
137
+	$spotter_array = $SpotterArchive->getMinLiveSpotterDataPlayback($begindate, $enddate, $filter);
138 138
 } elseif (isset($_COOKIE['archive']) && isset($_COOKIE['archive_begin']) && isset($_COOKIE['archive_end']) && isset($_COOKIE['archive_speed'])) {
139 139
 	$from_archive = true;
140 140
 //	$begindate = filter_input(INPUT_GET,'begindate',FILTER_VALIDATE_REGEXP,array("options"=>array("regexp"=>'~^\d{4}/\d{2}/\d{2}$~')));
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
 	$begindate = $_COOKIE['archive_begin'];
145 145
 	$enddate = $_COOKIE['archive_end'];
146 146
 
147
-	$archivespeed = filter_var($_COOKIE['archive_speed'],FILTER_SANITIZE_NUMBER_INT);
148
-	$begindate = date('Y-m-d H:i:s',$begindate);
149
-	$enddate = date('Y-m-d H:i:s',$enddate);
147
+	$archivespeed = filter_var($_COOKIE['archive_speed'], FILTER_SANITIZE_NUMBER_INT);
148
+	$begindate = date('Y-m-d H:i:s', $begindate);
149
+	$enddate = date('Y-m-d H:i:s', $enddate);
150 150
 //	echo 'Begin : '.$begindate.' - End : '.$enddate."\n";
151
-	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate,$enddate,$filter);
151
+	$spotter_array = $SpotterArchive->getMinLiveSpotterData($begindate, $enddate, $filter);
152 152
 } elseif ($tracker) {
153 153
 	$spotter_array = $TrackerLive->getMinLastLiveTrackerData($filter);
154 154
 } elseif ($marine) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 //print_r($spotter_array);
160 160
 if (!empty($spotter_array)) {
161 161
 	if (isset($_GET['archive'])) {
162
-		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter);
162
+		$flightcnt = $SpotterArchive->getLiveSpotterCount($begindate, $enddate, $filter);
163 163
 	} elseif ($tracker) {
164 164
 		$flightcnt = $TrackerLive->getLiveTrackerCount($filter);
165 165
 	} elseif ($marine) {
@@ -170,15 +170,15 @@  discard block
 block discarded – undo
170 170
 	if ($flightcnt == '') $flightcnt = 0;
171 171
 } else $flightcnt = 0;
172 172
 
173
-$sqltime = round(microtime(true)-$begintime,2);
173
+$sqltime = round(microtime(true) - $begintime, 2);
174 174
 $minitime = time();
175 175
 $maxitime = 0;
176 176
 
177 177
 $modelsdb = array();
178 178
 if (file_exists(dirname(__FILE__).'/models/modelsdb')) {
179
-	if (($handle = fopen(dirname(__FILE__).'/models/modelsdb','r')) !== FALSE) {
180
-		while (($row = fgetcsv($handle,1000)) !== FALSE) {
181
-			if (isset($row[1]) ){
179
+	if (($handle = fopen(dirname(__FILE__).'/models/modelsdb', 'r')) !== FALSE) {
180
+		while (($row = fgetcsv($handle, 1000)) !== FALSE) {
181
+			if (isset($row[1])) {
182 182
 				$model = $row[0];
183 183
 				$modelsdb[$model] = $row[1];
184 184
 			}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 $output .= '},';
215 215
 if (!empty($spotter_array) && is_array($spotter_array))
216 216
 {
217
-	foreach($spotter_array as $spotter_item)
217
+	foreach ($spotter_array as $spotter_item)
218 218
 	{
219 219
 		$j++;
220 220
 		//if (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'airwhere') $heightrelative = 'RELATIVE_TO_GROUND';
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
 					$output .= '},';
586 586
 				}
587 587
 			}
588
-			if ($onground) $output = str_replace('%onground%','true',$output);
589
-			else $output = str_replace('%onground%','false',$output);
588
+			if ($onground) $output = str_replace('%onground%', 'true', $output);
589
+			else $output = str_replace('%onground%', 'false', $output);
590 590
 
591 591
 	//		$output .= '"heightReference": "CLAMP_TO_GROUND",';
592 592
 			//$output .= '"heightReference": "'.$heightrelative.'",';
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 			$output .= '"cartographicDegrees": [';
602 602
 			if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']);
603 603
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
604
-			$output .= '"'.date("c",strtotime($spotter_item['date'])).'", ';
604
+			$output .= '"'.date("c", strtotime($spotter_item['date'])).'", ';
605 605
 			$output .= $spotter_item['longitude'].', ';
606 606
 			$output .= $spotter_item['latitude'];
607 607
 			$prevlong = $spotter_item['longitude'];
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 			//$quat = quaternionrotate(deg2rad($spotter_item['heading']),deg2rad(0),deg2rad(0));
630 630
 			//$orientation .= '"'.date("c",strtotime($spotter_item['date'])).'",'.$quat['x'].','.$quat['y'].','.$quat['z'].','.$quat['w'];
631 631
 		} else {
632
-			$output .= ',"'.date("c",strtotime($spotter_item['date'])).'", ';
632
+			$output .= ',"'.date("c", strtotime($spotter_item['date'])).'", ';
633 633
 			if ($maxitime < strtotime($spotter_item['date'])) $maxitime = strtotime($spotter_item['date']);
634 634
 			if ($spotter_item['ground_speed'] == 0) {
635 635
 				$output .= $prevlong.', ';
@@ -669,15 +669,15 @@  discard block
 block discarded – undo
669 669
 }
670 670
 $output .= ']';
671 671
 if (isset($globalArchive) && $globalArchive === TRUE) {
672
-	if ((time()-$globalLiveInterval) > $minitime) {
673
-		if (time()-$globalLiveInterval > $maxitime) {
674
-			$output = str_replace('%minitime%',date("c",$maxitime),$output);
672
+	if ((time() - $globalLiveInterval) > $minitime) {
673
+		if (time() - $globalLiveInterval > $maxitime) {
674
+			$output = str_replace('%minitime%', date("c", $maxitime), $output);
675 675
 		} else {
676
-			$output = str_replace('%minitime%',date("c",time()-$globalLiveInterval),$output);
676
+			$output = str_replace('%minitime%', date("c", time() - $globalLiveInterval), $output);
677 677
 		}
678 678
 	}
679
-	else $output = str_replace('%minitime%',date("c",$minitime),$output);
680
-} else $output = str_replace('%minitime%',date("c",$minitime),$output);
681
-$output = str_replace('%maxitime%',date("c",$maxitime),$output);
679
+	else $output = str_replace('%minitime%', date("c", $minitime), $output);
680
+} else $output = str_replace('%minitime%', date("c", $minitime), $output);
681
+$output = str_replace('%maxitime%', date("c", $maxitime), $output);
682 682
 print $output;
683 683
 ?>
Please login to merge, or discard this patch.
require/class.TrackerLive.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -16,33 +16,33 @@  discard block
 block discarded – undo
16 16
 	* @param Array $filter the filter
17 17
 	* @return Array the SQL part
18 18
 	*/
19
-	public function getFilter($filter = array(),$where = false,$and = false) {
19
+	public function getFilter($filter = array(), $where = false, $and = false) {
20 20
 		global $globalFilter, $globalStatsFilters, $globalFilterName, $globalDBdriver;
21 21
 		$filters = array();
22 22
 		if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
23 23
 			if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
24 24
 				$filters = $globalStatsFilters[$globalFilterName];
25 25
 			} else {
26
-				$filter = array_merge($filter,$globalStatsFilters[$globalFilterName]);
26
+				$filter = array_merge($filter, $globalStatsFilters[$globalFilterName]);
27 27
 			}
28 28
 		}
29 29
 		if (isset($filter[0]['source'])) {
30
-			$filters = array_merge($filters,$filter);
30
+			$filters = array_merge($filters, $filter);
31 31
 		}
32
-		if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
32
+		if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
33 33
 		$filter_query_join = '';
34 34
 		$filter_query_where = '';
35
-		foreach($filters as $flt) {
35
+		foreach ($filters as $flt) {
36 36
 			if (isset($flt['idents']) && !empty($flt['idents'])) {
37 37
 				if (isset($flt['source'])) {
38
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."') AND tracker_output.format_source IN ('".implode("','",$flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
38
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."') AND tracker_output.format_source IN ('".implode("','", $flt['source'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
39 39
 				} else {
40
-					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','",$flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
40
+					$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output WHERE tracker_output.ident IN ('".implode("','", $flt['idents'])."')) spid ON spid.famtrackid = tracker_live.famtrackid";
41 41
 				}
42 42
 			}
43 43
 		}
44 44
 		if (isset($filter['source']) && !empty($filter['source'])) {
45
-			$filter_query_where .= " AND format_source IN ('".implode("','",$filter['source'])."')";
45
+			$filter_query_where .= " AND format_source IN ('".implode("','", $filter['source'])."')";
46 46
 		}
47 47
 		if (isset($filter['ident']) && !empty($filter['ident'])) {
48 48
 			$filter_query_where .= " AND ident = '".$filter['ident']."'";
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 					$filter_query_date .= " AND EXTRACT(DAY FROM tracker_output.date) = '".$filter['day']."'";
72 72
 				}
73 73
 			}
74
-			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/',' WHERE',$filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
74
+			$filter_query_join .= " INNER JOIN (SELECT famtrackid FROM tracker_output".preg_replace('/^ AND/', ' WHERE', $filter_query_date).") sd ON sd.famtrackid = tracker_live.famtrackid";
75 75
 		}
76 76
 		if (isset($filter['source_aprs']) && !empty($filter['source_aprs'])) {
77
-			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')";
77
+			$filter_query_where .= " AND format_source = 'aprs' AND source_name IN ('".implode("','", $filter['source_aprs'])."')";
78 78
 		}
79 79
 		if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
80 80
 		elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
81 81
 		if ($filter_query_where != '') {
82
-			$filter_query_where = preg_replace('/^ AND/',' WHERE',$filter_query_where);
82
+			$filter_query_where = preg_replace('/^ AND/', ' WHERE', $filter_query_where);
83 83
 		}
84 84
 		$filter_query = $filter_query_join.$filter_query_where;
85 85
 		return $filter_query;
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 		if ($limit != '')
103 103
 		{
104 104
 			$limit_array = explode(',', $limit);
105
-			$limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT);
106
-			$limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT);
105
+			$limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT);
106
+			$limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT);
107 107
 			if ($limit_array[0] >= 0 && $limit_array[1] >= 0)
108 108
 			{
109 109
 				$limit_query = ' LIMIT '.$limit_array[1].' OFFSET '.$limit_array[0];
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		} else {
127 127
 			$query  = "SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query.$orderby_query;
128 128
 		}
129
-		$spotter_array = $Tracker->getDataFromDB($query.$limit_query,array(),'',true);
129
+		$spotter_array = $Tracker->getDataFromDB($query.$limit_query, array(), '', true);
130 130
 
131 131
 		return $spotter_array;
132 132
 	}
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		global $globalDBdriver, $globalLiveInterval;
143 143
 		date_default_timezone_set('UTC');
144 144
 
145
-		$filter_query = $this->getFilter($filter,true,true);
145
+		$filter_query = $this->getFilter($filter, true, true);
146 146
 
147 147
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
148 148
 		if ($globalDBdriver == 'mysql') {
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		try {
161 161
 			$sth = $this->db->prepare($query);
162 162
 			$sth->execute();
163
-		} catch(PDOException $e) {
163
+		} catch (PDOException $e) {
164 164
 			echo $e->getMessage();
165 165
 			die;
166 166
 		}
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 		global $globalDBdriver, $globalLiveInterval, $globalArchive;
181 181
 		date_default_timezone_set('UTC');
182 182
 
183
-		$filter_query = $this->getFilter($filter,true,true);
183
+		$filter_query = $this->getFilter($filter, true, true);
184 184
 
185 185
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
186 186
 		if ($globalDBdriver == 'mysql') {
187 187
 			if (isset($globalArchive) && $globalArchive) {
188
-				$query  = "SELECT * FROM (
188
+				$query = "SELECT * FROM (
189 189
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
190 190
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid 
191 191
 				    UNION
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 				    WHERE latitude <> '0' AND longitude <> '0' 
196 196
 				    ORDER BY famtrackid, date";
197 197
 			} else {
198
-				$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
198
+				$query = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
199 199
 				    FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date 
200 200
 				    AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
201 201
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
202 202
 			}
203 203
 		} else {
204 204
 			if (isset($globalArchive) && $globalArchive) {
205
-				$query  = "SELECT * FROM (
205
+				$query = "SELECT * FROM (
206 206
 					SELECT tracker_archive.ident, tracker_archive.famtrackid,tracker_archive.type,tracker_archive.latitude, tracker_archive.longitude, tracker_archive.altitude, tracker_archive.heading, tracker_archive.ground_speed, tracker_archive.date, tracker_archive.format_source 
207 207
 					FROM tracker_archive INNER JOIN (SELECT famtrackid FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date) l ON l.famtrackid = tracker_archive.famtrackid 
208 208
 				    UNION
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 				    WHERE latitude <> '0' AND longitude <> '0' 
213 213
 				    ORDER BY famtrackid, date";
214 214
 			} else {
215
-				$query  = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
215
+				$query = "SELECT tracker_live.ident, tracker_live.famtrackid, tracker_live.type,tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
216 216
 				    FROM tracker_live".$filter_query." CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' 
217 217
 				    ORDER BY tracker_live.famtrackid, tracker_live.date";
218 218
 			}
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 		try {
222 222
 			$sth = $this->db->prepare($query);
223 223
 			$sth->execute();
224
-		} catch(PDOException $e) {
224
+		} catch (PDOException $e) {
225 225
 			echo $e->getMessage();
226 226
 			die;
227 227
 		}
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	public function getLiveTrackerCount($filter = array())
239 239
 	{
240 240
 		global $globalDBdriver, $globalLiveInterval;
241
-		$filter_query = $this->getFilter($filter,true,true);
241
+		$filter_query = $this->getFilter($filter, true, true);
242 242
 
243 243
 		if (!isset($globalLiveInterval)) $globalLiveInterval = '200';
244 244
 		if ($globalDBdriver == 'mysql') {
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 		try {
250 250
 			$sth = $this->db->prepare($query);
251 251
 			$sth->execute();
252
-		} catch(PDOException $e) {
252
+		} catch (PDOException $e) {
253 253
 			echo $e->getMessage();
254 254
 			die;
255 255
 		}
@@ -272,10 +272,10 @@  discard block
 block discarded – undo
272 272
 		$filter_query = $this->getFilter($filter);
273 273
 
274 274
 		if (is_array($coord)) {
275
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
276
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
277
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
278
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
275
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
276
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
277
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
278
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
279 279
 		} else return array();
280 280
 		if ($globalDBdriver == 'mysql') {
281 281
 			$query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate AND tracker_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY tracker_live.famtrackid'.$filter_query;
@@ -300,17 +300,17 @@  discard block
 block discarded – undo
300 300
 		$filter_query = $this->getFilter($filter);
301 301
 
302 302
 		if (is_array($coord)) {
303
-			$minlong = filter_var($coord[0],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
304
-			$minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
305
-			$maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
306
-			$maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
303
+			$minlong = filter_var($coord[0], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
304
+			$minlat = filter_var($coord[1], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
305
+			$maxlong = filter_var($coord[2], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
306
+			$maxlat = filter_var($coord[3], FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
307 307
 		} else return array();
308 308
 		if ($globalDBdriver == 'mysql') {
309 309
 			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid,tracker_live.type, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
310 310
 			FROM tracker_live'.$filter_query.' DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval." SECOND) <= tracker_live.date AND tracker_live.latitude <> '0' AND tracker_live.longitude <> '0' AND tracker_live.latitude BETWEEN ".$minlat.' AND '.$maxlat.' AND tracker_live.longitude BETWEEN '.$minlong.' AND '.$maxlong."
311 311
 			ORDER BY tracker_live.famtrackid, tracker_live.date";
312 312
 		} else {
313
-			$query  = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
313
+			$query = "SELECT tracker_live.ident, tracker_live.type,tracker_live.famtrackid, tracker_live.latitude, tracker_live.longitude, tracker_live.altitude, tracker_live.heading, tracker_live.ground_speed, tracker_live.date, tracker_live.format_source 
314 314
 			FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$globalLiveInterval." SECONDS' <= l.date l.latitude BETWEEN ".$minlat." AND ".$maxlat." AND l.longitude BETWEEN ".$minlong." AND ".$maxlong." GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate".$filter_query." tracker_live.latitude <> '0' AND tracker_live.longitude <> '0'";
315 315
 		}
316 316
 		$spotter_array = $Spotter->getDataFromDB($query);
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
                 if ($interval == '1m')
359 359
                 {
360 360
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';
361
-                } else if ($interval == '15m'){
361
+                } else if ($interval == '15m') {
362 362
                     $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 15 MINUTE) <= tracker_live.date ';
363 363
                 } 
364 364
             }
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
          $additional_query = ' AND DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 MINUTE) <= tracker_live.date ';   
367 367
         }
368 368
 
369
-                $query  = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
369
+                $query = "SELECT tracker_live.*, ( 6371 * acos( cos( radians(:lat) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:lng) ) + sin( radians(:lat) ) * sin( radians( latitude ) ) ) ) AS distance FROM tracker_live 
370 370
                    WHERE tracker_live.latitude <> '' 
371 371
                                    AND tracker_live.longitude <> '' 
372 372
                    ".$additional_query."
373 373
                    HAVING distance < :radius  
374 374
                                    ORDER BY distance";
375 375
 
376
-                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng,':radius' => $radius));
376
+                $spotter_array = $Tracker->getDataFromDB($query, array(':lat' => $lat, ':lng' => $lng, ':radius' => $radius));
377 377
 
378 378
                 return $spotter_array;
379 379
         }
@@ -391,9 +391,9 @@  discard block
 block discarded – undo
391 391
 		date_default_timezone_set('UTC');
392 392
 
393 393
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
394
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
394
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
395 395
 
396
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident),'',true);
396
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident), '', true);
397 397
 
398 398
 		return $spotter_array;
399 399
 	}
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 	* @return Array the spotter information
405 405
 	*
406 406
 	*/
407
-	public function getDateLiveTrackerDataByIdent($ident,$date)
407
+	public function getDateLiveTrackerDataByIdent($ident, $date)
408 408
 	{
409 409
 		$Tracker = new Tracker($this->db);
410 410
 		date_default_timezone_set('UTC');
411 411
 
412 412
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
413
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
413
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.ident = :ident AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
414 414
 
415
-                $date = date('c',$date);
416
-		$spotter_array = $Tracker->getDataFromDB($query,array(':ident' => $ident,':date' => $date));
415
+                $date = date('c', $date);
416
+		$spotter_array = $Tracker->getDataFromDB($query, array(':ident' => $ident, ':date' => $date));
417 417
 
418 418
 		return $spotter_array;
419 419
 	}
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
 		date_default_timezone_set('UTC');
431 431
 
432 432
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
433
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
433
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
434 434
 
435
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id),'',true);
435
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id), '', true);
436 436
 
437 437
 		return $spotter_array;
438 438
 	}
@@ -443,15 +443,15 @@  discard block
 block discarded – undo
443 443
 	* @return Array the spotter information
444 444
 	*
445 445
 	*/
446
-	public function getDateLiveTrackerDataById($id,$date)
446
+	public function getDateLiveTrackerDataById($id, $date)
447 447
 	{
448 448
 		$Tracker = new Tracker($this->db);
449 449
 		date_default_timezone_set('UTC');
450 450
 
451 451
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
452
-                $query  = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
453
-                $date = date('c',$date);
454
-		$spotter_array = $Tracker->getDataFromDB($query,array(':id' => $id,':date' => $date),'',true);
452
+                $query = 'SELECT tracker_live.* FROM tracker_live INNER JOIN (SELECT l.famtrackid, max(l.date) as maxdate FROM tracker_live l WHERE l.famtrackid = :id AND l.date <= :date GROUP BY l.famtrackid) s on tracker_live.famtrackid = s.famtrackid AND tracker_live.date = s.maxdate ORDER BY tracker_live.date DESC';
453
+                $date = date('c', $date);
454
+		$spotter_array = $Tracker->getDataFromDB($query, array(':id' => $id, ':date' => $date), '', true);
455 455
 
456 456
 		return $spotter_array;
457 457
 	}
@@ -468,13 +468,13 @@  discard block
 block discarded – undo
468 468
 		date_default_timezone_set('UTC');
469 469
 
470 470
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
471
-                $query  = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
471
+                $query = 'SELECT tracker_live.altitude, tracker_live.date FROM tracker_live WHERE tracker_live.ident = :ident';
472 472
 
473 473
     		try {
474 474
 			
475 475
 			$sth = $this->db->prepare($query);
476 476
 			$sth->execute(array(':ident' => $ident));
477
-		} catch(PDOException $e) {
477
+		} catch (PDOException $e) {
478 478
 			echo $e->getMessage();
479 479
 			die;
480 480
 		}
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 	* @return Array the spotter information
490 490
 	*
491 491
 	*/
492
-	public function getAllLiveTrackerDataById($id,$liveinterval = false)
492
+	public function getAllLiveTrackerDataById($id, $liveinterval = false)
493 493
 	{
494 494
 		global $globalDBdriver, $globalLiveInterval;
495 495
 		date_default_timezone_set('UTC');
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 		try {
509 509
 			$sth = $this->db->prepare($query);
510 510
 			$sth->execute(array(':id' => $id));
511
-		} catch(PDOException $e) {
511
+		} catch (PDOException $e) {
512 512
 			echo $e->getMessage();
513 513
 			die;
514 514
 		}
@@ -526,12 +526,12 @@  discard block
 block discarded – undo
526 526
 	{
527 527
 		date_default_timezone_set('UTC');
528 528
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
529
-		$query  = self::$global_query.' WHERE tracker_live.ident = :ident';
529
+		$query = self::$global_query.' WHERE tracker_live.ident = :ident';
530 530
     		try {
531 531
 			
532 532
 			$sth = $this->db->prepare($query);
533 533
 			$sth->execute(array(':ident' => $ident));
534
-		} catch(PDOException $e) {
534
+		} catch (PDOException $e) {
535 535
 			echo $e->getMessage();
536 536
 			die;
537 537
 		}
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 			
562 562
 			$sth = $this->db->prepare($query);
563 563
 			$sth->execute();
564
-		} catch(PDOException $e) {
564
+		} catch (PDOException $e) {
565 565
 			return "error";
566 566
 		}
567 567
 
@@ -584,14 +584,14 @@  discard block
 block discarded – undo
584 584
 				
585 585
 				$sth = $this->db->prepare($query);
586 586
 				$sth->execute();
587
-			} catch(PDOException $e) {
587
+			} catch (PDOException $e) {
588 588
 				return "error";
589 589
 			}
590 590
 			$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
591 591
                         $i = 0;
592
-                        $j =0;
592
+                        $j = 0;
593 593
 			$all = $sth->fetchAll(PDO::FETCH_ASSOC);
594
-			foreach($all as $row)
594
+			foreach ($all as $row)
595 595
 			{
596 596
 				$i++;
597 597
 				$j++;
@@ -599,9 +599,9 @@  discard block
 block discarded – undo
599 599
 					if ($globalDebug) echo ".";
600 600
 				    	try {
601 601
 						
602
-						$sth = $this->db->prepare(substr($query_delete,0,-1).")");
602
+						$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
603 603
 						$sth->execute();
604
-					} catch(PDOException $e) {
604
+					} catch (PDOException $e) {
605 605
 						return "error";
606 606
 					}
607 607
                                 	$query_delete = 'DELETE FROM tracker_live WHERE famtrackid IN (';
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
 			if ($i > 0) {
613 613
     				try {
614 614
 					
615
-					$sth = $this->db->prepare(substr($query_delete,0,-1).")");
615
+					$sth = $this->db->prepare(substr($query_delete, 0, -1).")");
616 616
 					$sth->execute();
617
-				} catch(PDOException $e) {
617
+				} catch (PDOException $e) {
618 618
 					return "error";
619 619
 				}
620 620
 			}
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
 				
628 628
 				$sth = $this->db->prepare($query);
629 629
 				$sth->execute();
630
-			} catch(PDOException $e) {
630
+			} catch (PDOException $e) {
631 631
 				return "error";
632 632
 			}
633 633
 /*			$query_delete = "DELETE FROM tracker_live WHERE famtrackid IN (";
@@ -675,13 +675,13 @@  discard block
 block discarded – undo
675 675
 	public function deleteLiveTrackerDataByIdent($ident)
676 676
 	{
677 677
 		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
678
-		$query  = 'DELETE FROM tracker_live WHERE ident = :ident';
678
+		$query = 'DELETE FROM tracker_live WHERE ident = :ident';
679 679
         
680 680
     		try {
681 681
 			
682 682
 			$sth = $this->db->prepare($query);
683 683
 			$sth->execute(array(':ident' => $ident));
684
-		} catch(PDOException $e) {
684
+		} catch (PDOException $e) {
685 685
 			return "error";
686 686
 		}
687 687
 
@@ -697,13 +697,13 @@  discard block
 block discarded – undo
697 697
 	public function deleteLiveTrackerDataById($id)
698 698
 	{
699 699
 		$id = filter_var($id, FILTER_SANITIZE_STRING);
700
-		$query  = 'DELETE FROM tracker_live WHERE famtrackid = :id';
700
+		$query = 'DELETE FROM tracker_live WHERE famtrackid = :id';
701 701
         
702 702
     		try {
703 703
 			
704 704
 			$sth = $this->db->prepare($query);
705 705
 			$sth->execute(array(':id' => $id));
706
-		} catch(PDOException $e) {
706
+		} catch (PDOException $e) {
707 707
 			return "error";
708 708
 		}
709 709
 
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
 	{
722 722
 		global $globalDBdriver, $globalTimezone;
723 723
 		if ($globalDBdriver == 'mysql') {
724
-			$query  = 'SELECT tracker_live.ident FROM tracker_live 
724
+			$query = 'SELECT tracker_live.ident FROM tracker_live 
725 725
 				WHERE tracker_live.ident = :ident 
726 726
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) 
727 727
 				AND tracker_live.date < UTC_TIMESTAMP()';
728 728
 			$query_data = array(':ident' => $ident);
729 729
 		} else {
730
-			$query  = "SELECT tracker_live.ident FROM tracker_live 
730
+			$query = "SELECT tracker_live.ident FROM tracker_live 
731 731
 				WHERE tracker_live.ident = :ident 
732 732
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '1 HOURS'
733 733
 				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
 		
737 737
 		$sth = $this->db->prepare($query);
738 738
 		$sth->execute($query_data);
739
-		$ident_result='';
740
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
739
+		$ident_result = '';
740
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
741 741
 		{
742 742
 			$ident_result = $row['ident'];
743 743
 		}
@@ -754,13 +754,13 @@  discard block
 block discarded – undo
754 754
 	{
755 755
 		global $globalDBdriver, $globalTimezone;
756 756
 		if ($globalDBdriver == 'mysql') {
757
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
757
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
758 758
 				WHERE tracker_live.ident = :ident 
759 759
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 MINUTE)'; 
760 760
 //				AND tracker_live.date < UTC_TIMESTAMP()";
761 761
 			$query_data = array(':ident' => $ident);
762 762
 		} else {
763
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
763
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
764 764
 				WHERE tracker_live.ident = :ident 
765 765
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '30 MINUTES'";
766 766
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -769,8 +769,8 @@  discard block
 block discarded – undo
769 769
 		
770 770
 		$sth = $this->db->prepare($query);
771 771
 		$sth->execute($query_data);
772
-		$ident_result='';
773
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
772
+		$ident_result = '';
773
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
774 774
 		{
775 775
 			$ident_result = $row['famtrackid'];
776 776
 		}
@@ -787,13 +787,13 @@  discard block
 block discarded – undo
787 787
 	{
788 788
 		global $globalDBdriver, $globalTimezone;
789 789
 		if ($globalDBdriver == 'mysql') {
790
-			$query  = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
790
+			$query = 'SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
791 791
 				WHERE tracker_live.famtrackid = :id 
792 792
 				AND tracker_live.date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 10 HOUR)'; 
793 793
 //				AND tracker_live.date < UTC_TIMESTAMP()";
794 794
 			$query_data = array(':id' => $id);
795 795
 		} else {
796
-			$query  = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
796
+			$query = "SELECT tracker_live.ident, tracker_live.famtrackid FROM tracker_live 
797 797
 				WHERE tracker_live.famtrackid = :id 
798 798
 				AND tracker_live.date >= now() AT TIME ZONE 'UTC' - INTERVAL '10 HOUR'";
799 799
 //				AND tracker_live.date < now() AT TIME ZONE 'UTC'";
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
 		
803 803
 		$sth = $this->db->prepare($query);
804 804
 		$sth->execute($query_data);
805
-		$ident_result='';
806
-		while($row = $sth->fetch(PDO::FETCH_ASSOC))
805
+		$ident_result = '';
806
+		while ($row = $sth->fetch(PDO::FETCH_ASSOC))
807 807
 		{
808 808
 			$ident_result = $row['famtrackid'];
809 809
 		}
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	* @return String success or false
822 822
 	*
823 823
 	*/
824
-	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '',$noarchive = false,$format_source = '', $source_name = '', $over_country = '')
824
+	public function addLiveTrackerData($famtrackid = '', $ident = '', $latitude = '', $longitude = '', $altitude = '', $heading = '', $groundspeed = '', $date = '', $putinarchive = false, $comment = '', $type = '', $noarchive = false, $format_source = '', $source_name = '', $over_country = '')
825 825
 	{
826 826
 		global $globalURL, $globalArchive, $globalDebug;
827 827
 		$Common = new Common();
@@ -880,21 +880,21 @@  discard block
 block discarded – undo
880 880
 		if ($date == '') $date = date("Y-m-d H:i:s", time());
881 881
 
882 882
         
883
-		$famtrackid = filter_var($famtrackid,FILTER_SANITIZE_STRING);
884
-		$ident = filter_var($ident,FILTER_SANITIZE_STRING);
885
-		$latitude = filter_var($latitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
886
-		$longitude = filter_var($longitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
887
-		$altitude = filter_var($altitude,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
888
-		$heading = filter_var($heading,FILTER_SANITIZE_NUMBER_INT);
889
-		$groundspeed = filter_var($groundspeed,FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);
890
-		$format_source = filter_var($format_source,FILTER_SANITIZE_STRING);
891
-		$source_name = filter_var($source_name,FILTER_SANITIZE_STRING);
892
-		$over_country = filter_var($over_country,FILTER_SANITIZE_STRING);
893
-		$comment = filter_var($comment,FILTER_SANITIZE_STRING);
894
-		$type = filter_var($type,FILTER_SANITIZE_STRING);
895
-
896
-            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false ) $groundspeed = 0;
897
-            	if ($heading == '' || $Common->isInteger($heading) === false ) $heading = 0;
883
+		$famtrackid = filter_var($famtrackid, FILTER_SANITIZE_STRING);
884
+		$ident = filter_var($ident, FILTER_SANITIZE_STRING);
885
+		$latitude = filter_var($latitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
886
+		$longitude = filter_var($longitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
887
+		$altitude = filter_var($altitude, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
888
+		$heading = filter_var($heading, FILTER_SANITIZE_NUMBER_INT);
889
+		$groundspeed = filter_var($groundspeed, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
890
+		$format_source = filter_var($format_source, FILTER_SANITIZE_STRING);
891
+		$source_name = filter_var($source_name, FILTER_SANITIZE_STRING);
892
+		$over_country = filter_var($over_country, FILTER_SANITIZE_STRING);
893
+		$comment = filter_var($comment, FILTER_SANITIZE_STRING);
894
+		$type = filter_var($type, FILTER_SANITIZE_STRING);
895
+
896
+            	if ($groundspeed == '' || $Common->isInteger($groundspeed) === false) $groundspeed = 0;
897
+            	if ($heading == '' || $Common->isInteger($heading) === false) $heading = 0;
898 898
             	
899 899
 		$query = '';
900 900
 		if ($globalArchive) {
@@ -904,12 +904,12 @@  discard block
 block discarded – undo
904 904
 		$query  .= 'INSERT INTO tracker_live (famtrackid, ident, latitude, longitude, altitude, heading, ground_speed, date, format_source, source_name, over_country, comment, type) 
905 905
 		VALUES (:famtrackid,:ident,:latitude,:longitude,:altitude,:heading,:groundspeed,:date,:format_source, :source_name, :over_country,:comment,:type)';
906 906
 
907
-		$query_values = array(':famtrackid' => $famtrackid,':ident' => $ident,':latitude' => $latitude,':longitude' => $longitude,':altitude' => $altitude,':heading' => $heading,':groundspeed' => $groundspeed,':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country,':comment' => $comment,':type' => $type);
907
+		$query_values = array(':famtrackid' => $famtrackid, ':ident' => $ident, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':heading' => $heading, ':groundspeed' => $groundspeed, ':date' => $date, ':format_source' => $format_source, ':source_name' => $source_name, ':over_country' => $over_country, ':comment' => $comment, ':type' => $type);
908 908
 		try {
909 909
 			
910 910
 			$sth = $this->db->prepare($query);
911 911
 			$sth->execute($query_values);
912
-                } catch(PDOException $e) {
912
+                } catch (PDOException $e) {
913 913
                 	return "error : ".$e->getMessage();
914 914
                 }
915 915
                 /*
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
 		if (isset($globalArchive) && $globalArchive && $putinarchive && $noarchive !== true) {
920 920
 		    if ($globalDebug) echo '(Add to Tracker archive '.$famtrackid.' : ';
921 921
 		    $TrackerArchive = new TrackerArchive($this->db);
922
-		    $result =  $TrackerArchive->addTrackerArchiveData($famtrackid, $ident,$latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type,$noarchive,$format_source, $source_name, $over_country);
922
+		    $result = $TrackerArchive->addTrackerArchiveData($famtrackid, $ident, $latitude, $longitude, $altitude, $heading, $groundspeed, $date, $putinarchive, $comment, $type, $noarchive, $format_source, $source_name, $over_country);
923 923
 		    if ($globalDebug) echo $result.')';
924 924
 		}
925 925
 
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
 
930 930
 	public function getOrderBy()
931 931
 	{
932
-		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"),"manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"),"airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
932
+		$orderby = array("aircraft_asc" => array("key" => "aircraft_asc", "value" => "Aircraft Type - ASC", "sql" => "ORDER BY tracker_live.aircraft_icao ASC"), "aircraft_desc" => array("key" => "aircraft_desc", "value" => "Aircraft Type - DESC", "sql" => "ORDER BY tracker_live.aircraft_icao DESC"), "manufacturer_asc" => array("key" => "manufacturer_asc", "value" => "Aircraft Manufacturer - ASC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer ASC"), "manufacturer_desc" => array("key" => "manufacturer_desc", "value" => "Aircraft Manufacturer - DESC", "sql" => "ORDER BY tracker_live.aircraft_manufacturer DESC"), "airline_name_asc" => array("key" => "airline_name_asc", "value" => "Airline Name - ASC", "sql" => "ORDER BY tracker_live.airline_name ASC"), "airline_name_desc" => array("key" => "airline_name_desc", "value" => "Airline Name - DESC", "sql" => "ORDER BY tracker_live.airline_name DESC"), "ident_asc" => array("key" => "ident_asc", "value" => "Ident - ASC", "sql" => "ORDER BY tracker_live.ident ASC"), "ident_desc" => array("key" => "ident_desc", "value" => "Ident - DESC", "sql" => "ORDER BY tracker_live.ident DESC"), "airport_departure_asc" => array("key" => "airport_departure_asc", "value" => "Departure Airport - ASC", "sql" => "ORDER BY tracker_live.departure_airport_city ASC"), "airport_departure_desc" => array("key" => "airport_departure_desc", "value" => "Departure Airport - DESC", "sql" => "ORDER BY tracker_live.departure_airport_city DESC"), "airport_arrival_asc" => array("key" => "airport_arrival_asc", "value" => "Arrival Airport - ASC", "sql" => "ORDER BY tracker_live.arrival_airport_city ASC"), "airport_arrival_desc" => array("key" => "airport_arrival_desc", "value" => "Arrival Airport - DESC", "sql" => "ORDER BY tracker_live.arrival_airport_city DESC"), "date_asc" => array("key" => "date_asc", "value" => "Date - ASC", "sql" => "ORDER BY tracker_live.date ASC"), "date_desc" => array("key" => "date_desc", "value" => "Date - DESC", "sql" => "ORDER BY tracker_live.date DESC"));
933 933
 		return $orderby;
934 934
 	}
935 935
 
Please login to merge, or discard this patch.
require/class.TrackerImport.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 	    if (isset($this->all_tracked[$key]['id'])) {
48 48
 		//echo $this->all_tracked[$key]['id'].' - '.$this->all_tracked[$key]['latitude'].'  '.$this->all_tracked[$key]['longitude']."\n";
49 49
     		$Tracker = new Tracker($this->db);
50
-        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed'],$this->all_tracked[$key]['datetime']);
50
+        	$Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed'], $this->all_tracked[$key]['datetime']);
51 51
             }
52 52
 	}
53 53
     }
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	if ($globalDebug) echo 'Delete old values and update latest data...'."\n";
59 59
 	foreach ($this->all_tracked as $key => $flight) {
60 60
     	    if (isset($flight['lastupdate'])) {
61
-        	if ($flight['lastupdate'] < (time()-3000)) {
61
+        	if ($flight['lastupdate'] < (time() - 3000)) {
62 62
             	    if (isset($this->all_tracked[$key]['id'])) {
63 63
             		if ($globalDebug) echo "--- Delete old values with id ".$this->all_tracked[$key]['id']."\n";
64 64
 			/*
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
             		//$real_arrival = $this->arrival($key);
70 70
             		$Tracker = new Tracker($this->db);
71 71
             		if ($this->all_tracked[$key]['latitude'] != '' && $this->all_tracked[$key]['longitude'] != '') {
72
-				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'],$this->all_tracked[$key]['ident'],$this->all_tracked[$key]['latitude'],$this->all_tracked[$key]['longitude'],$this->all_tracked[$key]['altitude'],$this->all_tracked[$key]['speed']);
72
+				$result = $Tracker->updateLatestTrackerData($this->all_tracked[$key]['id'], $this->all_tracked[$key]['ident'], $this->all_tracked[$key]['latitude'], $this->all_tracked[$key]['longitude'], $this->all_tracked[$key]['altitude'], $this->all_tracked[$key]['speed']);
73 73
 				if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
74 74
 			}
75 75
 			// Put in archive
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	$send = false;
90 90
 	
91 91
 	// SBS format is CSV format
92
-	if(is_array($line) && isset($line['ident'])) {
92
+	if (is_array($line) && isset($line['ident'])) {
93 93
 	    //print_r($line);
94 94
   	    if (isset($line['ident'])) {
95 95
 
@@ -113,33 +113,33 @@  discard block
 block discarded – undo
113 113
 		
114 114
 		if (!isset($this->all_tracked[$id])) {
115 115
 		    $this->all_tracked[$id] = array();
116
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('addedTracker' => 0));
117
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => '','latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '','source_name' => '','comment'=> '','type' => '','noarchive' => false,'putinarchive' => true,'over_country' => ''));
118
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('lastupdate' => time()));
116
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('addedTracker' => 0));
117
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => '', 'latitude' => '', 'longitude' => '', 'speed' => '', 'altitude' => '', 'heading' => '', 'format_source' => '', 'source_name' => '', 'comment'=> '', 'type' => '', 'noarchive' => false, 'putinarchive' => true, 'over_country' => ''));
118
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('lastupdate' => time()));
119 119
 		    if (!isset($line['id'])) {
120 120
 			if (!isset($globalDaemon)) $globalDaemon = TRUE;
121
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $id.'-'.date('YmdHi')));
122
-		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $line['id']));
121
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $id.'-'.date('YmdHi')));
122
+		     } else $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $line['id']));
123 123
 		    if ($globalAllTracked !== FALSE) $dataFound = true;
124 124
 		}
125 125
 		
126
-		if (isset($line['datetime']) && strtotime($line['datetime']) > time()-20*60 && strtotime($line['datetime']) < time()+20*60) {
126
+		if (isset($line['datetime']) && strtotime($line['datetime']) > time() - 20*60 && strtotime($line['datetime']) < time() + 20*60) {
127 127
 		    if (!isset($this->all_tracked[$id]['datetime']) || strtotime($line['datetime']) >= strtotime($this->all_tracked[$id]['datetime'])) {
128
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => $line['datetime']));
128
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => $line['datetime']));
129 129
 		    } else {
130 130
 				if (strtotime($line['datetime']) == strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date is the same as previous data for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
131 131
 				elseif (strtotime($line['datetime']) > strtotime($this->all_tracked[$id]['datetime']) && $globalDebug) echo "!!! Date previous latest data (".$line['datetime']." > ".$this->all_tracked[$id]['datetime'].") !!! for ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."\n";
132 132
 				return '';
133 133
 		    }
134
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time()-20*60) {
134
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) < time() - 20*60) {
135 135
 			if ($globalDebug) echo "!!! Date is too old ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
136 136
 			return '';
137
-		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time()+20*60) {
137
+		} elseif (isset($line['datetime']) && strtotime($line['datetime']) > time() + 20*60) {
138 138
 			if ($globalDebug) echo "!!! Date is in the future ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
139 139
 			return '';
140 140
 		} elseif (!isset($line['datetime'])) {
141 141
 			date_default_timezone_set('UTC');
142
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('datetime' => date('Y-m-d H:i:s')));
142
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('datetime' => date('Y-m-d H:i:s')));
143 143
 		} else {
144 144
 			if ($globalDebug) echo "!!! Unknow date error ".$this->all_tracked[$id]['ident']." - format : ".$line['format_source']."!!!\n";
145 145
 			return '';
@@ -147,38 +147,38 @@  discard block
 block discarded – undo
147 147
 		
148 148
 		//if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident'])) && preg_match('/^[a-zA-Z0-9-]+$/', $line['ident'])) {
149 149
 		if (isset($line['ident']) && $line['ident'] != '' && $line['ident'] != '????????' && $line['ident'] != '00000000' && ($this->all_tracked[$id]['ident'] != trim($line['ident']))) {
150
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('ident' => trim($line['ident'])));
150
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('ident' => trim($line['ident'])));
151 151
 		    if ($this->all_tracked[$id]['addedTracker'] == 1) {
152 152
 			$timeelapsed = microtime(true);
153 153
             		$Tracker = new Tracker($this->db);
154 154
             		$fromsource = NULL;
155
-            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$fromsource);
155
+            		$result = $Tracker->updateIdentTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $fromsource);
156 156
 			if ($globalDebug && $result != 'success') echo '!!! ERROR : '.$result."\n";
157 157
 			$Tracker->db = null;
158
-			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
158
+			if ($globalDebugTimeElapsed) echo 'Time elapsed for update identspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
159 159
 		    }
160
-		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident']));
160
+		    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident']));
161 161
 		}
162 162
 
163 163
 		if (isset($line['speed']) && $line['speed'] != '') {
164
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($line['speed'])));
165
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed_fromsrc' => true));
164
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($line['speed'])));
165
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed_fromsrc' => true));
166 166
 		} else if (!isset($this->all_tracked[$id]['speed_fromsrc']) && isset($this->all_tracked[$id]['time_last_coord']) && $this->all_tracked[$id]['time_last_coord'] != time() && isset($line['latitude']) && isset($line['longitude'])) {
167
-		    $distance = $Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m');
167
+		    $distance = $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm');
168 168
 		    if ($distance > 100 && $distance < 10000) {
169 169
 			$speed = $distance/(time() - $this->all_tracked[$id]['time_last_coord']);
170 170
 			$speed = $speed*3.6;
171
-			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('speed' => round($speed)));
171
+			if ($speed < 1000) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('speed' => round($speed)));
172 172
   			if ($globalDebug) echo "ø Calculated Speed for ".$this->all_tracked[$id]['ident']." : ".$speed." - distance : ".$distance."\n";
173 173
 		    }
174 174
 		}
175 175
 
176 176
 	        if (isset($line['latitude']) && isset($line['longitude']) && $line['latitude'] != '' && $line['longitude'] != '' && is_numeric($line['latitude']) && is_numeric($line['longitude'])) {
177
-	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time()-$this->all_tracked[$id]['time_last_coord']);
177
+	    	    if (isset($this->all_tracked[$id]['time_last_coord'])) $timediff = round(time() - $this->all_tracked[$id]['time_last_coord']);
178 178
 	    	    else unset($timediff);
179
-	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff,$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')))) {
179
+	    	    if ($this->tmd > 5 || !isset($timediff) || $timediff > 100 || ($timediff > 30 && isset($this->all_tracked[$id]['latitude']) && isset($this->all_tracked[$id]['longitude']) && $Common->withinThreshold($timediff, $Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')))) {
180 180
 			if (isset($this->all_tracked[$id]['archive_latitude']) && isset($this->all_tracked[$id]['archive_longitude']) && isset($this->all_tracked[$id]['livedb_latitude']) && isset($this->all_tracked[$id]['livedb_longitude'])) {
181
-			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['livedb_latitude'],$this->all_tracked[$id]['livedb_longitude'],$line['latitude'],$line['longitude'],0.1)) {
181
+			    if (!$Common->checkLine($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['livedb_latitude'], $this->all_tracked[$id]['livedb_longitude'], $line['latitude'], $line['longitude'], 0.1)) {
182 182
 				$this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
183 183
 				$this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
184 184
 				$this->all_tracked[$id]['putinarchive'] = true;
@@ -186,10 +186,10 @@  discard block
 block discarded – undo
186 186
 				if ($globalDebug) echo "\n".' ------- Check Country for '.$this->all_tracked[$id]['ident'].' with latitude : '.$line['latitude'].' and longitude : '.$line['longitude'].'.... ';
187 187
 				$timeelapsed = microtime(true);
188 188
 				$Tracker = new Tracker($this->db);
189
-				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'],$line['longitude']);
189
+				$all_country = $Tracker->getCountryFromLatitudeLongitude($line['latitude'], $line['longitude']);
190 190
 				if (!empty($all_country)) $this->all_tracked[$id]['over_country'] = $all_country['iso2'];
191 191
 				$Tracker->db = null;
192
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
192
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update getCountryFromlatitudeLongitude : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
193 193
 				$this->tmd = 0;
194 194
 				if ($globalDebug) echo 'FOUND : '.$this->all_tracked[$id]['over_country'].' ---------------'."\n";
195 195
 			    }
@@ -197,75 +197,75 @@  discard block
 block discarded – undo
197 197
 
198 198
 			if (isset($line['latitude']) && $line['latitude'] != '' && $line['latitude'] != 0 && $line['latitude'] < 91 && $line['latitude'] > -90) {
199 199
 				if (!isset($this->all_tracked[$id]['archive_latitude'])) $this->all_tracked[$id]['archive_latitude'] = $line['latitude'];
200
-				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude']-$line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
200
+				if (!isset($this->all_tracked[$id]['livedb_latitude']) || abs($this->all_tracked[$id]['livedb_latitude'] - $line['latitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
201 201
 				    $this->all_tracked[$id]['livedb_latitude'] = $line['latitude'];
202 202
 				    $dataFound = true;
203 203
 				    $this->all_tracked[$id]['time_last_coord'] = time();
204 204
 				}
205
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('latitude' => $line['latitude']));
205
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('latitude' => $line['latitude']));
206 206
 			}
207 207
 			if (isset($line['longitude']) && $line['longitude'] != '' && $line['longitude'] != 0 && $line['longitude'] < 360 && $line['longitude'] > -180) {
208 208
 			    if ($line['longitude'] > 180) $line['longitude'] = $line['longitude'] - 360;
209 209
 				if (!isset($this->all_tracked[$id]['archive_longitude'])) $this->all_tracked[$id]['archive_longitude'] = $line['longitude'];
210
-				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude']-$line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
210
+				if (!isset($this->all_tracked[$id]['livedb_longitude']) || abs($this->all_tracked[$id]['livedb_longitude'] - $line['longitude']) > $globalCoordMinChangeTracker || $this->all_tracked[$id]['format_source'] == 'aprs') {
211 211
 				    $this->all_tracked[$id]['livedb_longitude'] = $line['longitude'];
212 212
 				    $dataFound = true;
213 213
 				    $this->all_tracked[$id]['time_last_coord'] = time();
214 214
 				}
215
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('longitude' => $line['longitude']));
215
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('longitude' => $line['longitude']));
216 216
 			}
217 217
 
218 218
 		    } else if ($globalDebug && $timediff > 20) {
219 219
 			$this->tmd = $this->tmd + 1;
220 220
 			if ($line['latitude'] != $this->all_tracked[$id]['latitude'] && $line['longitude'] != $this->all_tracked[$id]['longitude']) {
221 221
 				echo '!!! Too much distance in short time... for '.$this->all_tracked[$id]['ident']."\n";
222
-				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')."m -";
223
-				echo 'Speed : '.(($Common->distance($line['latitude'],$line['longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],'m')/$timediff)*3.6)." km/h - ";
222
+				echo 'Time : '.$timediff.'s - Distance : '.$Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')."m -";
223
+				echo 'Speed : '.(($Common->distance($line['latitude'], $line['longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], 'm')/$timediff)*3.6)." km/h - ";
224 224
 				echo 'Lat : '.$line['latitude'].' - long : '.$line['longitude'].' - prev lat : '.$this->all_tracked[$id]['latitude'].' - prev long : '.$this->all_tracked[$id]['longitude']." \n";
225 225
 			}
226 226
 		    }
227 227
 		}
228 228
 		if (isset($line['last_update']) && $line['last_update'] != '') {
229 229
 		    if (isset($this->all_tracked[$id]['last_update']) && $this->all_tracked[$id]['last_update'] != $line['last_update']) $dataFound = true;
230
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('last_update' => $line['last_update']));
230
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('last_update' => $line['last_update']));
231 231
 		}
232 232
 		if (isset($line['format_source']) && $line['format_source'] != '') {
233
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('format_source' => $line['format_source']));
233
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('format_source' => $line['format_source']));
234 234
 		}
235 235
 		if (isset($line['source_name']) && $line['source_name'] != '') {
236
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('source_name' => $line['source_name']));
236
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('source_name' => $line['source_name']));
237 237
 		}
238 238
 		if (isset($line['comment']) && $line['comment'] != '') {
239
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('comment' => $line['comment']));
239
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('comment' => $line['comment']));
240 240
 		    //$dataFound = true;
241 241
 		}
242 242
 		if (isset($line['type']) && $line['type'] != '') {
243
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('type' => $line['type']));
243
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('type' => $line['type']));
244 244
 		    //$dataFound = true;
245 245
 		}
246 246
 
247 247
 		if (isset($line['altitude']) && $line['altitude'] != '') {
248 248
 		    //if (!isset($this->all_tracked[$id]['altitude']) || $this->all_tracked[$id]['altitude'] == '' || ($this->all_tracked[$id]['altitude'] > 0 && $line['altitude'] != 0)) {
249
-			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100)-$this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude' => $line['altitude']));
251
-			$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('altitude_real' => $line['altitude']));
249
+			if (is_int($this->all_tracked[$id]['altitude']) && abs(round($line['altitude']/100) - $this->all_tracked[$id]['altitude']) > 3) $this->all_tracked[$id]['putinarchive'] = true;
250
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude' => $line['altitude']));
251
+			$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('altitude_real' => $line['altitude']));
252 252
 			//$dataFound = true;
253 253
 		    //} elseif ($globalDebug) echo "!!! Strange altitude data... not added.\n";
254 254
   		}
255 255
 
256 256
 		if (isset($line['noarchive']) && $line['noarchive'] === true) {
257
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('noarchive' => true));
257
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('noarchive' => true));
258 258
 		}
259 259
 		
260 260
 		if (isset($line['heading']) && $line['heading'] != '') {
261
-		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading']-round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($line['heading'])));
263
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading_fromsrc' => true));
261
+		    if (is_int($this->all_tracked[$id]['heading']) && abs($this->all_tracked[$id]['heading'] - round($line['heading'])) > 10) $this->all_tracked[$id]['putinarchive'] = true;
262
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($line['heading'])));
263
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading_fromsrc' => true));
264 264
 		    //$dataFound = true;
265 265
   		} elseif (!isset($this->all_tracked[$id]['heading_fromsrc']) && isset($this->all_tracked[$id]['archive_latitude']) && $this->all_tracked[$id]['archive_latitude'] != $this->all_tracked[$id]['latitude'] && isset($this->all_tracked[$id]['archive_longitude']) && $this->all_tracked[$id]['archive_longitude'] != $this->all_tracked[$id]['longitude']) {
266
-  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'],$this->all_tracked[$id]['archive_longitude'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
267
-		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('heading' => round($heading)));
268
-		    if (abs($this->all_tracked[$id]['heading']-round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
266
+  		    $heading = $Common->getHeading($this->all_tracked[$id]['archive_latitude'], $this->all_tracked[$id]['archive_longitude'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
267
+		    $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('heading' => round($heading)));
268
+		    if (abs($this->all_tracked[$id]['heading'] - round($heading)) > 10) $this->all_tracked[$id]['putinarchive'] = true;
269 269
   		    if ($globalDebug) echo "ø Calculated Heading for ".$this->all_tracked[$id]['ident']." : ".$heading."\n";
270 270
   		}
271 271
 		//if (isset($globalSourcesupdate) && $globalSourcesupdate != '' && isset($this->all_tracked[$id]['lastupdate']) && time()-$this->all_tracked[$id]['lastupdate'] < $globalSourcesupdate) $dataFound = false;
@@ -273,54 +273,54 @@  discard block
 block discarded – undo
273 273
 		if ($dataFound === true && isset($this->all_tracked[$id]['ident'])) {
274 274
 		    $this->all_tracked[$id]['lastupdate'] = time();
275 275
 		    if ($this->all_tracked[$id]['addedTracker'] == 0) {
276
-		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == ''  || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
276
+		        if (!isset($globalDistanceIgnore['latitude']) || $this->all_tracked[$id]['longitude'] == '' || $this->all_tracked[$id]['latitude'] == '' || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
277 277
 			    if (!isset($this->all_tracked[$id]['forcenew']) || $this->all_tracked[$id]['forcenew'] == 0) {
278 278
 				if ($globalDebug) echo "Check if aircraft is already in DB...";
279 279
 				$timeelapsed = microtime(true);
280 280
 				$TrackerLive = new TrackerLive($this->db);
281 281
 				if (isset($line['id'])) {
282 282
 				    $recent_ident = $TrackerLive->checkIdRecent($line['id']);
283
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
283
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
284 284
 				} elseif (isset($this->all_tracked[$id]['ident']) && $this->all_tracked[$id]['ident'] != '') {
285 285
 				    $recent_ident = $TrackerLive->checkIdentRecent($this->all_tracked[$id]['ident']);
286
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
286
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update checkIdentRecent : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
287 287
 				} else $recent_ident = '';
288
-				$TrackerLive->db=null;
288
+				$TrackerLive->db = null;
289 289
 
290 290
 				if ($globalDebug && $recent_ident == '') echo " Not in DB.\n";
291 291
 				elseif ($globalDebug && $recent_ident != '') echo " Already in DB.\n";
292 292
 			    } else {
293 293
 				$recent_ident = '';
294
-				$this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('forcenew' => 0));
294
+				$this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('forcenew' => 0));
295 295
 			    }
296 296
 			    //if there was no aircraft with the same callsign within the last hour and go post it into the archive
297
-			    if($recent_ident == "")
297
+			    if ($recent_ident == "")
298 298
 			    {
299 299
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." in archive DB : ";
300 300
 				//adds the spotter data for the archive
301 301
 				    $highlight = '';
302
-				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id],array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
302
+				    if (!isset($this->all_tracked[$id]['id'])) $this->all_tracked[$id] = array_merge($this->all_tracked[$id], array('id' => $this->all_tracked[$id]['ident'].'-'.date('YmdHi')));
303 303
 				    $timeelapsed = microtime(true);
304 304
 				    $Tracker = new Tracker($this->db);
305
-				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name']);
305
+				    $result = $Tracker->addTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name']);
306 306
 				    $Tracker->db = null;
307 307
 				    if ($globalDebug && isset($result)) echo $result."\n";
308
-				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
308
+				    if ($globalDebugTimeElapsed) echo 'Time elapsed for update addspotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
309 309
 				    
310 310
 				    
311 311
 				    // Add source stat in DB
312 312
 				    $Stats = new Stats($this->db);
313 313
 				    if (!empty($this->stats)) {
314 314
 					if ($globalDebug) echo 'Add source stats : ';
315
-				        foreach($this->stats as $date => $data) {
316
-					    foreach($data as $source => $sourced) {
315
+				        foreach ($this->stats as $date => $data) {
316
+					    foreach ($data as $source => $sourced) {
317 317
 					        //print_r($sourced);
318
-				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']),$source,'polar_tracker',$date);
319
-				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']),$source,'hist_tracker',$date);
318
+				    	        if (isset($sourced['polar'])) echo $Stats->addStatSource(json_encode($sourced['polar']), $source, 'polar_tracker', $date);
319
+				    	        if (isset($sourced['hist'])) echo $Stats->addStatSource(json_encode($sourced['hist']), $source, 'hist_tracker', $date);
320 320
 				    		if (isset($sourced['msg'])) {
321 321
 				    		    if (time() - $sourced['msg']['date'] > 10) {
322 322
 				    		        $nbmsg = round($sourced['msg']['nb']/(time() - $sourced['msg']['date']));
323
-				    		        echo $Stats->addStatSource($nbmsg,$source,'msg_tracker',$date);
323
+				    		        echo $Stats->addStatSource($nbmsg, $source, 'msg_tracker', $date);
324 324
 			    			        unset($this->stats[$date][$source]['msg']);
325 325
 			    			    }
326 326
 			    			}
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
 				    //TrackerLive->deleteLiveTrackerDataNotUpdated();
344 344
 				    $TrackerLive = new TrackerLive($this->db);
345 345
 				    $TrackerLive->deleteLiveTrackerData();
346
-				    $TrackerLive->db=null;
346
+				    $TrackerLive->db = null;
347 347
 				    if ($globalDebug) echo " Done\n";
348 348
 				    $this->last_delete = time();
349 349
 				}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 				$this->all_tracked[$id]['addedTracker'] = 1;
353 353
 				if (isset($globalDaemon) && !$globalDaemon) {
354 354
 					$Tracker = new Tracker($this->db);
355
-					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'],$this->all_tracked[$id]['ident'],$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$this->all_tracked[$id]['altitude'],$this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime']);
355
+					$Tracker->updateLatestTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime']);
356 356
 					$Tracker->db = null;
357 357
 				}
358 358
 				
@@ -366,14 +366,14 @@  discard block
 block discarded – undo
366 366
 		    $ignoreImport = false;
367 367
 
368 368
 		    if (!$ignoreImport) {
369
-			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude'],$globalDistanceIgnore['latitude'],$globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
369
+			if (!isset($globalDistanceIgnore['latitude']) || (isset($globalDistanceIgnore['latitude']) && $Common->distance($this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $globalDistanceIgnore['latitude'], $globalDistanceIgnore['longitude']) < $globalDistanceIgnore['distance'])) {
370 370
 				if ($globalDebug) echo "\o/ Add ".$this->all_tracked[$id]['ident']." from ".$this->all_tracked[$id]['format_source']." in Live DB : ";
371 371
 				$timeelapsed = microtime(true);
372 372
 				$TrackerLive = new TrackerLive($this->db);
373
-				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'],$this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'],$this->all_tracked[$id]['comment'],$this->all_tracked[$id]['type'],$this->all_tracked[$id]['noarchive'],$this->all_tracked[$id]['format_source'],$this->all_tracked[$id]['source_name'],$this->all_tracked[$id]['over_country']);
373
+				$result = $TrackerLive->addLiveTrackerData($this->all_tracked[$id]['id'], $this->all_tracked[$id]['ident'], $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude'], $this->all_tracked[$id]['altitude'], $this->all_tracked[$id]['heading'], $this->all_tracked[$id]['speed'], $this->all_tracked[$id]['datetime'], $this->all_tracked[$id]['putinarchive'], $this->all_tracked[$id]['comment'], $this->all_tracked[$id]['type'], $this->all_tracked[$id]['noarchive'], $this->all_tracked[$id]['format_source'], $this->all_tracked[$id]['source_name'], $this->all_tracked[$id]['over_country']);
374 374
 				$TrackerLive->db = null;
375 375
 				$this->all_tracked[$id]['putinarchive'] = false;
376
-				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true)-$timeelapsed,2).'s'."\n";
376
+				if ($globalDebugTimeElapsed) echo 'Time elapsed for update addlivespotterdata : '.round(microtime(true) - $timeelapsed, 2).'s'."\n";
377 377
 
378 378
 				// Put statistics in $this->stats variable
379 379
 				
@@ -390,19 +390,19 @@  discard block
 block discarded – undo
390 390
 							$latitude = $globalCenterLatitude;
391 391
 							$longitude = $globalCenterLongitude;
392 392
 						}
393
-						$this->source_location[$source] = array('latitude' => $latitude,'longitude' => $longitude);
393
+						$this->source_location[$source] = array('latitude' => $latitude, 'longitude' => $longitude);
394 394
 					} else {
395 395
 						$latitude = $this->source_location[$source]['latitude'];
396 396
 						$longitude = $this->source_location[$source]['longitude'];
397 397
 					}
398
-					$stats_heading = $Common->getHeading($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
398
+					$stats_heading = $Common->getHeading($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
399 399
 					//$stats_heading = $stats_heading%22.5;
400 400
 					$stats_heading = round($stats_heading/22.5);
401
-					$stats_distance = $Common->distance($latitude,$longitude,$this->all_tracked[$id]['latitude'],$this->all_tracked[$id]['longitude']);
401
+					$stats_distance = $Common->distance($latitude, $longitude, $this->all_tracked[$id]['latitude'], $this->all_tracked[$id]['longitude']);
402 402
 					$current_date = date('Y-m-d');
403 403
 					if ($stats_heading == 16) $stats_heading = 0;
404 404
 					if (!isset($this->stats[$current_date][$source]['polar'][1])) {
405
-						for ($i=0;$i<=15;$i++) {
405
+						for ($i = 0; $i <= 15; $i++) {
406 406
 						    $this->stats[$current_date][$source]['polar'][$i] = 0;
407 407
 						}
408 408
 						$this->stats[$current_date][$source]['polar'][$stats_heading] = $stats_distance;
@@ -417,9 +417,9 @@  discard block
 block discarded – undo
417 417
 					if (!isset($this->stats[$current_date][$source]['hist'][$distance])) {
418 418
 						if (isset($this->stats[$current_date][$source]['hist'][0])) {
419 419
 						    end($this->stats[$current_date][$source]['hist']);
420
-						    $mini = key($this->stats[$current_date][$source]['hist'])+10;
420
+						    $mini = key($this->stats[$current_date][$source]['hist']) + 10;
421 421
 						} else $mini = 0;
422
-						for ($i=$mini;$i<=$distance;$i+=10) {
422
+						for ($i = $mini; $i <= $distance; $i += 10) {
423 423
 						    $this->stats[$current_date][$source]['hist'][$i] = 0;
424 424
 						}
425 425
 						$this->stats[$current_date][$source]['hist'][$distance] = 1;
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
 				$this->all_tracked[$id]['lastupdate'] = time();
432 432
 				if ($this->all_tracked[$id]['putinarchive']) $send = true;
433 433
 				if ($globalDebug) echo $result."\n";
434
-			} 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";
434
+			} 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";
435 435
 			//$this->del();
436 436
 			
437 437
 			
Please login to merge, or discard this patch.
js/map-tracker.3d.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -177,7 +177,7 @@
 block discarded – undo
177 177
 } else {
178 178
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
179 179
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
180
-	$(".archivebox").html('<h4><?php echo str_replace("'","\'",_("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
180
+	$(".archivebox").html('<h4><?php echo str_replace("'", "\'", _("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
181 181
 }
182 182
 function TrackericonColor(color) {
183 183
 	document.cookie =  'TrackerIconColor='+color.substring(1)+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
Please login to merge, or discard this patch.
js/map-marine.3d.js.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@
 block discarded – undo
131 131
 } else {
132 132
 	var clockViewModel = new Cesium.ClockViewModel(viewer.clock);
133 133
 	var animationViewModel = new Cesium.AnimationViewModel(clockViewModel);
134
-	$(".archivebox").html('<h4><?php echo str_replace("'","\'",_("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
134
+	$(".archivebox").html('<h4><?php echo str_replace("'", "\'", _("Archive")); ?></h4>' + '<br/><form id="noarchive" method="post"><input type="hidden" name="noarchive" /></form><a href="#" onClick="animationViewModel.playReverseViewModel.command();"><i class="fa fa-play fa-flip-horizontal" aria-hidden="true"></i></a> <a href="#" onClick="'+"document.getElementById('noarchive').submit();"+'"><i class="fa fa-eject" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.pauseViewModel.command();"><i class="fa fa-pause" aria-hidden="true"></i></a> <a href="#" onClick="animationViewModel.playForwardViewModel.command();"><i class="fa fa-play" aria-hidden="true"></i></a>');
135 135
 }
136 136
 function MarineiconColor(color) {
137 137
 	document.cookie =  'MarineIconColor='+color.substring(1)+'; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'
Please login to merge, or discard this patch.
location-data.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 $Source = new Source();
6 6
 
7 7
 if (isset($_GET['sourceid'])) {
8
-	$sourceid = filter_input(INPUT_GET,'sourceid',FILTER_SANITIZE_NUMBER_INT);
8
+	$sourceid = filter_input(INPUT_GET, 'sourceid', FILTER_SANITIZE_NUMBER_INT);
9 9
 	$source_data = $Source->getLocationInfoById($sourceid);
10 10
 	if (isset($source_data[0])) {
11 11
  ?>
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
 print '</div>';
35 35
 
36 36
 if ($spotter_item['city'] != '') print '<div><span>'._("City").'</span>'.$spotter_item['city'].'</div>';
37
-if ($spotter_item['country'] !='') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
38
-print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
37
+if ($spotter_item['country'] != '') print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
38
+print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 3).', '.round($spotter_item['longitude'], 3).'</div>';
39 39
 /*
40 40
 if ($spotter_item['atc_range'] > 0) {
41 41
     print '<div><span>'._("Range").'</span>';
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 }
45 45
 */
46 46
 if ($spotter_item['type'] == 'wx') {
47
-	$weather = json_decode($spotter_item['description'],true);
47
+	$weather = json_decode($spotter_item['description'], true);
48 48
 	//print_r($weather);
49 49
 	if (isset($weather['temp'])) print '<div><span>'._("Temperature").'</span>'.$weather['temp'].'°C</div>';
50 50
 	if (isset($weather['pressure'])) print '<div><span>'._("Pressure").'</span>'.$weather['pressure'].'hPa</div>';
Please login to merge, or discard this patch.
require/class.Source.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 		try {
16 16
 			$sth = $this->db->prepare($query);
17 17
 			$sth->execute($query_values);
18
-		} catch(PDOException $e) {
18
+		} catch (PDOException $e) {
19 19
 			return "error : ".$e->getMessage();
20 20
 		}
21 21
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -28,20 +28,20 @@  discard block
 block discarded – undo
28 28
 		try {
29 29
 			$sth = $this->db->prepare($query);
30 30
 			$sth->execute($query_values);
31
-		} catch(PDOException $e) {
31
+		} catch (PDOException $e) {
32 32
 			return "error : ".$e->getMessage();
33 33
 		}
34 34
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
35 35
 		return $all;
36 36
 	}
37 37
 
38
-	public function getLocationInfobyNameType($name,$type) {
38
+	public function getLocationInfobyNameType($name, $type) {
39 39
 		$query = "SELECT * FROM source_location WHERE name = :name AND type = :type";
40
-		$query_values = array(':name' => $name,':type' => $type);
40
+		$query_values = array(':name' => $name, ':type' => $type);
41 41
 		try {
42 42
 			$sth = $this->db->prepare($query);
43 43
 			$sth->execute($query_values);
44
-		} catch(PDOException $e) {
44
+		} catch (PDOException $e) {
45 45
 			return "error : ".$e->getMessage();
46 46
 		}
47 47
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		try {
55 55
 			$sth = $this->db->prepare($query);
56 56
 			$sth->execute($query_values);
57
-		} catch(PDOException $e) {
57
+		} catch (PDOException $e) {
58 58
 			return "error : ".$e->getMessage();
59 59
 		}
60 60
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 		try {
68 68
 			$sth = $this->db->prepare($query);
69 69
 			$sth->execute($query_values);
70
-		} catch(PDOException $e) {
70
+		} catch (PDOException $e) {
71 71
 			return "error : ".$e->getMessage();
72 72
 		}
73 73
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		try {
81 81
 			$sth = $this->db->prepare($query);
82 82
 			$sth->execute($query_values);
83
-		} catch(PDOException $e) {
83
+		} catch (PDOException $e) {
84 84
 			return "error : ".$e->getMessage();
85 85
 		}
86 86
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -93,56 +93,56 @@  discard block
 block discarded – undo
93 93
 		try {
94 94
 			$sth = $this->db->prepare($query);
95 95
 			$sth->execute($query_values);
96
-		} catch(PDOException $e) {
96
+		} catch (PDOException $e) {
97 97
 			return "error : ".$e->getMessage();
98 98
 		}
99 99
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
100 100
 		return $all;
101 101
 	}
102 102
 
103
-	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') {
103
+	public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
104 104
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
105 105
 		$query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)";
106
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
106
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
107 107
 		try {
108 108
 			$sth = $this->db->prepare($query);
109 109
 			$sth->execute($query_values);
110
-		} catch(PDOException $e) {
110
+		} catch (PDOException $e) {
111 111
 			echo "error : ".$e->getMessage();
112 112
 		}
113 113
 	}
114 114
 
115
-	public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') {
115
+	public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') {
116 116
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
117 117
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source";
118
-		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
118
+		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
119 119
 		try {
120 120
 			$sth = $this->db->prepare($query);
121 121
 			$sth->execute($query_values);
122
-		} catch(PDOException $e) {
122
+		} catch (PDOException $e) {
123 123
 			return "error : ".$e->getMessage();
124 124
 		}
125 125
 	}
126 126
 
127
-	public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') {
127
+	public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') {
128 128
 		$query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source";
129
-		$query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description);
129
+		$query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description);
130 130
 		try {
131 131
 			$sth = $this->db->prepare($query);
132 132
 			$sth->execute($query_values);
133
-		} catch(PDOException $e) {
133
+		} catch (PDOException $e) {
134 134
 			return "error : ".$e->getMessage();
135 135
 		}
136 136
 	}
137 137
 
138
-	public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') {
138
+	public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') {
139 139
 		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s');
140 140
 		$query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id";
141
-		$query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description);
141
+		$query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description);
142 142
 		try {
143 143
 			$sth = $this->db->prepare($query);
144 144
 			$sth->execute($query_values);
145
-		} catch(PDOException $e) {
145
+		} catch (PDOException $e) {
146 146
 			echo "error : ".$e->getMessage();
147 147
 		}
148 148
 	}
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		try {
154 154
 			$sth = $this->db->prepare($query);
155 155
 			$sth->execute($query_values);
156
-		} catch(PDOException $e) {
156
+		} catch (PDOException $e) {
157 157
 			return "error : ".$e->getMessage();
158 158
 		}
159 159
 	}
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		try {
165 165
 			$sth = $this->db->prepare($query);
166 166
 			$sth->execute($query_values);
167
-		} catch(PDOException $e) {
167
+		} catch (PDOException $e) {
168 168
 			return "error : ".$e->getMessage();
169 169
 		}
170 170
 	}
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 		try {
176 176
 			$sth = $this->db->prepare($query);
177 177
 			$sth->execute($query_values);
178
-		} catch(PDOException $e) {
178
+		} catch (PDOException $e) {
179 179
 			return "error : ".$e->getMessage();
180 180
 		}
181 181
 	}
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 		try {
186 186
 			$sth = $this->db->prepare($query);
187 187
 			$sth->execute();
188
-		} catch(PDOException $e) {
188
+		} catch (PDOException $e) {
189 189
 			return "error : ".$e->getMessage();
190 190
 		}
191 191
 	}
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 		try {
215 215
 			$sth = $this->db->prepare($query);
216 216
 			$sth->execute(array(':type' => $type));
217
-		} catch(PDOException $e) {
217
+		} catch (PDOException $e) {
218 218
 			return "error";
219 219
 		}
220 220
 		return "success";
Please login to merge, or discard this patch.
location-geojson.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,43 +12,43 @@  discard block
 block discarded – undo
12 12
 if (!isset($globalDemo)) {
13 13
 	if (isset($_GET['coord'])) 
14 14
 	{
15
-		$coords = explode(',',$_GET['coord']);
15
+		$coords = explode(',', $_GET['coord']);
16 16
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
17 17
 		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
18 18
 			//$spotter_array = $Source->getAllLocationInfo();
19
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
19
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs'));
20 20
 		}
21 21
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
22 22
 		    || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) {
23
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
23
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx'));
24 24
 		}
25 25
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
26 26
 		    || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) {
27
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
27
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning'));
28 28
 		}
29
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
29
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType(''));
30 30
 	} else {
31 31
 		if ((isset($_COOKIE['show_GroundStation']) && $_COOKIE['show_GroundStation'] == 'true') 
32 32
 		    || (!isset($_COOKIE['show_GroundStation']) && (!isset($globalMapGroundStation) || $globalMapGroundStation === TRUE))) {
33 33
 			//$spotter_array = $Source->getAllLocationInfo();
34
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('gs'));
34
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('gs'));
35 35
 		}
36 36
 		if ((isset($_COOKIE['show_WeatherStation']) && $_COOKIE['show_WeatherStation'] == 'true') 
37 37
 		    || (!isset($_COOKIE['show_WeatherStation']) && (!isset($globalMapWeatherStation) || $globalMapWeatherStation === TRUE))) {
38
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('wx'));
38
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('wx'));
39 39
 		}
40 40
 		if ((isset($_COOKIE['show_Lightning']) && $_COOKIE['show_Lightning'] == 'true') 
41 41
 		    || (!isset($_COOKIE['show_Lightning']) && (!isset($globalMapLightning) || $globalMapLightning === TRUE))) {
42
-			$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType('lightning'));
42
+			$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType('lightning'));
43 43
 		}
44
-		$spotter_array = array_merge($spotter_array,$Source->getLocationInfoByType(''));
44
+		$spotter_array = array_merge($spotter_array, $Source->getLocationInfoByType(''));
45 45
 	}
46 46
 }
47 47
 
48 48
 $output = '{"type": "FeatureCollection","features": [';
49 49
 if (!empty($spotter_array) && count($spotter_array) > 0)
50 50
 {
51
-	foreach($spotter_array as $spotter_item)
51
+	foreach ($spotter_array as $spotter_item)
52 52
 	{
53 53
 		date_default_timezone_set('UTC');
54 54
 		//waypoint plotting
@@ -67,8 +67,8 @@  discard block
 block discarded – undo
67 67
 			$output .= '"icon": "'.$globalURL.'/images/'.$spotter_item['logo'].'",';
68 68
 			$output .= '"type": "'.$spotter_item['type'].'",';
69 69
 			if ($spotter_item['type'] == 'wx') {
70
-				$weather = json_decode($spotter_item['description'],true);
71
-				if (isset($weather['temp'])) $output.= '"temp": "'.$weather['temp'].'",';
70
+				$weather = json_decode($spotter_item['description'], true);
71
+				if (isset($weather['temp'])) $output .= '"temp": "'.$weather['temp'].'",';
72 72
 			}
73 73
 			$output .= '"image_thumb": "'.$spotter_item['image_thumb'].'"';
74 74
 		    $output .= '},';
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		    $output .= '}';
81 81
 		$output .= '},';
82 82
 	}
83
-	$output  = substr($output, 0, -1);
83
+	$output = substr($output, 0, -1);
84 84
 }
85 85
 $output .= ']}';
86 86
 
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 1 patch
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	    die;
47 47
 	}
48 48
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
49
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
50 50
     }
51 51
 }
52 52
 
53
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
54 54
 //if (isset($options['s'])) $hosts = array($options['s']);
55 55
 //elseif (isset($options['source'])) $hosts = array($options['source']);
56 56
 if (isset($options['s'])) {
57 57
     $globalSources = array();
58
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
59 59
     else $globalSources[] = array('host' => $options['s']);
60 60
 } elseif (isset($options['source'])) {
61 61
     $globalSources = array();
62
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
63 63
     else $globalSources[] = array('host' => $options['source']);
64 64
 }
65 65
 if (isset($options['aprsserverhost'])) {
@@ -76,28 +76,28 @@  discard block
 block discarded – undo
76 76
 else $id_source = 1;
77 77
 if (isset($globalServer) && $globalServer) {
78 78
     if ($globalDebug) echo "Using Server Mode\n";
79
-    $SI=new SpotterServer();
79
+    $SI = new SpotterServer();
80 80
 /*
81 81
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
82 82
     $SI = new adsb2aprs();
83 83
     $SI->connect();
84 84
 */
85
-} else $SI=new SpotterImport($Connection->db);
85
+} else $SI = new SpotterImport($Connection->db);
86 86
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
87 87
 if (isset($globalMarine) && $globalMarine) {
88 88
     $AIS = new AIS();
89 89
     $MI = new MarineImport($Connection->db);
90 90
 }
91 91
 //$APRS=new APRS($Connection->db);
92
-$SBS=new SBS();
93
-$ACARS=new ACARS($Connection->db);
94
-$Source=new Source($Connection->db);
95
-$Common=new Common();
92
+$SBS = new SBS();
93
+$ACARS = new ACARS($Connection->db);
94
+$Source = new Source($Connection->db);
95
+$Common = new Common();
96 96
 date_default_timezone_set('UTC');
97 97
 //$servertz = system('date +%Z');
98 98
 // signal handler - playing nice with sockets and dump1090
99 99
 if (function_exists('pcntl_fork')) {
100
-    pcntl_signal(SIGINT,  function() {
100
+    pcntl_signal(SIGINT, function() {
101 101
         global $sockets;
102 102
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
103 103
         die("Bye!\n");
@@ -113,30 +113,30 @@  discard block
 block discarded – undo
113 113
 
114 114
 function connect_all($hosts) {
115 115
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
116
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
116
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
117 117
     $reset++;
118 118
     if ($globalDebug) echo 'Connect to all...'."\n";
119 119
     foreach ($hosts as $id => $value) {
120 120
 	$host = $value['host'];
121 121
 	$globalSources[$id]['last_exec'] = 0;
122 122
 	// Here we check type of source(s)
123
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
124
+            if (preg_match('/deltadb.txt$/i', $host)) {
125 125
         	//$formats[$id] = 'deltadbtxt';
126 126
         	$globalSources[$id]['format'] = 'deltadbtxt';
127 127
         	//$last_exec['deltadbtxt'] = 0;
128 128
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
129
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
129
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
130 130
         	//$formats[$id] = 'vatsimtxt';
131 131
         	$globalSources[$id]['format'] = 'vatsimtxt';
132 132
         	//$last_exec['vatsimtxt'] = 0;
133 133
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
134
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
134
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
135 135
         	//$formats[$id] = 'aircraftlistjson';
136 136
         	$globalSources[$id]['format'] = 'aircraftlistjson';
137 137
         	//$last_exec['aircraftlistjson'] = 0;
138 138
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
139
-    	    } else if (preg_match('/opensky/i',$host)) {
139
+    	    } else if (preg_match('/opensky/i', $host)) {
140 140
         	//$formats[$id] = 'aircraftlistjson';
141 141
         	$globalSources[$id]['format'] = 'opensky';
142 142
         	//$last_exec['aircraftlistjson'] = 0;
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
         	    exit(0);
154 154
         	}
155 155
     	    */
156
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
156
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
157 157
         	//$formats[$id] = 'planeupdatefaa';
158 158
         	$globalSources[$id]['format'] = 'planeupdatefaa';
159 159
         	//$last_exec['planeupdatefaa'] = 0;
@@ -162,32 +162,32 @@  discard block
 block discarded – undo
162 162
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
163 163
         	    exit(0);
164 164
         	}
165
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
165
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
166 166
         	//$formats[$id] = 'phpvmacars';
167 167
         	$globalSources[$id]['format'] = 'phpvmacars';
168 168
         	//$last_exec['phpvmacars'] = 0;
169 169
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
170
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
170
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
171 171
         	//$formats[$id] = 'phpvmacars';
172 172
         	$globalSources[$id]['format'] = 'vam';
173 173
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
174
-            } else if (preg_match('/whazzup/i',$host)) {
174
+            } else if (preg_match('/whazzup/i', $host)) {
175 175
         	//$formats[$id] = 'whazzup';
176 176
         	$globalSources[$id]['format'] = 'whazzup';
177 177
         	//$last_exec['whazzup'] = 0;
178 178
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
179
-            } else if (preg_match('/blitzortung/i',$host)) {
179
+            } else if (preg_match('/blitzortung/i', $host)) {
180 180
         	$globalSources[$id]['format'] = 'blitzortung';
181 181
         	if ($globalDebug) echo "Connect to blitzortung source (".$host.")...\n";
182
-            } else if (preg_match('/airwhere/i',$host)) {
182
+            } else if (preg_match('/airwhere/i', $host)) {
183 183
         	$globalSources[$id]['format'] = 'airwhere';
184 184
         	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n";
185
-            } else if (preg_match('/recentpireps/i',$host)) {
185
+            } else if (preg_match('/recentpireps/i', $host)) {
186 186
         	//$formats[$id] = 'pirepsjson';
187 187
         	$globalSources[$id]['format'] = 'pirepsjson';
188 188
         	//$last_exec['pirepsjson'] = 0;
189 189
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
190
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
190
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
191 191
         	//$formats[$id] = 'fr24json';
192 192
         	$globalSources[$id]['format'] = 'fr24json';
193 193
         	//$last_exec['fr24json'] = 0;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
197 197
         	    exit(0);
198 198
         	}
199
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
199
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
200 200
         	//$formats[$id] = 'fr24json';
201 201
         	$globalSources[$id]['format'] = 'myshiptracking';
202 202
         	//$last_exec['fr24json'] = 0;
@@ -206,22 +206,22 @@  discard block
 block discarded – undo
206 206
         	    exit(0);
207 207
         	}
208 208
             //} else if (preg_match('/10001/',$host)) {
209
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
209
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
210 210
         	//$formats[$id] = 'tsv';
211 211
         	$globalSources[$id]['format'] = 'tsv';
212 212
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
213 213
             }
214
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
214
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
215 215
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
216
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
216
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
217 217
     		    if ($idf !== false) {
218 218
     			$httpfeeds[$id] = $idf;
219 219
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
220 220
     		    }
221 221
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
222 222
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
223
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
224
-	    $hostport = explode(':',$host);
223
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
224
+	    $hostport = explode(':', $host);
225 225
 	    if (isset($hostport[1])) {
226 226
 		$port = $hostport[1];
227 227
 		$hostn = $hostport[0];
@@ -231,19 +231,19 @@  discard block
 block discarded – undo
231 231
 	    }
232 232
 	    $Common = new Common();
233 233
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
234
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
234
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
235 235
     	    } else {
236
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
236
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
237 237
 	    }
238 238
 	    if ($s) {
239 239
     	        $sockets[$id] = $s;
240 240
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
241
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
241
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
242 242
 			//$formats[$id] = 'aprs';
243 243
 			$globalSources[$id]['format'] = 'aprs';
244 244
 			//$aprs_connect = 0;
245 245
 			//$use_aprs = true;
246
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
246
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
247 247
 			$globalSources[$id]['format'] = 'vrstcp';
248 248
     		    } elseif ($port == '10001') {
249 249
         		//$formats[$id] = 'tsv';
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
283 283
 else $timeout = 20;
284 284
 $errno = '';
285
-$errstr='';
285
+$errstr = '';
286 286
 
287 287
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
288 288
 /* Initiate connections to all the hosts simultaneously */
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 //connect_all($globalSources);
291 291
 
292 292
 if (isset($globalProxy) && $globalProxy) {
293
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
293
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
294 294
 } else {
295 295
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
296 296
 }
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
 
321 321
 if ($use_aprs) {
322 322
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
323
-	$APRS=new APRS();
323
+	$APRS = new APRS();
324 324
 	$aprs_connect = 0;
325 325
 	$aprs_keep = 120;
326 326
 	$aprs_last_tx = time();
327 327
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
328
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
328
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
329 329
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
330
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
330
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
331 331
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
332
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
332
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
333 333
 	if ($aprs_full) $aprs_filter = '';
334 334
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
335 335
 	else $aprs_pass = '-1';
@@ -343,12 +343,12 @@  discard block
 block discarded – undo
343 343
 sleep(1);
344 344
 if ($globalDebug) echo "SCAN MODE \n\n";
345 345
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
346
-$endtime = time()+$globalCronEnd;
346
+$endtime = time() + $globalCronEnd;
347 347
 $i = 1;
348 348
 $tt = array();
349 349
 // Delete all ATC
350 350
 if ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
351
-	$ATC=new ATC($Connection->db);
351
+	$ATC = new ATC($Connection->db);
352 352
 }
353 353
 if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
354 354
 	$ATC->deleteAll();
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 
357 357
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
358 358
 while ($i > 0) {
359
-    if (!$globalDaemon) $i = $endtime-time();
359
+    if (!$globalDaemon) $i = $endtime - time();
360 360
     // Delete old ATC
361 361
     if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
362 362
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
 	}
371 371
 	if ($max != $globalMinFetch) {
372 372
 	    if ($globalDebug) echo 'Sleeping...'."\n";
373
-	    sleep($globalMinFetch-$max+2);
373
+	    sleep($globalMinFetch - $max + 2);
374 374
 	}
375 375
     }
376 376
 
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 	    //$buffer = $Common->getData($hosts[$id]);
390 390
 	    $buffer = $Common->getData($value['host']);
391 391
 	    if ($buffer != '') $reset = 0;
392
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
393
-	    $buffer = explode('\n',$buffer);
392
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
393
+	    $buffer = explode('\n', $buffer);
394 394
 	    foreach ($buffer as $line) {
395 395
     		if ($line != '' && count($line) > 7) {
396 396
     		    $line = explode(',', $line);
@@ -423,11 +423,11 @@  discard block
 block discarded – undo
423 423
 	    )
424 424
 	) {
425 425
 	    date_default_timezone_set('CET');
426
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
426
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
427 427
 	    date_default_timezone_set('UTC');
428 428
 	    if ($buffer != '') $reset = 0;
429
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
430
-	    $buffer = explode('\n',$buffer);
429
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
430
+	    $buffer = explode('\n', $buffer);
431 431
 	    foreach ($buffer as $line) {
432 432
 		if ($line != '') {
433 433
 		    //echo "'".$line."'\n";
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
446 446
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
447 447
 		    if (isset($ais_data['timestamp'])) {
448
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
448
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
449 449
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
450 450
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
451 451
 			    $add = true;
@@ -468,12 +468,12 @@  discard block
 block discarded – undo
468 468
 	    $w = $e = null;
469 469
 	    
470 470
 	    if (isset($arr[$id])) {
471
-		$nn = stream_select($arr,$w,$e,$timeout);
471
+		$nn = stream_select($arr, $w, $e, $timeout);
472 472
 		if ($nn > 0) {
473 473
 		    foreach ($httpfeeds as $feed) {
474
-			$buffer = stream_get_line($feed,2000,"\n");
475
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
476
-			$buffer = explode('\n',$buffer);
474
+			$buffer = stream_get_line($feed, 2000, "\n");
475
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
476
+			$buffer = explode('\n', $buffer);
477 477
 			foreach ($buffer as $line) {
478 478
 			    if ($line != '') {
479 479
 				$ais_data = $AIS->parse_line(trim($line));
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
492 492
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
493 493
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
494
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
494
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
495 495
 				if (isset($ais_data['timestamp'])) {
496
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
496
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
497 497
 				} else {
498 498
 				    $data['datetime'] = date('Y-m-d H:i:s');
499 499
 				}
@@ -524,10 +524,10 @@  discard block
 block discarded – undo
524 524
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
525 525
 	    )
526 526
 	) {
527
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
527
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
528 528
 	    if ($buffer != '') {
529 529
 		//echo $buffer;
530
-		$all_data = json_decode($buffer,true);
530
+		$all_data = json_decode($buffer, true);
531 531
 		//print_r($all_data);
532 532
 		if (isset($all_data[0]['DATA'])) {
533 533
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
543 543
 			    $data['imo'] = $line['IMO'];
544 544
 			    //$data['arrival_code'] = $ais_data['destination'];
545
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
545
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
546 546
 			    $data['format_source'] = 'myshiptracking';
547 547
 			    $data['id_source'] = $id_source;
548 548
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -559,9 +559,9 @@  discard block
 block discarded – undo
559 559
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch*3))
560 560
 	    )
561 561
 	) {
562
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
562
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
563 563
 	    if ($buffer != '') {
564
-		$all_data = json_decode($buffer,true);
564
+		$all_data = json_decode($buffer, true);
565 565
 		if (isset($all_data[0]['mmsi'])) {
566 566
 		    foreach ($all_data as $line) {
567 567
 			if ($line != '') {
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 	) {
596 596
 	    $buffer = $Common->getData($value['host']);
597 597
 	    if ($buffer != '') {
598
-		$all_data = json_decode($buffer,true);
598
+		$all_data = json_decode($buffer, true);
599 599
 		if (isset($all_data['features'][0]['id'])) {
600 600
 		    foreach ($all_data['features'] as $line) {
601 601
 			$data = array();
@@ -628,27 +628,27 @@  discard block
 block discarded – undo
628 628
 	    )
629 629
 	) {
630 630
 	    echo 'download...';
631
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
631
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
632 632
 	    echo 'done !'."\n";
633 633
 	    if ($buffer != '') $reset = 0;
634
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
635
-	    $buffer = explode('\n',$buffer);
634
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
635
+	    $buffer = explode('\n', $buffer);
636 636
 	    foreach ($buffer as $line) {
637 637
 		if ($line != '') {
638 638
 		    $data = array();
639
-		    $data['mmsi'] = (int)substr($line,0,9);
640
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
639
+		    $data['mmsi'] = (int) substr($line, 0, 9);
640
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
641 641
 		    //$data['status'] = substr($line,21,2);
642 642
 		    //$data['type'] = substr($line,24,3);
643
-		    $data['latitude'] = substr($line,29,9);
644
-		    $data['longitude'] = substr($line,41,9);
645
-		    $data['speed'] = round(substr($line,51,5));
643
+		    $data['latitude'] = substr($line, 29, 9);
644
+		    $data['longitude'] = substr($line, 41, 9);
645
+		    $data['speed'] = round(substr($line, 51, 5));
646 646
 		    //$data['course'] = substr($line,57,5);
647
-		    $data['heading'] = round(substr($line,63,3));
647
+		    $data['heading'] = round(substr($line, 63, 3));
648 648
 		    //$data['draft'] = substr($line,67,4);
649 649
 		    //$data['length'] = substr($line,72,3);
650 650
 		    //$data['beam'] = substr($line,76,2);
651
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
651
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
652 652
 		    //$data['callsign'] = trim(substr($line,100,7);
653 653
 		    //$data['dest'] = substr($line,108,20);
654 654
 		    //$data['etaDate'] = substr($line,129,5);
@@ -681,8 +681,8 @@  discard block
 block discarded – undo
681 681
 	) {
682 682
 	    //$buffer = $Common->getData($hosts[$id]);
683 683
 	    $buffer = $Common->getData($value['host']);
684
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
685
-	    $buffer = explode('\n',$buffer);
684
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
685
+	    $buffer = explode('\n', $buffer);
686 686
 	    $reset = 0;
687 687
 	    foreach ($buffer as $line) {
688 688
     		if ($line != '') {
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
694 694
 			$data['pilot_id'] = $line[1];
695 695
 			$data['pilot_name'] = $line[2];
696
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
696
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
697 697
 			$data['ident'] = $line[0]; // ident
698 698
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
699 699
 			$data['speed'] = $line[8]; // speed
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
710 710
 			//if (isset($line[37])) $data['last_update'] = $line[37];
711 711
 		        $data['departure_airport_icao'] = $line[11];
712
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
712
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
713 713
 		        $data['arrival_airport_icao'] = $line[13];
714 714
 			$data['frequency'] = $line[4];
715 715
 			$data['type'] = $line[18];
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     			$data['id_source'] = $id_source;
719 719
 	    		//$data['arrival_airport_time'] = ;
720 720
 	    		if ($line[9] != '') {
721
-	    		    $aircraft_data = explode('/',$line[9]);
721
+	    		    $aircraft_data = explode('/', $line[9]);
722 722
 	    		    if (isset($aircraft_data[1])) {
723 723
 	    			$data['aircraft_icao'] = $aircraft_data[1];
724 724
 	    		    }
@@ -733,9 +733,9 @@  discard block
 block discarded – undo
733 733
     			if ($line[3] == 'PILOT') $SI->add($data);
734 734
 			elseif ($line[3] == 'ATC') {
735 735
 				//print_r($data);
736
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
737
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
738
-				$typec = substr($data['ident'],-3);
736
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
737
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
738
+				$typec = substr($data['ident'], -3);
739 739
 				if ($typec == 'APP') $data['type'] = 'Approach';
740 740
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
741 741
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -747,8 +747,8 @@  discard block
 block discarded – undo
747 747
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
748 748
 				if (!isset($data['source_name'])) $data['source_name'] = '';
749 749
 				if (isset($ATC)) {
750
-					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) echo $ATC->update($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
751
-					else echo $ATC->add($data['ident'],$data['frequency'],$data['latitude'],$data['longitude'],$data['range'],$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source'],$data['source_name']);
750
+					if (count($ATC->getByIdent($data['ident'], $data['format_source'])) > 0) echo $ATC->update($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
751
+					else echo $ATC->add($data['ident'], $data['frequency'], $data['latitude'], $data['longitude'], $data['range'], $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source'], $data['source_name']);
752 752
 				}
753 753
 			}
754 754
     			unset($data);
@@ -764,24 +764,24 @@  discard block
 block discarded – undo
764 764
     		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
765 765
     	    )
766 766
     	) {
767
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20');
767
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20');
768 768
 	    if ($buffer != '') {
769 769
 		$all_data = simplexml_load_string($buffer);
770
-		foreach($all_data->children() as $childdata) {
770
+		foreach ($all_data->children() as $childdata) {
771 771
 			$data = array();
772 772
 			$line = $childdata;
773 773
 			//$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT);
774
-			$data['id'] = date('Ymd').(int)$line['pktPilotID'];
775
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST'));
776
-			$data['latitude'] = (float)$line['pktLatitude'];
777
-			$data['longitude'] = (float)$line['pktLongitude'];
778
-			if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack'];
779
-			if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed'];
780
-			$data['altitude'] = round((int)$line['pktAltitude']*3.28084);
774
+			$data['id'] = date('Ymd').(int) $line['pktPilotID'];
775
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST'));
776
+			$data['latitude'] = (float) $line['pktLatitude'];
777
+			$data['longitude'] = (float) $line['pktLongitude'];
778
+			if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack'];
779
+			if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed'];
780
+			$data['altitude'] = round((int) $line['pktAltitude']*3.28084);
781 781
 			$data['altitude_relative'] = 'AMSL';
782
-			$data['pilot_id'] = (int)$line['pktPilotID'];
782
+			$data['pilot_id'] = (int) $line['pktPilotID'];
783 783
 			$data['aircraft_icao'] = 'PARAGLIDER';
784
-			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
784
+			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id']));
785 785
 			if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4];
786 786
 			$data['format_source'] = $value['format'];
787 787
 			$SI->add($data);
@@ -789,22 +789,22 @@  discard block
 block discarded – undo
789 789
 		}
790 790
 	    }
791 791
 	    $Source->deleteOldLocationByType('gs');
792
-	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20');
792
+	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20');
793 793
 	    if ($buffer != '') {
794 794
 		$all_data = simplexml_load_string($buffer);
795
-		foreach($all_data->children() as $childdata) {
795
+		foreach ($all_data->children() as $childdata) {
796 796
 			$data = array();
797 797
 			$line = $childdata;
798
-			$data['id'] = (int)$line['gsID'];
799
-			$data['latitude'] = (float)$line['gsLatitude'];
800
-			$data['longitude'] = (float)$line['gsLongitude'];
801
-			$data['altitude'] = round((int)$line['gsHeight']*3.28084);
798
+			$data['id'] = (int) $line['gsID'];
799
+			$data['latitude'] = (float) $line['gsLatitude'];
800
+			$data['longitude'] = (float) $line['gsLongitude'];
801
+			$data['altitude'] = round((int) $line['gsHeight']*3.28084);
802 802
 			$data['altitude_relative'] = 'AMSL';
803
-			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST'));
803
+			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST'));
804 804
 			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) {
805
-				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
805
+				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
806 806
 			} else {
807
-				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']);
807
+				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']);
808 808
 			}
809 809
 			unset($data);
810 810
 		}
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 		(!isset($globalSources[$id]['minfetch']) && (time() - $last_exec[$id]['last'] > $globalMinFetch))
823 823
 	    )
824 824
 	) {
825
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
825
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
826 826
 	    if ($buffer != '') {
827
-	        $all_data = json_decode($buffer,true);
827
+	        $all_data = json_decode($buffer, true);
828 828
 		if (isset($all_data['acList'])) {
829 829
 		    $reset = 0;
830 830
 		    foreach ($all_data['acList'] as $line) {
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
841 841
 			$data['emergency'] = ''; // emergency
842 842
 			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
843
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
843
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
844 844
 			else $data['datetime'] = date('Y-m-d H:i:s');
845 845
 			//$data['datetime'] = date('Y-m-d H:i:s');
846 846
 			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
@@ -865,7 +865,7 @@  discard block
 block discarded – undo
865 865
 			$data['verticalrate'] = $line['vrt']; // verticale rate
866 866
 			$data['squawk'] = $line['squawk']; // squawk
867 867
 			$data['emergency'] = ''; // emergency
868
-			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
868
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
869 869
 			else $data['datetime'] = date('Y-m-d H:i:s');
870 870
 			$data['format_source'] = 'aircraftlistjson';
871 871
 			$data['id_source'] = $id_source;
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
     	    )
887 887
     	) {
888 888
 	    $buffer = $Common->getData($value['host']);
889
-	    $all_data = json_decode($buffer,true);
889
+	    $all_data = json_decode($buffer, true);
890 890
 	    if (isset($all_data['planes'])) {
891 891
 		$reset = 0;
892 892
 		foreach ($all_data['planes'] as $key => $line) {
@@ -903,12 +903,12 @@  discard block
 block discarded – undo
903 903
 		    $data['emergency'] = ''; // emergency
904 904
 		    $data['registration'] = $line[2];
905 905
 		    $data['aircraft_icao'] = $line[0];
906
-		    $deparr = explode('-',$line[1]);
906
+		    $deparr = explode('-', $line[1]);
907 907
 		    if (count($deparr) == 2) {
908 908
 			$data['departure_airport_icao'] = $deparr[0];
909 909
 			$data['arrival_airport_icao'] = $deparr[1];
910 910
 		    }
911
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
911
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
912 912
 	    	    $data['format_source'] = 'planeupdatefaa';
913 913
     		    $data['id_source'] = $id_source;
914 914
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 	    )
927 927
 	) {
928 928
 	    $buffer = $Common->getData($value['host']);
929
-	    $all_data = json_decode($buffer,true);
929
+	    $all_data = json_decode($buffer, true);
930 930
 	    if (isset($all_data['states'])) {
931 931
 		$reset = 0;
932 932
 		foreach ($all_data['states'] as $key => $line) {
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 		    //$data['emergency'] = ''; // emergency
944 944
 		    //$data['registration'] = $line[2];
945 945
 		    //$data['aircraft_icao'] = $line[0];
946
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
946
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
947 947
 		    $data['format_source'] = 'opensky';
948 948
 		    $data['id_source'] = $id_source;
949 949
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -962,7 +962,7 @@  discard block
 block discarded – undo
962 962
 	) {
963 963
 	    //$buffer = $Common->getData($hosts[$id]);
964 964
 	    $buffer = $Common->getData($value['host']);
965
-	    $all_data = json_decode($buffer,true);
965
+	    $all_data = json_decode($buffer, true);
966 966
 	    if (!empty($all_data)) $reset = 0;
967 967
 	    foreach ($all_data as $key => $line) {
968 968
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -1000,11 +1000,11 @@  discard block
 block discarded – undo
1000 1000
 	    )
1001 1001
 	) {
1002 1002
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
1003
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
1003
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
1004 1004
 	    //echo $buffer;
1005
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
1006
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
1007
-	    $all_data = json_decode($buffer,true);
1005
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
1006
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
1007
+	    $all_data = json_decode($buffer, true);
1008 1008
 	    if (json_last_error() != JSON_ERROR_NONE) {
1009 1009
 		die(json_last_error_msg());
1010 1010
 	    }
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 			//$data['departure_airport_iata'] = $line[11];
1028 1028
 			//$data['arrival_airport_iata'] = $line[12];
1029 1029
 	    		//$data['emergency'] = ''; // emergency
1030
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
1030
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
1031 1031
 	    		$data['format_source'] = 'radarvirtueljson';
1032 1032
     			$data['id_source'] = $id_source;
1033 1033
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -1048,14 +1048,14 @@  discard block
 block discarded – undo
1048 1048
 	) {
1049 1049
 	    //$buffer = $Common->getData($hosts[$id]);
1050 1050
 	    $buffer = $Common->getData($value['host'].'?'.time());
1051
-	    $all_data = json_decode(utf8_encode($buffer),true);
1051
+	    $all_data = json_decode(utf8_encode($buffer), true);
1052 1052
 	    
1053 1053
 	    if (isset($all_data['pireps'])) {
1054 1054
 		$reset = 0;
1055 1055
 	        foreach ($all_data['pireps'] as $line) {
1056 1056
 		    $data = array();
1057 1057
 		    $data['id'] = $line['id'];
1058
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
1058
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
1059 1059
 		    $data['ident'] = $line['callsign']; // ident
1060 1060
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
1061 1061
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -1085,9 +1085,9 @@  discard block
 block discarded – undo
1085 1085
 			$SI->add($data);
1086 1086
 		    //    print_r($data);
1087 1087
     		    } elseif ($line['icon'] == 'ct') {
1088
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
1089
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
1090
-			$typec = substr($data['ident'],-3);
1088
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
1089
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
1090
+			$typec = substr($data['ident'], -3);
1091 1091
 			$data['type'] = '';
1092 1092
 			if ($typec == 'APP') $data['type'] = 'Approach';
1093 1093
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
1099 1099
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
1100 1100
 			else $data['type'] = 'Observer';
1101
-			if (isset($ATC)) echo $ATC->add($data['ident'],'',$data['latitude'],$data['longitude'],'0',$data['info'],$data['datetime'],$data['type'],$data['pilot_id'],$data['pilot_name'],$data['format_source']);
1101
+			if (isset($ATC)) echo $ATC->add($data['ident'], '', $data['latitude'], $data['longitude'], '0', $data['info'], $data['datetime'], $data['type'], $data['pilot_id'], $data['pilot_name'], $data['format_source']);
1102 1102
 		    }
1103 1103
 		    unset($data);
1104 1104
 		}
@@ -1115,14 +1115,14 @@  discard block
 block discarded – undo
1115 1115
 	    //$buffer = $Common->getData($hosts[$id]);
1116 1116
 	    if ($globalDebug) echo 'Get Data...'."\n";
1117 1117
 	    $buffer = $Common->getData($value['host']);
1118
-	    $all_data = json_decode($buffer,true);
1118
+	    $all_data = json_decode($buffer, true);
1119 1119
 	    if ($buffer != '' && is_array($all_data)) {
1120 1120
 		$reset = 0;
1121 1121
 		foreach ($all_data as $line) {
1122 1122
 	    	    $data = array();
1123 1123
 	    	    //$data['id'] = $line['id']; // id not usable
1124 1124
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1125
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
1125
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
1126 1126
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
1127 1127
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1128 1128
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 	    	    //$data['datetime'] = $line['lastupdate'];
1138 1138
 	    	    //$data['last_update'] = $line['lastupdate'];
1139 1139
 	    	    if (isset($value['timezone'])) {
1140
-	    		$datetime = new DateTime($line['lastupdate'],new DateTimeZone($value['timezone']));
1140
+	    		$datetime = new DateTime($line['lastupdate'], new DateTimeZone($value['timezone']));
1141 1141
 	    		$datetime->setTimeZone(new DateTimeZone('UTC'));
1142 1142
 	    		$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1143 1143
 	    	    } else $data['datetime'] = date('Y-m-d H:i:s');
@@ -1150,14 +1150,14 @@  discard block
 block discarded – undo
1150 1150
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1151 1151
 		    if (isset($line['aircraftname'])) {
1152 1152
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1153
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1154
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1153
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1154
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1155 1155
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1156 1156
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1157 1157
 	    		else {
1158
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1159
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1160
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1158
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1159
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1160
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1161 1161
 	    		}
1162 1162
 	    	    }
1163 1163
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1182,14 +1182,14 @@  discard block
 block discarded – undo
1182 1182
 	    //$buffer = $Common->getData($hosts[$id]);
1183 1183
 	    if ($globalDebug) echo 'Get Data...'."\n";
1184 1184
 	    $buffer = $Common->getData($value['host']);
1185
-	    $all_data = json_decode($buffer,true);
1185
+	    $all_data = json_decode($buffer, true);
1186 1186
 	    if ($buffer != '' && is_array($all_data)) {
1187 1187
 		$reset = 0;
1188 1188
 		foreach ($all_data as $line) {
1189 1189
 	    	    $data = array();
1190 1190
 	    	    //$data['id'] = $line['id']; // id not usable
1191 1191
 	    	    $data['id'] = trim($line['flight_id']);
1192
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1192
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1193 1193
 	    	    $data['pilot_name'] = $line['pilot_name'];
1194 1194
 	    	    $data['pilot_id'] = $line['pilot_id'];
1195 1195
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1233,24 +1233,24 @@  discard block
 block discarded – undo
1233 1233
 	    //$buffer = $Common->getData($hosts[$id]);
1234 1234
 	    if ($globalDebug) echo 'Get Data...'."\n";
1235 1235
 	    $buffer = $Common->getData($value['host']);
1236
-	    $all_data = json_decode($buffer,true);
1236
+	    $all_data = json_decode($buffer, true);
1237 1237
 	    if ($buffer != '') {
1238 1238
 		$Source->deleteLocationBySource('blitzortung');
1239
-		$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
1240
-		$buffer = explode('\n',$buffer);
1239
+		$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
1240
+		$buffer = explode('\n', $buffer);
1241 1241
 		foreach ($buffer as $buffer_line) {
1242
-		    $line = json_decode($buffer_line,true);
1242
+		    $line = json_decode($buffer_line, true);
1243 1243
 		    if (isset($line['time'])) {
1244 1244
 			$data = array();
1245 1245
 			$data['altitude'] = $line['alt']; // altitude
1246 1246
 			$data['latitude'] = $line['lat']; // lat
1247 1247
 			$data['longitude'] = $line['lon']; // long
1248
-			$data['datetime'] = date('Y-m-d H:i:s',substr($line['time'],0,10));
1248
+			$data['datetime'] = date('Y-m-d H:i:s', substr($line['time'], 0, 10));
1249 1249
 			$data['id_source'] = $id_source;
1250 1250
 			$data['format_source'] = 'blitzortung';
1251 1251
 			$SI->add($data);
1252 1252
 			if ($globalDebug) echo '☈ Lightning added'."\n";
1253
-			$Source->addLocation('',$data['latitude'],$data['longitude'],0,'','','blitzortung','weather/thunderstorm.png','lightning',$id,0,$data['datetime']);
1253
+			$Source->addLocation('', $data['latitude'], $data['longitude'], 0, '', '', 'blitzortung', 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime']);
1254 1254
 			unset($data);
1255 1255
 		    }
1256 1256
 		}
@@ -1275,11 +1275,11 @@  discard block
 block discarded – undo
1275 1275
 		    //$value = $formats[$nb];
1276 1276
 		    $format = $globalSources[$nb]['format'];
1277 1277
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1278
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1278
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1279 1279
 		    } elseif ($format == 'vrstcp') {
1280 1280
 			$buffer = @socket_read($r, 6000);
1281 1281
 		    } else {
1282
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1282
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1283 1283
 		    }
1284 1284
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1285 1285
 		    //echo $buffer."\n";
@@ -1288,8 +1288,8 @@  discard block
 block discarded – undo
1288 1288
 		    $error = false;
1289 1289
 		    //$SI::del();
1290 1290
 		    if ($format == 'vrstcp') {
1291
-			$buffer = explode('},{',$buffer);
1292
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1291
+			$buffer = explode('},{', $buffer);
1292
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1293 1293
 		    // SBS format is CSV format
1294 1294
 		    if ($buffer !== FALSE && $buffer != '') {
1295 1295
 			$tt[$format] = 0;
@@ -1323,13 +1323,13 @@  discard block
 block discarded – undo
1323 1323
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1324 1324
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1325 1325
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1326
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1326
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1327 1327
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1328 1328
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1329 1329
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1330 1330
 
1331 1331
 			    if (isset($ais_data['timestamp'])) {
1332
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1332
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1333 1333
 			    } else {
1334 1334
 				$data['datetime'] = date('Y-m-d H:i:s');
1335 1335
 			    }
@@ -1340,10 +1340,10 @@  discard block
 block discarded – undo
1340 1340
                         } elseif ($format == 'flightgearsp') {
1341 1341
                     	    //echo $buffer."\n";
1342 1342
                     	    if (strlen($buffer) > 5) {
1343
-				$line = explode(',',$buffer);
1343
+				$line = explode(',', $buffer);
1344 1344
 				$data = array();
1345 1345
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1346
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1346
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1347 1347
 				$data['ident'] = $line[6];
1348 1348
 				$data['aircraft_name'] = $line[7];
1349 1349
 				$data['longitude'] = $line[1];
@@ -1360,16 +1360,16 @@  discard block
 block discarded – undo
1360 1360
                         } elseif ($format == 'acars') {
1361 1361
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1362 1362
 			    $ACARS->add(trim($buffer));
1363
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1363
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1364 1364
 			    $ACARS->deleteLiveAcarsData();
1365 1365
 			} elseif ($format == 'flightgearmp') {
1366
-			    if (substr($buffer,0,1) != '#') {
1366
+			    if (substr($buffer, 0, 1) != '#') {
1367 1367
 				$data = array();
1368 1368
 				//echo $buffer."\n";
1369
-				$line = explode(' ',$buffer);
1369
+				$line = explode(' ', $buffer);
1370 1370
 				if (count($line) == 11) {
1371
-				    $userserver = explode('@',$line[0]);
1372
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1371
+				    $userserver = explode('@', $line[0]);
1372
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1373 1373
 				    $data['ident'] = $userserver[0];
1374 1374
 				    $data['registration'] = $userserver[0];
1375 1375
 				    $data['latitude'] = $line[4];
@@ -1377,8 +1377,8 @@  discard block
 block discarded – undo
1377 1377
 				    $data['altitude'] = $line[6];
1378 1378
 				    $data['datetime'] = date('Y-m-d H:i:s');
1379 1379
 				    $aircraft_type = $line[10];
1380
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1381
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1380
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1381
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1382 1382
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1383 1383
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1384 1384
 				}
@@ -1387,8 +1387,8 @@  discard block
 block discarded – undo
1387 1387
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1388 1388
 			    die;
1389 1389
 			} elseif ($format == 'vrstcp') {
1390
-			    foreach($buffer as $all_data) {
1391
-				$line = json_decode('{'.$all_data.'}',true);
1390
+			    foreach ($buffer as $all_data) {
1391
+				$line = json_decode('{'.$all_data.'}', true);
1392 1392
 				$data = array();
1393 1393
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1394 1394
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1414,16 +1414,16 @@  discard block
 block discarded – undo
1414 1414
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1415 1415
 				unset($data);
1416 1416
 			    }
1417
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1417
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1418 1418
 			    $line = explode("\t", $buffer);
1419
-			    for($k = 0; $k < count($line); $k=$k+2) {
1419
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1420 1420
 				$key = $line[$k];
1421
-			        $lined[$key] = $line[$k+1];
1421
+			        $lined[$key] = $line[$k + 1];
1422 1422
 			    }
1423 1423
     			    if (count($lined) > 3) {
1424 1424
     				$data['hex'] = $lined['hexid'];
1425 1425
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1426
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1426
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1427 1427
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1428 1428
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1429 1429
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1442,22 +1442,22 @@  discard block
 block discarded – undo
1442 1442
     			    } else $error = true;
1443 1443
 			} elseif ($format == 'aprs' && $use_aprs) {
1444 1444
 			    if ($aprs_connect == 0) {
1445
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1445
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1446 1446
 				$aprs_connect = 1;
1447 1447
 			    }
1448 1448
 			    
1449
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1449
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1450 1450
 				$aprs_last_tx = time();
1451 1451
 				$data_aprs = "# Keep alive";
1452
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1452
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1453 1453
 			    }
1454 1454
 			    
1455 1455
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1456 1456
 			    //echo 'APRS data : '.$buffer."\n";
1457
-			    $buffer = str_replace('APRS <- ','',$buffer);
1458
-			    $buffer = str_replace('APRS -> ','',$buffer);
1457
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1458
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1459 1459
 			    //echo $buffer."\n";
1460
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1460
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1461 1461
 				$line = $APRS->parse($buffer);
1462 1462
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1463 1463
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1472,7 +1472,7 @@  discard block
 block discarded – undo
1472 1472
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1473 1473
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1474 1474
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1475
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1475
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1476 1476
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1477 1477
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1478 1478
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1551,29 +1551,29 @@  discard block
 block discarded – undo
1551 1551
 				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident']) && isset($data['altitude'])) {
1552 1552
 					if (!isset($data['altitude'])) $data['altitude'] = 0;
1553 1553
 					$Source->deleteOldLocationByType('gs');
1554
-					if (count($Source->getLocationInfoByNameType($data['ident'],'gs')) > 0) {
1555
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1554
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'gs')) > 0) {
1555
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1556 1556
 					} else {
1557
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']);
1557
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']);
1558 1558
 					}
1559 1559
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1560 1560
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1561 1561
 					if ($globalDebug) echo '# Weather Station added'."\n";
1562 1562
 					$Source->deleteOldLocationByType('wx');
1563 1563
 					$weather_data = json_encode($line);
1564
-					if (count($Source->getLocationInfoByNameType($data['ident'],'wx')) > 0) {
1565
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1564
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'wx')) > 0) {
1565
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1566 1566
 					} else {
1567
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'wx.png','wx',$id,0,$data['datetime'],$weather_data);
1567
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'wx.png', 'wx', $id, 0, $data['datetime'], $weather_data);
1568 1568
 					}
1569 1569
 				    } elseif (isset($line['symbol']) && $line['symbol'] == 'Lightning') {
1570 1570
 					//if ($globalDebug) echo '!! Weather Station not yet supported'."\n";
1571 1571
 					if ($globalDebug) echo '☈ Lightning added'."\n";
1572 1572
 					$Source->deleteOldLocationByType('lightning');
1573
-					if (count($Source->getLocationInfoByNameType($data['ident'],'lightning')) > 0) {
1574
-						$Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1573
+					if (count($Source->getLocationInfoByNameType($data['ident'], 'lightning')) > 0) {
1574
+						$Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1575 1575
 					} else {
1576
-						$Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],0,'','',$data['source_name'],'weather/thunderstorm.png','lightning',$id,0,$data['datetime'],$data['comment']);
1576
+						$Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], 0, '', '', $data['source_name'], 'weather/thunderstorm.png', 'lightning', $id, 0, $data['datetime'], $data['comment']);
1577 1577
 					}
1578 1578
 				    } elseif ($globalDebug) {
1579 1579
 				    	echo '/!\ Not added: '.$buffer."\n";
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 				    unset($data);
1583 1583
 				}
1584 1584
 				elseif (is_array($line) && isset($line['ident']) && $line['ident'] != '') {
1585
-					$Source->updateLocationDescByName($line['ident'],$line['source'],$id,$line['comment']);
1585
+					$Source->updateLocationDescByName($line['ident'], $line['source'], $id, $line['comment']);
1586 1586
 				}
1587 1587
 				/*
1588 1588
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && ($line['symbol'] == 'Car' || $line['symbol'] == 'Ambulance' || $line['symbol'] == 'Van' || $line['symbol'] == 'Truck' || $line['symbol'] == 'Truck (18 Wheeler)' || $line['symbol'] == 'Motorcycle')) {
@@ -1591,7 +1591,7 @@  discard block
 block discarded – undo
1591 1591
 				*/
1592 1592
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1593 1593
 				elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1594
-				if (isset($globalSources[$nb]['last_weather_clean']) && time()-$globalSources[$nb]['last_weather_clean'] > 60*5) {
1594
+				if (isset($globalSources[$nb]['last_weather_clean']) && time() - $globalSources[$nb]['last_weather_clean'] > 60*5) {
1595 1595
 					$Source->deleteOldLocationByType('lightning');
1596 1596
 					$Source->deleteOldLocationByType('wx');
1597 1597
 					$globalSources[$nb]['last_weather_clean'] = time();
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 				connect_all($sourceee);
1677 1677
 				$sourceee = array();
1678 1678
 				//connect_all($globalSources);
1679
-				$tt[$format]=0;
1679
+				$tt[$format] = 0;
1680 1680
 				break;
1681 1681
 			    }
1682 1682
 			}
@@ -1685,14 +1685,14 @@  discard block
 block discarded – undo
1685 1685
 	    } else {
1686 1686
 		$error = socket_strerror(socket_last_error());
1687 1687
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1688
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1688
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1689 1689
 			if (isset($globalDebug)) echo "Restarting...\n";
1690 1690
 			// Restart the script if possible
1691 1691
 			if (is_array($sockets)) {
1692 1692
 			    if ($globalDebug) echo "Shutdown all sockets...";
1693 1693
 			    
1694 1694
 			    foreach ($sockets as $sock) {
1695
-				@socket_shutdown($sock,2);
1695
+				@socket_shutdown($sock, 2);
1696 1696
 				@socket_close($sock);
1697 1697
 			    }
1698 1698
 			    
Please login to merge, or discard this patch.