Completed
Push — master ( 8eb35e...77cd33 )
by Yannick
09:48
created
require/class.ATC.php 3 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -10,61 +10,61 @@  discard block
 block discarded – undo
10 10
 	}
11 11
 	
12 12
 	
13
-    /**
14
-    * Get SQL query part for filter used
15
-    * @param Array $filter the filter
16
-    * @return Array the SQL part
17
-    */
18
-    public function getFilter($filter = array(),$where = false,$and = false) {
13
+	/**
14
+	 * Get SQL query part for filter used
15
+	 * @param Array $filter the filter
16
+	 * @return Array the SQL part
17
+	 */
18
+	public function getFilter($filter = array(),$where = false,$and = false) {
19 19
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21
-	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
21
+		if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 		foreach($globalStatsFilters[$globalFilterName] as $source) {
23 23
 			if (isset($source['source'])) $filter['source'][] = $source['source'];
24 24
 		}
25
-	    } else {
25
+		} else {
26 26
 		$filter = $globalStatsFilters[$globalFilterName];
27
-	    }
27
+		}
28 28
 	}
29 29
 	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	if (isset($filter['source']) && !empty($filter['source'])) {
33
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
33
+		$filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 34
 	}
35 35
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36 36
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
37 37
 	$filter_query = $filter_query_join.$filter_query_where;
38 38
 	return $filter_query;
39
-    }
39
+	}
40 40
 
41
-       public function getAll() {
42
-    		$filter_query = $this->getFilter(array());
43
-                $query = "SELECT * FROM atc".$filter_query;
44
-                $query_values = array();
45
-                 try {
46
-                        $sth = $this->db->prepare($query);
47
-                        $sth->execute($query_values);
48
-                } catch(PDOException $e) {
49
-                        return "error : ".$e->getMessage();
50
-                }
51
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
52
-                return $all;
53
-        }
41
+	   public function getAll() {
42
+			$filter_query = $this->getFilter(array());
43
+				$query = "SELECT * FROM atc".$filter_query;
44
+				$query_values = array();
45
+				 try {
46
+						$sth = $this->db->prepare($query);
47
+						$sth->execute($query_values);
48
+				} catch(PDOException $e) {
49
+						return "error : ".$e->getMessage();
50
+				}
51
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
52
+				return $all;
53
+		}
54 54
 
55 55
 	public function getById($id) {
56
-    		$filter_query = $this->getFilter(array(),true);
57
-                $query = "SELECT * FROM atc".$filter_query." atc_id = :id";
58
-                $query_values = array(':id' => $id);
59
-                 try {
60
-                        $sth = $this->db->prepare($query);
61
-                        $sth->execute($query_values);
62
-                } catch(PDOException $e) {
63
-                        return "error : ".$e->getMessage();
64
-                }
65
-                $all = $sth->fetchAll(PDO::FETCH_ASSOC);
66
-                return $all;
67
-        }
56
+			$filter_query = $this->getFilter(array(),true);
57
+				$query = "SELECT * FROM atc".$filter_query." atc_id = :id";
58
+				$query_values = array(':id' => $id);
59
+				 try {
60
+						$sth = $this->db->prepare($query);
61
+						$sth->execute($query_values);
62
+				} catch(PDOException $e) {
63
+						return "error : ".$e->getMessage();
64
+				}
65
+				$all = $sth->fetchAll(PDO::FETCH_ASSOC);
66
+				return $all;
67
+		}
68 68
 
69 69
 	public function getByIdent($ident,$format_source = '') {
70 70
 		$filter_query = $this->getFilter(array(),true);
@@ -117,53 +117,53 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 	}
119 119
 
120
-       public function deleteById($id) {
121
-                $query = "DELETE FROM atc WHERE atc_id = :id";
122
-                $query_values = array(':id' => $id);
123
-                 try {
124
-                        $sth = $this->db->prepare($query);
125
-                        $sth->execute($query_values);
126
-                } catch(PDOException $e) {
127
-                        return "error : ".$e->getMessage();
128
-                }
129
-        }
120
+	   public function deleteById($id) {
121
+				$query = "DELETE FROM atc WHERE atc_id = :id";
122
+				$query_values = array(':id' => $id);
123
+				 try {
124
+						$sth = $this->db->prepare($query);
125
+						$sth->execute($query_values);
126
+				} catch(PDOException $e) {
127
+						return "error : ".$e->getMessage();
128
+				}
129
+		}
130 130
 
131
-       public function deleteByIdent($ident,$format_source) {
132
-                $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
133
-                $query_values = array(':ident' => $ident,':format_source' => $format_source);
134
-                 try {
135
-                        $sth = $this->db->prepare($query);
136
-                        $sth->execute($query_values);
137
-                } catch(PDOException $e) {
138
-                        return "error : ".$e->getMessage();
139
-                }
140
-        }
131
+	   public function deleteByIdent($ident,$format_source) {
132
+				$query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
133
+				$query_values = array(':ident' => $ident,':format_source' => $format_source);
134
+				 try {
135
+						$sth = $this->db->prepare($query);
136
+						$sth->execute($query_values);
137
+				} catch(PDOException $e) {
138
+						return "error : ".$e->getMessage();
139
+				}
140
+		}
141 141
 
142
-       public function deleteAll() {
143
-                $query = "DELETE FROM atc";
144
-                $query_values = array();
145
-                 try {
146
-                        $sth = $this->db->prepare($query);
147
-                        $sth->execute($query_values);
148
-                } catch(PDOException $e) {
149
-                        return "error : ".$e->getMessage();
150
-                }
151
-        }
142
+	   public function deleteAll() {
143
+				$query = "DELETE FROM atc";
144
+				$query_values = array();
145
+				 try {
146
+						$sth = $this->db->prepare($query);
147
+						$sth->execute($query_values);
148
+				} catch(PDOException $e) {
149
+						return "error : ".$e->getMessage();
150
+				}
151
+		}
152 152
 
153 153
 	public function deleteOldATC() {
154
-                global $globalDBdriver;
155
-                if ($globalDBdriver == 'mysql') {
156
-                        $query  = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen";
157
-                } else {
158
-                        $query  = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR' >= atc.atc_lastseen";
159
-                }
160
-                try {
161
-                        $sth = $this->db->prepare($query);
162
-                        $sth->execute();
163
-                } catch(PDOException $e) {
164
-                        return "error";
165
-                }
166
-                return "success";
167
-        }
154
+				global $globalDBdriver;
155
+				if ($globalDBdriver == 'mysql') {
156
+						$query  = "DELETE FROM atc WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 1 HOUR) >= atc.atc_lastseen";
157
+				} else {
158
+						$query  = "DELETE FROM atc WHERE NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR' >= atc.atc_lastseen";
159
+				}
160
+				try {
161
+						$sth = $this->db->prepare($query);
162
+						$sth->execute();
163
+				} catch(PDOException $e) {
164
+						return "error";
165
+				}
166
+				return "success";
167
+		}
168 168
 }
169 169
 ?>
170 170
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@  discard block
 block discarded – undo
15 15
     * @param Array $filter the filter
16 16
     * @return Array the SQL part
17 17
     */
18
-    public function getFilter($filter = array(),$where = false,$and = false) {
18
+    public function getFilter($filter = array(), $where = false, $and = false) {
19 19
 	global $globalFilter, $globalStatsFilters, $globalFilterName;
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22
-		foreach($globalStatsFilters[$globalFilterName] as $source) {
22
+		foreach ($globalStatsFilters[$globalFilterName] as $source) {
23 23
 			if (isset($source['source'])) $filter['source'][] = $source['source'];
24 24
 		}
25 25
 	    } else {
26 26
 		$filter = $globalStatsFilters[$globalFilterName];
27 27
 	    }
28 28
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
29
+	if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter);
30 30
 	$filter_query_join = '';
31 31
 	$filter_query_where = '';
32 32
 	if (isset($filter['source']) && !empty($filter['source'])) {
33
-	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
33
+	    $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')";
34 34
 	}
35 35
 	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36 36
 	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
                  try {
46 46
                         $sth = $this->db->prepare($query);
47 47
                         $sth->execute($query_values);
48
-                } catch(PDOException $e) {
48
+                } catch (PDOException $e) {
49 49
                         return "error : ".$e->getMessage();
50 50
                 }
51 51
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
@@ -53,66 +53,66 @@  discard block
 block discarded – undo
53 53
         }
54 54
 
55 55
 	public function getById($id) {
56
-    		$filter_query = $this->getFilter(array(),true);
56
+    		$filter_query = $this->getFilter(array(), true);
57 57
                 $query = "SELECT * FROM atc".$filter_query." atc_id = :id";
58 58
                 $query_values = array(':id' => $id);
59 59
                  try {
60 60
                         $sth = $this->db->prepare($query);
61 61
                         $sth->execute($query_values);
62
-                } catch(PDOException $e) {
62
+                } catch (PDOException $e) {
63 63
                         return "error : ".$e->getMessage();
64 64
                 }
65 65
                 $all = $sth->fetchAll(PDO::FETCH_ASSOC);
66 66
                 return $all;
67 67
         }
68 68
 
69
-	public function getByIdent($ident,$format_source = '') {
70
-		$filter_query = $this->getFilter(array(),true);
69
+	public function getByIdent($ident, $format_source = '') {
70
+		$filter_query = $this->getFilter(array(), true);
71 71
 		if ($format_source == '') {
72 72
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident";
73 73
 			$query_values = array(':ident' => $ident);
74 74
 		} else {
75 75
 			$query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source";
76
-			$query_values = array(':ident' => $ident,':format_source' => $format_source);
76
+			$query_values = array(':ident' => $ident, ':format_source' => $format_source);
77 77
 		}
78 78
 		try {
79 79
 			$sth = $this->db->prepare($query);
80 80
 			$sth->execute($query_values);
81
-		} catch(PDOException $e) {
81
+		} catch (PDOException $e) {
82 82
 			return "error : ".$e->getMessage();
83 83
 		}
84 84
 		$all = $sth->fetchAll(PDO::FETCH_ASSOC);
85 85
 		return $all;
86 86
 	}
87 87
 
88
-	public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
89
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
90
-		$info = str_replace('^','<br />',$info);
91
-		$info = str_replace('&amp;sect;','',$info);
92
-		$info = str_replace('"','',$info);
88
+	public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
89
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
90
+		$info = str_replace('^', '<br />', $info);
91
+		$info = str_replace('&amp;sect;', '', $info);
92
+		$info = str_replace('"', '', $info);
93 93
 		if ($type == '') $type = NULL;
94 94
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
95
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
95
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
96 96
 		try {
97 97
 			$sth = $this->db->prepare($query);
98 98
 			$sth->execute($query_values);
99
-		} catch(PDOException $e) {
99
+		} catch (PDOException $e) {
100 100
 			return "error : ".$e->getMessage();
101 101
 		}
102 102
 	}
103 103
 
104
-	public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') {
105
-		$info = preg_replace('/[^(\x20-\x7F)]*/','',$info);
106
-		$info = str_replace('^','<br />',$info);
107
-		$info = str_replace('&amp;sect;','',$info);
108
-		$info = str_replace('"','',$info);
104
+	public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') {
105
+		$info = preg_replace('/[^(\x20-\x7F)]*/', '', $info);
106
+		$info = str_replace('^', '<br />', $info);
107
+		$info = str_replace('&amp;sect;', '', $info);
108
+		$info = str_replace('"', '', $info);
109 109
 		if ($type == '') $type = NULL;
110 110
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
111
-		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
111
+		$query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name);
112 112
 		try {
113 113
 			$sth = $this->db->prepare($query);
114 114
 			$sth->execute($query_values);
115
-		} catch(PDOException $e) {
115
+		} catch (PDOException $e) {
116 116
 			return "error : ".$e->getMessage();
117 117
 		}
118 118
 	}
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
                  try {
124 124
                         $sth = $this->db->prepare($query);
125 125
                         $sth->execute($query_values);
126
-                } catch(PDOException $e) {
126
+                } catch (PDOException $e) {
127 127
                         return "error : ".$e->getMessage();
128 128
                 }
129 129
         }
130 130
 
131
-       public function deleteByIdent($ident,$format_source) {
131
+       public function deleteByIdent($ident, $format_source) {
132 132
                 $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source";
133
-                $query_values = array(':ident' => $ident,':format_source' => $format_source);
133
+                $query_values = array(':ident' => $ident, ':format_source' => $format_source);
134 134
                  try {
135 135
                         $sth = $this->db->prepare($query);
136 136
                         $sth->execute($query_values);
137
-                } catch(PDOException $e) {
137
+                } catch (PDOException $e) {
138 138
                         return "error : ".$e->getMessage();
139 139
                 }
140 140
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                  try {
146 146
                         $sth = $this->db->prepare($query);
147 147
                         $sth->execute($query_values);
148
-                } catch(PDOException $e) {
148
+                } catch (PDOException $e) {
149 149
                         return "error : ".$e->getMessage();
150 150
                 }
151 151
         }
@@ -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
                         return "error";
165 165
                 }
166 166
                 return "success";
Please login to merge, or discard this patch.
Braces   +17 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,20 +20,27 @@  discard block
 block discarded – undo
20 20
 	if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) {
21 21
 	    if (isset($globalStatsFilters[$globalFilterName][0]['source'])) {
22 22
 		foreach($globalStatsFilters[$globalFilterName] as $source) {
23
-			if (isset($source['source'])) $filter['source'][] = $source['source'];
23
+			if (isset($source['source'])) {
24
+				$filter['source'][] = $source['source'];
25
+			}
24 26
 		}
25 27
 	    } else {
26 28
 		$filter = $globalStatsFilters[$globalFilterName];
27 29
 	    }
28 30
 	}
29
-	if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter);
31
+	if (is_array($globalFilter)) {
32
+		$filter = array_merge($filter,$globalFilter);
33
+	}
30 34
 	$filter_query_join = '';
31 35
 	$filter_query_where = '';
32 36
 	if (isset($filter['source']) && !empty($filter['source'])) {
33 37
 	    $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')";
34 38
 	}
35
-	if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE';
36
-	elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND';
39
+	if ($filter_query_where == '' && $where) {
40
+		$filter_query_where = ' WHERE';
41
+	} elseif ($filter_query_where != '' && $and) {
42
+		$filter_query_where .= ' AND';
43
+	}
37 44
 	$filter_query = $filter_query_join.$filter_query_where;
38 45
 	return $filter_query;
39 46
     }
@@ -90,7 +97,9 @@  discard block
 block discarded – undo
90 97
 		$info = str_replace('^','<br />',$info);
91 98
 		$info = str_replace('&amp;sect;','',$info);
92 99
 		$info = str_replace('"','',$info);
93
-		if ($type == '') $type = NULL;
100
+		if ($type == '') {
101
+			$type = NULL;
102
+		}
94 103
 		$query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)";
95 104
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
96 105
 		try {
@@ -106,7 +115,9 @@  discard block
 block discarded – undo
106 115
 		$info = str_replace('^','<br />',$info);
107 116
 		$info = str_replace('&amp;sect;','',$info);
108 117
 		$info = str_replace('"','',$info);
109
-		if ($type == '') $type = NULL;
118
+		if ($type == '') {
119
+			$type = NULL;
120
+		}
110 121
 		$query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name";
111 122
 		$query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name);
112 123
 		try {
Please login to merge, or discard this patch.
js/map-aircraft.3d.js.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -720,12 +720,12 @@
 block discarded – undo
720 720
 	update_airportsLayer();
721 721
 }
722 722
 <?php
723
-    if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
723
+	if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
724 724
 ?>
725 725
 update_atcLayer();
726 726
 setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
727 727
 <?php
728
-    }
728
+	}
729 729
 ?>
730 730
 
731 731
 function iconColor(color) {
Please login to merge, or discard this patch.
Braces   +30 added lines, -5 removed lines patch added patch discarded remove patch
@@ -202,7 +202,12 @@  discard block
 block discarded – undo
202 202
 //				viewer.dataSources.get(dsn).entities.remove(entity);
203 203
 //			}
204 204
 			//console.log(entity.lastupdate);
205
-			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
205
+			if (parseInt(entity.lastupdate) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
206
+	print $globalMapRefresh*2000;
207
+} else {
208
+	print '60000';
209
+}
210
+?>)) {
206 211
 //				console.log('Remove an entity date');
207 212
 				viewer.dataSources.get(dsn).entities.remove(entity);
208 213
 			} else {
@@ -276,7 +281,12 @@  discard block
 block discarded – undo
276 281
 	} else {
277 282
 		for (var i = 0; i < viewer.dataSources.get(dsn).entities.values.length; i++) {
278 283
 			var entity = viewer.dataSources.get(dsn).entities.values[i];
279
-			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) print $globalMapRefresh*2000; else print '60000'; ?>)) {
284
+			if (parseInt(entity.lastupdatesat) < Math.floor(Date.now()-<?php if (isset($globalMapRefresh)) {
285
+	print $globalMapRefresh*2000;
286
+} else {
287
+	print '60000';
288
+}
289
+?>)) {
280 290
 				viewer.dataSources.get(dsn).entities.remove(entity);
281 291
 			}
282 292
 		}
@@ -606,7 +616,12 @@  discard block
 block discarded – undo
606 616
 		if (!((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM) || (isset($globalphpVMS) && $globalphpVMS)) && (isset($_COOKIE['polar']) && $_COOKIE['polar'] == 'true')) {
607 617
 ?>
608 618
 update_polarLayer();
609
-setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
619
+setInterval(function(){update_polarLayer()},<?php if (isset($globalMapRefresh)) {
620
+	print $globalMapRefresh*1000*2;
621
+} else {
622
+	print '60000';
623
+}
624
+?>);
610 625
 <?php
611 626
 		}
612 627
 ?>
@@ -704,7 +719,12 @@  discard block
 block discarded – undo
704 719
 				}
705 720
 			}
706 721
 		}
707
-	,<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000; else print '30000'; ?>);
722
+	,<?php if (isset($globalMapRefresh)) {
723
+	print $globalMapRefresh*1000;
724
+} else {
725
+	print '30000';
726
+}
727
+?>);
708 728
 } else {
709 729
 	//var widget = new Cesium.CesiumWidget('archivebox');
710 730
 //	var timeline = new Cesium.Timeline(viewer);
@@ -723,7 +743,12 @@  discard block
 block discarded – undo
723 743
     if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
724 744
 ?>
725 745
 update_atcLayer();
726
-setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) print $globalMapRefresh*1000*2; else print '60000'; ?>);
746
+setInterval(function(){update_atcLayer()},<?php if (isset($globalMapRefresh)) {
747
+	print $globalMapRefresh*1000*2;
748
+} else {
749
+	print '60000';
750
+}
751
+?>);
727 752
 <?php
728 753
     }
729 754
 ?>
Please login to merge, or discard this patch.
scripts/daemon-spotter.php 3 patches
Indentation   +883 added lines, -883 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16 16
 if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
17 17
 if (isset($globalMarine) && $globalMarine) {
18
-    require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
-    require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
18
+	require_once(dirname(__FILE__).'/../require/class.AIS.php');
19
+	require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 20
 }
21 21
 
22 22
 if (!isset($globalDebug)) $globalDebug = FALSE;
@@ -24,42 +24,42 @@  discard block
 block discarded – undo
24 24
 // Check if schema is at latest version
25 25
 $Connection = new Connection();
26 26
 if ($Connection->latest() === false) {
27
-    echo "You MUST update to latest schema. Run install/index.php";
28
-    exit();
27
+	echo "You MUST update to latest schema. Run install/index.php";
28
+	exit();
29 29
 }
30 30
 if (PHP_SAPI != 'cli') {
31
-    echo "This script MUST be called from console, not a web browser.";
31
+	echo "This script MUST be called from console, not a web browser.";
32 32
 //    exit();
33 33
 }
34 34
 
35 35
 // This is to be compatible with old version of settings.php
36 36
 if (!isset($globalSources)) {
37
-    if (isset($globalSBS1Hosts)) {
38
-        //$hosts = $globalSBS1Hosts;
39
-        foreach ($globalSBS1Hosts as $host) {
40
-	    $globalSources[] = array('host' => $host);
41
-    	}
42
-    } else {
43
-        if (!isset($globalSBS1Host)) {
44
-	    echo '$globalSources MUST be defined !';
45
-	    die;
37
+	if (isset($globalSBS1Hosts)) {
38
+		//$hosts = $globalSBS1Hosts;
39
+		foreach ($globalSBS1Hosts as $host) {
40
+		$globalSources[] = array('host' => $host);
41
+		}
42
+	} else {
43
+		if (!isset($globalSBS1Host)) {
44
+		echo '$globalSources MUST be defined !';
45
+		die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48 48
 	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
49
-    }
49
+	}
50 50
 }
51 51
 
52 52
 $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56
-    $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
56
+	$globalSources = array();
57
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
+	else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60
-    $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
60
+	$globalSources = array();
61
+	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
+	else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
65 65
 	$globalServerAPRS = TRUE;
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 if (isset($options['idsource'])) $id_source = $options['idsource'];
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
77
+	if ($globalDebug) echo "Using Server Mode\n";
78
+	$SI=new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
 } else $SI=new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87
-    $AIS = new AIS();
88
-    $MI = new MarineImport($Connection->db);
87
+	$AIS = new AIS();
88
+	$MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91 91
 $SBS=new SBS();
@@ -95,12 +95,12 @@  discard block
 block discarded – undo
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
99
-        global $sockets;
100
-        echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
-        die("Bye!\n");
102
-    });
103
-    pcntl_signal_dispatch();
98
+	pcntl_signal(SIGINT,  function() {
99
+		global $sockets;
100
+		echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101
+		die("Bye!\n");
102
+	});
103
+	pcntl_signal_dispatch();
104 104
 }
105 105
 
106 106
 // let's try and connect
@@ -110,36 +110,36 @@  discard block
 block discarded – undo
110 110
 $reset = 0;
111 111
 
112 112
 function connect_all($hosts) {
113
-    //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
-    $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
117
-    foreach ($hosts as $id => $value) {
113
+	//global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
+	global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115
+	$reset++;
116
+	if ($globalDebug) echo 'Connect to all...'."\n";
117
+	foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121 121
 	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
123
-        	//$formats[$id] = 'deltadbtxt';
124
-        	$globalSources[$id]['format'] = 'deltadbtxt';
125
-        	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
-        	//$formats[$id] = 'vatsimtxt';
129
-        	$globalSources[$id]['format'] = 'vatsimtxt';
130
-        	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133
-        	//$formats[$id] = 'aircraftlistjson';
134
-        	$globalSources[$id]['format'] = 'aircraftlistjson';
135
-        	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
138
-        	//$formats[$id] = 'aircraftlistjson';
139
-        	$globalSources[$id]['format'] = 'opensky';
140
-        	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
-    	    /*
122
+			if (preg_match('/deltadb.txt$/i',$host)) {
123
+			//$formats[$id] = 'deltadbtxt';
124
+			$globalSources[$id]['format'] = 'deltadbtxt';
125
+			//$last_exec['deltadbtxt'] = 0;
126
+			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
+			} else if (preg_match('/vatsim-data.txt$/i',$host)) {
128
+			//$formats[$id] = 'vatsimtxt';
129
+			$globalSources[$id]['format'] = 'vatsimtxt';
130
+			//$last_exec['vatsimtxt'] = 0;
131
+			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
+			} else if (preg_match('/aircraftlist.json$/i',$host)) {
133
+			//$formats[$id] = 'aircraftlistjson';
134
+			$globalSources[$id]['format'] = 'aircraftlistjson';
135
+			//$last_exec['aircraftlistjson'] = 0;
136
+			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
+			} else if (preg_match('/opensky/i',$host)) {
138
+			//$formats[$id] = 'aircraftlistjson';
139
+			$globalSources[$id]['format'] = 'opensky';
140
+			//$last_exec['aircraftlistjson'] = 0;
141
+			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
142
+			/*
143 143
     	    // Disabled for now, site change source format
144 144
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
145 145
         	//$formats[$id] = 'radarvirtueljson';
@@ -151,115 +151,115 @@  discard block
 block discarded – undo
151 151
         	    exit(0);
152 152
         	}
153 153
     	    */
154
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
155
-        	//$formats[$id] = 'planeupdatefaa';
156
-        	$globalSources[$id]['format'] = 'planeupdatefaa';
157
-        	//$last_exec['planeupdatefaa'] = 0;
158
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
159
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161
-        	    exit(0);
162
-        	}
163
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
164
-        	//$formats[$id] = 'phpvmacars';
165
-        	$globalSources[$id]['format'] = 'phpvmacars';
166
-        	//$last_exec['phpvmacars'] = 0;
167
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
168
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
169
-        	//$formats[$id] = 'phpvmacars';
170
-        	$globalSources[$id]['format'] = 'vam';
171
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
172
-            } else if (preg_match('/whazzup/i',$host)) {
173
-        	//$formats[$id] = 'whazzup';
174
-        	$globalSources[$id]['format'] = 'whazzup';
175
-        	//$last_exec['whazzup'] = 0;
176
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
177
-            } else if (preg_match('/recentpireps/i',$host)) {
178
-        	//$formats[$id] = 'pirepsjson';
179
-        	$globalSources[$id]['format'] = 'pirepsjson';
180
-        	//$last_exec['pirepsjson'] = 0;
181
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
182
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
183
-        	//$formats[$id] = 'fr24json';
184
-        	$globalSources[$id]['format'] = 'fr24json';
185
-        	//$last_exec['fr24json'] = 0;
186
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
187
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
188
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189
-        	    exit(0);
190
-        	}
191
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
192
-        	//$formats[$id] = 'fr24json';
193
-        	$globalSources[$id]['format'] = 'myshiptracking';
194
-        	//$last_exec['fr24json'] = 0;
195
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
196
-        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197
-        	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198
-        	    exit(0);
199
-        	}
200
-            //} else if (preg_match('/10001/',$host)) {
201
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202
-        	//$formats[$id] = 'tsv';
203
-        	$globalSources[$id]['format'] = 'tsv';
204
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205
-            }
206
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207
-    		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
209
-    		    if ($idf !== false) {
210
-    			$httpfeeds[$id] = $idf;
211
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
-    		    }
213
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
-	    $hostport = explode(':',$host);
217
-	    if (isset($hostport[1])) {
154
+			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
155
+			//$formats[$id] = 'planeupdatefaa';
156
+			$globalSources[$id]['format'] = 'planeupdatefaa';
157
+			//$last_exec['planeupdatefaa'] = 0;
158
+			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
159
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161
+				exit(0);
162
+			}
163
+			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
164
+			//$formats[$id] = 'phpvmacars';
165
+			$globalSources[$id]['format'] = 'phpvmacars';
166
+			//$last_exec['phpvmacars'] = 0;
167
+			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
168
+			} else if (preg_match('/VAM-json.php$/i',$host)) {
169
+			//$formats[$id] = 'phpvmacars';
170
+			$globalSources[$id]['format'] = 'vam';
171
+			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
172
+			} else if (preg_match('/whazzup/i',$host)) {
173
+			//$formats[$id] = 'whazzup';
174
+			$globalSources[$id]['format'] = 'whazzup';
175
+			//$last_exec['whazzup'] = 0;
176
+			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
177
+			} else if (preg_match('/recentpireps/i',$host)) {
178
+			//$formats[$id] = 'pirepsjson';
179
+			$globalSources[$id]['format'] = 'pirepsjson';
180
+			//$last_exec['pirepsjson'] = 0;
181
+			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
182
+			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
183
+			//$formats[$id] = 'fr24json';
184
+			$globalSources[$id]['format'] = 'fr24json';
185
+			//$last_exec['fr24json'] = 0;
186
+			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
187
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
188
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189
+				exit(0);
190
+			}
191
+			} else if (preg_match(':myshiptracking.com/:i',$host)) {
192
+			//$formats[$id] = 'fr24json';
193
+			$globalSources[$id]['format'] = 'myshiptracking';
194
+			//$last_exec['fr24json'] = 0;
195
+			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
196
+			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197
+				echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198
+				exit(0);
199
+			}
200
+			//} else if (preg_match('/10001/',$host)) {
201
+			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202
+			//$formats[$id] = 'tsv';
203
+			$globalSources[$id]['format'] = 'tsv';
204
+			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205
+			}
206
+		} elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207
+			if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
+				$idf = fopen($globalSources[$id]['host'],'r',false,$context);
209
+				if ($idf !== false) {
210
+				$httpfeeds[$id] = $idf;
211
+				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212
+				}
213
+				elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
+			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
+		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
+		$hostport = explode(':',$host);
217
+		if (isset($hostport[1])) {
218 218
 		$port = $hostport[1];
219 219
 		$hostn = $hostport[0];
220
-	    } else {
220
+		} else {
221 221
 		$port = $globalSources[$id]['port'];
222 222
 		$hostn = $globalSources[$id]['host'];
223
-	    }
224
-	    $Common = new Common();
225
-	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
226
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
227
-    	    } else {
228
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
229
-	    }
230
-	    if ($s) {
231
-    	        $sockets[$id] = $s;
232
-    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
233
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
223
+		}
224
+		$Common = new Common();
225
+		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
226
+			$s = $Common->create_socket($hostn,$port, $errno, $errstr);
227
+			} else {
228
+			$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
229
+		}
230
+		if ($s) {
231
+				$sockets[$id] = $s;
232
+				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
233
+			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
234 234
 			//$formats[$id] = 'aprs';
235 235
 			$globalSources[$id]['format'] = 'aprs';
236 236
 			//$aprs_connect = 0;
237 237
 			//$use_aprs = true;
238
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
238
+			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
239 239
 			$globalSources[$id]['format'] = 'vrstcp';
240
-    		    } elseif ($port == '10001') {
241
-        		//$formats[$id] = 'tsv';
242
-        		$globalSources[$id]['format'] = 'tsv';
243
-		    } elseif ($port == '30002') {
244
-        		//$formats[$id] = 'raw';
245
-        		$globalSources[$id]['format'] = 'raw';
246
-		    } elseif ($port == '5001') {
247
-        		//$formats[$id] = 'raw';
248
-        		$globalSources[$id]['format'] = 'flightgearmp';
249
-		    } elseif ($port == '30005') {
240
+				} elseif ($port == '10001') {
241
+				//$formats[$id] = 'tsv';
242
+				$globalSources[$id]['format'] = 'tsv';
243
+			} elseif ($port == '30002') {
244
+				//$formats[$id] = 'raw';
245
+				$globalSources[$id]['format'] = 'raw';
246
+			} elseif ($port == '5001') {
247
+				//$formats[$id] = 'raw';
248
+				$globalSources[$id]['format'] = 'flightgearmp';
249
+			} elseif ($port == '30005') {
250 250
 			// Not yet supported
251
-        		//$formats[$id] = 'beast';
252
-        		$globalSources[$id]['format'] = 'beast';
253
-		    //} else $formats[$id] = 'sbs';
254
-		    } else $globalSources[$id]['format'] = 'sbs';
255
-		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
251
+				//$formats[$id] = 'beast';
252
+				$globalSources[$id]['format'] = 'beast';
253
+			//} else $formats[$id] = 'sbs';
254
+			} else $globalSources[$id]['format'] = 'sbs';
255
+			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256 256
 		}
257 257
 		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
258
-            } else {
258
+			} else {
259 259
 		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
260
-    	    }
261
-        }
262
-    }
260
+			}
261
+		}
262
+	}
263 263
 }
264 264
 if (!isset($globalMinFetch)) $globalMinFetch = 15;
265 265
 
@@ -282,9 +282,9 @@  discard block
 block discarded – undo
282 282
 //connect_all($globalSources);
283 283
 
284 284
 if (isset($globalProxy) && $globalProxy) {
285
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
285
+	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
286 286
 } else {
287
-    $context = stream_context_create(array('http' => array('timeout' => $timeout)));
287
+	$context = stream_context_create(array('http' => array('timeout' => $timeout)));
288 288
 }
289 289
 
290 290
 // APRS Configuration
@@ -293,18 +293,18 @@  discard block
 block discarded – undo
293 293
 	die;
294 294
 }
295 295
 foreach ($globalSources as $key => $source) {
296
-    if (!isset($source['format'])) {
297
-        $globalSources[$key]['format'] = 'auto';
298
-    }
296
+	if (!isset($source['format'])) {
297
+		$globalSources[$key]['format'] = 'auto';
298
+	}
299 299
 }
300 300
 connect_all($globalSources);
301 301
 foreach ($globalSources as $key => $source) {
302
-    if (isset($source['format']) && $source['format'] == 'aprs') {
302
+	if (isset($source['format']) && $source['format'] == 'aprs') {
303 303
 	$aprs_connect = 0;
304 304
 	$use_aprs = true;
305 305
 	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
306 306
 	break;
307
-    }
307
+	}
308 308
 }
309 309
 
310 310
 if ($use_aprs) {
@@ -345,116 +345,116 @@  discard block
 block discarded – undo
345 345
 
346 346
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
347 347
 while ($i > 0) {
348
-    if (!$globalDaemon) $i = $endtime-time();
349
-    // Delete old ATC
350
-    if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
348
+	if (!$globalDaemon) $i = $endtime-time();
349
+	// Delete old ATC
350
+	if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
351 351
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
352
-        $ATC->deleteOldATC();
353
-    }
352
+		$ATC->deleteOldATC();
353
+	}
354 354
     
355
-    //if (count($last_exec) > 0) {
356
-    if (count($last_exec) == count($globalSources)) {
355
+	//if (count($last_exec) > 0) {
356
+	if (count($last_exec) == count($globalSources)) {
357 357
 	$max = $globalMinFetch;
358 358
 	foreach ($last_exec as $last) {
359
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
359
+		if ((time() - $last['last']) < $max) $max = time() - $last['last'];
360 360
 	}
361 361
 	if ($max != $globalMinFetch) {
362
-	    if ($globalDebug) echo 'Sleeping...'."\n";
363
-	    sleep($globalMinFetch-$max+2);
362
+		if ($globalDebug) echo 'Sleeping...'."\n";
363
+		sleep($globalMinFetch-$max+2);
364
+	}
364 365
 	}
365
-    }
366 366
 
367 367
     
368
-    //foreach ($formats as $id => $value) {
369
-    foreach ($globalSources as $id => $value) {
368
+	//foreach ($formats as $id => $value) {
369
+	foreach ($globalSources as $id => $value) {
370 370
 	date_default_timezone_set('UTC');
371 371
 	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
372 372
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
373
-	    //$buffer = $Common->getData($hosts[$id]);
374
-	    $buffer = $Common->getData($value['host']);
375
-	    if ($buffer != '') $reset = 0;
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
378
-	    foreach ($buffer as $line) {
379
-    		if ($line != '' && count($line) > 7) {
380
-    		    $line = explode(',', $line);
381
-	            $data = array();
382
-	            $data['hex'] = $line[1]; // hex
383
-	            $data['ident'] = $line[2]; // ident
384
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
385
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
386
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
387
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
388
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
389
-	            $data['verticalrate'] = ''; // vertical rate
390
-	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
391
-	            $data['emergency'] = ''; // emergency
392
-		    $data['datetime'] = date('Y-m-d H:i:s');
393
-		    $data['format_source'] = 'deltadbtxt';
394
-    		    $data['id_source'] = $id_source;
395
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
396
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
397
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
398
-    		    $SI->add($data);
399
-		    unset($data);
400
-    		}
401
-    	    }
402
-    	    $last_exec[$id]['last'] = time();
373
+		//$buffer = $Common->getData($hosts[$id]);
374
+		$buffer = $Common->getData($value['host']);
375
+		if ($buffer != '') $reset = 0;
376
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
+		$buffer = explode('\n',$buffer);
378
+		foreach ($buffer as $line) {
379
+			if ($line != '' && count($line) > 7) {
380
+				$line = explode(',', $line);
381
+				$data = array();
382
+				$data['hex'] = $line[1]; // hex
383
+				$data['ident'] = $line[2]; // ident
384
+				if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
385
+				if (isset($line[4])) $data['speed'] = $line[4]; // speed
386
+				if (isset($line[5])) $data['heading'] = $line[5]; // heading
387
+				if (isset($line[6])) $data['latitude'] = $line[6]; // lat
388
+				if (isset($line[7])) $data['longitude'] = $line[7]; // long
389
+				$data['verticalrate'] = ''; // vertical rate
390
+				//if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
391
+				$data['emergency'] = ''; // emergency
392
+			$data['datetime'] = date('Y-m-d H:i:s');
393
+			$data['format_source'] = 'deltadbtxt';
394
+				$data['id_source'] = $id_source;
395
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
396
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
397
+			if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
398
+				$SI->add($data);
399
+			unset($data);
400
+			}
401
+			}
402
+			$last_exec[$id]['last'] = time();
403 403
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
404
-	    date_default_timezone_set('CET');
405
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
406
-	    date_default_timezone_set('UTC');
407
-	    if ($buffer != '') $reset = 0;
408
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409
-	    $buffer = explode('\n',$buffer);
410
-	    foreach ($buffer as $line) {
404
+		date_default_timezone_set('CET');
405
+		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
406
+		date_default_timezone_set('UTC');
407
+		if ($buffer != '') $reset = 0;
408
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409
+		$buffer = explode('\n',$buffer);
410
+		foreach ($buffer as $line) {
411 411
 		if ($line != '') {
412
-		    echo "'".$line."'\n";
413
-		    $add = false;
414
-		    $ais_data = $AIS->parse_line(trim($line));
415
-		    $data = array();
416
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
417
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
418
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
419
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
420
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
421
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
422
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
423
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
424
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
426
-		    if (isset($ais_data['timestamp'])) {
412
+			echo "'".$line."'\n";
413
+			$add = false;
414
+			$ais_data = $AIS->parse_line(trim($line));
415
+			$data = array();
416
+			if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
417
+			if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
418
+			if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
419
+			if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
420
+			if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
421
+			if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
422
+			if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
423
+			if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
424
+			if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425
+			if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
426
+			if (isset($ais_data['timestamp'])) {
427 427
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
428 428
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
429
-			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
430
-			    $add = true;
429
+				$last_exec[$id]['timestamp'] = $ais_data['timestamp'];
430
+				$add = true;
431 431
 			}
432
-		    } else {
432
+			} else {
433 433
 			$data['datetime'] = date('Y-m-d H:i:s');
434 434
 			$add = true;
435
-		    }
436
-		    $data['format_source'] = 'aisnmeatxt';
437
-    		    $data['id_source'] = $id_source;
438
-		    //print_r($data);
439
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
440
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
441
-		    unset($data);
435
+			}
436
+			$data['format_source'] = 'aisnmeatxt';
437
+				$data['id_source'] = $id_source;
438
+			//print_r($data);
439
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
440
+			if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
441
+			unset($data);
442 442
 		}
443
-    	    }
444
-    	    $last_exec[$id]['last'] = time();
443
+			}
444
+			$last_exec[$id]['last'] = time();
445 445
 	} elseif ($value['format'] == 'aisnmeahttp') {
446
-	    $arr = $httpfeeds;
447
-	    $w = $e = null;
446
+		$arr = $httpfeeds;
447
+		$w = $e = null;
448 448
 	    
449
-	    if (isset($arr[$id])) {
449
+		if (isset($arr[$id])) {
450 450
 		$nn = stream_select($arr,$w,$e,$timeout);
451 451
 		if ($nn > 0) {
452
-		    foreach ($httpfeeds as $feed) {
452
+			foreach ($httpfeeds as $feed) {
453 453
 			$buffer = stream_get_line($feed,2000,"\n");
454 454
 			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
455 455
 			$buffer = explode('\n',$buffer);
456 456
 			foreach ($buffer as $line) {
457
-			    if ($line != '') {
457
+				if ($line != '') {
458 458
 				$ais_data = $AIS->parse_line(trim($line));
459 459
 				$data = array();
460 460
 				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
@@ -472,96 +472,96 @@  discard block
 block discarded – undo
472 472
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
473 473
 				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
474 474
 				if (isset($ais_data['timestamp'])) {
475
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
475
+					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
476 476
 				} else {
477
-				    $data['datetime'] = date('Y-m-d H:i:s');
477
+					$data['datetime'] = date('Y-m-d H:i:s');
478 478
 				}
479 479
 				$data['format_source'] = 'aisnmeahttp';
480 480
 				$data['id_source'] = $id_source;
481 481
 				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482 482
 				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
483 483
 				unset($data);
484
-			    }
484
+				}
485
+			}
485 486
 			}
486
-		    }
487 487
 		} else {
488
-		    $format = $value['format'];
489
-		    if (isset($tt[$format])) $tt[$format]++;
490
-		    else $tt[$format] = 0;
491
-		    if ($tt[$format] > 30) {
488
+			$format = $value['format'];
489
+			if (isset($tt[$format])) $tt[$format]++;
490
+			else $tt[$format] = 0;
491
+			if ($tt[$format] > 30) {
492 492
 			if ($globalDebug) echo 'Reconnect...'."\n";
493 493
 			sleep(2);
494 494
 			$sourceeen[] = $value;
495 495
 			connect_all($sourceeen);
496 496
 			$sourceeen = array();
497
-		    }
497
+			}
498
+		}
498 499
 		}
499
-	    }
500 500
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
501
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
502
-	    if ($buffer != '') {
501
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
502
+		if ($buffer != '') {
503 503
 		//echo $buffer;
504 504
 		$all_data = json_decode($buffer,true);
505 505
 		//print_r($all_data);
506 506
 		if (isset($all_data[0]['DATA'])) {
507
-		    foreach ($all_data[0]['DATA'] as $line) {
507
+			foreach ($all_data[0]['DATA'] as $line) {
508 508
 			if ($line != '') {
509
-			    $data = array();
510
-			    $data['ident'] = $line['NAME'];
511
-			    $data['mmsi'] = $line['MMSI'];
512
-			    $data['speed'] = $line['SOG'];
513
-			    $data['heading'] = $line['COG'];
514
-			    $data['latitude'] = $line['LAT'];
515
-			    $data['longitude'] = $line['LNG'];
516
-			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
517
-			    $data['imo'] = $line['IMO'];
518
-			    //$data['arrival_code'] = $ais_data['destination'];
519
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
520
-			    $data['format_source'] = 'myshiptracking';
521
-			    $data['id_source'] = $id_source;
522
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
523
-			    $MI->add($data);
524
-			    unset($data);
509
+				$data = array();
510
+				$data['ident'] = $line['NAME'];
511
+				$data['mmsi'] = $line['MMSI'];
512
+				$data['speed'] = $line['SOG'];
513
+				$data['heading'] = $line['COG'];
514
+				$data['latitude'] = $line['LAT'];
515
+				$data['longitude'] = $line['LNG'];
516
+				//    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
517
+				$data['imo'] = $line['IMO'];
518
+				//$data['arrival_code'] = $ais_data['destination'];
519
+				$data['datetime'] = date('Y-m-d H:i:s',$line['T']);
520
+				$data['format_source'] = 'myshiptracking';
521
+				$data['id_source'] = $id_source;
522
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
523
+				$MI->add($data);
524
+				unset($data);
525
+			}
525 526
 			}
526
-		    }
527 527
 		}
528
-	    }
529
-	    $last_exec[$id]['last'] = time();
528
+		}
529
+		$last_exec[$id]['last'] = time();
530 530
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
531
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
532
-	    if ($buffer != '') {
531
+		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
532
+		if ($buffer != '') {
533 533
 		$all_data = json_decode($buffer,true);
534 534
 		if (isset($all_data[0]['mmsi'])) {
535
-		    foreach ($all_data as $line) {
535
+			foreach ($all_data as $line) {
536 536
 			if ($line != '') {
537
-			    $data = array();
538
-			    $data['ident'] = $line['shipname'];
539
-			    $data['callsign'] = $line['callsign'];
540
-			    $data['mmsi'] = $line['mmsi'];
541
-			    $data['speed'] = $line['sog'];
542
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
543
-			    $data['latitude'] = $line['latitude'];
544
-			    $data['longitude'] = $line['longitude'];
545
-			    $data['type_id'] = $line['shiptype'];
546
-			    $data['arrival_code'] = $line['destination'];
547
-			    $data['datetime'] = $line['time'];
548
-			    $data['format_source'] = 'boatbeaconapp';
549
-			    $data['id_source'] = $id_source;
550
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
551
-			    $MI->add($data);
552
-			    unset($data);
537
+				$data = array();
538
+				$data['ident'] = $line['shipname'];
539
+				$data['callsign'] = $line['callsign'];
540
+				$data['mmsi'] = $line['mmsi'];
541
+				$data['speed'] = $line['sog'];
542
+				if ($line['heading'] != '511') $data['heading'] = $line['heading'];
543
+				$data['latitude'] = $line['latitude'];
544
+				$data['longitude'] = $line['longitude'];
545
+				$data['type_id'] = $line['shiptype'];
546
+				$data['arrival_code'] = $line['destination'];
547
+				$data['datetime'] = $line['time'];
548
+				$data['format_source'] = 'boatbeaconapp';
549
+				$data['id_source'] = $id_source;
550
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
551
+				$MI->add($data);
552
+				unset($data);
553
+			}
553 554
 			}
554
-		    }
555 555
 		}
556 556
 		
557
-	    }
558
-    	    $last_exec[$id]['last'] = time();
557
+		}
558
+			$last_exec[$id]['last'] = time();
559 559
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
560
-	    $buffer = $Common->getData($value['host']);
561
-	    if ($buffer != '') {
560
+		$buffer = $Common->getData($value['host']);
561
+		if ($buffer != '') {
562 562
 		$all_data = json_decode($buffer,true);
563 563
 		if (isset($all_data['features'][0]['id'])) {
564
-		    foreach ($all_data['features'] as $line) {
564
+			foreach ($all_data['features'] as $line) {
565 565
 			$data = array();
566 566
 			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
567 567
 			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
@@ -580,59 +580,59 @@  discard block
 block discarded – undo
580 580
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
581 581
 			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
582 582
 			unset($data);
583
-		    }
583
+			}
584 584
 		}
585 585
 		
586
-	    }
587
-    	    $last_exec[$id]['last'] = time();
586
+		}
587
+			$last_exec[$id]['last'] = time();
588 588
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
589
-	    echo 'download...';
590
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
591
-	    echo 'done !'."\n";
592
-	    if ($buffer != '') $reset = 0;
593
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
594
-	    $buffer = explode('\n',$buffer);
595
-	    foreach ($buffer as $line) {
589
+		echo 'download...';
590
+		$buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
591
+		echo 'done !'."\n";
592
+		if ($buffer != '') $reset = 0;
593
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
594
+		$buffer = explode('\n',$buffer);
595
+		foreach ($buffer as $line) {
596 596
 		if ($line != '') {
597
-		    $data = array();
598
-		    $data['mmsi'] = (int)substr($line,0,9);
599
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
600
-		    //$data['status'] = substr($line,21,2);
601
-		    //$data['type'] = substr($line,24,3);
602
-		    $data['latitude'] = substr($line,29,9);
603
-		    $data['longitude'] = substr($line,41,9);
604
-		    $data['speed'] = round(substr($line,51,5));
605
-		    //$data['course'] = substr($line,57,5);
606
-		    $data['heading'] = round(substr($line,63,3));
607
-		    //$data['draft'] = substr($line,67,4);
608
-		    //$data['length'] = substr($line,72,3);
609
-		    //$data['beam'] = substr($line,76,2);
610
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
611
-		    //$data['callsign'] = trim(substr($line,100,7);
612
-		    //$data['dest'] = substr($line,108,20);
613
-		    //$data['etaDate'] = substr($line,129,5);
614
-		    //$data['etaTime'] = substr($line,135,5);
615
-		    $data['format_source'] = 'shipplotter';
616
-    		    $data['id_source'] = $id_source;
617
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
618
-		    //print_r($data);
619
-		    echo 'Add...'."\n";
620
-		    $MI->add($data);
621
-		    unset($data);
597
+			$data = array();
598
+			$data['mmsi'] = (int)substr($line,0,9);
599
+			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
600
+			//$data['status'] = substr($line,21,2);
601
+			//$data['type'] = substr($line,24,3);
602
+			$data['latitude'] = substr($line,29,9);
603
+			$data['longitude'] = substr($line,41,9);
604
+			$data['speed'] = round(substr($line,51,5));
605
+			//$data['course'] = substr($line,57,5);
606
+			$data['heading'] = round(substr($line,63,3));
607
+			//$data['draft'] = substr($line,67,4);
608
+			//$data['length'] = substr($line,72,3);
609
+			//$data['beam'] = substr($line,76,2);
610
+			$data['ident'] = trim(utf8_encode(substr($line,79,20)));
611
+			//$data['callsign'] = trim(substr($line,100,7);
612
+			//$data['dest'] = substr($line,108,20);
613
+			//$data['etaDate'] = substr($line,129,5);
614
+			//$data['etaTime'] = substr($line,135,5);
615
+			$data['format_source'] = 'shipplotter';
616
+				$data['id_source'] = $id_source;
617
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
618
+			//print_r($data);
619
+			echo 'Add...'."\n";
620
+			$MI->add($data);
621
+			unset($data);
622 622
 		}
623
-    	    }
624
-    	    $last_exec[$id]['last'] = time();
623
+			}
624
+			$last_exec[$id]['last'] = time();
625 625
 	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) {
626 626
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
627
-	    //$buffer = $Common->getData($hosts[$id]);
628
-	    $buffer = $Common->getData($value['host']);
629
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
630
-	    $buffer = explode('\n',$buffer);
631
-	    $reset = 0;
632
-	    foreach ($buffer as $line) {
633
-    		if ($line != '') {
634
-    		    $line = explode(':', $line);
635
-    		    if (count($line) > 30 && $line[0] != 'callsign') {
627
+		//$buffer = $Common->getData($hosts[$id]);
628
+		$buffer = $Common->getData($value['host']);
629
+			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
630
+		$buffer = explode('\n',$buffer);
631
+		$reset = 0;
632
+		foreach ($buffer as $line) {
633
+			if ($line != '') {
634
+				$line = explode(':', $line);
635
+				if (count($line) > 30 && $line[0] != 'callsign') {
636 636
 			$data = array();
637 637
 			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
638 638
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
@@ -645,37 +645,37 @@  discard block
 block discarded – undo
645 645
 			if (isset($line[45])) $data['heading'] = $line[45]; // heading
646 646
 			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
647 647
 			$data['latitude'] = $line[5]; // lat
648
-	        	$data['longitude'] = $line[6]; // long
649
-	        	$data['verticalrate'] = ''; // vertical rate
650
-	        	$data['squawk'] = ''; // squawk
651
-	        	$data['emergency'] = ''; // emergency
652
-	        	$data['waypoints'] = $line[30];
648
+				$data['longitude'] = $line[6]; // long
649
+				$data['verticalrate'] = ''; // vertical rate
650
+				$data['squawk'] = ''; // squawk
651
+				$data['emergency'] = ''; // emergency
652
+				$data['waypoints'] = $line[30];
653 653
 			$data['datetime'] = date('Y-m-d H:i:s');
654 654
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
655 655
 			//if (isset($line[37])) $data['last_update'] = $line[37];
656
-		        $data['departure_airport_icao'] = $line[11];
657
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
658
-		        $data['arrival_airport_icao'] = $line[13];
656
+				$data['departure_airport_icao'] = $line[11];
657
+				$data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
658
+				$data['arrival_airport_icao'] = $line[13];
659 659
 			$data['frequency'] = $line[4];
660 660
 			$data['type'] = $line[18];
661 661
 			$data['range'] = $line[19];
662 662
 			if (isset($line[35])) $data['info'] = $line[35];
663
-    			$data['id_source'] = $id_source;
664
-	    		//$data['arrival_airport_time'] = ;
665
-	    		if ($line[9] != '') {
666
-	    		    $aircraft_data = explode('/',$line[9]);
667
-	    		    if (isset($aircraft_data[1])) {
668
-	    			$data['aircraft_icao'] = $aircraft_data[1];
669
-	    		    }
670
-        		}
671
-	    		/*
663
+				$data['id_source'] = $id_source;
664
+				//$data['arrival_airport_time'] = ;
665
+				if ($line[9] != '') {
666
+					$aircraft_data = explode('/',$line[9]);
667
+					if (isset($aircraft_data[1])) {
668
+					$data['aircraft_icao'] = $aircraft_data[1];
669
+					}
670
+				}
671
+				/*
672 672
 	    		if ($value == 'whazzup') $data['format_source'] = 'whazzup';
673 673
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
674 674
 	    		*/
675
-	    		$data['format_source'] = $value['format'];
675
+				$data['format_source'] = $value['format'];
676 676
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
677 677
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
678
-    			if ($line[3] == 'PILOT') $SI->add($data);
678
+				if ($line[3] == 'PILOT') $SI->add($data);
679 679
 			elseif ($line[3] == 'ATC') {
680 680
 				//print_r($data);
681 681
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
@@ -696,255 +696,255 @@  discard block
 block discarded – undo
696 696
 					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']);
697 697
 				}
698 698
 			}
699
-    			unset($data);
700
-    		    }
701
-    		}
702
-    	    }
703
-    	    //if ($value == 'whazzup') $last_exec['whazzup'] = time();
704
-    	    //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
705
-    	    $last_exec[$id]['last'] = time();
706
-    	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
707
-    	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
708
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
709
-	    if ($buffer != '') {
710
-	    $all_data = json_decode($buffer,true);
711
-	    if (isset($all_data['acList'])) {
699
+				unset($data);
700
+				}
701
+			}
702
+			}
703
+			//if ($value == 'whazzup') $last_exec['whazzup'] = time();
704
+			//elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time();
705
+			$last_exec[$id]['last'] = time();
706
+		//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
707
+		} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
708
+		$buffer = $Common->getData($value['host'],'get','','','','','20');
709
+		if ($buffer != '') {
710
+		$all_data = json_decode($buffer,true);
711
+		if (isset($all_data['acList'])) {
712 712
 		$reset = 0;
713 713
 		foreach ($all_data['acList'] as $line) {
714
-		    $data = array();
715
-		    $data['hex'] = $line['Icao']; // hex
716
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
717
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
718
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
719
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
720
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
721
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
722
-		    //$data['verticalrate'] = $line['']; // verticale rate
723
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
724
-		    $data['emergency'] = ''; // emergency
725
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
714
+			$data = array();
715
+			$data['hex'] = $line['Icao']; // hex
716
+			if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
717
+			if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
718
+			if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
719
+			if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
720
+			if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
721
+			if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
722
+			//$data['verticalrate'] = $line['']; // verticale rate
723
+			if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
724
+			$data['emergency'] = ''; // emergency
725
+			if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
726 726
 		    
727
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
728
-		    else $data['datetime'] = date('Y-m-d H:i:s');
727
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
728
+			else $data['datetime'] = date('Y-m-d H:i:s');
729 729
 		    
730
-		    //$data['datetime'] = date('Y-m-d H:i:s');
731
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
732
-	    	    $data['format_source'] = 'aircraftlistjson';
733
-		    $data['id_source'] = $id_source;
734
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
735
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
736
-		    if (isset($data['latitude'])) $SI->add($data);
737
-		    unset($data);
730
+			//$data['datetime'] = date('Y-m-d H:i:s');
731
+			if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
732
+				$data['format_source'] = 'aircraftlistjson';
733
+			$data['id_source'] = $id_source;
734
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
735
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
736
+			if (isset($data['latitude'])) $SI->add($data);
737
+			unset($data);
738 738
 		}
739
-	    } elseif (is_array($all_data)) {
739
+		} elseif (is_array($all_data)) {
740 740
 		$reset = 0;
741 741
 		foreach ($all_data as $line) {
742
-		    $data = array();
743
-		    $data['hex'] = $line['hex']; // hex
744
-		    $data['ident'] = $line['flight']; // ident
745
-		    $data['altitude'] = $line['altitude']; // altitude
746
-		    $data['speed'] = $line['speed']; // speed
747
-		    $data['heading'] = $line['track']; // heading
748
-		    $data['latitude'] = $line['lat']; // lat
749
-		    $data['longitude'] = $line['lon']; // long
750
-		    $data['verticalrate'] = $line['vrt']; // verticale rate
751
-		    $data['squawk'] = $line['squawk']; // squawk
752
-		    $data['emergency'] = ''; // emergency
753
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
754
-		    else $data['datetime'] = date('Y-m-d H:i:s');
755
-	    	    $data['format_source'] = 'aircraftlistjson';
756
-    		    $data['id_source'] = $id_source;
757
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
758
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
759
-		    $SI->add($data);
760
-		    unset($data);
742
+			$data = array();
743
+			$data['hex'] = $line['hex']; // hex
744
+			$data['ident'] = $line['flight']; // ident
745
+			$data['altitude'] = $line['altitude']; // altitude
746
+			$data['speed'] = $line['speed']; // speed
747
+			$data['heading'] = $line['track']; // heading
748
+			$data['latitude'] = $line['lat']; // lat
749
+			$data['longitude'] = $line['lon']; // long
750
+			$data['verticalrate'] = $line['vrt']; // verticale rate
751
+			$data['squawk'] = $line['squawk']; // squawk
752
+			$data['emergency'] = ''; // emergency
753
+			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
754
+			else $data['datetime'] = date('Y-m-d H:i:s');
755
+				$data['format_source'] = 'aircraftlistjson';
756
+				$data['id_source'] = $id_source;
757
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
758
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
759
+			$SI->add($data);
760
+			unset($data);
761
+		}
762
+		}
761 763
 		}
762
-	    }
763
-	    }
764
-    	    //$last_exec['aircraftlistjson'] = time();
765
-    	    $last_exec[$id]['last'] = time();
766
-    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
767
-    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
-	    $buffer = $Common->getData($value['host']);
769
-	    $all_data = json_decode($buffer,true);
770
-	    if (isset($all_data['planes'])) {
764
+			//$last_exec['aircraftlistjson'] = time();
765
+			$last_exec[$id]['last'] = time();
766
+		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
767
+		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768
+		$buffer = $Common->getData($value['host']);
769
+		$all_data = json_decode($buffer,true);
770
+		if (isset($all_data['planes'])) {
771 771
 		$reset = 0;
772 772
 		foreach ($all_data['planes'] as $key => $line) {
773
-		    $data = array();
774
-		    $data['hex'] = $key; // hex
775
-		    $data['ident'] = $line[3]; // ident
776
-		    $data['altitude'] = $line[6]; // altitude
777
-		    $data['speed'] = $line[8]; // speed
778
-		    $data['heading'] = $line[7]; // heading
779
-		    $data['latitude'] = $line[4]; // lat
780
-		    $data['longitude'] = $line[5]; // long
781
-		    //$data['verticalrate'] = $line[]; // verticale rate
782
-		    $data['squawk'] = $line[10]; // squawk
783
-		    $data['emergency'] = ''; // emergency
784
-		    $data['registration'] = $line[2];
785
-		    $data['aircraft_icao'] = $line[0];
786
-		    $deparr = explode('-',$line[1]);
787
-		    if (count($deparr) == 2) {
773
+			$data = array();
774
+			$data['hex'] = $key; // hex
775
+			$data['ident'] = $line[3]; // ident
776
+			$data['altitude'] = $line[6]; // altitude
777
+			$data['speed'] = $line[8]; // speed
778
+			$data['heading'] = $line[7]; // heading
779
+			$data['latitude'] = $line[4]; // lat
780
+			$data['longitude'] = $line[5]; // long
781
+			//$data['verticalrate'] = $line[]; // verticale rate
782
+			$data['squawk'] = $line[10]; // squawk
783
+			$data['emergency'] = ''; // emergency
784
+			$data['registration'] = $line[2];
785
+			$data['aircraft_icao'] = $line[0];
786
+			$deparr = explode('-',$line[1]);
787
+			if (count($deparr) == 2) {
788 788
 			$data['departure_airport_icao'] = $deparr[0];
789 789
 			$data['arrival_airport_icao'] = $deparr[1];
790
-		    }
791
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
792
-	    	    $data['format_source'] = 'planeupdatefaa';
793
-    		    $data['id_source'] = $id_source;
794
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
795
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
796
-		    $SI->add($data);
797
-		    unset($data);
790
+			}
791
+			$data['datetime'] = date('Y-m-d H:i:s',$line[9]);
792
+				$data['format_source'] = 'planeupdatefaa';
793
+				$data['id_source'] = $id_source;
794
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
795
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
796
+			$SI->add($data);
797
+			unset($data);
798
+		}
798 799
 		}
799
-	    }
800
-    	    //$last_exec['planeupdatefaa'] = time();
801
-    	    $last_exec[$id]['last'] = time();
802
-    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
803
-	    $buffer = $Common->getData($value['host']);
804
-	    $all_data = json_decode($buffer,true);
805
-	    if (isset($all_data['states'])) {
800
+			//$last_exec['planeupdatefaa'] = time();
801
+			$last_exec[$id]['last'] = time();
802
+		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
803
+		$buffer = $Common->getData($value['host']);
804
+		$all_data = json_decode($buffer,true);
805
+		if (isset($all_data['states'])) {
806 806
 		$reset = 0;
807 807
 		foreach ($all_data['states'] as $key => $line) {
808
-		    $data = array();
809
-		    $data['hex'] = $line[0]; // hex
810
-		    $data['ident'] = trim($line[1]); // ident
811
-		    $data['altitude'] = round($line[7]*3.28084); // altitude
812
-		    $data['speed'] = round($line[9]*1.94384); // speed
813
-		    $data['heading'] = round($line[10]); // heading
814
-		    $data['latitude'] = $line[6]; // lat
815
-		    $data['longitude'] = $line[5]; // long
816
-		    $data['verticalrate'] = $line[11]; // verticale rate
817
-		    //$data['squawk'] = $line[10]; // squawk
818
-		    //$data['emergency'] = ''; // emergency
819
-		    //$data['registration'] = $line[2];
820
-		    //$data['aircraft_icao'] = $line[0];
821
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
822
-	    	    $data['format_source'] = 'opensky';
823
-    		    $data['id_source'] = $id_source;
824
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
825
-		    $SI->add($data);
826
-		    unset($data);
808
+			$data = array();
809
+			$data['hex'] = $line[0]; // hex
810
+			$data['ident'] = trim($line[1]); // ident
811
+			$data['altitude'] = round($line[7]*3.28084); // altitude
812
+			$data['speed'] = round($line[9]*1.94384); // speed
813
+			$data['heading'] = round($line[10]); // heading
814
+			$data['latitude'] = $line[6]; // lat
815
+			$data['longitude'] = $line[5]; // long
816
+			$data['verticalrate'] = $line[11]; // verticale rate
817
+			//$data['squawk'] = $line[10]; // squawk
818
+			//$data['emergency'] = ''; // emergency
819
+			//$data['registration'] = $line[2];
820
+			//$data['aircraft_icao'] = $line[0];
821
+			$data['datetime'] = date('Y-m-d H:i:s',$line[3]);
822
+				$data['format_source'] = 'opensky';
823
+				$data['id_source'] = $id_source;
824
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
825
+			$SI->add($data);
826
+			unset($data);
827 827
 		}
828
-	    }
829
-    	    //$last_exec['planeupdatefaa'] = time();
830
-    	    $last_exec[$id]['last'] = time();
831
-    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
832
-    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
833
-	    //$buffer = $Common->getData($hosts[$id]);
834
-	    $buffer = $Common->getData($value['host']);
835
-	    $all_data = json_decode($buffer,true);
836
-	    if (!empty($all_data)) $reset = 0;
837
-	    foreach ($all_data as $key => $line) {
828
+		}
829
+			//$last_exec['planeupdatefaa'] = time();
830
+			$last_exec[$id]['last'] = time();
831
+		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) {
832
+		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
833
+		//$buffer = $Common->getData($hosts[$id]);
834
+		$buffer = $Common->getData($value['host']);
835
+		$all_data = json_decode($buffer,true);
836
+		if (!empty($all_data)) $reset = 0;
837
+		foreach ($all_data as $key => $line) {
838 838
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
839
-		    $data = array();
840
-		    $data['hex'] = $line[0];
841
-		    $data['ident'] = $line[16]; //$line[13]
842
-	    	    $data['altitude'] = $line[4]; // altitude
843
-	    	    $data['speed'] = $line[5]; // speed
844
-	    	    $data['heading'] = $line[3]; // heading
845
-	    	    $data['latitude'] = $line[1]; // lat
846
-	    	    $data['longitude'] = $line[2]; // long
847
-	    	    $data['verticalrate'] = $line[15]; // verticale rate
848
-	    	    $data['squawk'] = $line[6]; // squawk
849
-	    	    $data['aircraft_icao'] = $line[8];
850
-	    	    $data['registration'] = $line[9];
851
-		    $data['departure_airport_iata'] = $line[11];
852
-		    $data['arrival_airport_iata'] = $line[12];
853
-	    	    $data['emergency'] = ''; // emergency
854
-		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
855
-	    	    $data['format_source'] = 'fr24json';
856
-    		    $data['id_source'] = $id_source;
857
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
858
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
859
-		    $SI->add($data);
860
-		    unset($data);
839
+			$data = array();
840
+			$data['hex'] = $line[0];
841
+			$data['ident'] = $line[16]; //$line[13]
842
+				$data['altitude'] = $line[4]; // altitude
843
+				$data['speed'] = $line[5]; // speed
844
+				$data['heading'] = $line[3]; // heading
845
+				$data['latitude'] = $line[1]; // lat
846
+				$data['longitude'] = $line[2]; // long
847
+				$data['verticalrate'] = $line[15]; // verticale rate
848
+				$data['squawk'] = $line[6]; // squawk
849
+				$data['aircraft_icao'] = $line[8];
850
+				$data['registration'] = $line[9];
851
+			$data['departure_airport_iata'] = $line[11];
852
+			$data['arrival_airport_iata'] = $line[12];
853
+				$data['emergency'] = ''; // emergency
854
+			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
855
+				$data['format_source'] = 'fr24json';
856
+				$data['id_source'] = $id_source;
857
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
858
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
859
+			$SI->add($data);
860
+			unset($data);
861
+		}
861 862
 		}
862
-	    }
863
-    	    //$last_exec['fr24json'] = time();
864
-    	    $last_exec[$id]['last'] = time();
865
-    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
866
-    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
867
-	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
868
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
869
-	    //echo $buffer;
870
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
871
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
872
-	    $all_data = json_decode($buffer,true);
873
-	    if (json_last_error() != JSON_ERROR_NONE) {
863
+			//$last_exec['fr24json'] = time();
864
+			$last_exec[$id]['last'] = time();
865
+		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
866
+		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
867
+		//$buffer = $Common->getData($hosts[$id],'get','','','','','150');
868
+		$buffer = $Common->getData($value['host'],'get','','','','','150');
869
+		//echo $buffer;
870
+		$buffer = str_replace(array("\n","\r"),"",$buffer);
871
+		$buffer = preg_replace('/,"num":(.+)/','}',$buffer);
872
+		$all_data = json_decode($buffer,true);
873
+		if (json_last_error() != JSON_ERROR_NONE) {
874 874
 		die(json_last_error_msg());
875
-	    }
876
-	    if (isset($all_data['mrkrs'])) {
875
+		}
876
+		if (isset($all_data['mrkrs'])) {
877 877
 		$reset = 0;
878 878
 		foreach ($all_data['mrkrs'] as $key => $line) {
879
-		    if (isset($line['inf'])) {
879
+			if (isset($line['inf'])) {
880 880
 			$data = array();
881 881
 			$data['hex'] = $line['inf']['ia'];
882 882
 			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
883
-	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
884
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
885
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
886
-	    		$data['latitude'] = $line['pt'][0]; // lat
887
-	    		$data['longitude'] = $line['pt'][1]; // long
888
-	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
889
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
890
-	    		//$data['aircraft_icao'] = $line[8];
891
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
883
+				$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
884
+				if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
885
+				if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
886
+				$data['latitude'] = $line['pt'][0]; // lat
887
+				$data['longitude'] = $line['pt'][1]; // long
888
+				//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
889
+				if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
890
+				//$data['aircraft_icao'] = $line[8];
891
+				if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
892 892
 			//$data['departure_airport_iata'] = $line[11];
893 893
 			//$data['arrival_airport_iata'] = $line[12];
894
-	    		//$data['emergency'] = ''; // emergency
894
+				//$data['emergency'] = ''; // emergency
895 895
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
896
-	    		$data['format_source'] = 'radarvirtueljson';
897
-    			$data['id_source'] = $id_source;
896
+				$data['format_source'] = 'radarvirtueljson';
897
+				$data['id_source'] = $id_source;
898 898
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
899 899
 			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
900 900
 			$SI->add($data);
901 901
 			unset($data);
902
-		    }
902
+			}
903 903
 		}
904
-	    }
905
-    	    //$last_exec['radarvirtueljson'] = time();
906
-    	    $last_exec[$id]['last'] = time();
907
-    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
908
-    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
909
-	    //$buffer = $Common->getData($hosts[$id]);
910
-	    $buffer = $Common->getData($value['host'].'?'.time());
911
-	    $all_data = json_decode(utf8_encode($buffer),true);
904
+		}
905
+			//$last_exec['radarvirtueljson'] = time();
906
+			$last_exec[$id]['last'] = time();
907
+		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) {
908
+		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
909
+		//$buffer = $Common->getData($hosts[$id]);
910
+		$buffer = $Common->getData($value['host'].'?'.time());
911
+		$all_data = json_decode(utf8_encode($buffer),true);
912 912
 	    
913
-	    if (isset($all_data['pireps'])) {
913
+		if (isset($all_data['pireps'])) {
914 914
 		$reset = 0;
915
-	        foreach ($all_data['pireps'] as $line) {
916
-		    $data = array();
917
-		    $data['id'] = $line['id'];
918
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
919
-		    $data['ident'] = $line['callsign']; // ident
920
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
921
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
922
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
923
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
924
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
925
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
926
-		    $data['latitude'] = $line['lat']; // lat
927
-		    $data['longitude'] = $line['lon']; // long
928
-		    //$data['verticalrate'] = $line['vrt']; // verticale rate
929
-		    //$data['squawk'] = $line['squawk']; // squawk
930
-		    //$data['emergency'] = ''; // emergency
931
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
932
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
933
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
934
-		    //$data['arrival_airport_time'] = $line['arrtime'];
935
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
936
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
937
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
938
-		    else $data['info'] = '';
939
-		    $data['format_source'] = 'pireps';
940
-    		    $data['id_source'] = $id_source;
941
-		    $data['datetime'] = date('Y-m-d H:i:s');
942
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
943
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
944
-		    if ($line['icon'] == 'plane') {
915
+			foreach ($all_data['pireps'] as $line) {
916
+			$data = array();
917
+			$data['id'] = $line['id'];
918
+			$data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
919
+			$data['ident'] = $line['callsign']; // ident
920
+			if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
921
+			if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
922
+			if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
923
+			if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
924
+			if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
925
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
926
+			$data['latitude'] = $line['lat']; // lat
927
+			$data['longitude'] = $line['lon']; // long
928
+			//$data['verticalrate'] = $line['vrt']; // verticale rate
929
+			//$data['squawk'] = $line['squawk']; // squawk
930
+			//$data['emergency'] = ''; // emergency
931
+			if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
932
+			if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
933
+			if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
934
+			//$data['arrival_airport_time'] = $line['arrtime'];
935
+			if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
936
+			if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
937
+			if (isset($line['atis'])) $data['info'] = $line['atis'];
938
+			else $data['info'] = '';
939
+			$data['format_source'] = 'pireps';
940
+				$data['id_source'] = $id_source;
941
+			$data['datetime'] = date('Y-m-d H:i:s');
942
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
943
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
944
+			if ($line['icon'] == 'plane') {
945 945
 			$SI->add($data);
946
-		    //    print_r($data);
947
-    		    } elseif ($line['icon'] == 'ct') {
946
+			//    print_r($data);
947
+				} elseif ($line['icon'] == 'ct') {
948 948
 			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
949 949
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
950 950
 			$typec = substr($data['ident'],-3);
@@ -959,199 +959,199 @@  discard block
 block discarded – undo
959 959
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
960 960
 			else $data['type'] = 'Observer';
961 961
 			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']);
962
-		    }
963
-		    unset($data);
962
+			}
963
+			unset($data);
964 964
 		}
965
-	    }
966
-    	    //$last_exec['pirepsjson'] = time();
967
-    	    $last_exec[$id]['last'] = time();
968
-    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
969
-    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
970
-	    //$buffer = $Common->getData($hosts[$id]);
971
-	    if ($globalDebug) echo 'Get Data...'."\n";
972
-	    $buffer = $Common->getData($value['host']);
973
-	    $all_data = json_decode($buffer,true);
974
-	    if ($buffer != '' && is_array($all_data)) {
965
+		}
966
+			//$last_exec['pirepsjson'] = time();
967
+			$last_exec[$id]['last'] = time();
968
+		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
969
+		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
970
+		//$buffer = $Common->getData($hosts[$id]);
971
+		if ($globalDebug) echo 'Get Data...'."\n";
972
+		$buffer = $Common->getData($value['host']);
973
+		$all_data = json_decode($buffer,true);
974
+		if ($buffer != '' && is_array($all_data)) {
975 975
 		$reset = 0;
976 976
 		foreach ($all_data as $line) {
977
-	    	    $data = array();
978
-	    	    //$data['id'] = $line['id']; // id not usable
979
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
980
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
981
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
982
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
983
-	    	    $data['ident'] = $line['flightnum']; // ident
984
-	    	    $data['altitude'] = $line['alt']; // altitude
985
-	    	    $data['speed'] = $line['gs']; // speed
986
-	    	    $data['heading'] = $line['heading']; // heading
987
-	    	    $data['latitude'] = $line['lat']; // lat
988
-	    	    $data['longitude'] = $line['lng']; // long
989
-	    	    $data['verticalrate'] = ''; // verticale rate
990
-	    	    $data['squawk'] = ''; // squawk
991
-	    	    $data['emergency'] = ''; // emergency
992
-	    	    //$data['datetime'] = $line['lastupdate'];
993
-	    	    $data['last_update'] = $line['lastupdate'];
994
-		    $data['datetime'] = date('Y-m-d H:i:s');
995
-	    	    $data['departure_airport_icao'] = $line['depicao'];
996
-	    	    $data['departure_airport_time'] = $line['deptime'];
997
-	    	    $data['arrival_airport_icao'] = $line['arricao'];
998
-    		    $data['arrival_airport_time'] = $line['arrtime'];
999
-    		    $data['registration'] = $line['aircraft'];
1000
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1001
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1002
-		    if (isset($line['aircraftname'])) {
977
+				$data = array();
978
+				//$data['id'] = $line['id']; // id not usable
979
+				if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
980
+				$data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
981
+				if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
982
+				if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
983
+				$data['ident'] = $line['flightnum']; // ident
984
+				$data['altitude'] = $line['alt']; // altitude
985
+				$data['speed'] = $line['gs']; // speed
986
+				$data['heading'] = $line['heading']; // heading
987
+				$data['latitude'] = $line['lat']; // lat
988
+				$data['longitude'] = $line['lng']; // long
989
+				$data['verticalrate'] = ''; // verticale rate
990
+				$data['squawk'] = ''; // squawk
991
+				$data['emergency'] = ''; // emergency
992
+				//$data['datetime'] = $line['lastupdate'];
993
+				$data['last_update'] = $line['lastupdate'];
994
+			$data['datetime'] = date('Y-m-d H:i:s');
995
+				$data['departure_airport_icao'] = $line['depicao'];
996
+				$data['departure_airport_time'] = $line['deptime'];
997
+				$data['arrival_airport_icao'] = $line['arricao'];
998
+				$data['arrival_airport_time'] = $line['arrtime'];
999
+				$data['registration'] = $line['aircraft'];
1000
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1001
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1002
+			if (isset($line['aircraftname'])) {
1003 1003
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1004 1004
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1005
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1006
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1007
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1008
-	    		else {
1009
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1010
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1011
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1012
-	    		}
1013
-	    	    }
1014
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1015
-    		    $data['id_source'] = $id_source;
1016
-	    	    $data['format_source'] = 'phpvmacars';
1017
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1018
-		    $SI->add($data);
1019
-		    unset($data);
1005
+				$aircraft_data = explode('-',$line['aircraftname']);
1006
+				if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1007
+				elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1008
+				else {
1009
+					$aircraft_data = explode(' ',$line['aircraftname']);
1010
+					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1011
+					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1012
+				}
1013
+				}
1014
+				if (isset($line['route'])) $data['waypoints'] = $line['route'];
1015
+				$data['id_source'] = $id_source;
1016
+				$data['format_source'] = 'phpvmacars';
1017
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1018
+			$SI->add($data);
1019
+			unset($data);
1020 1020
 		}
1021 1021
 		if ($globalDebug) echo 'No more data...'."\n";
1022 1022
 		unset($buffer);
1023 1023
 		unset($all_data);
1024
-	    }
1025
-    	    //$last_exec['phpvmacars'] = time();
1026
-    	    $last_exec[$id]['last'] = time();
1027
-    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1028
-	    //$buffer = $Common->getData($hosts[$id]);
1029
-	    if ($globalDebug) echo 'Get Data...'."\n";
1030
-	    $buffer = $Common->getData($value['host']);
1031
-	    $all_data = json_decode($buffer,true);
1032
-	    if ($buffer != '' && is_array($all_data)) {
1024
+		}
1025
+			//$last_exec['phpvmacars'] = time();
1026
+			$last_exec[$id]['last'] = time();
1027
+		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1028
+		//$buffer = $Common->getData($hosts[$id]);
1029
+		if ($globalDebug) echo 'Get Data...'."\n";
1030
+		$buffer = $Common->getData($value['host']);
1031
+		$all_data = json_decode($buffer,true);
1032
+		if ($buffer != '' && is_array($all_data)) {
1033 1033
 		$reset = 0;
1034 1034
 		foreach ($all_data as $line) {
1035
-	    	    $data = array();
1036
-	    	    //$data['id'] = $line['id']; // id not usable
1037
-	    	    $data['id'] = trim($line['flight_id']);
1038
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1039
-	    	    $data['pilot_name'] = $line['pilot_name'];
1040
-	    	    $data['pilot_id'] = $line['pilot_id'];
1041
-	    	    $data['ident'] = trim($line['callsign']); // ident
1042
-	    	    $data['altitude'] = $line['altitude']; // altitude
1043
-	    	    $data['speed'] = $line['gs']; // speed
1044
-	    	    $data['heading'] = $line['heading']; // heading
1045
-	    	    $data['latitude'] = $line['latitude']; // lat
1046
-	    	    $data['longitude'] = $line['longitude']; // long
1047
-	    	    $data['verticalrate'] = ''; // verticale rate
1048
-	    	    $data['squawk'] = ''; // squawk
1049
-	    	    $data['emergency'] = ''; // emergency
1050
-	    	    //$data['datetime'] = $line['lastupdate'];
1051
-	    	    $data['last_update'] = $line['last_update'];
1052
-		    $data['datetime'] = date('Y-m-d H:i:s');
1053
-	    	    $data['departure_airport_icao'] = $line['departure'];
1054
-	    	    //$data['departure_airport_time'] = $line['departure_time'];
1055
-	    	    $data['arrival_airport_icao'] = $line['arrival'];
1056
-    		    //$data['arrival_airport_time'] = $line['arrival_time'];
1057
-    		    //$data['registration'] = $line['aircraft'];
1058
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1059
-	    	    $data['aircraft_icao'] = $line['plane_type'];
1060
-    		    $data['id_source'] = $id_source;
1061
-	    	    $data['format_source'] = 'vam';
1062
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1063
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1064
-		    $SI->add($data);
1065
-		    unset($data);
1035
+				$data = array();
1036
+				//$data['id'] = $line['id']; // id not usable
1037
+				$data['id'] = trim($line['flight_id']);
1038
+				$data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1039
+				$data['pilot_name'] = $line['pilot_name'];
1040
+				$data['pilot_id'] = $line['pilot_id'];
1041
+				$data['ident'] = trim($line['callsign']); // ident
1042
+				$data['altitude'] = $line['altitude']; // altitude
1043
+				$data['speed'] = $line['gs']; // speed
1044
+				$data['heading'] = $line['heading']; // heading
1045
+				$data['latitude'] = $line['latitude']; // lat
1046
+				$data['longitude'] = $line['longitude']; // long
1047
+				$data['verticalrate'] = ''; // verticale rate
1048
+				$data['squawk'] = ''; // squawk
1049
+				$data['emergency'] = ''; // emergency
1050
+				//$data['datetime'] = $line['lastupdate'];
1051
+				$data['last_update'] = $line['last_update'];
1052
+			$data['datetime'] = date('Y-m-d H:i:s');
1053
+				$data['departure_airport_icao'] = $line['departure'];
1054
+				//$data['departure_airport_time'] = $line['departure_time'];
1055
+				$data['arrival_airport_icao'] = $line['arrival'];
1056
+				//$data['arrival_airport_time'] = $line['arrival_time'];
1057
+				//$data['registration'] = $line['aircraft'];
1058
+			if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1059
+				$data['aircraft_icao'] = $line['plane_type'];
1060
+				$data['id_source'] = $id_source;
1061
+				$data['format_source'] = 'vam';
1062
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1063
+			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1064
+			$SI->add($data);
1065
+			unset($data);
1066 1066
 		}
1067 1067
 		if ($globalDebug) echo 'No more data...'."\n";
1068 1068
 		unset($buffer);
1069 1069
 		unset($all_data);
1070
-	    }
1071
-    	    //$last_exec['phpvmacars'] = time();
1072
-    	    $last_exec[$id]['last'] = time();
1070
+		}
1071
+			//$last_exec['phpvmacars'] = time();
1072
+			$last_exec[$id]['last'] = time();
1073 1073
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1074 1074
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1075
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1076
-    	    //$last_exec[$id]['last'] = time();
1075
+		if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1076
+			//$last_exec[$id]['last'] = time();
1077 1077
 
1078
-	    //$read = array( $sockets[$id] );
1079
-	    $read = $sockets;
1080
-	    $write = NULL;
1081
-	    $e = NULL;
1082
-	    $n = socket_select($read, $write, $e, $timeout);
1083
-	    if ($e != NULL) var_dump($e);
1084
-	    if ($n > 0) {
1078
+		//$read = array( $sockets[$id] );
1079
+		$read = $sockets;
1080
+		$write = NULL;
1081
+		$e = NULL;
1082
+		$n = socket_select($read, $write, $e, $timeout);
1083
+		if ($e != NULL) var_dump($e);
1084
+		if ($n > 0) {
1085 1085
 		$reset = 0;
1086 1086
 		foreach ($read as $nb => $r) {
1087
-		    //$value = $formats[$nb];
1088
-		    $format = $globalSources[$nb]['format'];
1089
-		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1087
+			//$value = $formats[$nb];
1088
+			$format = $globalSources[$nb]['format'];
1089
+			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1090 1090
 			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1091
-		    } elseif ($format == 'vrstcp') {
1091
+			} elseif ($format == 'vrstcp') {
1092 1092
 			$buffer = @socket_read($r, 6000);
1093
-		    } else {
1093
+			} else {
1094 1094
 			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1095
-		    }
1096
-		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1097
-		    //echo $buffer."\n";
1098
-		    // lets play nice and handle signals such as ctrl-c/kill properly
1099
-		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1100
-		    $error = false;
1101
-		    //$SI::del();
1102
-		    if ($format == 'vrstcp') {
1095
+			}
1096
+			//$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1097
+			//echo $buffer."\n";
1098
+			// lets play nice and handle signals such as ctrl-c/kill properly
1099
+			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1100
+			$error = false;
1101
+			//$SI::del();
1102
+			if ($format == 'vrstcp') {
1103 1103
 			$buffer = explode('},{',$buffer);
1104
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1105
-		    // SBS format is CSV format
1106
-		    if ($buffer !== FALSE && $buffer != '') {
1104
+			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1105
+			// SBS format is CSV format
1106
+			if ($buffer !== FALSE && $buffer != '') {
1107 1107
 			$tt[$format] = 0;
1108 1108
 			if ($format == 'acarssbs3') {
1109
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1110
-			    $ACARS->add(trim($buffer));
1111
-			    $ACARS->deleteLiveAcarsData();
1109
+				if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1110
+				$ACARS->add(trim($buffer));
1111
+				$ACARS->deleteLiveAcarsData();
1112 1112
 			} elseif ($format == 'raw') {
1113
-			    // AVR format
1114
-			    $data = $SBS->parse($buffer);
1115
-			    if (is_array($data)) {
1113
+				// AVR format
1114
+				$data = $SBS->parse($buffer);
1115
+				if (is_array($data)) {
1116 1116
 				$data['datetime'] = date('Y-m-d H:i:s');
1117 1117
 				$data['format_source'] = 'raw';
1118 1118
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1119 1119
 				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1120 1120
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1121 1121
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1122
-			    }
1122
+				}
1123 1123
 			} elseif ($format == 'ais') {
1124
-			    $ais_data = $AIS->parse_line(trim($buffer));
1125
-			    $data = array();
1126
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1127
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1128
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1129
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1130
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1131
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1132
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1133
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1134
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1135
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1136
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1137
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1138
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1139
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1140
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1141
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1124
+				$ais_data = $AIS->parse_line(trim($buffer));
1125
+				$data = array();
1126
+				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1127
+				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1128
+				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1129
+				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1130
+				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1131
+				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1132
+				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1133
+				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1134
+				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1135
+				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1136
+				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1137
+				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1138
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1139
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1140
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1141
+				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1142 1142
 
1143
-			    if (isset($ais_data['timestamp'])) {
1143
+				if (isset($ais_data['timestamp'])) {
1144 1144
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1145
-			    } else {
1145
+				} else {
1146 1146
 				$data['datetime'] = date('Y-m-d H:i:s');
1147
-			    }
1148
-			    $data['format_source'] = 'aisnmea';
1149
-    			    $data['id_source'] = $id_source;
1150
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1151
-			    unset($data);
1152
-                        } elseif ($format == 'flightgearsp') {
1153
-                    	    //echo $buffer."\n";
1154
-                    	    if (strlen($buffer) > 5) {
1147
+				}
1148
+				$data['format_source'] = 'aisnmea';
1149
+					$data['id_source'] = $id_source;
1150
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1151
+				unset($data);
1152
+						} elseif ($format == 'flightgearsp') {
1153
+							//echo $buffer."\n";
1154
+							if (strlen($buffer) > 5) {
1155 1155
 				$line = explode(',',$buffer);
1156 1156
 				$data = array();
1157 1157
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
@@ -1168,38 +1168,38 @@  discard block
 block discarded – undo
1168 1168
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1169 1169
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1170 1170
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1171
-			    }
1172
-                        } elseif ($format == 'acars') {
1173
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1174
-			    $ACARS->add(trim($buffer));
1175
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1176
-			    $ACARS->deleteLiveAcarsData();
1171
+				}
1172
+						} elseif ($format == 'acars') {
1173
+							if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1174
+				$ACARS->add(trim($buffer));
1175
+				socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1176
+				$ACARS->deleteLiveAcarsData();
1177 1177
 			} elseif ($format == 'flightgearmp') {
1178
-			    if (substr($buffer,0,1) != '#') {
1178
+				if (substr($buffer,0,1) != '#') {
1179 1179
 				$data = array();
1180 1180
 				//echo $buffer."\n";
1181 1181
 				$line = explode(' ',$buffer);
1182 1182
 				if (count($line) == 11) {
1183
-				    $userserver = explode('@',$line[0]);
1184
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1185
-				    $data['ident'] = $userserver[0];
1186
-				    $data['registration'] = $userserver[0];
1187
-				    $data['latitude'] = $line[4];
1188
-				    $data['longitude'] = $line[5];
1189
-				    $data['altitude'] = $line[6];
1190
-				    $data['datetime'] = date('Y-m-d H:i:s');
1191
-				    $aircraft_type = $line[10];
1192
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1193
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1194
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1195
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1183
+					$userserver = explode('@',$line[0]);
1184
+					$data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1185
+					$data['ident'] = $userserver[0];
1186
+					$data['registration'] = $userserver[0];
1187
+					$data['latitude'] = $line[4];
1188
+					$data['longitude'] = $line[5];
1189
+					$data['altitude'] = $line[6];
1190
+					$data['datetime'] = date('Y-m-d H:i:s');
1191
+					$aircraft_type = $line[10];
1192
+					$aircraft_type = preg_split(':/:',$aircraft_type);
1193
+					$data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1194
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1195
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1196
+				}
1196 1197
 				}
1197
-			    }
1198 1198
 			} elseif ($format == 'beast') {
1199
-			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1200
-			    die;
1199
+				echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1200
+				die;
1201 1201
 			} elseif ($format == 'vrstcp') {
1202
-			    foreach($buffer as $all_data) {
1202
+				foreach($buffer as $all_data) {
1203 1203
 				$line = json_decode('{'.$all_data.'}',true);
1204 1204
 				$data = array();
1205 1205
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
@@ -1219,113 +1219,113 @@  discard block
 block discarded – undo
1219 1219
 				*/
1220 1220
 				$data['datetime'] = date('Y-m-d H:i:s');
1221 1221
 				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1222
-		    		$data['format_source'] = 'vrstcp';
1222
+					$data['format_source'] = 'vrstcp';
1223 1223
 				$data['id_source'] = $id_source;
1224 1224
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1225 1225
 				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1226 1226
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1227 1227
 				unset($data);
1228
-			    }
1228
+				}
1229 1229
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1230
-			    $line = explode("\t", $buffer);
1231
-			    for($k = 0; $k < count($line); $k=$k+2) {
1230
+				$line = explode("\t", $buffer);
1231
+				for($k = 0; $k < count($line); $k=$k+2) {
1232 1232
 				$key = $line[$k];
1233
-			        $lined[$key] = $line[$k+1];
1234
-			    }
1235
-    			    if (count($lined) > 3) {
1236
-    				$data['hex'] = $lined['hexid'];
1237
-    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1238
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1239
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1240
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1241
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1242
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1243
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1244
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1245
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1246
-    				$data['id_source'] = $id_source;
1247
-    				$data['format_source'] = 'tsv';
1248
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1249
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1233
+					$lined[$key] = $line[$k+1];
1234
+				}
1235
+					if (count($lined) > 3) {
1236
+					$data['hex'] = $lined['hexid'];
1237
+					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1238
+					$data['datetime'] = date('Y-m-d H:i:s');;
1239
+					if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1240
+					if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1241
+					if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1242
+					if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1243
+					if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1244
+					if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1245
+					if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1246
+					$data['id_source'] = $id_source;
1247
+					$data['format_source'] = 'tsv';
1248
+					if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1249
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1250 1250
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1251
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1252
-    				unset($lined);
1253
-    				unset($data);
1254
-    			    } else $error = true;
1251
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1252
+					unset($lined);
1253
+					unset($data);
1254
+					} else $error = true;
1255 1255
 			} elseif ($format == 'aprs' && $use_aprs) {
1256
-			    if ($aprs_connect == 0) {
1256
+				if ($aprs_connect == 0) {
1257 1257
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1258 1258
 				$aprs_connect = 1;
1259
-			    }
1259
+				}
1260 1260
 			    
1261
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1261
+				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1262 1262
 				$aprs_last_tx = time();
1263 1263
 				$data_aprs = "# Keep alive";
1264 1264
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1265
-			    }
1265
+				}
1266 1266
 			    
1267
-			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1268
-			    //echo 'APRS data : '.$buffer."\n";
1269
-			    $buffer = str_replace('APRS <- ','',$buffer);
1270
-			    $buffer = str_replace('APRS -> ','',$buffer);
1271
-			    //echo $buffer."\n";
1272
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1267
+				//echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1268
+				//echo 'APRS data : '.$buffer."\n";
1269
+				$buffer = str_replace('APRS <- ','',$buffer);
1270
+				$buffer = str_replace('APRS -> ','',$buffer);
1271
+				//echo $buffer."\n";
1272
+				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1273 1273
 				$line = $APRS->parse($buffer);
1274 1274
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1275 1275
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
1276
-				    $aprs_last_tx = time();
1277
-				    $data = array();
1278
-				    //print_r($line);
1279
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1280
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1281
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1282
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1283
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1284
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1285
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1286
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1287
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1288
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1289
-				    //$data['datetime'] = date('Y-m-d H:i:s');
1290
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1291
-				    $data['latitude'] = $line['latitude'];
1292
-				    $data['longitude'] = $line['longitude'];
1293
-				    //$data['verticalrate'] = $line[16];
1294
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1295
-				    else $data['speed'] = 0;
1296
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1297
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1298
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1299
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1300
-				    //else $data['heading'] = 0;
1301
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1302
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1303
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1304
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1305
-    				    $data['id_source'] = $id_source;
1306
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1307
-				    else $data['format_source'] = 'aprs';
1308
-				    $data['source_name'] = $line['source'];
1309
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1310
-				    else $data['source_type'] = 'flarm';
1311
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1312
-				    $currentdate = date('Y-m-d H:i:s');
1313
-				    $aprsdate = strtotime($data['datetime']);
1314
-				    // Accept data if time <= system time + 20s
1315
-				    //if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1316
-				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1276
+					$aprs_last_tx = time();
1277
+					$data = array();
1278
+					//print_r($line);
1279
+					if (isset($line['address'])) $data['hex'] = $line['address'];
1280
+					if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1281
+					if (isset($line['imo'])) $data['imo'] = $line['imo'];
1282
+					if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1283
+					if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1284
+					if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1285
+					if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1286
+					if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1287
+					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1288
+					else $data['datetime'] = date('Y-m-d H:i:s');
1289
+					//$data['datetime'] = date('Y-m-d H:i:s');
1290
+					if (isset($line['ident'])) $data['ident'] = $line['ident'];
1291
+					$data['latitude'] = $line['latitude'];
1292
+					$data['longitude'] = $line['longitude'];
1293
+					//$data['verticalrate'] = $line[16];
1294
+					if (isset($line['speed'])) $data['speed'] = $line['speed'];
1295
+					else $data['speed'] = 0;
1296
+					if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1297
+					if (isset($line['comment'])) $data['comment'] = $line['comment'];
1298
+					if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1299
+					if (isset($line['heading'])) $data['heading'] = $line['heading'];
1300
+					//else $data['heading'] = 0;
1301
+					if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1302
+					if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1303
+					if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1304
+					elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1305
+						$data['id_source'] = $id_source;
1306
+						if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1307
+					else $data['format_source'] = 'aprs';
1308
+					$data['source_name'] = $line['source'];
1309
+					if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1310
+					else $data['source_type'] = 'flarm';
1311
+						if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1312
+					$currentdate = date('Y-m-d H:i:s');
1313
+					$aprsdate = strtotime($data['datetime']);
1314
+					// Accept data if time <= system time + 20s
1315
+					//if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (strtotime($data['datetime']) <= strtotime($currentdate)+20) && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1316
+					if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1317 1317
 					$send = $SI->add($data);
1318
-				    } elseif ($data['source_type'] == 'ais') {
1318
+					} elseif ($data['source_type'] == 'ais') {
1319 1319
 					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1320
-				    } elseif (isset($line['stealth'])) {
1320
+					} elseif (isset($line['stealth'])) {
1321 1321
 					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1322 1322
 					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1323
-				    //} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1324
-				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1323
+					//} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1324
+					} elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1325 1325
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1326 1326
 					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1327
-				    }
1328
-				    unset($data);
1327
+					}
1328
+					unset($data);
1329 1329
 				} 
1330 1330
 				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1331 1331
 					echo '!! Weather Station not yet supported'."\n";
@@ -1335,12 +1335,12 @@  discard block
 block discarded – undo
1335 1335
 				}
1336 1336
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
1337 1337
 				//elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n";
1338
-			    }
1338
+				}
1339 1339
 			} else {
1340
-			    $line = explode(',', $buffer);
1341
-    			    if (count($line) > 20) {
1342
-    			    	$data['hex'] = $line[4];
1343
-    				/*
1340
+				$line = explode(',', $buffer);
1341
+					if (count($line) > 20) {
1342
+						$data['hex'] = $line[4];
1343
+					/*
1344 1344
     				$data['datetime'] = $line[6].' '.$line[7];
1345 1345
     					date_default_timezone_set($globalTimezone);
1346 1346
     					$datetime = new DateTime($data['datetime']);
@@ -1348,30 +1348,30 @@  discard block
 block discarded – undo
1348 1348
     					$data['datetime'] = $datetime->format('Y-m-d H:i:s');
1349 1349
     					date_default_timezone_set('UTC');
1350 1350
     				*/
1351
-    				// Force datetime to current UTC datetime
1352
-    				date_default_timezone_set('UTC');
1353
-    				$data['datetime'] = date('Y-m-d H:i:s');
1354
-    				$data['ident'] = trim($line[10]);
1355
-    				$data['latitude'] = $line[14];
1356
-    				$data['longitude'] = $line[15];
1357
-    				$data['verticalrate'] = $line[16];
1358
-    				$data['emergency'] = $line[20];
1359
-    				$data['speed'] = $line[12];
1360
-    				$data['squawk'] = $line[17];
1361
-    				$data['altitude'] = $line[11];
1362
-    				$data['heading'] = $line[13];
1363
-    				$data['ground'] = $line[21];
1364
-    				$data['emergency'] = $line[19];
1365
-    				$data['format_source'] = 'sbs';
1351
+					// Force datetime to current UTC datetime
1352
+					date_default_timezone_set('UTC');
1353
+					$data['datetime'] = date('Y-m-d H:i:s');
1354
+					$data['ident'] = trim($line[10]);
1355
+					$data['latitude'] = $line[14];
1356
+					$data['longitude'] = $line[15];
1357
+					$data['verticalrate'] = $line[16];
1358
+					$data['emergency'] = $line[20];
1359
+					$data['speed'] = $line[12];
1360
+					$data['squawk'] = $line[17];
1361
+					$data['altitude'] = $line[11];
1362
+					$data['heading'] = $line[13];
1363
+					$data['ground'] = $line[21];
1364
+					$data['emergency'] = $line[19];
1365
+					$data['format_source'] = 'sbs';
1366 1366
 				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1367
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1367
+					if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368 1368
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1369
-    				$data['id_source'] = $id_source;
1370
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1371
-    				else $error = true;
1372
-    				unset($data);
1373
-    			    } else $error = true;
1374
-			    if ($error) {
1369
+					$data['id_source'] = $id_source;
1370
+					if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1371
+					else $error = true;
1372
+					unset($data);
1373
+					} else $error = true;
1374
+				if ($error) {
1375 1375
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1376 1376
 					if ($globalDebug) echo "Not a message. Ignoring... \n";
1377 1377
 				} else {
@@ -1387,13 +1387,13 @@  discard block
 block discarded – undo
1387 1387
 					connect_all($sourceer);
1388 1388
 					$sourceer = array();
1389 1389
 				}
1390
-			    }
1390
+				}
1391 1391
 			}
1392 1392
 			// Sleep for xxx microseconds
1393 1393
 			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
1394
-		    } else {
1394
+			} else {
1395 1395
 			if ($format == 'flightgearmp') {
1396
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
1396
+					if ($globalDebug) echo "Reconnect FlightGear MP...";
1397 1397
 				//@socket_close($r);
1398 1398
 				sleep($globalMinFetch);
1399 1399
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1402,9 +1402,9 @@  discard block
 block discarded – undo
1402 1402
 				break;
1403 1403
 				
1404 1404
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1405
-			    if (isset($tt[$format])) $tt[$format]++;
1406
-			    else $tt[$format] = 0;
1407
-			    if ($tt[$format] > 30) {
1405
+				if (isset($tt[$format])) $tt[$format]++;
1406
+				else $tt[$format] = 0;
1407
+				if ($tt[$format] > 30) {
1408 1408
 				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
1409 1409
 				//@socket_close($r);
1410 1410
 				sleep(2);
@@ -1415,23 +1415,23 @@  discard block
 block discarded – undo
1415 1415
 				//connect_all($globalSources);
1416 1416
 				$tt[$format]=0;
1417 1417
 				break;
1418
-			    }
1418
+				}
1419
+			}
1419 1420
 			}
1420
-		    }
1421 1421
 		}
1422
-	    } else {
1422
+		} else {
1423 1423
 		$error = socket_strerror(socket_last_error());
1424 1424
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1425 1425
 			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1426 1426
 			if (isset($globalDebug)) echo "Restarting...\n";
1427 1427
 			// Restart the script if possible
1428 1428
 			if (is_array($sockets)) {
1429
-			    if ($globalDebug) echo "Shutdown all sockets...";
1429
+				if ($globalDebug) echo "Shutdown all sockets...";
1430 1430
 			    
1431
-			    foreach ($sockets as $sock) {
1431
+				foreach ($sockets as $sock) {
1432 1432
 				@socket_shutdown($sock,2);
1433 1433
 				@socket_close($sock);
1434
-			    }
1434
+				}
1435 1435
 			    
1436 1436
 			}
1437 1437
 			if ($globalDebug) echo "Waiting...";
@@ -1446,13 +1446,13 @@  discard block
 block discarded – undo
1446 1446
 			if ($globalDebug) echo "Restart all connections...";
1447 1447
 			connect_all($globalSources);
1448 1448
 		}
1449
-	    }
1449
+		}
1450 1450
 	}
1451 1451
 	if ($globalDaemon === false) {
1452
-	    if ($globalDebug) echo 'Check all...'."\n";
1453
-	    $SI->checkAll();
1452
+		if ($globalDebug) echo 'Check all...'."\n";
1453
+		$SI->checkAll();
1454
+	}
1454 1455
 	}
1455
-    }
1456 1456
 }
1457 1457
 
1458 1458
 ?>
Please login to merge, or discard this patch.
Spacing   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -45,20 +45,20 @@  discard block
 block discarded – undo
45 45
 	    die;
46 46
 	}
47 47
 	//$hosts = array($globalSBS1Host.':'.$globalSBS1Port);
48
-	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port);
48
+	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port);
49 49
     }
50 50
 }
51 51
 
52
-$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver'));
52
+$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver'));
53 53
 //if (isset($options['s'])) $hosts = array($options['s']);
54 54
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 55
 if (isset($options['s'])) {
56 56
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
57
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']);
58 58
     else $globalSources[] = array('host' => $options['s']);
59 59
 } elseif (isset($options['source'])) {
60 60
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
61
+    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']);
62 62
     else $globalSources[] = array('host' => $options['source']);
63 63
 }
64 64
 if (isset($options['aprsserverhost'])) {
@@ -75,27 +75,27 @@  discard block
 block discarded – undo
75 75
 else $id_source = 1;
76 76
 if (isset($globalServer) && $globalServer) {
77 77
     if ($globalDebug) echo "Using Server Mode\n";
78
-    $SI=new SpotterServer();
78
+    $SI = new SpotterServer();
79 79
 /*
80 80
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 81
     $SI = new adsb2aprs();
82 82
     $SI->connect();
83 83
 */
84
-} else $SI=new SpotterImport($Connection->db);
84
+} else $SI = new SpotterImport($Connection->db);
85 85
 if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
86 86
 if (isset($globalMarine) && $globalMarine) {
87 87
     $AIS = new AIS();
88 88
     $MI = new MarineImport($Connection->db);
89 89
 }
90 90
 //$APRS=new APRS($Connection->db);
91
-$SBS=new SBS();
92
-$ACARS=new ACARS($Connection->db);
93
-$Common=new Common();
91
+$SBS = new SBS();
92
+$ACARS = new ACARS($Connection->db);
93
+$Common = new Common();
94 94
 date_default_timezone_set('UTC');
95 95
 //$servertz = system('date +%Z');
96 96
 // signal handler - playing nice with sockets and dump1090
97 97
 if (function_exists('pcntl_fork')) {
98
-    pcntl_signal(SIGINT,  function() {
98
+    pcntl_signal(SIGINT, function() {
99 99
         global $sockets;
100 100
         echo "\n\nctrl-c or kill signal received. Tidying up ... ";
101 101
         die("Bye!\n");
@@ -111,30 +111,30 @@  discard block
 block discarded – undo
111 111
 
112 112
 function connect_all($hosts) {
113 113
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114
-    global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
114
+    global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context;
115 115
     $reset++;
116 116
     if ($globalDebug) echo 'Connect to all...'."\n";
117 117
     foreach ($hosts as $id => $value) {
118 118
 	$host = $value['host'];
119 119
 	$globalSources[$id]['last_exec'] = 0;
120 120
 	// Here we check type of source(s)
121
-	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
-            if (preg_match('/deltadb.txt$/i',$host)) {
121
+	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) {
122
+            if (preg_match('/deltadb.txt$/i', $host)) {
123 123
         	//$formats[$id] = 'deltadbtxt';
124 124
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 125
         	//$last_exec['deltadbtxt'] = 0;
126 126
         	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
127
-            } else if (preg_match('/vatsim-data.txt$/i',$host)) {
127
+            } else if (preg_match('/vatsim-data.txt$/i', $host)) {
128 128
         	//$formats[$id] = 'vatsimtxt';
129 129
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 130
         	//$last_exec['vatsimtxt'] = 0;
131 131
         	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
132
-    	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
132
+    	    } else if (preg_match('/aircraftlist.json$/i', $host)) {
133 133
         	//$formats[$id] = 'aircraftlistjson';
134 134
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 135
         	//$last_exec['aircraftlistjson'] = 0;
136 136
         	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
137
-    	    } else if (preg_match('/opensky/i',$host)) {
137
+    	    } else if (preg_match('/opensky/i', $host)) {
138 138
         	//$formats[$id] = 'aircraftlistjson';
139 139
         	$globalSources[$id]['format'] = 'opensky';
140 140
         	//$last_exec['aircraftlistjson'] = 0;
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
         	    exit(0);
152 152
         	}
153 153
     	    */
154
-    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) {
154
+    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) {
155 155
         	//$formats[$id] = 'planeupdatefaa';
156 156
         	$globalSources[$id]['format'] = 'planeupdatefaa';
157 157
         	//$last_exec['planeupdatefaa'] = 0;
@@ -160,26 +160,26 @@  discard block
 block discarded – undo
160 160
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161 161
         	    exit(0);
162 162
         	}
163
-            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) {
163
+            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) {
164 164
         	//$formats[$id] = 'phpvmacars';
165 165
         	$globalSources[$id]['format'] = 'phpvmacars';
166 166
         	//$last_exec['phpvmacars'] = 0;
167 167
         	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
168
-            } else if (preg_match('/VAM-json.php$/i',$host)) {
168
+            } else if (preg_match('/VAM-json.php$/i', $host)) {
169 169
         	//$formats[$id] = 'phpvmacars';
170 170
         	$globalSources[$id]['format'] = 'vam';
171 171
         	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
172
-            } else if (preg_match('/whazzup/i',$host)) {
172
+            } else if (preg_match('/whazzup/i', $host)) {
173 173
         	//$formats[$id] = 'whazzup';
174 174
         	$globalSources[$id]['format'] = 'whazzup';
175 175
         	//$last_exec['whazzup'] = 0;
176 176
         	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
177
-            } else if (preg_match('/recentpireps/i',$host)) {
177
+            } else if (preg_match('/recentpireps/i', $host)) {
178 178
         	//$formats[$id] = 'pirepsjson';
179 179
         	$globalSources[$id]['format'] = 'pirepsjson';
180 180
         	//$last_exec['pirepsjson'] = 0;
181 181
         	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
182
-            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
182
+            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) {
183 183
         	//$formats[$id] = 'fr24json';
184 184
         	$globalSources[$id]['format'] = 'fr24json';
185 185
         	//$last_exec['fr24json'] = 0;
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189 189
         	    exit(0);
190 190
         	}
191
-            } else if (preg_match(':myshiptracking.com/:i',$host)) {
191
+            } else if (preg_match(':myshiptracking.com/:i', $host)) {
192 192
         	//$formats[$id] = 'fr24json';
193 193
         	$globalSources[$id]['format'] = 'myshiptracking';
194 194
         	//$last_exec['fr24json'] = 0;
@@ -198,22 +198,22 @@  discard block
 block discarded – undo
198 198
         	    exit(0);
199 199
         	}
200 200
             //} else if (preg_match('/10001/',$host)) {
201
-            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
201
+            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202 202
         	//$formats[$id] = 'tsv';
203 203
         	$globalSources[$id]['format'] = 'tsv';
204 204
         	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
205 205
             }
206
-        } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
206
+        } elseif (filter_var($host, FILTER_VALIDATE_URL)) {
207 207
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208
-    		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
208
+    		    $idf = fopen($globalSources[$id]['host'], 'r', false, $context);
209 209
     		    if ($idf !== false) {
210 210
     			$httpfeeds[$id] = $idf;
211 211
         		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
212 212
     		    }
213 213
     		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214 214
     		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
215
-        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216
-	    $hostport = explode(':',$host);
215
+        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) {
216
+	    $hostport = explode(':', $host);
217 217
 	    if (isset($hostport[1])) {
218 218
 		$port = $hostport[1];
219 219
 		$hostn = $hostport[0];
@@ -223,19 +223,19 @@  discard block
 block discarded – undo
223 223
 	    }
224 224
 	    $Common = new Common();
225 225
 	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) {
226
-        	$s = $Common->create_socket($hostn,$port, $errno, $errstr);
226
+        	$s = $Common->create_socket($hostn, $port, $errno, $errstr);
227 227
     	    } else {
228
-        	$s = $Common->create_socket_udp($hostn,$port, $errno, $errstr);
228
+        	$s = $Common->create_socket_udp($hostn, $port, $errno, $errstr);
229 229
 	    }
230 230
 	    if ($s) {
231 231
     	        $sockets[$id] = $s;
232 232
     	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') {
233
-		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') {
233
+		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') {
234 234
 			//$formats[$id] = 'aprs';
235 235
 			$globalSources[$id]['format'] = 'aprs';
236 236
 			//$aprs_connect = 0;
237 237
 			//$use_aprs = true;
238
-		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
238
+		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') {
239 239
 			$globalSources[$id]['format'] = 'vrstcp';
240 240
     		    } elseif ($port == '10001') {
241 241
         		//$formats[$id] = 'tsv';
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
275 275
 else $timeout = 20;
276 276
 $errno = '';
277
-$errstr='';
277
+$errstr = '';
278 278
 
279 279
 if (!isset($globalDaemon)) $globalDaemon = TRUE;
280 280
 /* Initiate connections to all the hosts simultaneously */
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 //connect_all($globalSources);
283 283
 
284 284
 if (isset($globalProxy) && $globalProxy) {
285
-    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true)));
285
+    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true)));
286 286
 } else {
287 287
     $context = stream_context_create(array('http' => array('timeout' => $timeout)));
288 288
 }
@@ -309,16 +309,16 @@  discard block
 block discarded – undo
309 309
 
310 310
 if ($use_aprs) {
311 311
 	require_once(dirname(__FILE__).'/../require/class.APRS.php');
312
-	$APRS=new APRS();
312
+	$APRS = new APRS();
313 313
 	$aprs_connect = 0;
314 314
 	$aprs_keep = 120;
315 315
 	$aprs_last_tx = time();
316 316
 	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
317
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
317
+	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName);
318 318
 	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
319
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
319
+	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8);
320 320
 	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
321
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
321
+	else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
322 322
 	if ($aprs_full) $aprs_filter = '';
323 323
 	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
324 324
 	else $aprs_pass = '-1';
@@ -332,12 +332,12 @@  discard block
 block discarded – undo
332 332
 sleep(1);
333 333
 if ($globalDebug) echo "SCAN MODE \n\n";
334 334
 if (!isset($globalCronEnd)) $globalCronEnd = 60;
335
-$endtime = time()+$globalCronEnd;
335
+$endtime = time() + $globalCronEnd;
336 336
 $i = 1;
337 337
 $tt = array();
338 338
 // Delete all ATC
339 339
 if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) {
340
-	$ATC=new ATC($Connection->db);
340
+	$ATC = new ATC($Connection->db);
341 341
 }
342 342
 if (!$globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
343 343
 	$ATC->deleteAll();
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 
346 346
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
347 347
 while ($i > 0) {
348
-    if (!$globalDaemon) $i = $endtime-time();
348
+    if (!$globalDaemon) $i = $endtime - time();
349 349
     // Delete old ATC
350 350
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
351 351
 	if ($globalDebug) echo 'Delete old ATC...'."\n";
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	}
361 361
 	if ($max != $globalMinFetch) {
362 362
 	    if ($globalDebug) echo 'Sleeping...'."\n";
363
-	    sleep($globalMinFetch-$max+2);
363
+	    sleep($globalMinFetch - $max + 2);
364 364
 	}
365 365
     }
366 366
 
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	    //$buffer = $Common->getData($hosts[$id]);
374 374
 	    $buffer = $Common->getData($value['host']);
375 375
 	    if ($buffer != '') $reset = 0;
376
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377
-	    $buffer = explode('\n',$buffer);
376
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
377
+	    $buffer = explode('\n', $buffer);
378 378
 	    foreach ($buffer as $line) {
379 379
     		if ($line != '' && count($line) > 7) {
380 380
     		    $line = explode(',', $line);
@@ -402,11 +402,11 @@  discard block
 block discarded – undo
402 402
     	    $last_exec[$id]['last'] = time();
403 403
 	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
404 404
 	    date_default_timezone_set('CET');
405
-	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
405
+	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host']));
406 406
 	    date_default_timezone_set('UTC');
407 407
 	    if ($buffer != '') $reset = 0;
408
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409
-	    $buffer = explode('\n',$buffer);
408
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
409
+	    $buffer = explode('\n', $buffer);
410 410
 	    foreach ($buffer as $line) {
411 411
 		if ($line != '') {
412 412
 		    echo "'".$line."'\n";
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425 425
 		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
426 426
 		    if (isset($ais_data['timestamp'])) {
427
-			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
427
+			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
428 428
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
429 429
 			    $last_exec[$id]['timestamp'] = $ais_data['timestamp'];
430 430
 			    $add = true;
@@ -447,12 +447,12 @@  discard block
 block discarded – undo
447 447
 	    $w = $e = null;
448 448
 	    
449 449
 	    if (isset($arr[$id])) {
450
-		$nn = stream_select($arr,$w,$e,$timeout);
450
+		$nn = stream_select($arr, $w, $e, $timeout);
451 451
 		if ($nn > 0) {
452 452
 		    foreach ($httpfeeds as $feed) {
453
-			$buffer = stream_get_line($feed,2000,"\n");
454
-			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
455
-			$buffer = explode('\n',$buffer);
453
+			$buffer = stream_get_line($feed, 2000, "\n");
454
+			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
455
+			$buffer = explode('\n', $buffer);
456 456
 			foreach ($buffer as $line) {
457 457
 			    if ($line != '') {
458 458
 				$ais_data = $AIS->parse_line(trim($line));
@@ -470,9 +470,9 @@  discard block
 block discarded – undo
470 470
 				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
471 471
 				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
472 472
 				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
473
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
473
+				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
474 474
 				if (isset($ais_data['timestamp'])) {
475
-				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
475
+				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
476 476
 				} else {
477 477
 				    $data['datetime'] = date('Y-m-d H:i:s');
478 478
 				}
@@ -498,10 +498,10 @@  discard block
 block discarded – undo
498 498
 		}
499 499
 	    }
500 500
 	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
501
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
501
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
502 502
 	    if ($buffer != '') {
503 503
 		//echo $buffer;
504
-		$all_data = json_decode($buffer,true);
504
+		$all_data = json_decode($buffer, true);
505 505
 		//print_r($all_data);
506 506
 		if (isset($all_data[0]['DATA'])) {
507 507
 		    foreach ($all_data[0]['DATA'] as $line) {
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 			    //    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
517 517
 			    $data['imo'] = $line['IMO'];
518 518
 			    //$data['arrival_code'] = $ais_data['destination'];
519
-			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
519
+			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']);
520 520
 			    $data['format_source'] = 'myshiptracking';
521 521
 			    $data['id_source'] = $id_source;
522 522
 			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 	    }
529 529
 	    $last_exec[$id]['last'] = time();
530 530
 	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
531
-	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host']));
531
+	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host']));
532 532
 	    if ($buffer != '') {
533
-		$all_data = json_decode($buffer,true);
533
+		$all_data = json_decode($buffer, true);
534 534
 		if (isset($all_data[0]['mmsi'])) {
535 535
 		    foreach ($all_data as $line) {
536 536
 			if ($line != '') {
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
 	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
560 560
 	    $buffer = $Common->getData($value['host']);
561 561
 	    if ($buffer != '') {
562
-		$all_data = json_decode($buffer,true);
562
+		$all_data = json_decode($buffer, true);
563 563
 		if (isset($all_data['features'][0]['id'])) {
564 564
 		    foreach ($all_data['features'] as $line) {
565 565
 			$data = array();
@@ -587,27 +587,27 @@  discard block
 block discarded – undo
587 587
     	    $last_exec[$id]['last'] = time();
588 588
 	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) {
589 589
 	    echo 'download...';
590
-	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
590
+	    $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter');
591 591
 	    echo 'done !'."\n";
592 592
 	    if ($buffer != '') $reset = 0;
593
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
594
-	    $buffer = explode('\n',$buffer);
593
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
594
+	    $buffer = explode('\n', $buffer);
595 595
 	    foreach ($buffer as $line) {
596 596
 		if ($line != '') {
597 597
 		    $data = array();
598
-		    $data['mmsi'] = (int)substr($line,0,9);
599
-		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10));
598
+		    $data['mmsi'] = (int) substr($line, 0, 9);
599
+		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10));
600 600
 		    //$data['status'] = substr($line,21,2);
601 601
 		    //$data['type'] = substr($line,24,3);
602
-		    $data['latitude'] = substr($line,29,9);
603
-		    $data['longitude'] = substr($line,41,9);
604
-		    $data['speed'] = round(substr($line,51,5));
602
+		    $data['latitude'] = substr($line, 29, 9);
603
+		    $data['longitude'] = substr($line, 41, 9);
604
+		    $data['speed'] = round(substr($line, 51, 5));
605 605
 		    //$data['course'] = substr($line,57,5);
606
-		    $data['heading'] = round(substr($line,63,3));
606
+		    $data['heading'] = round(substr($line, 63, 3));
607 607
 		    //$data['draft'] = substr($line,67,4);
608 608
 		    //$data['length'] = substr($line,72,3);
609 609
 		    //$data['beam'] = substr($line,76,2);
610
-		    $data['ident'] = trim(utf8_encode(substr($line,79,20)));
610
+		    $data['ident'] = trim(utf8_encode(substr($line, 79, 20)));
611 611
 		    //$data['callsign'] = trim(substr($line,100,7);
612 612
 		    //$data['dest'] = substr($line,108,20);
613 613
 		    //$data['etaDate'] = substr($line,129,5);
@@ -626,8 +626,8 @@  discard block
 block discarded – undo
626 626
 	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) {
627 627
 	    //$buffer = $Common->getData($hosts[$id]);
628 628
 	    $buffer = $Common->getData($value['host']);
629
-    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
630
-	    $buffer = explode('\n',$buffer);
629
+    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer));
630
+	    $buffer = explode('\n', $buffer);
631 631
 	    $reset = 0;
632 632
 	    foreach ($buffer as $line) {
633 633
     		if ($line != '') {
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
639 639
 			$data['pilot_id'] = $line[1];
640 640
 			$data['pilot_name'] = $line[2];
641
-			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
641
+			$data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT);
642 642
 			$data['ident'] = $line[0]; // ident
643 643
 			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
644 644
 			$data['speed'] = $line[8]; // speed
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37]));
655 655
 			//if (isset($line[37])) $data['last_update'] = $line[37];
656 656
 		        $data['departure_airport_icao'] = $line[11];
657
-		        $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':');
657
+		        $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':');
658 658
 		        $data['arrival_airport_icao'] = $line[13];
659 659
 			$data['frequency'] = $line[4];
660 660
 			$data['type'] = $line[18];
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
     			$data['id_source'] = $id_source;
664 664
 	    		//$data['arrival_airport_time'] = ;
665 665
 	    		if ($line[9] != '') {
666
-	    		    $aircraft_data = explode('/',$line[9]);
666
+	    		    $aircraft_data = explode('/', $line[9]);
667 667
 	    		    if (isset($aircraft_data[1])) {
668 668
 	    			$data['aircraft_icao'] = $aircraft_data[1];
669 669
 	    		    }
@@ -678,9 +678,9 @@  discard block
 block discarded – undo
678 678
     			if ($line[3] == 'PILOT') $SI->add($data);
679 679
 			elseif ($line[3] == 'ATC') {
680 680
 				//print_r($data);
681
-				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
682
-				$data['info'] = str_replace('&amp;sect;','',$data['info']);
683
-				$typec = substr($data['ident'],-3);
681
+				$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
682
+				$data['info'] = str_replace('&amp;sect;', '', $data['info']);
683
+				$typec = substr($data['ident'], -3);
684 684
 				if ($typec == 'APP') $data['type'] = 'Approach';
685 685
 				elseif ($typec == 'TWR') $data['type'] = 'Tower';
686 686
 				elseif ($typec == 'OBS') $data['type'] = 'Observer';
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 				elseif ($data['type'] == '') $data['type'] = 'Observer';
693 693
 				if (!isset($data['source_name'])) $data['source_name'] = '';
694 694
 				if (isset($ATC)) {
695
-					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']);
696
-					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']);
695
+					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']);
696
+					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']);
697 697
 				}
698 698
 			}
699 699
     			unset($data);
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
     	    $last_exec[$id]['last'] = time();
706 706
     	//} elseif ($value == 'aircraftlistjson' && (time() - $last_exec['aircraftlistjson'] > $globalMinFetch)) {
707 707
     	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
708
-	    $buffer = $Common->getData($value['host'],'get','','','','','20');
708
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20');
709 709
 	    if ($buffer != '') {
710
-	    $all_data = json_decode($buffer,true);
710
+	    $all_data = json_decode($buffer, true);
711 711
 	    if (isset($all_data['acList'])) {
712 712
 		$reset = 0;
713 713
 		foreach ($all_data['acList'] as $line) {
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 		    $data['emergency'] = ''; // emergency
725 725
 		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
726 726
 		    
727
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
727
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
728 728
 		    else $data['datetime'] = date('Y-m-d H:i:s');
729 729
 		    
730 730
 		    //$data['datetime'] = date('Y-m-d H:i:s');
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
751 751
 		    $data['squawk'] = $line['squawk']; // squawk
752 752
 		    $data['emergency'] = ''; // emergency
753
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
753
+		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000));
754 754
 		    else $data['datetime'] = date('Y-m-d H:i:s');
755 755
 	    	    $data['format_source'] = 'aircraftlistjson';
756 756
     		    $data['id_source'] = $id_source;
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
     	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) {
767 767
     	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
768 768
 	    $buffer = $Common->getData($value['host']);
769
-	    $all_data = json_decode($buffer,true);
769
+	    $all_data = json_decode($buffer, true);
770 770
 	    if (isset($all_data['planes'])) {
771 771
 		$reset = 0;
772 772
 		foreach ($all_data['planes'] as $key => $line) {
@@ -783,12 +783,12 @@  discard block
 block discarded – undo
783 783
 		    $data['emergency'] = ''; // emergency
784 784
 		    $data['registration'] = $line[2];
785 785
 		    $data['aircraft_icao'] = $line[0];
786
-		    $deparr = explode('-',$line[1]);
786
+		    $deparr = explode('-', $line[1]);
787 787
 		    if (count($deparr) == 2) {
788 788
 			$data['departure_airport_icao'] = $deparr[0];
789 789
 			$data['arrival_airport_icao'] = $deparr[1];
790 790
 		    }
791
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
791
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]);
792 792
 	    	    $data['format_source'] = 'planeupdatefaa';
793 793
     		    $data['id_source'] = $id_source;
794 794
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
     	    $last_exec[$id]['last'] = time();
802 802
     	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
803 803
 	    $buffer = $Common->getData($value['host']);
804
-	    $all_data = json_decode($buffer,true);
804
+	    $all_data = json_decode($buffer, true);
805 805
 	    if (isset($all_data['states'])) {
806 806
 		$reset = 0;
807 807
 		foreach ($all_data['states'] as $key => $line) {
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
 		    //$data['emergency'] = ''; // emergency
819 819
 		    //$data['registration'] = $line[2];
820 820
 		    //$data['aircraft_icao'] = $line[0];
821
-		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
821
+		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]);
822 822
 	    	    $data['format_source'] = 'opensky';
823 823
     		    $data['id_source'] = $id_source;
824 824
 		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
     	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
833 833
 	    //$buffer = $Common->getData($hosts[$id]);
834 834
 	    $buffer = $Common->getData($value['host']);
835
-	    $all_data = json_decode($buffer,true);
835
+	    $all_data = json_decode($buffer, true);
836 836
 	    if (!empty($all_data)) $reset = 0;
837 837
 	    foreach ($all_data as $key => $line) {
838 838
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
@@ -865,11 +865,11 @@  discard block
 block discarded – undo
865 865
     	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) {
866 866
     	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
867 867
 	    //$buffer = $Common->getData($hosts[$id],'get','','','','','150');
868
-	    $buffer = $Common->getData($value['host'],'get','','','','','150');
868
+	    $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150');
869 869
 	    //echo $buffer;
870
-	    $buffer = str_replace(array("\n","\r"),"",$buffer);
871
-	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer);
872
-	    $all_data = json_decode($buffer,true);
870
+	    $buffer = str_replace(array("\n", "\r"), "", $buffer);
871
+	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer);
872
+	    $all_data = json_decode($buffer, true);
873 873
 	    if (json_last_error() != JSON_ERROR_NONE) {
874 874
 		die(json_last_error_msg());
875 875
 	    }
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 			//$data['departure_airport_iata'] = $line[11];
893 893
 			//$data['arrival_airport_iata'] = $line[12];
894 894
 	    		//$data['emergency'] = ''; // emergency
895
-			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
895
+			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10]
896 896
 	    		$data['format_source'] = 'radarvirtueljson';
897 897
     			$data['id_source'] = $id_source;
898 898
 			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
@@ -908,14 +908,14 @@  discard block
 block discarded – undo
908 908
     	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
909 909
 	    //$buffer = $Common->getData($hosts[$id]);
910 910
 	    $buffer = $Common->getData($value['host'].'?'.time());
911
-	    $all_data = json_decode(utf8_encode($buffer),true);
911
+	    $all_data = json_decode(utf8_encode($buffer), true);
912 912
 	    
913 913
 	    if (isset($all_data['pireps'])) {
914 914
 		$reset = 0;
915 915
 	        foreach ($all_data['pireps'] as $line) {
916 916
 		    $data = array();
917 917
 		    $data['id'] = $line['id'];
918
-		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
918
+		    $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6);
919 919
 		    $data['ident'] = $line['callsign']; // ident
920 920
 		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
921 921
 		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
@@ -945,9 +945,9 @@  discard block
 block discarded – undo
945 945
 			$SI->add($data);
946 946
 		    //    print_r($data);
947 947
     		    } elseif ($line['icon'] == 'ct') {
948
-			$data['info'] = str_replace('^&sect;','<br />',$data['info']);
949
-			$data['info'] = str_replace('&amp;sect;','',$data['info']);
950
-			$typec = substr($data['ident'],-3);
948
+			$data['info'] = str_replace('^&sect;', '<br />', $data['info']);
949
+			$data['info'] = str_replace('&amp;sect;', '', $data['info']);
950
+			$typec = substr($data['ident'], -3);
951 951
 			$data['type'] = '';
952 952
 			if ($typec == 'APP') $data['type'] = 'Approach';
953 953
 			elseif ($typec == 'TWR') $data['type'] = 'Tower';
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
959 959
 			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
960 960
 			else $data['type'] = 'Observer';
961
-			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']);
961
+			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']);
962 962
 		    }
963 963
 		    unset($data);
964 964
 		}
@@ -970,14 +970,14 @@  discard block
 block discarded – undo
970 970
 	    //$buffer = $Common->getData($hosts[$id]);
971 971
 	    if ($globalDebug) echo 'Get Data...'."\n";
972 972
 	    $buffer = $Common->getData($value['host']);
973
-	    $all_data = json_decode($buffer,true);
973
+	    $all_data = json_decode($buffer, true);
974 974
 	    if ($buffer != '' && is_array($all_data)) {
975 975
 		$reset = 0;
976 976
 		foreach ($all_data as $line) {
977 977
 	    	    $data = array();
978 978
 	    	    //$data['id'] = $line['id']; // id not usable
979 979
 	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
980
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
980
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex
981 981
 	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
982 982
 	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
983 983
 	    	    $data['ident'] = $line['flightnum']; // ident
@@ -1001,14 +1001,14 @@  discard block
 block discarded – undo
1001 1001
 		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1002 1002
 		    if (isset($line['aircraftname'])) {
1003 1003
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1004
-			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1005
-	    		$aircraft_data = explode('-',$line['aircraftname']);
1004
+			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']);
1005
+	    		$aircraft_data = explode('-', $line['aircraftname']);
1006 1006
 	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1007 1007
 	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1008 1008
 	    		else {
1009
-	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1010
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1011
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1009
+	    		    $aircraft_data = explode(' ', $line['aircraftname']);
1010
+	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]);
1011
+	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']);
1012 1012
 	    		}
1013 1013
 	    	    }
1014 1014
     		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
@@ -1028,14 +1028,14 @@  discard block
 block discarded – undo
1028 1028
 	    //$buffer = $Common->getData($hosts[$id]);
1029 1029
 	    if ($globalDebug) echo 'Get Data...'."\n";
1030 1030
 	    $buffer = $Common->getData($value['host']);
1031
-	    $all_data = json_decode($buffer,true);
1031
+	    $all_data = json_decode($buffer, true);
1032 1032
 	    if ($buffer != '' && is_array($all_data)) {
1033 1033
 		$reset = 0;
1034 1034
 		foreach ($all_data as $line) {
1035 1035
 	    	    $data = array();
1036 1036
 	    	    //$data['id'] = $line['id']; // id not usable
1037 1037
 	    	    $data['id'] = trim($line['flight_id']);
1038
-	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex
1038
+	    	    $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex
1039 1039
 	    	    $data['pilot_name'] = $line['pilot_name'];
1040 1040
 	    	    $data['pilot_id'] = $line['pilot_id'];
1041 1041
 	    	    $data['ident'] = trim($line['callsign']); // ident
@@ -1087,11 +1087,11 @@  discard block
 block discarded – undo
1087 1087
 		    //$value = $formats[$nb];
1088 1088
 		    $format = $globalSources[$nb]['format'];
1089 1089
 		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') {
1090
-			$buffer = @socket_read($r, 6000,PHP_NORMAL_READ);
1090
+			$buffer = @socket_read($r, 6000, PHP_NORMAL_READ);
1091 1091
 		    } elseif ($format == 'vrstcp') {
1092 1092
 			$buffer = @socket_read($r, 6000);
1093 1093
 		    } else {
1094
-			$az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port);
1094
+			$az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port);
1095 1095
 		    }
1096 1096
 		    //$buffer = socket_read($r, 60000,PHP_NORMAL_READ);
1097 1097
 		    //echo $buffer."\n";
@@ -1100,8 +1100,8 @@  discard block
 block discarded – undo
1100 1100
 		    $error = false;
1101 1101
 		    //$SI::del();
1102 1102
 		    if ($format == 'vrstcp') {
1103
-			$buffer = explode('},{',$buffer);
1104
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1103
+			$buffer = explode('},{', $buffer);
1104
+		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer));
1105 1105
 		    // SBS format is CSV format
1106 1106
 		    if ($buffer !== FALSE && $buffer != '') {
1107 1107
 			$tt[$format] = 0;
@@ -1135,13 +1135,13 @@  discard block
 block discarded – undo
1135 1135
 			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1136 1136
 			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1137 1137
 			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1138
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1138
+			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']);
1139 1139
 			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1140 1140
 			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1141 1141
 			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1142 1142
 
1143 1143
 			    if (isset($ais_data['timestamp'])) {
1144
-				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
1144
+				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']);
1145 1145
 			    } else {
1146 1146
 				$data['datetime'] = date('Y-m-d H:i:s');
1147 1147
 			    }
@@ -1152,10 +1152,10 @@  discard block
 block discarded – undo
1152 1152
                         } elseif ($format == 'flightgearsp') {
1153 1153
                     	    //echo $buffer."\n";
1154 1154
                     	    if (strlen($buffer) > 5) {
1155
-				$line = explode(',',$buffer);
1155
+				$line = explode(',', $buffer);
1156 1156
 				$data = array();
1157 1157
 				//XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p
1158
-				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6);
1158
+				$data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6);
1159 1159
 				$data['ident'] = $line[6];
1160 1160
 				$data['aircraft_name'] = $line[7];
1161 1161
 				$data['longitude'] = $line[1];
@@ -1167,21 +1167,21 @@  discard block
 block discarded – undo
1167 1167
 				$data['format_source'] = 'flightgearsp';
1168 1168
 				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1169 1169
 				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1170
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1170
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1171 1171
 			    }
1172 1172
                         } elseif ($format == 'acars') {
1173 1173
                     	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1174 1174
 			    $ACARS->add(trim($buffer));
1175
-			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1175
+			    socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port);
1176 1176
 			    $ACARS->deleteLiveAcarsData();
1177 1177
 			} elseif ($format == 'flightgearmp') {
1178
-			    if (substr($buffer,0,1) != '#') {
1178
+			    if (substr($buffer, 0, 1) != '#') {
1179 1179
 				$data = array();
1180 1180
 				//echo $buffer."\n";
1181
-				$line = explode(' ',$buffer);
1181
+				$line = explode(' ', $buffer);
1182 1182
 				if (count($line) == 11) {
1183
-				    $userserver = explode('@',$line[0]);
1184
-				    $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex
1183
+				    $userserver = explode('@', $line[0]);
1184
+				    $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex
1185 1185
 				    $data['ident'] = $userserver[0];
1186 1186
 				    $data['registration'] = $userserver[0];
1187 1187
 				    $data['latitude'] = $line[4];
@@ -1189,8 +1189,8 @@  discard block
 block discarded – undo
1189 1189
 				    $data['altitude'] = $line[6];
1190 1190
 				    $data['datetime'] = date('Y-m-d H:i:s');
1191 1191
 				    $aircraft_type = $line[10];
1192
-				    $aircraft_type = preg_split(':/:',$aircraft_type);
1193
-				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1192
+				    $aircraft_type = preg_split(':/:', $aircraft_type);
1193
+				    $data['aircraft_name'] = substr(end($aircraft_type), 0, -4);
1194 1194
 				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1195 1195
 				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1196 1196
 				}
@@ -1199,8 +1199,8 @@  discard block
 block discarded – undo
1199 1199
 			    echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n";
1200 1200
 			    die;
1201 1201
 			} elseif ($format == 'vrstcp') {
1202
-			    foreach($buffer as $all_data) {
1203
-				$line = json_decode('{'.$all_data.'}',true);
1202
+			    foreach ($buffer as $all_data) {
1203
+				$line = json_decode('{'.$all_data.'}', true);
1204 1204
 				$data = array();
1205 1205
 				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1206 1206
 				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
@@ -1226,16 +1226,16 @@  discard block
 block discarded – undo
1226 1226
 				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1227 1227
 				unset($data);
1228 1228
 			    }
1229
-			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
1229
+			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') {
1230 1230
 			    $line = explode("\t", $buffer);
1231
-			    for($k = 0; $k < count($line); $k=$k+2) {
1231
+			    for ($k = 0; $k < count($line); $k = $k + 2) {
1232 1232
 				$key = $line[$k];
1233
-			        $lined[$key] = $line[$k+1];
1233
+			        $lined[$key] = $line[$k + 1];
1234 1234
 			    }
1235 1235
     			    if (count($lined) > 3) {
1236 1236
     				$data['hex'] = $lined['hexid'];
1237 1237
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1238
-    				$data['datetime'] = date('Y-m-d H:i:s');;
1238
+    				$data['datetime'] = date('Y-m-d H:i:s'); ;
1239 1239
     				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1240 1240
     				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1241 1241
     				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
@@ -1254,22 +1254,22 @@  discard block
 block discarded – undo
1254 1254
     			    } else $error = true;
1255 1255
 			} elseif ($format == 'aprs' && $use_aprs) {
1256 1256
 			    if ($aprs_connect == 0) {
1257
-				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
1257
+				$send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0);
1258 1258
 				$aprs_connect = 1;
1259 1259
 			    }
1260 1260
 			    
1261
-			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) {
1261
+			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) {
1262 1262
 				$aprs_last_tx = time();
1263 1263
 				$data_aprs = "# Keep alive";
1264
-				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1264
+				$send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0);
1265 1265
 			    }
1266 1266
 			    
1267 1267
 			    //echo 'Connect : '.$aprs_connect.' '.$buffer."\n";
1268 1268
 			    //echo 'APRS data : '.$buffer."\n";
1269
-			    $buffer = str_replace('APRS <- ','',$buffer);
1270
-			    $buffer = str_replace('APRS -> ','',$buffer);
1269
+			    $buffer = str_replace('APRS <- ', '', $buffer);
1270
+			    $buffer = str_replace('APRS -> ', '', $buffer);
1271 1271
 			    //echo $buffer."\n";
1272
-			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') {
1272
+			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') {
1273 1273
 				$line = $APRS->parse($buffer);
1274 1274
 				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) {
1275 1275
 				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) {
@@ -1284,7 +1284,7 @@  discard block
 block discarded – undo
1284 1284
 				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1285 1285
 				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1286 1286
 				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1287
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1287
+				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']);
1288 1288
 				    else $data['datetime'] = date('Y-m-d H:i:s');
1289 1289
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1290 1290
 				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
@@ -1413,7 +1413,7 @@  discard block
 block discarded – undo
1413 1413
 				connect_all($sourceee);
1414 1414
 				$sourceee = array();
1415 1415
 				//connect_all($globalSources);
1416
-				$tt[$format]=0;
1416
+				$tt[$format] = 0;
1417 1417
 				break;
1418 1418
 			    }
1419 1419
 			}
@@ -1422,14 +1422,14 @@  discard block
 block discarded – undo
1422 1422
 	    } else {
1423 1423
 		$error = socket_strerror(socket_last_error());
1424 1424
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1425
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1425
+			if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n";
1426 1426
 			if (isset($globalDebug)) echo "Restarting...\n";
1427 1427
 			// Restart the script if possible
1428 1428
 			if (is_array($sockets)) {
1429 1429
 			    if ($globalDebug) echo "Shutdown all sockets...";
1430 1430
 			    
1431 1431
 			    foreach ($sockets as $sock) {
1432
-				@socket_shutdown($sock,2);
1432
+				@socket_shutdown($sock, 2);
1433 1433
 				@socket_close($sock);
1434 1434
 			    }
1435 1435
 			    
Please login to merge, or discard this patch.
Braces   +969 added lines, -333 removed lines patch added patch discarded remove patch
@@ -13,13 +13,17 @@  discard block
 block discarded – undo
13 13
 require_once(dirname(__FILE__).'/../require/class.SBS.php');
14 14
 require_once(dirname(__FILE__).'/../require/class.Connection.php');
15 15
 require_once(dirname(__FILE__).'/../require/class.Common.php');
16
-if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
16
+if (isset($globalTracker) && $globalTracker) {
17
+	require_once(dirname(__FILE__).'/../require/class.TrackerImport.php');
18
+}
17 19
 if (isset($globalMarine) && $globalMarine) {
18 20
     require_once(dirname(__FILE__).'/../require/class.AIS.php');
19 21
     require_once(dirname(__FILE__).'/../require/class.MarineImport.php');
20 22
 }
21 23
 
22
-if (!isset($globalDebug)) $globalDebug = FALSE;
24
+if (!isset($globalDebug)) {
25
+	$globalDebug = FALSE;
26
+}
23 27
 
24 28
 // Check if schema is at latest version
25 29
 $Connection = new Connection();
@@ -54,35 +58,62 @@  discard block
 block discarded – undo
54 58
 //elseif (isset($options['source'])) $hosts = array($options['source']);
55 59
 if (isset($options['s'])) {
56 60
     $globalSources = array();
57
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']);
58
-    else $globalSources[] = array('host' => $options['s']);
59
-} elseif (isset($options['source'])) {
61
+    if (isset($options['format'])) {
62
+    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']);
63
+    } else {
64
+    	$globalSources[] = array('host' => $options['s']);
65
+    }
66
+    } elseif (isset($options['source'])) {
60 67
     $globalSources = array();
61
-    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']);
62
-    else $globalSources[] = array('host' => $options['source']);
63
-}
68
+    if (isset($options['format'])) {
69
+    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']);
70
+    } else {
71
+    	$globalSources[] = array('host' => $options['source']);
72
+    }
73
+    }
64 74
 if (isset($options['aprsserverhost'])) {
65 75
 	$globalServerAPRS = TRUE;
66 76
 	$globalServerAPRShost = $options['aprsserverhost'];
67 77
 }
68
-if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport'];
69
-if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid'];
70
-if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass'];
71
-if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; 
72
-if (isset($options['nodaemon'])) $globalDaemon = FALSE;
73
-if (isset($options['server'])) $globalServer = TRUE;
74
-if (isset($options['idsource'])) $id_source = $options['idsource'];
75
-else $id_source = 1;
78
+if (isset($options['aprsserverport'])) {
79
+	$globalServerAPRSport = $options['aprsserverport'];
80
+}
81
+if (isset($options['aprsserverssid'])) {
82
+	$globalServerAPRSssid = $options['aprsserverssid'];
83
+}
84
+if (isset($options['aprsserverpass'])) {
85
+	$globalServerAPRSpass = $options['aprsserverpass'];
86
+}
87
+if (isset($options['noaprsserver'])) {
88
+	$globalServerAPRS = FALSE;
89
+}
90
+if (isset($options['nodaemon'])) {
91
+	$globalDaemon = FALSE;
92
+}
93
+if (isset($options['server'])) {
94
+	$globalServer = TRUE;
95
+}
96
+if (isset($options['idsource'])) {
97
+	$id_source = $options['idsource'];
98
+} else {
99
+	$id_source = 1;
100
+}
76 101
 if (isset($globalServer) && $globalServer) {
77
-    if ($globalDebug) echo "Using Server Mode\n";
102
+    if ($globalDebug) {
103
+    	echo "Using Server Mode\n";
104
+    }
78 105
     $SI=new SpotterServer();
79 106
 /*
80 107
     require_once(dirname(__FILE__).'/../require/class.APRS.php');
81 108
     $SI = new adsb2aprs();
82 109
     $SI->connect();
83 110
 */
84
-} else $SI=new SpotterImport($Connection->db);
85
-if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db);
111
+} else {
112
+	$SI=new SpotterImport($Connection->db);
113
+}
114
+if (isset($globalTracker) && $globalTracker) {
115
+	$TI = new TrackerImport($Connection->db);
116
+}
86 117
 if (isset($globalMarine) && $globalMarine) {
87 118
     $AIS = new AIS();
88 119
     $MI = new MarineImport($Connection->db);
@@ -104,7 +135,9 @@  discard block
 block discarded – undo
104 135
 }
105 136
 
106 137
 // let's try and connect
107
-if ($globalDebug) echo "Connecting...\n";
138
+if ($globalDebug) {
139
+	echo "Connecting...\n";
140
+}
108 141
 $use_aprs = false;
109 142
 $aprs_full = false;
110 143
 $reset = 0;
@@ -113,7 +146,9 @@  discard block
 block discarded – undo
113 146
     //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs;
114 147
     global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context;
115 148
     $reset++;
116
-    if ($globalDebug) echo 'Connect to all...'."\n";
149
+    if ($globalDebug) {
150
+    	echo 'Connect to all...'."\n";
151
+    }
117 152
     foreach ($hosts as $id => $value) {
118 153
 	$host = $value['host'];
119 154
 	$globalSources[$id]['last_exec'] = 0;
@@ -123,22 +158,30 @@  discard block
 block discarded – undo
123 158
         	//$formats[$id] = 'deltadbtxt';
124 159
         	$globalSources[$id]['format'] = 'deltadbtxt';
125 160
         	//$last_exec['deltadbtxt'] = 0;
126
-        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n";
161
+        	if ($globalDebug) {
162
+        		echo "Connect to deltadb source (".$host.")...\n";
163
+        	}
127 164
             } else if (preg_match('/vatsim-data.txt$/i',$host)) {
128 165
         	//$formats[$id] = 'vatsimtxt';
129 166
         	$globalSources[$id]['format'] = 'vatsimtxt';
130 167
         	//$last_exec['vatsimtxt'] = 0;
131
-        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n";
168
+        	if ($globalDebug) {
169
+        		echo "Connect to vatsim source (".$host.")...\n";
170
+        	}
132 171
     	    } else if (preg_match('/aircraftlist.json$/i',$host)) {
133 172
         	//$formats[$id] = 'aircraftlistjson';
134 173
         	$globalSources[$id]['format'] = 'aircraftlistjson';
135 174
         	//$last_exec['aircraftlistjson'] = 0;
136
-        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n";
175
+        	if ($globalDebug) {
176
+        		echo "Connect to aircraftlist.json source (".$host.")...\n";
177
+        	}
137 178
     	    } else if (preg_match('/opensky/i',$host)) {
138 179
         	//$formats[$id] = 'aircraftlistjson';
139 180
         	$globalSources[$id]['format'] = 'opensky';
140 181
         	//$last_exec['aircraftlistjson'] = 0;
141
-        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n";
182
+        	if ($globalDebug) {
183
+        		echo "Connect to opensky source (".$host.")...\n";
184
+        	}
142 185
     	    /*
143 186
     	    // Disabled for now, site change source format
144 187
     	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) {
@@ -155,7 +198,9 @@  discard block
 block discarded – undo
155 198
         	//$formats[$id] = 'planeupdatefaa';
156 199
         	$globalSources[$id]['format'] = 'planeupdatefaa';
157 200
         	//$last_exec['planeupdatefaa'] = 0;
158
-        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
201
+        	if ($globalDebug) {
202
+        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n";
203
+        	}
159 204
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
160 205
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
161 206
         	    exit(0);
@@ -164,26 +209,36 @@  discard block
 block discarded – undo
164 209
         	//$formats[$id] = 'phpvmacars';
165 210
         	$globalSources[$id]['format'] = 'phpvmacars';
166 211
         	//$last_exec['phpvmacars'] = 0;
167
-        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n";
212
+        	if ($globalDebug) {
213
+        		echo "Connect to phpvmacars source (".$host.")...\n";
214
+        	}
168 215
             } else if (preg_match('/VAM-json.php$/i',$host)) {
169 216
         	//$formats[$id] = 'phpvmacars';
170 217
         	$globalSources[$id]['format'] = 'vam';
171
-        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n";
218
+        	if ($globalDebug) {
219
+        		echo "Connect to Vam source (".$host.")...\n";
220
+        	}
172 221
             } else if (preg_match('/whazzup/i',$host)) {
173 222
         	//$formats[$id] = 'whazzup';
174 223
         	$globalSources[$id]['format'] = 'whazzup';
175 224
         	//$last_exec['whazzup'] = 0;
176
-        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n";
225
+        	if ($globalDebug) {
226
+        		echo "Connect to whazzup source (".$host.")...\n";
227
+        	}
177 228
             } else if (preg_match('/recentpireps/i',$host)) {
178 229
         	//$formats[$id] = 'pirepsjson';
179 230
         	$globalSources[$id]['format'] = 'pirepsjson';
180 231
         	//$last_exec['pirepsjson'] = 0;
181
-        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n";
232
+        	if ($globalDebug) {
233
+        		echo "Connect to pirepsjson source (".$host.")...\n";
234
+        	}
182 235
             } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) {
183 236
         	//$formats[$id] = 'fr24json';
184 237
         	$globalSources[$id]['format'] = 'fr24json';
185 238
         	//$last_exec['fr24json'] = 0;
186
-        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n";
239
+        	if ($globalDebug) {
240
+        		echo "Connect to fr24 source (".$host.")...\n";
241
+        	}
187 242
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
188 243
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
189 244
         	    exit(0);
@@ -192,7 +247,9 @@  discard block
 block discarded – undo
192 247
         	//$formats[$id] = 'fr24json';
193 248
         	$globalSources[$id]['format'] = 'myshiptracking';
194 249
         	//$last_exec['fr24json'] = 0;
195
-        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n";
250
+        	if ($globalDebug) {
251
+        		echo "Connect to myshiptracking source (".$host.")...\n";
252
+        	}
196 253
         	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) {
197 254
         	    echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n";
198 255
         	    exit(0);
@@ -201,17 +258,24 @@  discard block
 block discarded – undo
201 258
             } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) {
202 259
         	//$formats[$id] = 'tsv';
203 260
         	$globalSources[$id]['format'] = 'tsv';
204
-        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n";
261
+        	if ($globalDebug) {
262
+        		echo "Connect to tsv source (".$host.")...\n";
263
+        	}
205 264
             }
206 265
         } elseif (filter_var($host,FILTER_VALIDATE_URL)) {
207 266
     		if ($globalSources[$id]['format'] == 'aisnmeahttp') {
208 267
     		    $idf = fopen($globalSources[$id]['host'],'r',false,$context);
209 268
     		    if ($idf !== false) {
210 269
     			$httpfeeds[$id] = $idf;
211
-        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
270
+        		if ($globalDebug) {
271
+        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n";
272
+        		}
273
+    		    } elseif ($globalDebug) {
274
+    		    	echo "Can't connect to ".$globalSources[$id]['host']."\n";
212 275
     		    }
213
-    		    elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n";
214
-    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
276
+    		} elseif ($globalDebug) {
277
+    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n";
278
+    		}
215 279
         } elseif (!filter_var($host,FILTER_VALIDATE_URL)) {
216 280
 	    $hostport = explode(':',$host);
217 281
 	    if (isset($hostport[1])) {
@@ -251,17 +315,25 @@  discard block
 block discarded – undo
251 315
         		//$formats[$id] = 'beast';
252 316
         		$globalSources[$id]['format'] = 'beast';
253 317
 		    //} else $formats[$id] = 'sbs';
254
-		    } else $globalSources[$id]['format'] = 'sbs';
318
+		    } else {
319
+		    	$globalSources[$id]['format'] = 'sbs';
320
+		    }
255 321
 		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n";
256 322
 		}
257
-		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
323
+		if ($globalDebug) {
324
+			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n";
325
+		}
258 326
             } else {
259
-		if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
327
+		if ($globalDebug) {
328
+			echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n";
329
+		}
260 330
     	    }
261 331
         }
262 332
     }
263 333
 }
264
-if (!isset($globalMinFetch)) $globalMinFetch = 15;
334
+if (!isset($globalMinFetch)) {
335
+	$globalMinFetch = 15;
336
+}
265 337
 
266 338
 // Initialize all
267 339
 $status = array();
@@ -270,13 +342,19 @@  discard block
 block discarded – undo
270 342
 $formats = array();
271 343
 $last_exec = array();
272 344
 $time = time();
273
-if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut;
274
-else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut;
275
-else $timeout = 20;
345
+if (isset($globalSourcesTimeout)) {
346
+	$timeout = $globalSourcesTimeOut;
347
+} else if (isset($globalSBS1TimeOut)) {
348
+	$timeout = $globalSBS1TimeOut;
349
+} else {
350
+	$timeout = 20;
351
+}
276 352
 $errno = '';
277 353
 $errstr='';
278 354
 
279
-if (!isset($globalDaemon)) $globalDaemon = TRUE;
355
+if (!isset($globalDaemon)) {
356
+	$globalDaemon = TRUE;
357
+}
280 358
 /* Initiate connections to all the hosts simultaneously */
281 359
 //connect_all($hosts);
282 360
 //connect_all($globalSources);
@@ -302,7 +380,9 @@  discard block
 block discarded – undo
302 380
     if (isset($source['format']) && $source['format'] == 'aprs') {
303 381
 	$aprs_connect = 0;
304 382
 	$use_aprs = true;
305
-	if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true;
383
+	if (isset($source['port']) && $source['port'] == '10152') {
384
+		$aprs_full = true;
385
+	}
306 386
 	break;
307 387
     }
308 388
 }
@@ -313,25 +393,48 @@  discard block
 block discarded – undo
313 393
 	$aprs_connect = 0;
314 394
 	$aprs_keep = 120;
315 395
 	$aprs_last_tx = time();
316
-	if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion;
317
-	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
318
-	if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid;
319
-	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
320
-	if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter;
321
-	else $aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
322
-	if ($aprs_full) $aprs_filter = '';
323
-	if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass;
324
-	else $aprs_pass = '-1';
396
+	if (isset($globalAPRSversion)) {
397
+		$aprs_version = $globalAPRSversion;
398
+	} else {
399
+		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName);
400
+	}
401
+	if (isset($globalAPRSssid)) {
402
+		$aprs_ssid = $globalAPRSssid;
403
+	} else {
404
+		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8);
405
+	}
406
+	if (isset($globalAPRSfilter)) {
407
+		$aprs_filter = $globalAPRSfilter;
408
+	} else {
409
+		$aprs_filter =  'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0';
410
+	}
411
+	if ($aprs_full) {
412
+		$aprs_filter = '';
413
+	}
414
+	if (isset($globalAPRSpass)) {
415
+		$aprs_pass = $globalAPRSpass;
416
+	} else {
417
+		$aprs_pass = '-1';
418
+	}
325 419
 
326
-	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
327
-	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
328
-}
420
+	if ($aprs_filter != '') {
421
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n";
422
+	} else {
423
+		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n";
424
+	}
425
+	}
329 426
 
330 427
 // connected - lets do some work
331
-if ($globalDebug) echo "Connected!\n";
428
+if ($globalDebug) {
429
+	echo "Connected!\n";
430
+}
332 431
 sleep(1);
333
-if ($globalDebug) echo "SCAN MODE \n\n";
334
-if (!isset($globalCronEnd)) $globalCronEnd = 60;
432
+if ($globalDebug) {
433
+	echo "SCAN MODE \n\n";
434
+}
435
+if (!isset($globalCronEnd)) {
436
+	$globalCronEnd = 60;
437
+}
335 438
 $endtime = time()+$globalCronEnd;
336 439
 $i = 1;
337 440
 $tt = array();
@@ -345,10 +448,14 @@  discard block
 block discarded – undo
345 448
 
346 449
 // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time.
347 450
 while ($i > 0) {
348
-    if (!$globalDaemon) $i = $endtime-time();
451
+    if (!$globalDaemon) {
452
+    	$i = $endtime-time();
453
+    }
349 454
     // Delete old ATC
350 455
     if ($globalDaemon && ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) {
351
-	if ($globalDebug) echo 'Delete old ATC...'."\n";
456
+	if ($globalDebug) {
457
+		echo 'Delete old ATC...'."\n";
458
+	}
352 459
         $ATC->deleteOldATC();
353 460
     }
354 461
     
@@ -356,10 +463,14 @@  discard block
 block discarded – undo
356 463
     if (count($last_exec) == count($globalSources)) {
357 464
 	$max = $globalMinFetch;
358 465
 	foreach ($last_exec as $last) {
359
-	    if ((time() - $last['last']) < $max) $max = time() - $last['last'];
466
+	    if ((time() - $last['last']) < $max) {
467
+	    	$max = time() - $last['last'];
468
+	    }
360 469
 	}
361 470
 	if ($max != $globalMinFetch) {
362
-	    if ($globalDebug) echo 'Sleeping...'."\n";
471
+	    if ($globalDebug) {
472
+	    	echo 'Sleeping...'."\n";
473
+	    }
363 474
 	    sleep($globalMinFetch-$max+2);
364 475
 	}
365 476
     }
@@ -368,11 +479,15 @@  discard block
 block discarded – undo
368 479
     //foreach ($formats as $id => $value) {
369 480
     foreach ($globalSources as $id => $value) {
370 481
 	date_default_timezone_set('UTC');
371
-	if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0;
482
+	if (!isset($last_exec[$id]['last'])) {
483
+		$last_exec[$id]['last'] = 0;
484
+	}
372 485
 	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
373 486
 	    //$buffer = $Common->getData($hosts[$id]);
374 487
 	    $buffer = $Common->getData($value['host']);
375
-	    if ($buffer != '') $reset = 0;
488
+	    if ($buffer != '') {
489
+	    	$reset = 0;
490
+	    }
376 491
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
377 492
 	    $buffer = explode('\n',$buffer);
378 493
 	    foreach ($buffer as $line) {
@@ -381,20 +496,41 @@  discard block
 block discarded – undo
381 496
 	            $data = array();
382 497
 	            $data['hex'] = $line[1]; // hex
383 498
 	            $data['ident'] = $line[2]; // ident
384
-	            if (isset($line[3])) $data['altitude'] = $line[3]; // altitude
385
-	            if (isset($line[4])) $data['speed'] = $line[4]; // speed
386
-	            if (isset($line[5])) $data['heading'] = $line[5]; // heading
387
-	            if (isset($line[6])) $data['latitude'] = $line[6]; // lat
388
-	            if (isset($line[7])) $data['longitude'] = $line[7]; // long
499
+	            if (isset($line[3])) {
500
+	            	$data['altitude'] = $line[3];
501
+	            }
502
+	            // altitude
503
+	            if (isset($line[4])) {
504
+	            	$data['speed'] = $line[4];
505
+	            }
506
+	            // speed
507
+	            if (isset($line[5])) {
508
+	            	$data['heading'] = $line[5];
509
+	            }
510
+	            // heading
511
+	            if (isset($line[6])) {
512
+	            	$data['latitude'] = $line[6];
513
+	            }
514
+	            // lat
515
+	            if (isset($line[7])) {
516
+	            	$data['longitude'] = $line[7];
517
+	            }
518
+	            // long
389 519
 	            $data['verticalrate'] = ''; // vertical rate
390 520
 	            //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk
391 521
 	            $data['emergency'] = ''; // emergency
392 522
 		    $data['datetime'] = date('Y-m-d H:i:s');
393 523
 		    $data['format_source'] = 'deltadbtxt';
394 524
     		    $data['id_source'] = $id_source;
395
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
396
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
397
-		    if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats'];
525
+		    if (isset($value['name']) && $value['name'] != '') {
526
+		    	$data['source_name'] = $value['name'];
527
+		    }
528
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
529
+		    	$data['noarchive'] = true;
530
+		    }
531
+		    if (isset($value['sourcestats'])) {
532
+		    	$data['sourcestats'] = $value['sourcestats'];
533
+		    }
398 534
     		    $SI->add($data);
399 535
 		    unset($data);
400 536
     		}
@@ -404,7 +540,9 @@  discard block
 block discarded – undo
404 540
 	    date_default_timezone_set('CET');
405 541
 	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host']));
406 542
 	    date_default_timezone_set('UTC');
407
-	    if ($buffer != '') $reset = 0;
543
+	    if ($buffer != '') {
544
+	    	$reset = 0;
545
+	    }
408 546
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
409 547
 	    $buffer = explode('\n',$buffer);
410 548
 	    foreach ($buffer as $line) {
@@ -413,16 +551,36 @@  discard block
 block discarded – undo
413 551
 		    $add = false;
414 552
 		    $ais_data = $AIS->parse_line(trim($line));
415 553
 		    $data = array();
416
-		    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
417
-		    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
418
-		    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
419
-		    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
420
-		    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
421
-		    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
422
-		    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
423
-		    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
424
-		    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
425
-		    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
554
+		    if (isset($ais_data['ident'])) {
555
+		    	$data['ident'] = $ais_data['ident'];
556
+		    }
557
+		    if (isset($ais_data['mmsi'])) {
558
+		    	$data['mmsi'] = $ais_data['mmsi'];
559
+		    }
560
+		    if (isset($ais_data['speed'])) {
561
+		    	$data['speed'] = $ais_data['speed'];
562
+		    }
563
+		    if (isset($ais_data['heading'])) {
564
+		    	$data['heading'] = $ais_data['heading'];
565
+		    }
566
+		    if (isset($ais_data['latitude'])) {
567
+		    	$data['latitude'] = $ais_data['latitude'];
568
+		    }
569
+		    if (isset($ais_data['longitude'])) {
570
+		    	$data['longitude'] = $ais_data['longitude'];
571
+		    }
572
+		    if (isset($ais_data['status'])) {
573
+		    	$data['status'] = $ais_data['status'];
574
+		    }
575
+		    if (isset($ais_data['type'])) {
576
+		    	$data['type'] = $ais_data['type'];
577
+		    }
578
+		    if (isset($ais_data['imo'])) {
579
+		    	$data['imo'] = $ais_data['imo'];
580
+		    }
581
+		    if (isset($ais_data['callsign'])) {
582
+		    	$data['callsign'] = $ais_data['callsign'];
583
+		    }
426 584
 		    if (isset($ais_data['timestamp'])) {
427 585
 			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
428 586
 			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) {
@@ -436,8 +594,12 @@  discard block
 block discarded – undo
436 594
 		    $data['format_source'] = 'aisnmeatxt';
437 595
     		    $data['id_source'] = $id_source;
438 596
 		    //print_r($data);
439
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
440
-		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
597
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
598
+		    	$data['noarchive'] = true;
599
+		    }
600
+		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
601
+		    	$MI->add($data);
602
+		    }
441 603
 		    unset($data);
442 604
 		}
443 605
     	    }
@@ -457,20 +619,48 @@  discard block
 block discarded – undo
457 619
 			    if ($line != '') {
458 620
 				$ais_data = $AIS->parse_line(trim($line));
459 621
 				$data = array();
460
-				if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
461
-				if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
462
-				if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
463
-				if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
464
-				if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
465
-				if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
466
-				if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
467
-				if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
468
-				if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
469
-				if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid'];
470
-				if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
471
-				if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
472
-				if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
473
-				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
622
+				if (isset($ais_data['ident'])) {
623
+					$data['ident'] = $ais_data['ident'];
624
+				}
625
+				if (isset($ais_data['mmsi'])) {
626
+					$data['mmsi'] = $ais_data['mmsi'];
627
+				}
628
+				if (isset($ais_data['speed'])) {
629
+					$data['speed'] = $ais_data['speed'];
630
+				}
631
+				if (isset($ais_data['heading'])) {
632
+					$data['heading'] = $ais_data['heading'];
633
+				}
634
+				if (isset($ais_data['latitude'])) {
635
+					$data['latitude'] = $ais_data['latitude'];
636
+				}
637
+				if (isset($ais_data['longitude'])) {
638
+					$data['longitude'] = $ais_data['longitude'];
639
+				}
640
+				if (isset($ais_data['status'])) {
641
+					$data['status'] = $ais_data['status'];
642
+				}
643
+				if (isset($ais_data['statusid'])) {
644
+					$data['status_id'] = $ais_data['statusid'];
645
+				}
646
+				if (isset($ais_data['type'])) {
647
+					$data['type'] = $ais_data['type'];
648
+				}
649
+				if (isset($ais_data['typeid'])) {
650
+					$data['type_id'] = $ais_data['typeid'];
651
+				}
652
+				if (isset($ais_data['imo'])) {
653
+					$data['imo'] = $ais_data['imo'];
654
+				}
655
+				if (isset($ais_data['callsign'])) {
656
+					$data['callsign'] = $ais_data['callsign'];
657
+				}
658
+				if (isset($ais_data['destination'])) {
659
+					$data['arrival_code'] = $ais_data['destination'];
660
+				}
661
+				if (isset($ais_data['eta_ts'])) {
662
+					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
663
+				}
474 664
 				if (isset($ais_data['timestamp'])) {
475 665
 				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
476 666
 				} else {
@@ -478,18 +668,27 @@  discard block
 block discarded – undo
478 668
 				}
479 669
 				$data['format_source'] = 'aisnmeahttp';
480 670
 				$data['id_source'] = $id_source;
481
-				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
482
-				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
671
+				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
672
+					$data['noarchive'] = true;
673
+				}
674
+				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
675
+					$MI->add($data);
676
+				}
483 677
 				unset($data);
484 678
 			    }
485 679
 			}
486 680
 		    }
487 681
 		} else {
488 682
 		    $format = $value['format'];
489
-		    if (isset($tt[$format])) $tt[$format]++;
490
-		    else $tt[$format] = 0;
683
+		    if (isset($tt[$format])) {
684
+		    	$tt[$format]++;
685
+		    } else {
686
+		    	$tt[$format] = 0;
687
+		    }
491 688
 		    if ($tt[$format] > 30) {
492
-			if ($globalDebug) echo 'Reconnect...'."\n";
689
+			if ($globalDebug) {
690
+				echo 'Reconnect...'."\n";
691
+			}
493 692
 			sleep(2);
494 693
 			$sourceeen[] = $value;
495 694
 			connect_all($sourceeen);
@@ -519,7 +718,9 @@  discard block
 block discarded – undo
519 718
 			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']);
520 719
 			    $data['format_source'] = 'myshiptracking';
521 720
 			    $data['id_source'] = $id_source;
522
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
721
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
722
+			    	$data['noarchive'] = true;
723
+			    }
523 724
 			    $MI->add($data);
524 725
 			    unset($data);
525 726
 			}
@@ -539,7 +740,9 @@  discard block
 block discarded – undo
539 740
 			    $data['callsign'] = $line['callsign'];
540 741
 			    $data['mmsi'] = $line['mmsi'];
541 742
 			    $data['speed'] = $line['sog'];
542
-			    if ($line['heading'] != '511') $data['heading'] = $line['heading'];
743
+			    if ($line['heading'] != '511') {
744
+			    	$data['heading'] = $line['heading'];
745
+			    }
543 746
 			    $data['latitude'] = $line['latitude'];
544 747
 			    $data['longitude'] = $line['longitude'];
545 748
 			    $data['type_id'] = $line['shiptype'];
@@ -547,7 +750,9 @@  discard block
 block discarded – undo
547 750
 			    $data['datetime'] = $line['time'];
548 751
 			    $data['format_source'] = 'boatbeaconapp';
549 752
 			    $data['id_source'] = $id_source;
550
-			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
753
+			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
754
+			    	$data['noarchive'] = true;
755
+			    }
551 756
 			    $MI->add($data);
552 757
 			    unset($data);
553 758
 			}
@@ -563,22 +768,44 @@  discard block
 block discarded – undo
563 768
 		if (isset($all_data['features'][0]['id'])) {
564 769
 		    foreach ($all_data['features'] as $line) {
565 770
 			$data = array();
566
-			if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name'];
567
-			if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign'];
568
-			if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi'];
569
-			if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo'];
570
-			if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed'];
571
-			if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading'];
771
+			if (isset($line['properties']['name'])) {
772
+				$data['ident'] = $line['properties']['name'];
773
+			}
774
+			if (isset($line['properties']['callsign'])) {
775
+				$data['callsign'] = $line['properties']['callsign'];
776
+			}
777
+			if (isset($line['properties']['mmsi'])) {
778
+				$data['mmsi'] = $line['properties']['mmsi'];
779
+			}
780
+			if (isset($line['properties']['imo'])) {
781
+				$data['mmsi'] = $line['properties']['imo'];
782
+			}
783
+			if (isset($line['properties']['speed'])) {
784
+				$data['speed'] = $line['properties']['speed'];
785
+			}
786
+			if (isset($line['properties']['heading'])) {
787
+				$data['heading'] = $line['properties']['heading'];
788
+			}
572 789
 			$data['latitude'] = $line['geometry']['coordinates'][1];
573 790
 			$data['longitude'] = $line['geometry']['coordinates'][0];
574
-			if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType'];
575
-			if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination'];
576
-			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta'];
791
+			if (isset($line['properties']['vesselType'])) {
792
+				$data['type'] = $line['properties']['vesselType'];
793
+			}
794
+			if (isset($line['properties']['destination'])) {
795
+				$data['arrival_code'] = $line['properties']['destination'];
796
+			}
797
+			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') {
798
+				$data['arrival_date'] = $line['properties']['eta'];
799
+			}
577 800
 			$data['format_source'] = 'boatnerd';
578 801
 			$data['id_source'] = $id_source;
579 802
 			$data['datetime'] = date('Y-m-d H:i:s');
580
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
581
-			if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data);
803
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
804
+				$data['noarchive'] = true;
805
+			}
806
+			if ($line['properties']['vesselType'] != 'Navigation Aid') {
807
+				$MI->add($data);
808
+			}
582 809
 			unset($data);
583 810
 		    }
584 811
 		}
@@ -589,7 +816,9 @@  discard block
 block discarded – undo
589 816
 	    echo 'download...';
590 817
 	    $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter');
591 818
 	    echo 'done !'."\n";
592
-	    if ($buffer != '') $reset = 0;
819
+	    if ($buffer != '') {
820
+	    	$reset = 0;
821
+	    }
593 822
     	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer));
594 823
 	    $buffer = explode('\n',$buffer);
595 824
 	    foreach ($buffer as $line) {
@@ -614,7 +843,9 @@  discard block
 block discarded – undo
614 843
 		    //$data['etaTime'] = substr($line,135,5);
615 844
 		    $data['format_source'] = 'shipplotter';
616 845
     		    $data['id_source'] = $id_source;
617
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
846
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
847
+		    	$data['noarchive'] = true;
848
+		    }
618 849
 		    //print_r($data);
619 850
 		    echo 'Add...'."\n";
620 851
 		    $MI->add($data);
@@ -634,16 +865,28 @@  discard block
 block discarded – undo
634 865
     		    $line = explode(':', $line);
635 866
     		    if (count($line) > 30 && $line[0] != 'callsign') {
636 867
 			$data = array();
637
-			if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
638
-			else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
868
+			if (isset($line[37]) && $line[37] != '') {
869
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37];
870
+			} else {
871
+				$data['id'] = $value['format'].'-'.$line[1].'-'.$line[0];
872
+			}
639 873
 			$data['pilot_id'] = $line[1];
640 874
 			$data['pilot_name'] = $line[2];
641 875
 			$data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT);
642 876
 			$data['ident'] = $line[0]; // ident
643
-			if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude
877
+			if ($line[7] != '' && $line[7] != 0) {
878
+				$data['altitude'] = $line[7];
879
+			}
880
+			// altitude
644 881
 			$data['speed'] = $line[8]; // speed
645
-			if (isset($line[45])) $data['heading'] = $line[45]; // heading
646
-			elseif (isset($line[38])) $data['heading'] = $line[38]; // heading
882
+			if (isset($line[45])) {
883
+				$data['heading'] = $line[45];
884
+			}
885
+			// heading
886
+			elseif (isset($line[38])) {
887
+				$data['heading'] = $line[38];
888
+			}
889
+			// heading
647 890
 			$data['latitude'] = $line[5]; // lat
648 891
 	        	$data['longitude'] = $line[6]; // long
649 892
 	        	$data['verticalrate'] = ''; // vertical rate
@@ -659,7 +902,9 @@  discard block
 block discarded – undo
659 902
 			$data['frequency'] = $line[4];
660 903
 			$data['type'] = $line[18];
661 904
 			$data['range'] = $line[19];
662
-			if (isset($line[35])) $data['info'] = $line[35];
905
+			if (isset($line[35])) {
906
+				$data['info'] = $line[35];
907
+			}
663 908
     			$data['id_source'] = $id_source;
664 909
 	    		//$data['arrival_airport_time'] = ;
665 910
 	    		if ($line[9] != '') {
@@ -673,27 +918,47 @@  discard block
 block discarded – undo
673 918
 	    		elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt';
674 919
 	    		*/
675 920
 	    		$data['format_source'] = $value['format'];
676
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
677
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
678
-    			if ($line[3] == 'PILOT') $SI->add($data);
679
-			elseif ($line[3] == 'ATC') {
921
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
922
+				$data['noarchive'] = true;
923
+			}
924
+			if (isset($value['name']) && $value['name'] != '') {
925
+				$data['source_name'] = $value['name'];
926
+			}
927
+    			if ($line[3] == 'PILOT') {
928
+    				$SI->add($data);
929
+    			} elseif ($line[3] == 'ATC') {
680 930
 				//print_r($data);
681 931
 				$data['info'] = str_replace('^&sect;','<br />',$data['info']);
682 932
 				$data['info'] = str_replace('&amp;sect;','',$data['info']);
683 933
 				$typec = substr($data['ident'],-3);
684
-				if ($typec == 'APP') $data['type'] = 'Approach';
685
-				elseif ($typec == 'TWR') $data['type'] = 'Tower';
686
-				elseif ($typec == 'OBS') $data['type'] = 'Observer';
687
-				elseif ($typec == 'GND') $data['type'] = 'Ground';
688
-				elseif ($typec == 'DEL') $data['type'] = 'Delivery';
689
-				elseif ($typec == 'DEP') $data['type'] = 'Departure';
690
-				elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
691
-				elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
692
-				elseif ($data['type'] == '') $data['type'] = 'Observer';
693
-				if (!isset($data['source_name'])) $data['source_name'] = '';
934
+				if ($typec == 'APP') {
935
+					$data['type'] = 'Approach';
936
+				} elseif ($typec == 'TWR') {
937
+					$data['type'] = 'Tower';
938
+				} elseif ($typec == 'OBS') {
939
+					$data['type'] = 'Observer';
940
+				} elseif ($typec == 'GND') {
941
+					$data['type'] = 'Ground';
942
+				} elseif ($typec == 'DEL') {
943
+					$data['type'] = 'Delivery';
944
+				} elseif ($typec == 'DEP') {
945
+					$data['type'] = 'Departure';
946
+				} elseif ($typec == 'FSS') {
947
+					$data['type'] = 'Flight Service Station';
948
+				} elseif ($typec == 'CTR') {
949
+					$data['type'] = 'Control Radar or Centre';
950
+				} elseif ($data['type'] == '') {
951
+					$data['type'] = 'Observer';
952
+				}
953
+				if (!isset($data['source_name'])) {
954
+					$data['source_name'] = '';
955
+				}
694 956
 				if (isset($ATC)) {
695
-					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']);
696
-					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']);
957
+					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) {
958
+						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']);
959
+					} else {
960
+						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']);
961
+					}
697 962
 				}
698 963
 			}
699 964
     			unset($data);
@@ -713,27 +978,61 @@  discard block
 block discarded – undo
713 978
 		foreach ($all_data['acList'] as $line) {
714 979
 		    $data = array();
715 980
 		    $data['hex'] = $line['Icao']; // hex
716
-		    if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
717
-		    if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
718
-		    if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
719
-		    if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
720
-		    if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
721
-		    if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
981
+		    if (isset($line['Call'])) {
982
+		    	$data['ident'] = $line['Call'];
983
+		    }
984
+		    // ident
985
+		    if (isset($line['Alt'])) {
986
+		    	$data['altitude'] = $line['Alt'];
987
+		    }
988
+		    // altitude
989
+		    if (isset($line['Spd'])) {
990
+		    	$data['speed'] = $line['Spd'];
991
+		    }
992
+		    // speed
993
+		    if (isset($line['Trak'])) {
994
+		    	$data['heading'] = $line['Trak'];
995
+		    }
996
+		    // heading
997
+		    if (isset($line['Lat'])) {
998
+		    	$data['latitude'] = $line['Lat'];
999
+		    }
1000
+		    // lat
1001
+		    if (isset($line['Long'])) {
1002
+		    	$data['longitude'] = $line['Long'];
1003
+		    }
1004
+		    // long
722 1005
 		    //$data['verticalrate'] = $line['']; // verticale rate
723
-		    if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1006
+		    if (isset($line['Sqk'])) {
1007
+		    	$data['squawk'] = $line['Sqk'];
1008
+		    }
1009
+		    // squawk
724 1010
 		    $data['emergency'] = ''; // emergency
725
-		    if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1011
+		    if (isset($line['Reg'])) {
1012
+		    	$data['registration'] = $line['Reg'];
1013
+		    }
726 1014
 		    
727
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
728
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1015
+		    if (isset($line['PosTime'])) {
1016
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1017
+		    } else {
1018
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1019
+		    }
729 1020
 		    
730 1021
 		    //$data['datetime'] = date('Y-m-d H:i:s');
731
-		    if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1022
+		    if (isset($line['Type'])) {
1023
+		    	$data['aircraft_icao'] = $line['Type'];
1024
+		    }
732 1025
 	    	    $data['format_source'] = 'aircraftlistjson';
733 1026
 		    $data['id_source'] = $id_source;
734
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
735
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
736
-		    if (isset($data['latitude'])) $SI->add($data);
1027
+		    if (isset($value['name']) && $value['name'] != '') {
1028
+		    	$data['source_name'] = $value['name'];
1029
+		    }
1030
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1031
+		    	$data['noarchive'] = true;
1032
+		    }
1033
+		    if (isset($data['latitude'])) {
1034
+		    	$SI->add($data);
1035
+		    }
737 1036
 		    unset($data);
738 1037
 		}
739 1038
 	    } elseif (is_array($all_data)) {
@@ -750,12 +1049,19 @@  discard block
 block discarded – undo
750 1049
 		    $data['verticalrate'] = $line['vrt']; // verticale rate
751 1050
 		    $data['squawk'] = $line['squawk']; // squawk
752 1051
 		    $data['emergency'] = ''; // emergency
753
-		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
754
-		    else $data['datetime'] = date('Y-m-d H:i:s');
1052
+		    if (isset($line['PosTime'])) {
1053
+		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000));
1054
+		    } else {
1055
+		    	$data['datetime'] = date('Y-m-d H:i:s');
1056
+		    }
755 1057
 	    	    $data['format_source'] = 'aircraftlistjson';
756 1058
     		    $data['id_source'] = $id_source;
757
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
758
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1059
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1060
+		    	$data['noarchive'] = true;
1061
+		    }
1062
+		    if (isset($value['name']) && $value['name'] != '') {
1063
+		    	$data['source_name'] = $value['name'];
1064
+		    }
759 1065
 		    $SI->add($data);
760 1066
 		    unset($data);
761 1067
 		}
@@ -791,8 +1097,12 @@  discard block
 block discarded – undo
791 1097
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]);
792 1098
 	    	    $data['format_source'] = 'planeupdatefaa';
793 1099
     		    $data['id_source'] = $id_source;
794
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
795
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1100
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1101
+		    	$data['noarchive'] = true;
1102
+		    }
1103
+		    if (isset($value['name']) && $value['name'] != '') {
1104
+		    	$data['source_name'] = $value['name'];
1105
+		    }
796 1106
 		    $SI->add($data);
797 1107
 		    unset($data);
798 1108
 		}
@@ -821,7 +1131,9 @@  discard block
 block discarded – undo
821 1131
 		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]);
822 1132
 	    	    $data['format_source'] = 'opensky';
823 1133
     		    $data['id_source'] = $id_source;
824
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1134
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1135
+		    	$data['noarchive'] = true;
1136
+		    }
825 1137
 		    $SI->add($data);
826 1138
 		    unset($data);
827 1139
 		}
@@ -833,7 +1145,9 @@  discard block
 block discarded – undo
833 1145
 	    //$buffer = $Common->getData($hosts[$id]);
834 1146
 	    $buffer = $Common->getData($value['host']);
835 1147
 	    $all_data = json_decode($buffer,true);
836
-	    if (!empty($all_data)) $reset = 0;
1148
+	    if (!empty($all_data)) {
1149
+	    	$reset = 0;
1150
+	    }
837 1151
 	    foreach ($all_data as $key => $line) {
838 1152
 		if ($key != 'full_count' && $key != 'version' && $key != 'stats') {
839 1153
 		    $data = array();
@@ -854,8 +1168,12 @@  discard block
 block discarded – undo
854 1168
 		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10]
855 1169
 	    	    $data['format_source'] = 'fr24json';
856 1170
     		    $data['id_source'] = $id_source;
857
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
858
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1171
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1172
+		    	$data['noarchive'] = true;
1173
+		    }
1174
+		    if (isset($value['name']) && $value['name'] != '') {
1175
+		    	$data['source_name'] = $value['name'];
1176
+		    }
859 1177
 		    $SI->add($data);
860 1178
 		    unset($data);
861 1179
 		}
@@ -879,24 +1197,42 @@  discard block
 block discarded – undo
879 1197
 		    if (isset($line['inf'])) {
880 1198
 			$data = array();
881 1199
 			$data['hex'] = $line['inf']['ia'];
882
-			if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13]
1200
+			if (isset($line['inf']['cs'])) {
1201
+				$data['ident'] = $line['inf']['cs'];
1202
+			}
1203
+			//$line[13]
883 1204
 	    		$data['altitude'] = round($line['inf']['al']*3.28084); // altitude
884
-	    		if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed
885
-	    		if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading
1205
+	    		if (isset($line['inf']['gs'])) {
1206
+	    			$data['speed'] = round($line['inf']['gs']*0.539957);
1207
+	    		}
1208
+	    		// speed
1209
+	    		if (isset($line['inf']['tr'])) {
1210
+	    			$data['heading'] = $line['inf']['tr'];
1211
+	    		}
1212
+	    		// heading
886 1213
 	    		$data['latitude'] = $line['pt'][0]; // lat
887 1214
 	    		$data['longitude'] = $line['pt'][1]; // long
888 1215
 	    		//if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate
889
-	    		if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk
1216
+	    		if (isset($line['inf']['sq'])) {
1217
+	    			$data['squawk'] = $line['inf']['sq'];
1218
+	    		}
1219
+	    		// squawk
890 1220
 	    		//$data['aircraft_icao'] = $line[8];
891
-	    		if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc'];
1221
+	    		if (isset($line['inf']['rc'])) {
1222
+	    			$data['registration'] = $line['inf']['rc'];
1223
+	    		}
892 1224
 			//$data['departure_airport_iata'] = $line[11];
893 1225
 			//$data['arrival_airport_iata'] = $line[12];
894 1226
 	    		//$data['emergency'] = ''; // emergency
895 1227
 			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10]
896 1228
 	    		$data['format_source'] = 'radarvirtueljson';
897 1229
     			$data['id_source'] = $id_source;
898
-			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
899
-			if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1230
+			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1231
+				$data['noarchive'] = true;
1232
+			}
1233
+			if (isset($value['name']) && $value['name'] != '') {
1234
+				$data['source_name'] = $value['name'];
1235
+			}
900 1236
 			$SI->add($data);
901 1237
 			unset($data);
902 1238
 		    }
@@ -917,30 +1253,65 @@  discard block
 block discarded – undo
917 1253
 		    $data['id'] = $line['id'];
918 1254
 		    $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6);
919 1255
 		    $data['ident'] = $line['callsign']; // ident
920
-		    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id
921
-		    if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name
922
-		    if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude
923
-		    if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed
924
-		    if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading
925
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1256
+		    if (isset($line['pilotid'])) {
1257
+		    	$data['pilot_id'] = $line['pilotid'];
1258
+		    }
1259
+		    // pilot id
1260
+		    if (isset($line['name'])) {
1261
+		    	$data['pilot_name'] = $line['name'];
1262
+		    }
1263
+		    // pilot name
1264
+		    if (isset($line['alt'])) {
1265
+		    	$data['altitude'] = $line['alt'];
1266
+		    }
1267
+		    // altitude
1268
+		    if (isset($line['gs'])) {
1269
+		    	$data['speed'] = $line['gs'];
1270
+		    }
1271
+		    // speed
1272
+		    if (isset($line['heading'])) {
1273
+		    	$data['heading'] = $line['heading'];
1274
+		    }
1275
+		    // heading
1276
+		    if (isset($line['route'])) {
1277
+		    	$data['waypoints'] = $line['route'];
1278
+		    }
1279
+		    // route
926 1280
 		    $data['latitude'] = $line['lat']; // lat
927 1281
 		    $data['longitude'] = $line['lon']; // long
928 1282
 		    //$data['verticalrate'] = $line['vrt']; // verticale rate
929 1283
 		    //$data['squawk'] = $line['squawk']; // squawk
930 1284
 		    //$data['emergency'] = ''; // emergency
931
-		    if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao'];
932
-		    if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime'];
933
-		    if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao'];
1285
+		    if (isset($line['depicao'])) {
1286
+		    	$data['departure_airport_icao'] = $line['depicao'];
1287
+		    }
1288
+		    if (isset($line['deptime'])) {
1289
+		    	$data['departure_airport_time'] = $line['deptime'];
1290
+		    }
1291
+		    if (isset($line['arricao'])) {
1292
+		    	$data['arrival_airport_icao'] = $line['arricao'];
1293
+		    }
934 1294
 		    //$data['arrival_airport_time'] = $line['arrtime'];
935
-		    if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft'];
936
-		    if (isset($line['transponder'])) $data['squawk'] = $line['transponder'];
937
-		    if (isset($line['atis'])) $data['info'] = $line['atis'];
938
-		    else $data['info'] = '';
1295
+		    if (isset($line['aircraft'])) {
1296
+		    	$data['aircraft_icao'] = $line['aircraft'];
1297
+		    }
1298
+		    if (isset($line['transponder'])) {
1299
+		    	$data['squawk'] = $line['transponder'];
1300
+		    }
1301
+		    if (isset($line['atis'])) {
1302
+		    	$data['info'] = $line['atis'];
1303
+		    } else {
1304
+		    	$data['info'] = '';
1305
+		    }
939 1306
 		    $data['format_source'] = 'pireps';
940 1307
     		    $data['id_source'] = $id_source;
941 1308
 		    $data['datetime'] = date('Y-m-d H:i:s');
942
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
943
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1309
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1310
+		    	$data['noarchive'] = true;
1311
+		    }
1312
+		    if (isset($value['name']) && $value['name'] != '') {
1313
+		    	$data['source_name'] = $value['name'];
1314
+		    }
944 1315
 		    if ($line['icon'] == 'plane') {
945 1316
 			$SI->add($data);
946 1317
 		    //    print_r($data);
@@ -949,16 +1320,28 @@  discard block
 block discarded – undo
949 1320
 			$data['info'] = str_replace('&amp;sect;','',$data['info']);
950 1321
 			$typec = substr($data['ident'],-3);
951 1322
 			$data['type'] = '';
952
-			if ($typec == 'APP') $data['type'] = 'Approach';
953
-			elseif ($typec == 'TWR') $data['type'] = 'Tower';
954
-			elseif ($typec == 'OBS') $data['type'] = 'Observer';
955
-			elseif ($typec == 'GND') $data['type'] = 'Ground';
956
-			elseif ($typec == 'DEL') $data['type'] = 'Delivery';
957
-			elseif ($typec == 'DEP') $data['type'] = 'Departure';
958
-			elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station';
959
-			elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre';
960
-			else $data['type'] = 'Observer';
961
-			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']);
1323
+			if ($typec == 'APP') {
1324
+				$data['type'] = 'Approach';
1325
+			} elseif ($typec == 'TWR') {
1326
+				$data['type'] = 'Tower';
1327
+			} elseif ($typec == 'OBS') {
1328
+				$data['type'] = 'Observer';
1329
+			} elseif ($typec == 'GND') {
1330
+				$data['type'] = 'Ground';
1331
+			} elseif ($typec == 'DEL') {
1332
+				$data['type'] = 'Delivery';
1333
+			} elseif ($typec == 'DEP') {
1334
+				$data['type'] = 'Departure';
1335
+			} elseif ($typec == 'FSS') {
1336
+				$data['type'] = 'Flight Service Station';
1337
+			} elseif ($typec == 'CTR') {
1338
+				$data['type'] = 'Control Radar or Centre';
1339
+			} else {
1340
+				$data['type'] = 'Observer';
1341
+			}
1342
+			if (isset($ATC)) {
1343
+				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']);
1344
+			}
962 1345
 		    }
963 1346
 		    unset($data);
964 1347
 		}
@@ -968,7 +1351,9 @@  discard block
 block discarded – undo
968 1351
     	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) {
969 1352
     	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
970 1353
 	    //$buffer = $Common->getData($hosts[$id]);
971
-	    if ($globalDebug) echo 'Get Data...'."\n";
1354
+	    if ($globalDebug) {
1355
+	    	echo 'Get Data...'."\n";
1356
+	    }
972 1357
 	    $buffer = $Common->getData($value['host']);
973 1358
 	    $all_data = json_decode($buffer,true);
974 1359
 	    if ($buffer != '' && is_array($all_data)) {
@@ -976,10 +1361,16 @@  discard block
 block discarded – undo
976 1361
 		foreach ($all_data as $line) {
977 1362
 	    	    $data = array();
978 1363
 	    	    //$data['id'] = $line['id']; // id not usable
979
-	    	    if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum'];
1364
+	    	    if (isset($line['pilotid'])) {
1365
+	    	    	$data['id'] = $line['pilotid'].$line['flightnum'];
1366
+	    	    }
980 1367
 	    	    $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex
981
-	    	    if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname'];
982
-	    	    if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid'];
1368
+	    	    if (isset($line['pilotname'])) {
1369
+	    	    	$data['pilot_name'] = $line['pilotname'];
1370
+	    	    }
1371
+	    	    if (isset($line['pilotid'])) {
1372
+	    	    	$data['pilot_id'] = $line['pilotid'];
1373
+	    	    }
983 1374
 	    	    $data['ident'] = $line['flightnum']; // ident
984 1375
 	    	    $data['altitude'] = $line['alt']; // altitude
985 1376
 	    	    $data['speed'] = $line['gs']; // speed
@@ -997,28 +1388,44 @@  discard block
 block discarded – undo
997 1388
 	    	    $data['arrival_airport_icao'] = $line['arricao'];
998 1389
     		    $data['arrival_airport_time'] = $line['arrtime'];
999 1390
     		    $data['registration'] = $line['aircraft'];
1000
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1001
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1391
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1392
+		    	$data['noarchive'] = true;
1393
+		    }
1394
+		    if (isset($line['route'])) {
1395
+		    	$data['waypoints'] = $line['route'];
1396
+		    }
1397
+		    // route
1002 1398
 		    if (isset($line['aircraftname'])) {
1003 1399
 			$line['aircraftname'] = strtoupper($line['aircraftname']);
1004 1400
 			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']);
1005 1401
 	    		$aircraft_data = explode('-',$line['aircraftname']);
1006
-	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0];
1007
-	    		elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1];
1008
-	    		else {
1402
+	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) {
1403
+	    			$data['aircraft_icao'] = $aircraft_data[0];
1404
+	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) {
1405
+	    			$data['aircraft_icao'] = $aircraft_data[1];
1406
+	    		} else {
1009 1407
 	    		    $aircraft_data = explode(' ',$line['aircraftname']);
1010
-	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1011
-	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1408
+	    		    if (isset($aircraft_data[1])) {
1409
+	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]);
1410
+	    		    } else {
1411
+	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']);
1412
+	    		    }
1012 1413
 	    		}
1013 1414
 	    	    }
1014
-    		    if (isset($line['route'])) $data['waypoints'] = $line['route'];
1415
+    		    if (isset($line['route'])) {
1416
+    		    	$data['waypoints'] = $line['route'];
1417
+    		    }
1015 1418
     		    $data['id_source'] = $id_source;
1016 1419
 	    	    $data['format_source'] = 'phpvmacars';
1017
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1420
+		    if (isset($value['name']) && $value['name'] != '') {
1421
+		    	$data['source_name'] = $value['name'];
1422
+		    }
1018 1423
 		    $SI->add($data);
1019 1424
 		    unset($data);
1020 1425
 		}
1021
-		if ($globalDebug) echo 'No more data...'."\n";
1426
+		if ($globalDebug) {
1427
+			echo 'No more data...'."\n";
1428
+		}
1022 1429
 		unset($buffer);
1023 1430
 		unset($all_data);
1024 1431
 	    }
@@ -1026,7 +1433,9 @@  discard block
 block discarded – undo
1026 1433
     	    $last_exec[$id]['last'] = time();
1027 1434
     	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) {
1028 1435
 	    //$buffer = $Common->getData($hosts[$id]);
1029
-	    if ($globalDebug) echo 'Get Data...'."\n";
1436
+	    if ($globalDebug) {
1437
+	    	echo 'Get Data...'."\n";
1438
+	    }
1030 1439
 	    $buffer = $Common->getData($value['host']);
1031 1440
 	    $all_data = json_decode($buffer,true);
1032 1441
 	    if ($buffer != '' && is_array($all_data)) {
@@ -1055,16 +1464,25 @@  discard block
 block discarded – undo
1055 1464
 	    	    $data['arrival_airport_icao'] = $line['arrival'];
1056 1465
     		    //$data['arrival_airport_time'] = $line['arrival_time'];
1057 1466
     		    //$data['registration'] = $line['aircraft'];
1058
-		    if (isset($line['route'])) $data['waypoints'] = $line['route']; // route
1467
+		    if (isset($line['route'])) {
1468
+		    	$data['waypoints'] = $line['route'];
1469
+		    }
1470
+		    // route
1059 1471
 	    	    $data['aircraft_icao'] = $line['plane_type'];
1060 1472
     		    $data['id_source'] = $id_source;
1061 1473
 	    	    $data['format_source'] = 'vam';
1062
-		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true;
1063
-		    if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1474
+		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) {
1475
+		    	$data['noarchive'] = true;
1476
+		    }
1477
+		    if (isset($value['name']) && $value['name'] != '') {
1478
+		    	$data['source_name'] = $value['name'];
1479
+		    }
1064 1480
 		    $SI->add($data);
1065 1481
 		    unset($data);
1066 1482
 		}
1067
-		if ($globalDebug) echo 'No more data...'."\n";
1483
+		if ($globalDebug) {
1484
+			echo 'No more data...'."\n";
1485
+		}
1068 1486
 		unset($buffer);
1069 1487
 		unset($all_data);
1070 1488
 	    }
@@ -1072,7 +1490,9 @@  discard block
 block discarded – undo
1072 1490
     	    $last_exec[$id]['last'] = time();
1073 1491
 	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') {
1074 1492
 	} elseif ($value['format'] == 'sbs' || $value['format'] == 'tsv' || $value['format'] == 'raw' || $value['format'] == 'aprs' || $value['format'] == 'famaprs' || $value['format'] == 'beast' || $value['format'] == 'flightgearmp' || $value['format'] == 'flightgearsp' || $value['format'] == 'acars' || $value['format'] == 'acarssbs3' || $value['format'] == 'ais' || $value['format'] == 'vrstcp') {
1075
-	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch();
1493
+	    if (function_exists('pcntl_fork')) {
1494
+	    	pcntl_signal_dispatch();
1495
+	    }
1076 1496
     	    //$last_exec[$id]['last'] = time();
1077 1497
 
1078 1498
 	    //$read = array( $sockets[$id] );
@@ -1080,7 +1500,9 @@  discard block
 block discarded – undo
1080 1500
 	    $write = NULL;
1081 1501
 	    $e = NULL;
1082 1502
 	    $n = socket_select($read, $write, $e, $timeout);
1083
-	    if ($e != NULL) var_dump($e);
1503
+	    if ($e != NULL) {
1504
+	    	var_dump($e);
1505
+	    }
1084 1506
 	    if ($n > 0) {
1085 1507
 		$reset = 0;
1086 1508
 		foreach ($read as $nb => $r) {
@@ -1101,12 +1523,16 @@  discard block
 block discarded – undo
1101 1523
 		    //$SI::del();
1102 1524
 		    if ($format == 'vrstcp') {
1103 1525
 			$buffer = explode('},{',$buffer);
1104
-		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1526
+		    } else {
1527
+		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer));
1528
+		    }
1105 1529
 		    // SBS format is CSV format
1106 1530
 		    if ($buffer !== FALSE && $buffer != '') {
1107 1531
 			$tt[$format] = 0;
1108 1532
 			if ($format == 'acarssbs3') {
1109
-			    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1533
+			    if ($globalDebug) {
1534
+			    	echo 'ACARS : '.$buffer."\n";
1535
+			    }
1110 1536
 			    $ACARS->add(trim($buffer));
1111 1537
 			    $ACARS->deleteLiveAcarsData();
1112 1538
 			} elseif ($format == 'raw') {
@@ -1115,30 +1541,70 @@  discard block
 block discarded – undo
1115 1541
 			    if (is_array($data)) {
1116 1542
 				$data['datetime'] = date('Y-m-d H:i:s');
1117 1543
 				$data['format_source'] = 'raw';
1118
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1119
-				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1120
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1121
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1544
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1545
+					$data['source_name'] = $globalSources[$nb]['name'];
1546
+				}
1547
+				if (isset($globalSources[$nb]['sourcestats'])) {
1548
+					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1549
+				}
1550
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1551
+					$data['noarchive'] = true;
1552
+				}
1553
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1554
+					$SI->add($data);
1555
+				}
1122 1556
 			    }
1123 1557
 			} elseif ($format == 'ais') {
1124 1558
 			    $ais_data = $AIS->parse_line(trim($buffer));
1125 1559
 			    $data = array();
1126
-			    if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident'];
1127
-			    if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi'];
1128
-			    if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed'];
1129
-			    if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading'];
1130
-			    if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude'];
1131
-			    if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude'];
1132
-			    if (isset($ais_data['status'])) $data['status'] = $ais_data['status'];
1133
-			    if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid'];
1134
-			    if (isset($ais_data['type'])) $data['type'] = $ais_data['type'];
1135
-			    if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo'];
1136
-			    if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign'];
1137
-			    if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination'];
1138
-			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1139
-			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1140
-			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1141
-			    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1560
+			    if (isset($ais_data['ident'])) {
1561
+			    	$data['ident'] = $ais_data['ident'];
1562
+			    }
1563
+			    if (isset($ais_data['mmsi'])) {
1564
+			    	$data['mmsi'] = $ais_data['mmsi'];
1565
+			    }
1566
+			    if (isset($ais_data['speed'])) {
1567
+			    	$data['speed'] = $ais_data['speed'];
1568
+			    }
1569
+			    if (isset($ais_data['heading'])) {
1570
+			    	$data['heading'] = $ais_data['heading'];
1571
+			    }
1572
+			    if (isset($ais_data['latitude'])) {
1573
+			    	$data['latitude'] = $ais_data['latitude'];
1574
+			    }
1575
+			    if (isset($ais_data['longitude'])) {
1576
+			    	$data['longitude'] = $ais_data['longitude'];
1577
+			    }
1578
+			    if (isset($ais_data['status'])) {
1579
+			    	$data['status'] = $ais_data['status'];
1580
+			    }
1581
+			    if (isset($ais_data['statusid'])) {
1582
+			    	$data['status_id'] = $ais_data['statusid'];
1583
+			    }
1584
+			    if (isset($ais_data['type'])) {
1585
+			    	$data['type'] = $ais_data['type'];
1586
+			    }
1587
+			    if (isset($ais_data['imo'])) {
1588
+			    	$data['imo'] = $ais_data['imo'];
1589
+			    }
1590
+			    if (isset($ais_data['callsign'])) {
1591
+			    	$data['callsign'] = $ais_data['callsign'];
1592
+			    }
1593
+			    if (isset($ais_data['destination'])) {
1594
+			    	$data['arrival_code'] = $ais_data['destination'];
1595
+			    }
1596
+			    if (isset($ais_data['eta_ts'])) {
1597
+			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']);
1598
+			    }
1599
+			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1600
+			    	$data['noarchive'] = true;
1601
+			    }
1602
+			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1603
+			    	$data['source_name'] = $globalSources[$nb]['name'];
1604
+			    }
1605
+			    if (isset($globalSources[$nb]['sourcestats'])) {
1606
+			    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1607
+			    }
1142 1608
 
1143 1609
 			    if (isset($ais_data['timestamp'])) {
1144 1610
 				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']);
@@ -1147,7 +1613,9 @@  discard block
 block discarded – undo
1147 1613
 			    }
1148 1614
 			    $data['format_source'] = 'aisnmea';
1149 1615
     			    $data['id_source'] = $id_source;
1150
-			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data);
1616
+			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') {
1617
+			    	$MI->add($data);
1618
+			    }
1151 1619
 			    unset($data);
1152 1620
                         } elseif ($format == 'flightgearsp') {
1153 1621
                     	    //echo $buffer."\n";
@@ -1165,12 +1633,18 @@  discard block
 block discarded – undo
1165 1633
 				$data['speed'] = round($line[5]*1.94384);
1166 1634
 				$data['datetime'] = date('Y-m-d H:i:s');
1167 1635
 				$data['format_source'] = 'flightgearsp';
1168
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1169
-				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1636
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1637
+					$data['noarchive'] = true;
1638
+				}
1639
+				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1640
+					$SI->add($data);
1641
+				}
1170 1642
 				$send = @ socket_send( $r  , $data_aprs , strlen($data_aprs) , 0 );
1171 1643
 			    }
1172 1644
                         } elseif ($format == 'acars') {
1173
-                    	    if ($globalDebug) echo 'ACARS : '.$buffer."\n";
1645
+                    	    if ($globalDebug) {
1646
+                    	    	echo 'ACARS : '.$buffer."\n";
1647
+                    	    }
1174 1648
 			    $ACARS->add(trim($buffer));
1175 1649
 			    socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port);
1176 1650
 			    $ACARS->deleteLiveAcarsData();
@@ -1191,8 +1665,12 @@  discard block
 block discarded – undo
1191 1665
 				    $aircraft_type = $line[10];
1192 1666
 				    $aircraft_type = preg_split(':/:',$aircraft_type);
1193 1667
 				    $data['aircraft_name'] = substr(end($aircraft_type),0,-4);
1194
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1195
-				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1668
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1669
+				    	$data['noarchive'] = true;
1670
+				    }
1671
+				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1672
+				    	$SI->add($data);
1673
+				    }
1196 1674
 				}
1197 1675
 			    }
1198 1676
 			} elseif ($format == 'beast') {
@@ -1202,28 +1680,62 @@  discard block
 block discarded – undo
1202 1680
 			    foreach($buffer as $all_data) {
1203 1681
 				$line = json_decode('{'.$all_data.'}',true);
1204 1682
 				$data = array();
1205
-				if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex
1206
-				if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident
1207
-				if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude
1208
-				if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed
1209
-				if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading
1210
-				if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat
1211
-				if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long
1683
+				if (isset($line['Icao'])) {
1684
+					$data['hex'] = $line['Icao'];
1685
+				}
1686
+				// hex
1687
+				if (isset($line['Call'])) {
1688
+					$data['ident'] = $line['Call'];
1689
+				}
1690
+				// ident
1691
+				if (isset($line['Alt'])) {
1692
+					$data['altitude'] = $line['Alt'];
1693
+				}
1694
+				// altitude
1695
+				if (isset($line['Spd'])) {
1696
+					$data['speed'] = $line['Spd'];
1697
+				}
1698
+				// speed
1699
+				if (isset($line['Trak'])) {
1700
+					$data['heading'] = $line['Trak'];
1701
+				}
1702
+				// heading
1703
+				if (isset($line['Lat'])) {
1704
+					$data['latitude'] = $line['Lat'];
1705
+				}
1706
+				// lat
1707
+				if (isset($line['Long'])) {
1708
+					$data['longitude'] = $line['Long'];
1709
+				}
1710
+				// long
1212 1711
 				//$data['verticalrate'] = $line['']; // verticale rate
1213
-				if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk
1712
+				if (isset($line['Sqk'])) {
1713
+					$data['squawk'] = $line['Sqk'];
1714
+				}
1715
+				// squawk
1214 1716
 				$data['emergency'] = ''; // emergency
1215
-				if (isset($line['Reg'])) $data['registration'] = $line['Reg'];
1717
+				if (isset($line['Reg'])) {
1718
+					$data['registration'] = $line['Reg'];
1719
+				}
1216 1720
 				/*
1217 1721
 				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000);
1218 1722
 				else $data['datetime'] = date('Y-m-d H:i:s');
1219 1723
 				*/
1220 1724
 				$data['datetime'] = date('Y-m-d H:i:s');
1221
-				if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type'];
1725
+				if (isset($line['Type'])) {
1726
+					$data['aircraft_icao'] = $line['Type'];
1727
+				}
1222 1728
 		    		$data['format_source'] = 'vrstcp';
1223 1729
 				$data['id_source'] = $id_source;
1224
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1225
-				if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name'];
1226
-				if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data);
1730
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1731
+					$data['noarchive'] = true;
1732
+				}
1733
+				if (isset($value['name']) && $value['name'] != '') {
1734
+					$data['source_name'] = $value['name'];
1735
+				}
1736
+				if (isset($data['latitude']) && isset($data['hex'])) {
1737
+					$SI->add($data);
1738
+				}
1227 1739
 				unset($data);
1228 1740
 			    }
1229 1741
 			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') {
@@ -1236,22 +1748,46 @@  discard block
 block discarded – undo
1236 1748
     				$data['hex'] = $lined['hexid'];
1237 1749
     				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));;
1238 1750
     				$data['datetime'] = date('Y-m-d H:i:s');;
1239
-    				if (isset($lined['ident'])) $data['ident'] = $lined['ident'];
1240
-    				if (isset($lined['lat'])) $data['latitude'] = $lined['lat'];
1241
-    				if (isset($lined['lon'])) $data['longitude'] = $lined['lon'];
1242
-    				if (isset($lined['speed'])) $data['speed'] = $lined['speed'];
1243
-    				if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk'];
1244
-    				if (isset($lined['alt'])) $data['altitude'] = $lined['alt'];
1245
-    				if (isset($lined['heading'])) $data['heading'] = $lined['heading'];
1751
+    				if (isset($lined['ident'])) {
1752
+    					$data['ident'] = $lined['ident'];
1753
+    				}
1754
+    				if (isset($lined['lat'])) {
1755
+    					$data['latitude'] = $lined['lat'];
1756
+    				}
1757
+    				if (isset($lined['lon'])) {
1758
+    					$data['longitude'] = $lined['lon'];
1759
+    				}
1760
+    				if (isset($lined['speed'])) {
1761
+    					$data['speed'] = $lined['speed'];
1762
+    				}
1763
+    				if (isset($lined['squawk'])) {
1764
+    					$data['squawk'] = $lined['squawk'];
1765
+    				}
1766
+    				if (isset($lined['alt'])) {
1767
+    					$data['altitude'] = $lined['alt'];
1768
+    				}
1769
+    				if (isset($lined['heading'])) {
1770
+    					$data['heading'] = $lined['heading'];
1771
+    				}
1246 1772
     				$data['id_source'] = $id_source;
1247 1773
     				$data['format_source'] = 'tsv';
1248
-    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1249
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1250
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1251
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data);
1774
+    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1775
+    					$data['source_name'] = $globalSources[$nb]['name'];
1776
+    				}
1777
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1778
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1779
+    				}
1780
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1781
+					$data['noarchive'] = true;
1782
+				}
1783
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1784
+    					$SI->add($data);
1785
+    				}
1252 1786
     				unset($lined);
1253 1787
     				unset($data);
1254
-    			    } else $error = true;
1788
+    			    } else {
1789
+    			    	$error = true;
1790
+    			    }
1255 1791
 			} elseif ($format == 'aprs' && $use_aprs) {
1256 1792
 			    if ($aprs_connect == 0) {
1257 1793
 				$send = @ socket_send( $r  , $aprs_login , strlen($aprs_login) , 0 );
@@ -1276,39 +1812,86 @@  discard block
 block discarded – undo
1276 1812
 				    $aprs_last_tx = time();
1277 1813
 				    $data = array();
1278 1814
 				    //print_r($line);
1279
-				    if (isset($line['address'])) $data['hex'] = $line['address'];
1280
-				    if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi'];
1281
-				    if (isset($line['imo'])) $data['imo'] = $line['imo'];
1282
-				    if (isset($line['squawk'])) $data['squawk'] = $line['squawk'];
1283
-				    if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code'];
1284
-				    if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date'];
1285
-				    if (isset($line['type_id'])) $data['type_id'] = $line['typeid'];
1286
-				    if (isset($line['status_id'])) $data['status_id'] = $line['statusid'];
1287
-				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1288
-				    else $data['datetime'] = date('Y-m-d H:i:s');
1815
+				    if (isset($line['address'])) {
1816
+				    	$data['hex'] = $line['address'];
1817
+				    }
1818
+				    if (isset($line['mmsi'])) {
1819
+				    	$data['mmsi'] = $line['mmsi'];
1820
+				    }
1821
+				    if (isset($line['imo'])) {
1822
+				    	$data['imo'] = $line['imo'];
1823
+				    }
1824
+				    if (isset($line['squawk'])) {
1825
+				    	$data['squawk'] = $line['squawk'];
1826
+				    }
1827
+				    if (isset($line['arrival_code'])) {
1828
+				    	$data['arrical_code'] = $line['arrival_code'];
1829
+				    }
1830
+				    if (isset($line['arrival_date'])) {
1831
+				    	$data['arrical_date'] = $line['arrival_date'];
1832
+				    }
1833
+				    if (isset($line['type_id'])) {
1834
+				    	$data['type_id'] = $line['typeid'];
1835
+				    }
1836
+				    if (isset($line['status_id'])) {
1837
+				    	$data['status_id'] = $line['statusid'];
1838
+				    }
1839
+				    if (isset($line['timestamp'])) {
1840
+				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']);
1841
+				    } else {
1842
+				    	$data['datetime'] = date('Y-m-d H:i:s');
1843
+				    }
1289 1844
 				    //$data['datetime'] = date('Y-m-d H:i:s');
1290
-				    if (isset($line['ident'])) $data['ident'] = $line['ident'];
1845
+				    if (isset($line['ident'])) {
1846
+				    	$data['ident'] = $line['ident'];
1847
+				    }
1291 1848
 				    $data['latitude'] = $line['latitude'];
1292 1849
 				    $data['longitude'] = $line['longitude'];
1293 1850
 				    //$data['verticalrate'] = $line[16];
1294
-				    if (isset($line['speed'])) $data['speed'] = $line['speed'];
1295
-				    else $data['speed'] = 0;
1296
-				    if (isset($line['altitude'])) $data['altitude'] = $line['altitude'];
1297
-				    if (isset($line['comment'])) $data['comment'] = $line['comment'];
1298
-				    if (isset($line['symbol'])) $data['type'] = $line['symbol'];
1299
-				    if (isset($line['heading'])) $data['heading'] = $line['heading'];
1851
+				    if (isset($line['speed'])) {
1852
+				    	$data['speed'] = $line['speed'];
1853
+				    } else {
1854
+				    	$data['speed'] = 0;
1855
+				    }
1856
+				    if (isset($line['altitude'])) {
1857
+				    	$data['altitude'] = $line['altitude'];
1858
+				    }
1859
+				    if (isset($line['comment'])) {
1860
+				    	$data['comment'] = $line['comment'];
1861
+				    }
1862
+				    if (isset($line['symbol'])) {
1863
+				    	$data['type'] = $line['symbol'];
1864
+				    }
1865
+				    if (isset($line['heading'])) {
1866
+				    	$data['heading'] = $line['heading'];
1867
+				    }
1300 1868
 				    //else $data['heading'] = 0;
1301
-				    if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth'];
1302
-				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true;
1303
-				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1304
-				    elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false;
1869
+				    if (isset($line['stealth'])) {
1870
+				    	$data['aircraft_type'] = $line['stealth'];
1871
+				    }
1872
+				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) {
1873
+				    	$data['noarchive'] = true;
1874
+				    }
1875
+				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1876
+				    	$data['noarchive'] = true;
1877
+				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) {
1878
+				    	$data['noarchive'] = false;
1879
+				    }
1305 1880
     				    $data['id_source'] = $id_source;
1306
-    				    if (isset($line['format_source'])) $data['format_source'] = $line['format_source'];
1307
-				    else $data['format_source'] = 'aprs';
1881
+    				    if (isset($line['format_source'])) {
1882
+    				    	$data['format_source'] = $line['format_source'];
1883
+    				    } else {
1884
+				    	$data['format_source'] = 'aprs';
1885
+				    }
1308 1886
 				    $data['source_name'] = $line['source'];
1309
-				    if (isset($line['source_type'])) $data['source_type'] = $line['source_type'];
1310
-				    else $data['source_type'] = 'flarm';
1311
-    				    if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1887
+				    if (isset($line['source_type'])) {
1888
+				    	$data['source_type'] = $line['source_type'];
1889
+				    } else {
1890
+				    	$data['source_type'] = 'flarm';
1891
+				    }
1892
+    				    if (isset($globalSources[$nb]['sourcestats'])) {
1893
+    				    	$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1894
+    				    }
1312 1895
 				    $currentdate = date('Y-m-d H:i:s');
1313 1896
 				    $aprsdate = strtotime($data['datetime']);
1314 1897
 				    // Accept data if time <= system time + 20s
@@ -1316,21 +1899,26 @@  discard block
 block discarded – undo
1316 1899
 				    if (($data['source_type'] == 'modes') || isset($line['stealth']) && ($line['stealth'] == 0 || $line['stealth'] == '') && (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude'])))) {
1317 1900
 					$send = $SI->add($data);
1318 1901
 				    } elseif ($data['source_type'] == 'ais') {
1319
-					if (isset($globalMarine) && $globalMarine) $send = $MI->add($data);
1902
+					if (isset($globalMarine) && $globalMarine) {
1903
+						$send = $MI->add($data);
1904
+					}
1320 1905
 				    } elseif (isset($line['stealth'])) {
1321
-					if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1322
-					else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1906
+					if ($line['stealth'] != 0) {
1907
+						echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n";
1908
+					} else {
1909
+						echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n";
1910
+					}
1323 1911
 				    //} elseif (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' || $line['symbol'] == 'Police' || $line['symbol'] == 'Bike' || $line['symbol'] == 'Jogger' || $line['symbol'] == 'Bus' || $line['symbol'] == 'Jeep' || $line['symbol'] == 'Recreational Vehicle' || $line['symbol'] == 'Yacht (Sail)' || $line['symbol'] == 'Ship (Power Boat)' || $line['symbol'] == 'Firetruck' || $line['symbol'] == 'Balloon' || $line['symbol'] == 'Aircraft (small)' || $line['symbol'] == 'Helicopter')) {
1324 1912
 				    } elseif (isset($line['symbol']) && isset($line['latitude']) && isset($line['longitude']) && isset($line['speed']) && $line['symbol'] != 'Weather Station' && $line['symbol'] != 'House QTH (VHF)' && $line['symbol'] != 'Dot' && $line['symbol'] != 'TCP-IP' && $line['symbol'] != 'xAPRS (UNIX)' && $line['symbol'] != 'Antenna' && $line['symbol'] != 'Cloudy' && $line['symbol'] != 'HF Gateway' && $line['symbol'] != 'Yagi At QTH' && $line['symbol'] != 'Digi' && $line['symbol'] != '8' && $line['symbol'] != 'MacAPRS') {
1325 1913
 					//echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n";
1326
-					if (isset($globalTracker) && $globalTracker) $send = $TI->add($data);
1914
+					if (isset($globalTracker) && $globalTracker) {
1915
+						$send = $TI->add($data);
1916
+					}
1327 1917
 				    }
1328 1918
 				    unset($data);
1329
-				} 
1330
-				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1919
+				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') {
1331 1920
 					echo '!! Weather Station not yet supported'."\n";
1332
-				}
1333
-				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')) {
1921
+				} 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')) {
1334 1922
 					echo '!! Car & Trucks not yet supported'."\n";
1335 1923
 				}
1336 1924
 				//elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n";
@@ -1363,26 +1951,45 @@  discard block
 block discarded – undo
1363 1951
     				$data['ground'] = $line[21];
1364 1952
     				$data['emergency'] = $line[19];
1365 1953
     				$data['format_source'] = 'sbs';
1366
-				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name'];
1367
-    				if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1368
-				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true;
1954
+				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') {
1955
+					$data['source_name'] = $globalSources[$nb]['name'];
1956
+				}
1957
+    				if (isset($globalSources[$nb]['sourcestats'])) {
1958
+    					$data['sourcestats'] = $globalSources[$nb]['sourcestats'];
1959
+    				}
1960
+				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) {
1961
+					$data['noarchive'] = true;
1962
+				}
1369 1963
     				$data['id_source'] = $id_source;
1370
-    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data);
1371
-    				else $error = true;
1964
+    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) {
1965
+    					$send = $SI->add($data);
1966
+    				} else {
1967
+    					$error = true;
1968
+    				}
1372 1969
     				unset($data);
1373
-    			    } else $error = true;
1970
+    			    } else {
1971
+    			    	$error = true;
1972
+    			    }
1374 1973
 			    if ($error) {
1375 1974
 				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) { 
1376
-					if ($globalDebug) echo "Not a message. Ignoring... \n";
1975
+					if ($globalDebug) {
1976
+						echo "Not a message. Ignoring... \n";
1977
+					}
1377 1978
 				} else {
1378
-					if ($globalDebug) echo "Wrong line format. Ignoring... \n";
1979
+					if ($globalDebug) {
1980
+						echo "Wrong line format. Ignoring... \n";
1981
+					}
1379 1982
 					if ($globalDebug) {
1380 1983
 						echo $buffer;
1381 1984
 						//print_r($line);
1382 1985
 					}
1383 1986
 					//socket_close($r);
1384
-					if ($globalDebug) echo "Reconnect after an error...\n";
1385
-					if ($format == 'aprs') $aprs_connect = 0;
1987
+					if ($globalDebug) {
1988
+						echo "Reconnect after an error...\n";
1989
+					}
1990
+					if ($format == 'aprs') {
1991
+						$aprs_connect = 0;
1992
+					}
1386 1993
 					$sourceer[$nb] = $globalSources[$nb];
1387 1994
 					connect_all($sourceer);
1388 1995
 					$sourceer = array();
@@ -1390,10 +1997,14 @@  discard block
 block discarded – undo
1390 1997
 			    }
1391 1998
 			}
1392 1999
 			// Sleep for xxx microseconds
1393
-			if (isset($globalSBSSleep)) usleep($globalSBSSleep);
2000
+			if (isset($globalSBSSleep)) {
2001
+				usleep($globalSBSSleep);
2002
+			}
1394 2003
 		    } else {
1395 2004
 			if ($format == 'flightgearmp') {
1396
-			    	if ($globalDebug) echo "Reconnect FlightGear MP...";
2005
+			    	if ($globalDebug) {
2006
+			    		echo "Reconnect FlightGear MP...";
2007
+			    	}
1397 2008
 				//@socket_close($r);
1398 2009
 				sleep($globalMinFetch);
1399 2010
 				$sourcefg[$nb] = $globalSources[$nb];
@@ -1402,10 +2013,15 @@  discard block
 block discarded – undo
1402 2013
 				break;
1403 2014
 				
1404 2015
 			} elseif ($format != 'acars' && $format != 'flightgearsp') {
1405
-			    if (isset($tt[$format])) $tt[$format]++;
1406
-			    else $tt[$format] = 0;
2016
+			    if (isset($tt[$format])) {
2017
+			    	$tt[$format]++;
2018
+			    } else {
2019
+			    	$tt[$format] = 0;
2020
+			    }
1407 2021
 			    if ($tt[$format] > 30) {
1408
-				if ($globalDebug) echo "ERROR : Reconnect ".$format."...";
2022
+				if ($globalDebug) {
2023
+					echo "ERROR : Reconnect ".$format."...";
2024
+				}
1409 2025
 				//@socket_close($r);
1410 2026
 				sleep(2);
1411 2027
 				$aprs_connect = 0;
@@ -1422,11 +2038,17 @@  discard block
 block discarded – undo
1422 2038
 	    } else {
1423 2039
 		$error = socket_strerror(socket_last_error());
1424 2040
 		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) {
1425
-			if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n";
1426
-			if (isset($globalDebug)) echo "Restarting...\n";
2041
+			if ($globalDebug) {
2042
+				echo "ERROR : socket_select give this error ".$error . "\n";
2043
+			}
2044
+			if (isset($globalDebug)) {
2045
+				echo "Restarting...\n";
2046
+			}
1427 2047
 			// Restart the script if possible
1428 2048
 			if (is_array($sockets)) {
1429
-			    if ($globalDebug) echo "Shutdown all sockets...";
2049
+			    if ($globalDebug) {
2050
+			    	echo "Shutdown all sockets...";
2051
+			    }
1430 2052
 			    
1431 2053
 			    foreach ($sockets as $sock) {
1432 2054
 				@socket_shutdown($sock,2);
@@ -1434,22 +2056,36 @@  discard block
 block discarded – undo
1434 2056
 			    }
1435 2057
 			    
1436 2058
 			}
1437
-			if ($globalDebug) echo "Waiting...";
2059
+			if ($globalDebug) {
2060
+				echo "Waiting...";
2061
+			}
1438 2062
 			sleep(2);
1439 2063
 			$time = time();
1440 2064
 			//connect_all($hosts);
1441 2065
 			$aprs_connect = 0;
1442
-			if ($reset%5 == 0) sleep(20);
1443
-			if ($reset%10 == 0) sleep(100);
1444
-			if ($reset%20 == 0) sleep(200);
1445
-			if ($reset > 100) exit('Too many attempts...');
1446
-			if ($globalDebug) echo "Restart all connections...";
2066
+			if ($reset%5 == 0) {
2067
+				sleep(20);
2068
+			}
2069
+			if ($reset%10 == 0) {
2070
+				sleep(100);
2071
+			}
2072
+			if ($reset%20 == 0) {
2073
+				sleep(200);
2074
+			}
2075
+			if ($reset > 100) {
2076
+				exit('Too many attempts...');
2077
+			}
2078
+			if ($globalDebug) {
2079
+				echo "Restart all connections...";
2080
+			}
1447 2081
 			connect_all($globalSources);
1448 2082
 		}
1449 2083
 	    }
1450 2084
 	}
1451 2085
 	if ($globalDaemon === false) {
1452
-	    if ($globalDebug) echo 'Check all...'."\n";
2086
+	    if ($globalDebug) {
2087
+	    	echo 'Check all...'."\n";
2088
+	    }
1453 2089
 	    $SI->checkAll();
1454 2090
 	}
1455 2091
     }
Please login to merge, or discard this patch.
atc-data.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,15 +40,15 @@
 block discarded – undo
40 40
 //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41 41
 print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
42 42
 if ($spotter_item['atc_range'] > 0) {
43
-    print '<div><span>'._("Range").'</span>';
44
-    print $spotter_item['atc_range'];
45
-    print '</div>';
43
+	print '<div><span>'._("Range").'</span>';
44
+	print $spotter_item['atc_range'];
45
+	print '</div>';
46 46
 }
47 47
 print '</div>';
48 48
 if ($spotter_item['info'] != '') {
49
-    print '<div class="notamtext"><span>'._("Info").'</span>';
50
-    print $spotter_item['info'];
51
-    print '</div>';
49
+	print '<div class="notamtext"><span>'._("Info").'</span>';
50
+	print $spotter_item['info'];
51
+	print '</div>';
52 52
 }
53 53
 print '</div>';
54 54
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -5,8 +5,8 @@  discard block
 block discarded – undo
5 5
 $ATC = new ATC();
6 6
 
7 7
 if (isset($_GET['atcid'])) {
8
-	$atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT);
9
-	$atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING);
8
+	$atcid = filter_input(INPUT_GET, 'atcid', FILTER_SANITIZE_NUMBER_INT);
9
+	$atcident = filter_input(INPUT_GET, 'atcident', FILTER_SANITIZE_STRING);
10 10
 	$atc_data = $ATC->getById($atcid);
11 11
 	if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident);
12 12
  ?>
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 print '</div>';
39 39
 
40 40
 //print '<div><span>'._("Country").'</span>'.$spotter_item['country'].'</div>';
41
-print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'],3).', '.round($spotter_item['longitude'],3).'</div>';
41
+print '<div><span>'._("Coordinates").'</span>'.round($spotter_item['latitude'], 3).', '.round($spotter_item['longitude'], 3).'</div>';
42 42
 if ($spotter_item['atc_range'] > 0) {
43 43
     print '<div><span>'._("Range").'</span>';
44 44
     print $spotter_item['atc_range'];
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@
 block discarded – undo
8 8
 	$atcid = filter_input(INPUT_GET,'atcid',FILTER_SANITIZE_NUMBER_INT);
9 9
 	$atcident = filter_input(INPUT_GET,'atcident',FILTER_SANITIZE_STRING);
10 10
 	$atc_data = $ATC->getById($atcid);
11
-	if (!isset($atc_data[0])) $atc_data = $ATC->getByIdent($atcident);
11
+	if (!isset($atc_data[0])) {
12
+		$atc_data = $ATC->getByIdent($atcident);
13
+	}
12 14
  ?>
13 15
 <div class="alldetails">
14 16
 <button type="button" class="close">&times;</button>
Please login to merge, or discard this patch.
atc-geojson.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 		date_default_timezone_set('UTC');
25 25
 		//waypoint plotting
26 26
 		$output .= '{"type": "Feature",';
27
-		    $output .= '"properties": {';
27
+			$output .= '"properties": {';
28 28
 			$output .= '"ref": "'.$spotter_item['atc_id'].'",';
29 29
 			$output .= '"ident": "'.$spotter_item['ident'].'",';
30 30
 			$output .= '"frequency": "'.$spotter_item['frequency'].'",';
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
 			} else {
51 51
 				$output .= '"icon": "images/atc.png"';
52 52
 			}
53
-		    $output .= '},';
54
-		    $output .= '"geometry": {';
53
+			$output .= '},';
54
+			$output .= '"geometry": {';
55 55
 			$output .= '"type": "Point",';
56 56
 			$output .= '"coordinates": [';
57
-			    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
57
+				$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
58 58
 			$output .= ']';
59
-		    $output .= '}';
59
+			$output .= '}';
60 60
 		$output .= '},';
61 61
 		$radius = $spotter_item['atc_range']*100;
62 62
 		if ($radius > 0) {
63 63
 			$output .= '{"type": "Feature",';
64
-			    $output .= '"properties": {';
64
+				$output .= '"properties": {';
65 65
 				$output .= '"ref": "'.$spotter_item['atc_id'].'",';
66 66
 				$output .= '"ident": "'.$spotter_item['ident'].'",';
67 67
 				$output .= '"frequency": "'.$spotter_item['frequency'].'",';
@@ -87,13 +87,13 @@  discard block
 block discarded – undo
87 87
 				} else {
88 88
 					$output .= '"atccolor": "#888219"';
89 89
 				}
90
-			    $output .= '},';
91
-			    $output .= '"geometry": {';
90
+				$output .= '},';
91
+				$output .= '"geometry": {';
92 92
 				$output .= '"type": "Point",';
93 93
 				$output .= '"coordinates": [';
94
-				    $output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
94
+					$output .= $spotter_item['longitude'].', '.$spotter_item['latitude'];
95 95
 				$output .= ']';
96
-			    $output .= '}';
96
+				$output .= '}';
97 97
 			$output .= '},';
98 98
 		}
99 99
 	}
Please login to merge, or discard this patch.