| @@ -6,6 +6,9 @@ discard block | ||
| 6 | 6 | public $dbs = array(); | 
| 7 | 7 | public $latest_schema = 42; | 
| 8 | 8 | |
| 9 | + /** | |
| 10 | + * @param string $dbname | |
| 11 | + */ | |
| 9 | 12 |  	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { | 
| 10 | 13 | global $globalDBdriver, $globalNoDB; | 
| 11 | 14 |  	    if (isset($globalNoDB) && $globalNoDB === TRUE) { | 
| @@ -141,6 +144,9 @@ discard block | ||
| 141 | 144 | return true; | 
| 142 | 145 | } | 
| 143 | 146 | |
| 147 | + /** | |
| 148 | + * @param string $table | |
| 149 | + */ | |
| 144 | 150 | public function tableExists($table) | 
| 145 | 151 |  	{ | 
| 146 | 152 | global $globalDBdriver, $globalDBname; | 
| @@ -190,6 +196,11 @@ discard block | ||
| 190 | 196 | /* | 
| 191 | 197 | * Check if index exist | 
| 192 | 198 | */ | 
| 199 | + | |
| 200 | + /** | |
| 201 | + * @param string $table | |
| 202 | + * @param string $index | |
| 203 | + */ | |
| 193 | 204 | public function indexExists($table,$index) | 
| 194 | 205 |  	{ | 
| 195 | 206 | global $globalDBdriver, $globalDBname; | 
| @@ -232,6 +243,10 @@ discard block | ||
| 232 | 243 | return $columns; | 
| 233 | 244 | } | 
| 234 | 245 | |
| 246 | + /** | |
| 247 | + * @param string $table | |
| 248 | + * @param string $column | |
| 249 | + */ | |
| 235 | 250 |  	public function getColumnType($table,$column) { | 
| 236 | 251 |  		$select = $this->db->query('SELECT '.$column.' FROM '.$table); | 
| 237 | 252 | $tomet = $select->getColumnMeta(0); | 
| @@ -242,6 +257,11 @@ discard block | ||
| 242 | 257 | * Check if a column name exist in a table | 
| 243 | 258 | * @return Boolean column exist or not | 
| 244 | 259 | */ | 
| 260 | + | |
| 261 | + /** | |
| 262 | + * @param string $table | |
| 263 | + * @param string $name | |
| 264 | + */ | |
| 245 | 265 | public function checkColumnName($table,$name) | 
| 246 | 266 |  	{ | 
| 247 | 267 | global $globalDBdriver, $globalDBname; | 
| @@ -7,35 +7,35 @@ discard block | ||
| 7 | 7 | public $latest_schema = 42; | 
| 8 | 8 | |
| 9 | 9 |  	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { | 
| 10 | - global $globalDBdriver, $globalNoDB; | |
| 11 | -	    if (isset($globalNoDB) && $globalNoDB === TRUE) { | |
| 10 | + global $globalDBdriver, $globalNoDB; | |
| 11 | +		if (isset($globalNoDB) && $globalNoDB === TRUE) { | |
| 12 | 12 | $this->db = null; | 
| 13 | -	    } else { | |
| 13 | +		} else { | |
| 14 | 14 |  		if ($dbc === null) { | 
| 15 | -		    if ($this->db === null && $dbname === null) { | |
| 15 | +			if ($this->db === null && $dbname === null) { | |
| 16 | 16 |  			if ($user === null && $pass === null) { | 
| 17 | - $this->createDBConnection(); | |
| 17 | + $this->createDBConnection(); | |
| 18 | 18 |  			} else { | 
| 19 | - $this->createDBConnection(null,$user,$pass); | |
| 19 | + $this->createDBConnection(null,$user,$pass); | |
| 20 | 20 | } | 
| 21 | -		    } else { | |
| 21 | +			} else { | |
| 22 | 22 | $this->createDBConnection($dbname); | 
| 23 | - } | |
| 23 | + } | |
| 24 | 24 |  		} elseif ($dbname === null || $dbname === 'default') { | 
| 25 | - $this->db = $dbc; | |
| 26 | -	    	    if ($this->connectionExists() === false) { | |
| 25 | + $this->db = $dbc; | |
| 26 | +				if ($this->connectionExists() === false) { | |
| 27 | 27 | /* | 
| 28 | 28 | echo 'Restart Connection !!!'."\n"; | 
| 29 | 29 | $e = new \Exception; | 
| 30 | 30 | var_dump($e->getTraceAsString()); | 
| 31 | 31 | */ | 
| 32 | 32 | $this->createDBConnection(); | 
| 33 | - } | |
| 33 | + } | |
| 34 | 34 |  		} else { | 
| 35 | - //$this->connectionExists(); | |
| 36 | - $this->dbs[$dbname] = $dbc; | |
| 35 | + //$this->connectionExists(); | |
| 36 | + $this->dbs[$dbname] = $dbc; | |
| 37 | + } | |
| 37 | 38 | } | 
| 38 | - } | |
| 39 | 39 | } | 
| 40 | 40 | |
| 41 | 41 |  	public function db() { | 
| @@ -56,11 +56,11 @@ discard block | ||
| 56 | 56 | } | 
| 57 | 57 | |
| 58 | 58 | /** | 
| 59 | - * Creates the database connection | |
| 60 | - * | |
| 61 | - * @return Boolean of the database connection | |
| 62 | - * | |
| 63 | - */ | |
| 59 | + * Creates the database connection | |
| 60 | + * | |
| 61 | + * @return Boolean of the database connection | |
| 62 | + * | |
| 63 | + */ | |
| 64 | 64 | |
| 65 | 65 | public function createDBConnection($DBname = null, $user = null, $pass = null) | 
| 66 | 66 |  	{ | 
| @@ -157,7 +157,7 @@ discard block | ||
| 157 | 157 | return false; | 
| 158 | 158 | } | 
| 159 | 159 |  		if($results->rowCount()>0) { | 
| 160 | - return true; | |
| 160 | + return true; | |
| 161 | 161 | } | 
| 162 | 162 | else return false; | 
| 163 | 163 | } | 
| @@ -174,14 +174,14 @@ discard block | ||
| 174 | 174 | $sum = $sum->fetchColumn(0); | 
| 175 | 175 | } else $sum = 0; | 
| 176 | 176 |  			if (intval($sum) !== 2) { | 
| 177 | - return false; | |
| 177 | + return false; | |
| 178 | 178 | } | 
| 179 | 179 | |
| 180 | 180 |  		} catch(PDOException $e) { | 
| 181 | 181 |  			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { | 
| 182 | - throw $e; | |
| 183 | - } | |
| 184 | - //echo 'error ! '.$e->getMessage(); | |
| 182 | + throw $e; | |
| 183 | + } | |
| 184 | + //echo 'error ! '.$e->getMessage(); | |
| 185 | 185 | return false; | 
| 186 | 186 | } | 
| 187 | 187 | return true; | 
| @@ -285,8 +285,8 @@ discard block | ||
| 285 | 285 | $version = 0; | 
| 286 | 286 |  		if ($this->tableExists('aircraft')) { | 
| 287 | 287 |  			if (!$this->tableExists('config')) { | 
| 288 | - $version = '1'; | |
| 289 | - return $version; | |
| 288 | + $version = '1'; | |
| 289 | + return $version; | |
| 290 | 290 |  			} else { | 
| 291 | 291 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; | 
| 292 | 292 |  				try { | 
| @@ -307,10 +307,10 @@ discard block | ||
| 307 | 307 | * @return Boolean if latest version or not | 
| 308 | 308 | */ | 
| 309 | 309 |  	public function latest() { | 
| 310 | - global $globalNoDB; | |
| 311 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; | |
| 312 | - if ($this->check_schema_version() == $this->latest_schema) return true; | |
| 313 | - else return false; | |
| 310 | + global $globalNoDB; | |
| 311 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; | |
| 312 | + if ($this->check_schema_version() == $this->latest_schema) return true; | |
| 313 | + else return false; | |
| 314 | 314 | } | 
| 315 | 315 | |
| 316 | 316 | } | 
| @@ -1,12 +1,12 @@ discard block | ||
| 1 | 1 | <?php | 
| 2 | 2 | require_once(dirname(__FILE__).'/settings.php'); | 
| 3 | 3 | |
| 4 | -class Connection{ | |
| 4 | +class Connection { | |
| 5 | 5 | public $db = null; | 
| 6 | 6 | public $dbs = array(); | 
| 7 | 7 | public $latest_schema = 42; | 
| 8 | 8 | |
| 9 | -	public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { | |
| 9 | +	public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { | |
| 10 | 10 | global $globalDBdriver, $globalNoDB; | 
| 11 | 11 |  	    if (isset($globalNoDB) && $globalNoDB === TRUE) { | 
| 12 | 12 | $this->db = null; | 
| @@ -16,7 +16,7 @@ discard block | ||
| 16 | 16 |  			if ($user === null && $pass === null) { | 
| 17 | 17 | $this->createDBConnection(); | 
| 18 | 18 |  			} else { | 
| 19 | - $this->createDBConnection(null,$user,$pass); | |
| 19 | + $this->createDBConnection(null, $user, $pass); | |
| 20 | 20 | } | 
| 21 | 21 |  		    } else { | 
| 22 | 22 | $this->createDBConnection($dbname); | 
| @@ -100,14 +100,14 @@ discard block | ||
| 100 | 100 |  		while (true) { | 
| 101 | 101 |  			try { | 
| 102 | 102 |  				if ($globalDBSdriver == 'mysql') { | 
| 103 | -					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser,  $globalDBSpass); | |
| 103 | +					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); | |
| 104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); | 
| 105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | 
| 106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); | |
| 107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); | |
| 108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); | |
| 109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); | |
| 110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); | |
| 106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); | |
| 107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); | |
| 108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); | |
| 109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); | |
| 110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); | |
| 111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); | 
| 112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); | 
| 113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode | 
| @@ -117,19 +117,19 @@ discard block | ||
| 117 | 117 |  					$this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); | 
| 118 | 118 |  					//$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); | 
| 119 | 119 |  				} else { | 
| 120 | -					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser,  $globalDBSpass); | |
| 120 | +					$this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); | |
| 121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); | 
| 122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | 
| 123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); | |
| 124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); | |
| 125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); | |
| 126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); | |
| 127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); | |
| 123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); | |
| 124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); | |
| 125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); | |
| 126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); | |
| 127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); | |
| 128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); | 
| 129 | 129 |  					$this->dbs[$DBname]->exec('SET timezone="UTC"'); | 
| 130 | 130 | } | 
| 131 | 131 | break; | 
| 132 | -			} catch(PDOException $e) { | |
| 132 | +			} catch (PDOException $e) { | |
| 133 | 133 | $i++; | 
| 134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; | 
| 135 | 135 | //exit; | 
| @@ -153,10 +153,10 @@ discard block | ||
| 153 | 153 |  		try { | 
| 154 | 154 | //$Connection = new Connection(); | 
| 155 | 155 | $results = $this->db->query($query); | 
| 156 | -		} catch(PDOException $e) { | |
| 156 | +		} catch (PDOException $e) { | |
| 157 | 157 | return false; | 
| 158 | 158 | } | 
| 159 | -		if($results->rowCount()>0) { | |
| 159 | +		if ($results->rowCount() > 0) { | |
| 160 | 160 | return true; | 
| 161 | 161 | } | 
| 162 | 162 | else return false; | 
| @@ -177,8 +177,8 @@ discard block | ||
| 177 | 177 | return false; | 
| 178 | 178 | } | 
| 179 | 179 | |
| 180 | -		} catch(PDOException $e) { | |
| 181 | -			if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { | |
| 180 | +		} catch (PDOException $e) { | |
| 181 | +			if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { | |
| 182 | 182 | throw $e; | 
| 183 | 183 | } | 
| 184 | 184 | //echo 'error ! '.$e->getMessage(); | 
| @@ -190,7 +190,7 @@ discard block | ||
| 190 | 190 | /* | 
| 191 | 191 | * Check if index exist | 
| 192 | 192 | */ | 
| 193 | - public function indexExists($table,$index) | |
| 193 | + public function indexExists($table, $index) | |
| 194 | 194 |  	{ | 
| 195 | 195 | global $globalDBdriver, $globalDBname; | 
| 196 | 196 |  		if ($globalDBdriver == 'mysql') { | 
| @@ -201,11 +201,11 @@ discard block | ||
| 201 | 201 |  		try { | 
| 202 | 202 | //$Connection = new Connection(); | 
| 203 | 203 | $results = $this->db->query($query); | 
| 204 | -		} catch(PDOException $e) { | |
| 204 | +		} catch (PDOException $e) { | |
| 205 | 205 | return false; | 
| 206 | 206 | } | 
| 207 | 207 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); | 
| 208 | -		if($nb[0]['nb'] > 0) { | |
| 208 | +		if ($nb[0]['nb'] > 0) { | |
| 209 | 209 | return true; | 
| 210 | 210 | } | 
| 211 | 211 | else return false; | 
| @@ -220,7 +220,7 @@ discard block | ||
| 220 | 220 | $query = "SELECT * FROM ".$table." LIMIT 0"; | 
| 221 | 221 |  		try { | 
| 222 | 222 | $results = $this->db->query($query); | 
| 223 | -		} catch(PDOException $e) { | |
| 223 | +		} catch (PDOException $e) { | |
| 224 | 224 | return "error : ".$e->getMessage()."\n"; | 
| 225 | 225 | } | 
| 226 | 226 | $columns = array(); | 
| @@ -232,7 +232,7 @@ discard block | ||
| 232 | 232 | return $columns; | 
| 233 | 233 | } | 
| 234 | 234 | |
| 235 | -	public function getColumnType($table,$column) { | |
| 235 | +	public function getColumnType($table, $column) { | |
| 236 | 236 |  		$select = $this->db->query('SELECT '.$column.' FROM '.$table); | 
| 237 | 237 | $tomet = $select->getColumnMeta(0); | 
| 238 | 238 | return $tomet['native_type']; | 
| @@ -242,7 +242,7 @@ discard block | ||
| 242 | 242 | * Check if a column name exist in a table | 
| 243 | 243 | * @return Boolean column exist or not | 
| 244 | 244 | */ | 
| 245 | - public function checkColumnName($table,$name) | |
| 245 | + public function checkColumnName($table, $name) | |
| 246 | 246 |  	{ | 
| 247 | 247 | global $globalDBdriver, $globalDBname; | 
| 248 | 248 |  		if ($globalDBdriver == 'mysql') { | 
| @@ -252,8 +252,8 @@ discard block | ||
| 252 | 252 | } | 
| 253 | 253 |  			try { | 
| 254 | 254 | $sth = $this->db()->prepare($query); | 
| 255 | -				$sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); | |
| 256 | -			} catch(PDOException $e) { | |
| 255 | +				$sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); | |
| 256 | +			} catch (PDOException $e) { | |
| 257 | 257 | echo "error : ".$e->getMessage()."\n"; | 
| 258 | 258 | } | 
| 259 | 259 | $result = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -292,7 +292,7 @@ discard block | ||
| 292 | 292 |  				try { | 
| 293 | 293 | $sth = $this->db->prepare($query); | 
| 294 | 294 | $sth->execute(); | 
| 295 | -				} catch(PDOException $e) { | |
| 295 | +				} catch (PDOException $e) { | |
| 296 | 296 | return "error : ".$e->getMessage()."\n"; | 
| 297 | 297 | } | 
| 298 | 298 | $result = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -16,8 +16,8 @@ discard block | ||
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); | 
| 17 | 17 | if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | 
| 18 | 18 |  if (isset($globalMarine) && $globalMarine) { | 
| 19 | - require_once(dirname(__FILE__).'/../require/class.AIS.php'); | |
| 20 | - require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); | |
| 19 | + require_once(dirname(__FILE__).'/../require/class.AIS.php'); | |
| 20 | + require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); | |
| 21 | 21 | } | 
| 22 | 22 | |
| 23 | 23 | if (!isset($globalDebug)) $globalDebug = FALSE; | 
| @@ -25,42 +25,42 @@ discard block | ||
| 25 | 25 | // Check if schema is at latest version | 
| 26 | 26 | $Connection = new Connection(); | 
| 27 | 27 |  if ($Connection->latest() === false) { | 
| 28 | - echo "You MUST update to latest schema. Run install/index.php"; | |
| 29 | - exit(); | |
| 28 | + echo "You MUST update to latest schema. Run install/index.php"; | |
| 29 | + exit(); | |
| 30 | 30 | } | 
| 31 | 31 |  if (PHP_SAPI != 'cli') { | 
| 32 | - echo "This script MUST be called from console, not a web browser."; | |
| 32 | + echo "This script MUST be called from console, not a web browser."; | |
| 33 | 33 | // exit(); | 
| 34 | 34 | } | 
| 35 | 35 | |
| 36 | 36 | // This is to be compatible with old version of settings.php | 
| 37 | 37 |  if (!isset($globalSources)) { | 
| 38 | -    if (isset($globalSBS1Hosts)) { | |
| 39 | - //$hosts = $globalSBS1Hosts; | |
| 40 | -        foreach ($globalSBS1Hosts as $host) { | |
| 41 | -	    $globalSources[] = array('host' => $host); | |
| 42 | - } | |
| 43 | -    } else { | |
| 44 | -        if (!isset($globalSBS1Host)) { | |
| 45 | - echo '$globalSources MUST be defined !'; | |
| 46 | - die; | |
| 38 | +	if (isset($globalSBS1Hosts)) { | |
| 39 | + //$hosts = $globalSBS1Hosts; | |
| 40 | +		foreach ($globalSBS1Hosts as $host) { | |
| 41 | +		$globalSources[] = array('host' => $host); | |
| 42 | + } | |
| 43 | +	} else { | |
| 44 | +		if (!isset($globalSBS1Host)) { | |
| 45 | + echo '$globalSources MUST be defined !'; | |
| 46 | + die; | |
| 47 | 47 | } | 
| 48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); | 
| 49 | 49 |  	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); | 
| 50 | - } | |
| 50 | + } | |
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | 53 |  $options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); | 
| 54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); | 
| 55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); | 
| 56 | 56 |  if (isset($options['s'])) { | 
| 57 | - $globalSources = array(); | |
| 58 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 59 | -    else $globalSources[] = array('host' => $options['s']); | |
| 57 | + $globalSources = array(); | |
| 58 | +	if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 59 | +	else $globalSources[] = array('host' => $options['s']); | |
| 60 | 60 |  } elseif (isset($options['source'])) { | 
| 61 | - $globalSources = array(); | |
| 62 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 63 | -    else $globalSources[] = array('host' => $options['source']); | |
| 61 | + $globalSources = array(); | |
| 62 | +	if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 63 | +	else $globalSources[] = array('host' => $options['source']); | |
| 64 | 64 | } | 
| 65 | 65 |  if (isset($options['aprsserverhost'])) { | 
| 66 | 66 | $globalServerAPRS = TRUE; | 
| @@ -75,8 +75,8 @@ discard block | ||
| 75 | 75 | if (isset($options['idsource'])) $id_source = $options['idsource']; | 
| 76 | 76 | else $id_source = 1; | 
| 77 | 77 |  if (isset($globalServer) && $globalServer) { | 
| 78 | - if ($globalDebug) echo "Using Server Mode\n"; | |
| 79 | - $SI=new SpotterServer(); | |
| 78 | + if ($globalDebug) echo "Using Server Mode\n"; | |
| 79 | + $SI=new SpotterServer(); | |
| 80 | 80 | /* | 
| 81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 82 | 82 | $SI = new adsb2aprs(); | 
| @@ -85,8 +85,8 @@ discard block | ||
| 85 | 85 | } else $SI=new SpotterImport($Connection->db); | 
| 86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); | 
| 87 | 87 |  if (isset($globalMarine) && $globalMarine) { | 
| 88 | - $AIS = new AIS(); | |
| 89 | - $MI = new MarineImport($Connection->db); | |
| 88 | + $AIS = new AIS(); | |
| 89 | + $MI = new MarineImport($Connection->db); | |
| 90 | 90 | } | 
| 91 | 91 | //$APRS=new APRS($Connection->db); | 
| 92 | 92 | $SBS=new SBS(); | 
| @@ -97,12 +97,12 @@ discard block | ||
| 97 | 97 |  //$servertz = system('date +%Z'); | 
| 98 | 98 | // signal handler - playing nice with sockets and dump1090 | 
| 99 | 99 |  if (function_exists('pcntl_fork')) { | 
| 100 | -    pcntl_signal(SIGINT,  function() { | |
| 101 | - global $sockets; | |
| 102 | - echo "\n\nctrl-c or kill signal received. Tidying up ... "; | |
| 103 | -        die("Bye!\n"); | |
| 104 | - }); | |
| 105 | - pcntl_signal_dispatch(); | |
| 100 | +	pcntl_signal(SIGINT,  function() { | |
| 101 | + global $sockets; | |
| 102 | + echo "\n\nctrl-c or kill signal received. Tidying up ... "; | |
| 103 | +		die("Bye!\n"); | |
| 104 | + }); | |
| 105 | + pcntl_signal_dispatch(); | |
| 106 | 106 | } | 
| 107 | 107 | |
| 108 | 108 | // let's try and connect | 
| @@ -112,36 +112,36 @@ discard block | ||
| 112 | 112 | $reset = 0; | 
| 113 | 113 | |
| 114 | 114 |  function connect_all($hosts) { | 
| 115 | - //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | |
| 116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | |
| 117 | - $reset++; | |
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; | |
| 119 | -    foreach ($hosts as $id => $value) { | |
| 115 | + //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | |
| 116 | + global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | |
| 117 | + $reset++; | |
| 118 | + if ($globalDebug) echo 'Connect to all...'."\n"; | |
| 119 | +	foreach ($hosts as $id => $value) { | |
| 120 | 120 | $host = $value['host']; | 
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; | 
| 122 | 122 | // Here we check type of source(s) | 
| 123 | 123 |  	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { | 
| 124 | -            if (preg_match('/deltadb.txt$/i',$host)) { | |
| 125 | - //$formats[$id] = 'deltadbtxt'; | |
| 126 | - $globalSources[$id]['format'] = 'deltadbtxt'; | |
| 127 | - //$last_exec['deltadbtxt'] = 0; | |
| 128 | -        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | |
| 129 | -            } else if (preg_match('/vatsim-data.txt$/i',$host)) { | |
| 130 | - //$formats[$id] = 'vatsimtxt'; | |
| 131 | - $globalSources[$id]['format'] = 'vatsimtxt'; | |
| 132 | - //$last_exec['vatsimtxt'] = 0; | |
| 133 | -        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | |
| 134 | -    	    } else if (preg_match('/aircraftlist.json$/i',$host)) { | |
| 135 | - //$formats[$id] = 'aircraftlistjson'; | |
| 136 | - $globalSources[$id]['format'] = 'aircraftlistjson'; | |
| 137 | - //$last_exec['aircraftlistjson'] = 0; | |
| 138 | -        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 139 | -    	    } else if (preg_match('/opensky/i',$host)) { | |
| 140 | - //$formats[$id] = 'aircraftlistjson'; | |
| 141 | - $globalSources[$id]['format'] = 'opensky'; | |
| 142 | - //$last_exec['aircraftlistjson'] = 0; | |
| 143 | -        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; | |
| 144 | - /* | |
| 124 | +			if (preg_match('/deltadb.txt$/i',$host)) { | |
| 125 | + //$formats[$id] = 'deltadbtxt'; | |
| 126 | + $globalSources[$id]['format'] = 'deltadbtxt'; | |
| 127 | + //$last_exec['deltadbtxt'] = 0; | |
| 128 | +			if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | |
| 129 | +			} else if (preg_match('/vatsim-data.txt$/i',$host)) { | |
| 130 | + //$formats[$id] = 'vatsimtxt'; | |
| 131 | + $globalSources[$id]['format'] = 'vatsimtxt'; | |
| 132 | + //$last_exec['vatsimtxt'] = 0; | |
| 133 | +			if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | |
| 134 | +			} else if (preg_match('/aircraftlist.json$/i',$host)) { | |
| 135 | + //$formats[$id] = 'aircraftlistjson'; | |
| 136 | + $globalSources[$id]['format'] = 'aircraftlistjson'; | |
| 137 | + //$last_exec['aircraftlistjson'] = 0; | |
| 138 | +			if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 139 | +			} else if (preg_match('/opensky/i',$host)) { | |
| 140 | + //$formats[$id] = 'aircraftlistjson'; | |
| 141 | + $globalSources[$id]['format'] = 'opensky'; | |
| 142 | + //$last_exec['aircraftlistjson'] = 0; | |
| 143 | +			if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; | |
| 144 | + /* | |
| 145 | 145 | // Disabled for now, site change source format | 
| 146 | 146 |      	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { | 
| 147 | 147 | //$formats[$id] = 'radarvirtueljson'; | 
| @@ -153,118 +153,118 @@ discard block | ||
| 153 | 153 | exit(0); | 
| 154 | 154 | } | 
| 155 | 155 | */ | 
| 156 | -    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { | |
| 157 | - //$formats[$id] = 'planeupdatefaa'; | |
| 158 | - $globalSources[$id]['format'] = 'planeupdatefaa'; | |
| 159 | - //$last_exec['planeupdatefaa'] = 0; | |
| 160 | -        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 161 | -        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 162 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 163 | - exit(0); | |
| 164 | - } | |
| 165 | -            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { | |
| 166 | - //$formats[$id] = 'phpvmacars'; | |
| 167 | - $globalSources[$id]['format'] = 'phpvmacars'; | |
| 168 | - //$last_exec['phpvmacars'] = 0; | |
| 169 | -        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 170 | -            } else if (preg_match('/VAM-json.php$/i',$host)) { | |
| 171 | - //$formats[$id] = 'phpvmacars'; | |
| 172 | - $globalSources[$id]['format'] = 'vam'; | |
| 173 | -        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | |
| 174 | -            } else if (preg_match('/whazzup/i',$host)) { | |
| 175 | - //$formats[$id] = 'whazzup'; | |
| 176 | - $globalSources[$id]['format'] = 'whazzup'; | |
| 177 | - //$last_exec['whazzup'] = 0; | |
| 178 | -        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | |
| 179 | -            } else if (preg_match('/airwhere/i',$host)) { | |
| 180 | - $globalSources[$id]['format'] = 'airwhere'; | |
| 181 | -        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | |
| 182 | -            } else if (preg_match('/recentpireps/i',$host)) { | |
| 183 | - //$formats[$id] = 'pirepsjson'; | |
| 184 | - $globalSources[$id]['format'] = 'pirepsjson'; | |
| 185 | - //$last_exec['pirepsjson'] = 0; | |
| 186 | -        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 187 | -            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | |
| 188 | - //$formats[$id] = 'fr24json'; | |
| 189 | - $globalSources[$id]['format'] = 'fr24json'; | |
| 190 | - //$last_exec['fr24json'] = 0; | |
| 191 | -        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; | |
| 192 | -        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 193 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 194 | - exit(0); | |
| 195 | - } | |
| 196 | -            } else if (preg_match(':myshiptracking.com/:i',$host)) { | |
| 197 | - //$formats[$id] = 'fr24json'; | |
| 198 | - $globalSources[$id]['format'] = 'myshiptracking'; | |
| 199 | - //$last_exec['fr24json'] = 0; | |
| 200 | -        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 201 | -        	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 202 | - echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 203 | - exit(0); | |
| 204 | - } | |
| 205 | -            //} else if (preg_match('/10001/',$host)) { | |
| 206 | -            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 207 | - //$formats[$id] = 'tsv'; | |
| 208 | - $globalSources[$id]['format'] = 'tsv'; | |
| 209 | -        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | |
| 210 | - } | |
| 211 | -        } elseif (filter_var($host,FILTER_VALIDATE_URL)) { | |
| 212 | -    		if ($globalSources[$id]['format'] == 'aisnmeahttp') { | |
| 213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); | |
| 214 | -    		    if ($idf !== false) { | |
| 215 | - $httpfeeds[$id] = $idf; | |
| 216 | -        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 217 | - } | |
| 218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 219 | -    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 220 | -        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | |
| 221 | -	    $hostport = explode(':',$host); | |
| 222 | -	    if (isset($hostport[1])) { | |
| 156 | +			} else if (preg_match('/planeUpdateFAA.php$/i',$host)) { | |
| 157 | + //$formats[$id] = 'planeupdatefaa'; | |
| 158 | + $globalSources[$id]['format'] = 'planeupdatefaa'; | |
| 159 | + //$last_exec['planeupdatefaa'] = 0; | |
| 160 | +			if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 161 | +			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 162 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 163 | + exit(0); | |
| 164 | + } | |
| 165 | +			} else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { | |
| 166 | + //$formats[$id] = 'phpvmacars'; | |
| 167 | + $globalSources[$id]['format'] = 'phpvmacars'; | |
| 168 | + //$last_exec['phpvmacars'] = 0; | |
| 169 | +			if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 170 | +			} else if (preg_match('/VAM-json.php$/i',$host)) { | |
| 171 | + //$formats[$id] = 'phpvmacars'; | |
| 172 | + $globalSources[$id]['format'] = 'vam'; | |
| 173 | +			if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | |
| 174 | +			} else if (preg_match('/whazzup/i',$host)) { | |
| 175 | + //$formats[$id] = 'whazzup'; | |
| 176 | + $globalSources[$id]['format'] = 'whazzup'; | |
| 177 | + //$last_exec['whazzup'] = 0; | |
| 178 | +			if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | |
| 179 | +			} else if (preg_match('/airwhere/i',$host)) { | |
| 180 | + $globalSources[$id]['format'] = 'airwhere'; | |
| 181 | +			if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | |
| 182 | +			} else if (preg_match('/recentpireps/i',$host)) { | |
| 183 | + //$formats[$id] = 'pirepsjson'; | |
| 184 | + $globalSources[$id]['format'] = 'pirepsjson'; | |
| 185 | + //$last_exec['pirepsjson'] = 0; | |
| 186 | +			if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 187 | +			} else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | |
| 188 | + //$formats[$id] = 'fr24json'; | |
| 189 | + $globalSources[$id]['format'] = 'fr24json'; | |
| 190 | + //$last_exec['fr24json'] = 0; | |
| 191 | +			if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; | |
| 192 | +			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 193 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 194 | + exit(0); | |
| 195 | + } | |
| 196 | +			} else if (preg_match(':myshiptracking.com/:i',$host)) { | |
| 197 | + //$formats[$id] = 'fr24json'; | |
| 198 | + $globalSources[$id]['format'] = 'myshiptracking'; | |
| 199 | + //$last_exec['fr24json'] = 0; | |
| 200 | +			if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 201 | +			if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | |
| 202 | + echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | |
| 203 | + exit(0); | |
| 204 | + } | |
| 205 | +			//} else if (preg_match('/10001/',$host)) { | |
| 206 | +			} else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 207 | + //$formats[$id] = 'tsv'; | |
| 208 | + $globalSources[$id]['format'] = 'tsv'; | |
| 209 | +			if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | |
| 210 | + } | |
| 211 | +		} elseif (filter_var($host,FILTER_VALIDATE_URL)) { | |
| 212 | +			if ($globalSources[$id]['format'] == 'aisnmeahttp') { | |
| 213 | + $idf = fopen($globalSources[$id]['host'],'r',false,$context); | |
| 214 | +				if ($idf !== false) { | |
| 215 | + $httpfeeds[$id] = $idf; | |
| 216 | +				if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 217 | + } | |
| 218 | + elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 219 | +			} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 220 | +		} elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | |
| 221 | +		$hostport = explode(':',$host); | |
| 222 | +		if (isset($hostport[1])) { | |
| 223 | 223 | $port = $hostport[1]; | 
| 224 | 224 | $hostn = $hostport[0]; | 
| 225 | -	    } else { | |
| 225 | +		} else { | |
| 226 | 226 | $port = $globalSources[$id]['port']; | 
| 227 | 227 | $hostn = $globalSources[$id]['host']; | 
| 228 | - } | |
| 229 | - $Common = new Common(); | |
| 230 | -	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { | |
| 231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); | |
| 232 | -    	    } else { | |
| 233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); | |
| 234 | - } | |
| 235 | -	    if ($s) { | |
| 236 | - $sockets[$id] = $s; | |
| 237 | -    	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { | |
| 238 | -		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { | |
| 228 | + } | |
| 229 | + $Common = new Common(); | |
| 230 | +		if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { | |
| 231 | + $s = $Common->create_socket($hostn,$port, $errno, $errstr); | |
| 232 | +			} else { | |
| 233 | + $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); | |
| 234 | + } | |
| 235 | +		if ($s) { | |
| 236 | + $sockets[$id] = $s; | |
| 237 | +				if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { | |
| 238 | +			if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { | |
| 239 | 239 | //$formats[$id] = 'aprs'; | 
| 240 | 240 | $globalSources[$id]['format'] = 'aprs'; | 
| 241 | 241 | //$aprs_connect = 0; | 
| 242 | 242 | //$use_aprs = true; | 
| 243 | -		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 243 | +			} elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; | 
| 245 | -    		    } elseif ($port == '10001') { | |
| 246 | - //$formats[$id] = 'tsv'; | |
| 247 | - $globalSources[$id]['format'] = 'tsv'; | |
| 248 | -		    } elseif ($port == '30002') { | |
| 249 | - //$formats[$id] = 'raw'; | |
| 250 | - $globalSources[$id]['format'] = 'raw'; | |
| 251 | -		    } elseif ($port == '5001') { | |
| 252 | - //$formats[$id] = 'raw'; | |
| 253 | - $globalSources[$id]['format'] = 'flightgearmp'; | |
| 254 | -		    } elseif ($port == '30005') { | |
| 245 | +				} elseif ($port == '10001') { | |
| 246 | + //$formats[$id] = 'tsv'; | |
| 247 | + $globalSources[$id]['format'] = 'tsv'; | |
| 248 | +			} elseif ($port == '30002') { | |
| 249 | + //$formats[$id] = 'raw'; | |
| 250 | + $globalSources[$id]['format'] = 'raw'; | |
| 251 | +			} elseif ($port == '5001') { | |
| 252 | + //$formats[$id] = 'raw'; | |
| 253 | + $globalSources[$id]['format'] = 'flightgearmp'; | |
| 254 | +			} elseif ($port == '30005') { | |
| 255 | 255 | // Not yet supported | 
| 256 | - //$formats[$id] = 'beast'; | |
| 257 | - $globalSources[$id]['format'] = 'beast'; | |
| 258 | - //} else $formats[$id] = 'sbs'; | |
| 259 | - } else $globalSources[$id]['format'] = 'sbs'; | |
| 260 | -		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; | |
| 256 | + //$formats[$id] = 'beast'; | |
| 257 | + $globalSources[$id]['format'] = 'beast'; | |
| 258 | + //} else $formats[$id] = 'sbs'; | |
| 259 | + } else $globalSources[$id]['format'] = 'sbs'; | |
| 260 | +			//if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; | |
| 261 | 261 | } | 
| 262 | 262 |  		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | 
| 263 | -            } else { | |
| 263 | +			} else { | |
| 264 | 264 | if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | 
| 265 | - } | |
| 266 | - } | |
| 267 | - } | |
| 265 | + } | |
| 266 | + } | |
| 267 | + } | |
| 268 | 268 | } | 
| 269 | 269 | if (!isset($globalMinFetch)) $globalMinFetch = 15; | 
| 270 | 270 | |
| @@ -287,9 +287,9 @@ discard block | ||
| 287 | 287 | //connect_all($globalSources); | 
| 288 | 288 | |
| 289 | 289 |  if (isset($globalProxy) && $globalProxy) { | 
| 290 | -    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); | |
| 290 | +	$context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); | |
| 291 | 291 |  } else { | 
| 292 | -    $context = stream_context_create(array('http' => array('timeout' => $timeout))); | |
| 292 | +	$context = stream_context_create(array('http' => array('timeout' => $timeout))); | |
| 293 | 293 | } | 
| 294 | 294 | |
| 295 | 295 | // APRS Configuration | 
| @@ -298,18 +298,18 @@ discard block | ||
| 298 | 298 | die; | 
| 299 | 299 | } | 
| 300 | 300 |  foreach ($globalSources as $key => $source) { | 
| 301 | -    if (!isset($source['format'])) { | |
| 302 | - $globalSources[$key]['format'] = 'auto'; | |
| 303 | - } | |
| 301 | +	if (!isset($source['format'])) { | |
| 302 | + $globalSources[$key]['format'] = 'auto'; | |
| 303 | + } | |
| 304 | 304 | } | 
| 305 | 305 | connect_all($globalSources); | 
| 306 | 306 |  foreach ($globalSources as $key => $source) { | 
| 307 | -    if (isset($source['format']) && $source['format'] == 'aprs') { | |
| 307 | +	if (isset($source['format']) && $source['format'] == 'aprs') { | |
| 308 | 308 | $aprs_connect = 0; | 
| 309 | 309 | $use_aprs = true; | 
| 310 | 310 | if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; | 
| 311 | 311 | break; | 
| 312 | - } | |
| 312 | + } | |
| 313 | 313 | } | 
| 314 | 314 | |
| 315 | 315 |  if ($use_aprs) { | 
| @@ -350,115 +350,115 @@ discard block | ||
| 350 | 350 | |
| 351 | 351 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. | 
| 352 | 352 |  while ($i > 0) { | 
| 353 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 354 | - // Delete old ATC | |
| 355 | -    if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | |
| 353 | + if (!$globalDaemon) $i = $endtime-time(); | |
| 354 | + // Delete old ATC | |
| 355 | +	if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | |
| 356 | 356 | if ($globalDebug) echo 'Delete old ATC...'."\n"; | 
| 357 | - $ATC->deleteOldATC(); | |
| 358 | - } | |
| 357 | + $ATC->deleteOldATC(); | |
| 358 | + } | |
| 359 | 359 | |
| 360 | -    if (count($last_exec) == count($globalSources)) { | |
| 360 | +	if (count($last_exec) == count($globalSources)) { | |
| 361 | 361 | $max = $globalMinFetch; | 
| 362 | 362 |  	foreach ($last_exec as $last) { | 
| 363 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; | |
| 363 | + if ((time() - $last['last']) < $max) $max = time() - $last['last']; | |
| 364 | 364 | } | 
| 365 | 365 |  	if ($max != $globalMinFetch) { | 
| 366 | - if ($globalDebug) echo 'Sleeping...'."\n"; | |
| 367 | - sleep($globalMinFetch-$max+2); | |
| 366 | + if ($globalDebug) echo 'Sleeping...'."\n"; | |
| 367 | + sleep($globalMinFetch-$max+2); | |
| 368 | + } | |
| 368 | 369 | } | 
| 369 | - } | |
| 370 | 370 | |
| 371 | 371 | |
| 372 | -    //foreach ($formats as $id => $value) { | |
| 373 | -    foreach ($globalSources as $id => $value) { | |
| 372 | +	//foreach ($formats as $id => $value) { | |
| 373 | +	foreach ($globalSources as $id => $value) { | |
| 374 | 374 |  	date_default_timezone_set('UTC'); | 
| 375 | 375 | if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; | 
| 376 | 376 |  	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 377 | - //$buffer = $Common->getData($hosts[$id]); | |
| 378 | - $buffer = $Common->getData($value['host']); | |
| 379 | - if ($buffer != '') $reset = 0; | |
| 380 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 381 | -	    $buffer = explode('\n',$buffer); | |
| 382 | -	    foreach ($buffer as $line) { | |
| 383 | -    		if ($line != '' && count($line) > 7) { | |
| 384 | -    		    $line = explode(',', $line); | |
| 385 | - $data = array(); | |
| 386 | - $data['hex'] = $line[1]; // hex | |
| 387 | - $data['ident'] = $line[2]; // ident | |
| 388 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude | |
| 389 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed | |
| 390 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading | |
| 391 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat | |
| 392 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long | |
| 393 | - $data['verticalrate'] = ''; // vertical rate | |
| 394 | - //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk | |
| 395 | - $data['emergency'] = ''; // emergency | |
| 396 | -		    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 397 | - $data['format_source'] = 'deltadbtxt'; | |
| 398 | - $data['id_source'] = $id_source; | |
| 399 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 400 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 401 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 402 | - $SI->add($data); | |
| 403 | - unset($data); | |
| 404 | - } | |
| 405 | - } | |
| 406 | - $last_exec[$id]['last'] = time(); | |
| 377 | + //$buffer = $Common->getData($hosts[$id]); | |
| 378 | + $buffer = $Common->getData($value['host']); | |
| 379 | + if ($buffer != '') $reset = 0; | |
| 380 | +			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 381 | +		$buffer = explode('\n',$buffer); | |
| 382 | +		foreach ($buffer as $line) { | |
| 383 | +			if ($line != '' && count($line) > 7) { | |
| 384 | +				$line = explode(',', $line); | |
| 385 | + $data = array(); | |
| 386 | + $data['hex'] = $line[1]; // hex | |
| 387 | + $data['ident'] = $line[2]; // ident | |
| 388 | + if (isset($line[3])) $data['altitude'] = $line[3]; // altitude | |
| 389 | + if (isset($line[4])) $data['speed'] = $line[4]; // speed | |
| 390 | + if (isset($line[5])) $data['heading'] = $line[5]; // heading | |
| 391 | + if (isset($line[6])) $data['latitude'] = $line[6]; // lat | |
| 392 | + if (isset($line[7])) $data['longitude'] = $line[7]; // long | |
| 393 | + $data['verticalrate'] = ''; // vertical rate | |
| 394 | + //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk | |
| 395 | + $data['emergency'] = ''; // emergency | |
| 396 | +			$data['datetime'] = date('Y-m-d H:i:s'); | |
| 397 | + $data['format_source'] = 'deltadbtxt'; | |
| 398 | + $data['id_source'] = $id_source; | |
| 399 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 400 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 401 | + if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 402 | + $SI->add($data); | |
| 403 | + unset($data); | |
| 404 | + } | |
| 405 | + } | |
| 406 | + $last_exec[$id]['last'] = time(); | |
| 407 | 407 |  	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 408 | -	    date_default_timezone_set('CET'); | |
| 409 | -	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | |
| 410 | -	    date_default_timezone_set('UTC'); | |
| 411 | - if ($buffer != '') $reset = 0; | |
| 412 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 413 | -	    $buffer = explode('\n',$buffer); | |
| 414 | -	    foreach ($buffer as $line) { | |
| 408 | +		date_default_timezone_set('CET'); | |
| 409 | +		$buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | |
| 410 | +		date_default_timezone_set('UTC'); | |
| 411 | + if ($buffer != '') $reset = 0; | |
| 412 | +			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 413 | +		$buffer = explode('\n',$buffer); | |
| 414 | +		foreach ($buffer as $line) { | |
| 415 | 415 |  		if ($line != '') { | 
| 416 | - echo "'".$line."'\n"; | |
| 417 | - $add = false; | |
| 418 | - $ais_data = $AIS->parse_line(trim($line)); | |
| 419 | - $data = array(); | |
| 420 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 421 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 422 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 423 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 424 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 425 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 426 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 427 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 428 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 429 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 430 | -		    if (isset($ais_data['timestamp'])) { | |
| 416 | + echo "'".$line."'\n"; | |
| 417 | + $add = false; | |
| 418 | + $ais_data = $AIS->parse_line(trim($line)); | |
| 419 | + $data = array(); | |
| 420 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 421 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 422 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 423 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 424 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 425 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 426 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 427 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 428 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 429 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 430 | +			if (isset($ais_data['timestamp'])) { | |
| 431 | 431 |  			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 432 | 432 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| 433 | - $last_exec[$id]['timestamp'] = $ais_data['timestamp']; | |
| 434 | - $add = true; | |
| 433 | + $last_exec[$id]['timestamp'] = $ais_data['timestamp']; | |
| 434 | + $add = true; | |
| 435 | 435 | } | 
| 436 | -		    } else { | |
| 436 | +			} else { | |
| 437 | 437 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 438 | 438 | $add = true; | 
| 439 | - } | |
| 440 | - $data['format_source'] = 'aisnmeatxt'; | |
| 441 | - $data['id_source'] = $id_source; | |
| 442 | - //print_r($data); | |
| 443 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 444 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 445 | - unset($data); | |
| 439 | + } | |
| 440 | + $data['format_source'] = 'aisnmeatxt'; | |
| 441 | + $data['id_source'] = $id_source; | |
| 442 | + //print_r($data); | |
| 443 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 444 | + if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 445 | + unset($data); | |
| 446 | 446 | } | 
| 447 | - } | |
| 448 | - $last_exec[$id]['last'] = time(); | |
| 447 | + } | |
| 448 | + $last_exec[$id]['last'] = time(); | |
| 449 | 449 |  	} elseif ($value['format'] == 'aisnmeahttp') { | 
| 450 | - $arr = $httpfeeds; | |
| 451 | - $w = $e = null; | |
| 450 | + $arr = $httpfeeds; | |
| 451 | + $w = $e = null; | |
| 452 | 452 | |
| 453 | -	    if (isset($arr[$id])) { | |
| 453 | +		if (isset($arr[$id])) { | |
| 454 | 454 | $nn = stream_select($arr,$w,$e,$timeout); | 
| 455 | 455 |  		if ($nn > 0) { | 
| 456 | -		    foreach ($httpfeeds as $feed) { | |
| 456 | +			foreach ($httpfeeds as $feed) { | |
| 457 | 457 | $buffer = stream_get_line($feed,2000,"\n"); | 
| 458 | 458 |  			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 459 | 459 |  			$buffer = explode('\n',$buffer); | 
| 460 | 460 |  			foreach ($buffer as $line) { | 
| 461 | -			    if ($line != '') { | |
| 461 | +				if ($line != '') { | |
| 462 | 462 | $ais_data = $AIS->parse_line(trim($line)); | 
| 463 | 463 | $data = array(); | 
| 464 | 464 | if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | 
| @@ -476,96 +476,96 @@ discard block | ||
| 476 | 476 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | 
| 477 | 477 |  				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | 
| 478 | 478 |  				if (isset($ais_data['timestamp'])) { | 
| 479 | -				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 479 | +					$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 480 | 480 |  				} else { | 
| 481 | -				    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 481 | +					$data['datetime'] = date('Y-m-d H:i:s'); | |
| 482 | 482 | } | 
| 483 | 483 | $data['format_source'] = 'aisnmeahttp'; | 
| 484 | 484 | $data['id_source'] = $id_source; | 
| 485 | 485 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 486 | 486 | if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | 
| 487 | 487 | unset($data); | 
| 488 | - } | |
| 488 | + } | |
| 489 | + } | |
| 489 | 490 | } | 
| 490 | - } | |
| 491 | 491 |  		} else { | 
| 492 | - $format = $value['format']; | |
| 493 | - if (isset($tt[$format])) $tt[$format]++; | |
| 494 | - else $tt[$format] = 0; | |
| 495 | -		    if ($tt[$format] > 30) { | |
| 492 | + $format = $value['format']; | |
| 493 | + if (isset($tt[$format])) $tt[$format]++; | |
| 494 | + else $tt[$format] = 0; | |
| 495 | +			if ($tt[$format] > 30) { | |
| 496 | 496 | if ($globalDebug) echo 'Reconnect...'."\n"; | 
| 497 | 497 | sleep(2); | 
| 498 | 498 | $sourceeen[] = $value; | 
| 499 | 499 | connect_all($sourceeen); | 
| 500 | 500 | $sourceeen = array(); | 
| 501 | - } | |
| 501 | + } | |
| 502 | + } | |
| 502 | 503 | } | 
| 503 | - } | |
| 504 | 504 |  	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 505 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 506 | -	    if ($buffer != '') { | |
| 505 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 506 | +		if ($buffer != '') { | |
| 507 | 507 | //echo $buffer; | 
| 508 | 508 | $all_data = json_decode($buffer,true); | 
| 509 | 509 | //print_r($all_data); | 
| 510 | 510 |  		if (isset($all_data[0]['DATA'])) { | 
| 511 | -		    foreach ($all_data[0]['DATA'] as $line) { | |
| 511 | +			foreach ($all_data[0]['DATA'] as $line) { | |
| 512 | 512 |  			if ($line != '') { | 
| 513 | - $data = array(); | |
| 514 | - $data['ident'] = $line['NAME']; | |
| 515 | - $data['mmsi'] = $line['MMSI']; | |
| 516 | - $data['speed'] = $line['SOG']; | |
| 517 | - $data['heading'] = $line['COG']; | |
| 518 | - $data['latitude'] = $line['LAT']; | |
| 519 | - $data['longitude'] = $line['LNG']; | |
| 520 | - // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 521 | - $data['imo'] = $line['IMO']; | |
| 522 | - //$data['arrival_code'] = $ais_data['destination']; | |
| 523 | -			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | |
| 524 | - $data['format_source'] = 'myshiptracking'; | |
| 525 | - $data['id_source'] = $id_source; | |
| 526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 527 | - $MI->add($data); | |
| 528 | - unset($data); | |
| 513 | + $data = array(); | |
| 514 | + $data['ident'] = $line['NAME']; | |
| 515 | + $data['mmsi'] = $line['MMSI']; | |
| 516 | + $data['speed'] = $line['SOG']; | |
| 517 | + $data['heading'] = $line['COG']; | |
| 518 | + $data['latitude'] = $line['LAT']; | |
| 519 | + $data['longitude'] = $line['LNG']; | |
| 520 | + // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 521 | + $data['imo'] = $line['IMO']; | |
| 522 | + //$data['arrival_code'] = $ais_data['destination']; | |
| 523 | +				$data['datetime'] = date('Y-m-d H:i:s',$line['T']); | |
| 524 | + $data['format_source'] = 'myshiptracking'; | |
| 525 | + $data['id_source'] = $id_source; | |
| 526 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 527 | + $MI->add($data); | |
| 528 | + unset($data); | |
| 529 | + } | |
| 529 | 530 | } | 
| 530 | - } | |
| 531 | 531 | } | 
| 532 | - } | |
| 533 | - $last_exec[$id]['last'] = time(); | |
| 532 | + } | |
| 533 | + $last_exec[$id]['last'] = time(); | |
| 534 | 534 |  	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 535 | -	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); | |
| 536 | -	    if ($buffer != '') { | |
| 535 | +		$buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); | |
| 536 | +		if ($buffer != '') { | |
| 537 | 537 | $all_data = json_decode($buffer,true); | 
| 538 | 538 |  		if (isset($all_data[0]['mmsi'])) { | 
| 539 | -		    foreach ($all_data as $line) { | |
| 539 | +			foreach ($all_data as $line) { | |
| 540 | 540 |  			if ($line != '') { | 
| 541 | - $data = array(); | |
| 542 | - $data['ident'] = $line['shipname']; | |
| 543 | - $data['callsign'] = $line['callsign']; | |
| 544 | - $data['mmsi'] = $line['mmsi']; | |
| 545 | - $data['speed'] = $line['sog']; | |
| 546 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; | |
| 547 | - $data['latitude'] = $line['latitude']; | |
| 548 | - $data['longitude'] = $line['longitude']; | |
| 549 | - $data['type_id'] = $line['shiptype']; | |
| 550 | - $data['arrival_code'] = $line['destination']; | |
| 551 | - $data['datetime'] = $line['time']; | |
| 552 | - $data['format_source'] = 'boatbeaconapp'; | |
| 553 | - $data['id_source'] = $id_source; | |
| 554 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 555 | - $MI->add($data); | |
| 556 | - unset($data); | |
| 541 | + $data = array(); | |
| 542 | + $data['ident'] = $line['shipname']; | |
| 543 | + $data['callsign'] = $line['callsign']; | |
| 544 | + $data['mmsi'] = $line['mmsi']; | |
| 545 | + $data['speed'] = $line['sog']; | |
| 546 | + if ($line['heading'] != '511') $data['heading'] = $line['heading']; | |
| 547 | + $data['latitude'] = $line['latitude']; | |
| 548 | + $data['longitude'] = $line['longitude']; | |
| 549 | + $data['type_id'] = $line['shiptype']; | |
| 550 | + $data['arrival_code'] = $line['destination']; | |
| 551 | + $data['datetime'] = $line['time']; | |
| 552 | + $data['format_source'] = 'boatbeaconapp'; | |
| 553 | + $data['id_source'] = $id_source; | |
| 554 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 555 | + $MI->add($data); | |
| 556 | + unset($data); | |
| 557 | + } | |
| 557 | 558 | } | 
| 558 | - } | |
| 559 | 559 | } | 
| 560 | 560 | |
| 561 | - } | |
| 562 | - $last_exec[$id]['last'] = time(); | |
| 561 | + } | |
| 562 | + $last_exec[$id]['last'] = time(); | |
| 563 | 563 |  	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 564 | - $buffer = $Common->getData($value['host']); | |
| 565 | -	    if ($buffer != '') { | |
| 564 | + $buffer = $Common->getData($value['host']); | |
| 565 | +		if ($buffer != '') { | |
| 566 | 566 | $all_data = json_decode($buffer,true); | 
| 567 | 567 |  		if (isset($all_data['features'][0]['id'])) { | 
| 568 | -		    foreach ($all_data['features'] as $line) { | |
| 568 | +			foreach ($all_data['features'] as $line) { | |
| 569 | 569 | $data = array(); | 
| 570 | 570 | if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; | 
| 571 | 571 | if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; | 
| @@ -584,59 +584,59 @@ discard block | ||
| 584 | 584 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 585 | 585 | if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); | 
| 586 | 586 | unset($data); | 
| 587 | - } | |
| 587 | + } | |
| 588 | 588 | } | 
| 589 | 589 | |
| 590 | - } | |
| 591 | - $last_exec[$id]['last'] = time(); | |
| 590 | + } | |
| 591 | + $last_exec[$id]['last'] = time(); | |
| 592 | 592 |  	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 593 | - echo 'download...'; | |
| 594 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | |
| 595 | - echo 'done !'."\n"; | |
| 596 | - if ($buffer != '') $reset = 0; | |
| 597 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 598 | -	    $buffer = explode('\n',$buffer); | |
| 599 | -	    foreach ($buffer as $line) { | |
| 593 | + echo 'download...'; | |
| 594 | + $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | |
| 595 | + echo 'done !'."\n"; | |
| 596 | + if ($buffer != '') $reset = 0; | |
| 597 | +			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 598 | +		$buffer = explode('\n',$buffer); | |
| 599 | +		foreach ($buffer as $line) { | |
| 600 | 600 |  		if ($line != '') { | 
| 601 | - $data = array(); | |
| 602 | - $data['mmsi'] = (int)substr($line,0,9); | |
| 603 | -		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); | |
| 604 | - //$data['status'] = substr($line,21,2); | |
| 605 | - //$data['type'] = substr($line,24,3); | |
| 606 | - $data['latitude'] = substr($line,29,9); | |
| 607 | - $data['longitude'] = substr($line,41,9); | |
| 608 | - $data['speed'] = round(substr($line,51,5)); | |
| 609 | - //$data['course'] = substr($line,57,5); | |
| 610 | - $data['heading'] = round(substr($line,63,3)); | |
| 611 | - //$data['draft'] = substr($line,67,4); | |
| 612 | - //$data['length'] = substr($line,72,3); | |
| 613 | - //$data['beam'] = substr($line,76,2); | |
| 614 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); | |
| 615 | - //$data['callsign'] = trim(substr($line,100,7); | |
| 616 | - //$data['dest'] = substr($line,108,20); | |
| 617 | - //$data['etaDate'] = substr($line,129,5); | |
| 618 | - //$data['etaTime'] = substr($line,135,5); | |
| 619 | - $data['format_source'] = 'shipplotter'; | |
| 620 | - $data['id_source'] = $id_source; | |
| 621 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 622 | - //print_r($data); | |
| 623 | - echo 'Add...'."\n"; | |
| 624 | - $MI->add($data); | |
| 625 | - unset($data); | |
| 601 | + $data = array(); | |
| 602 | + $data['mmsi'] = (int)substr($line,0,9); | |
| 603 | +			$data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); | |
| 604 | + //$data['status'] = substr($line,21,2); | |
| 605 | + //$data['type'] = substr($line,24,3); | |
| 606 | + $data['latitude'] = substr($line,29,9); | |
| 607 | + $data['longitude'] = substr($line,41,9); | |
| 608 | + $data['speed'] = round(substr($line,51,5)); | |
| 609 | + //$data['course'] = substr($line,57,5); | |
| 610 | + $data['heading'] = round(substr($line,63,3)); | |
| 611 | + //$data['draft'] = substr($line,67,4); | |
| 612 | + //$data['length'] = substr($line,72,3); | |
| 613 | + //$data['beam'] = substr($line,76,2); | |
| 614 | + $data['ident'] = trim(utf8_encode(substr($line,79,20))); | |
| 615 | + //$data['callsign'] = trim(substr($line,100,7); | |
| 616 | + //$data['dest'] = substr($line,108,20); | |
| 617 | + //$data['etaDate'] = substr($line,129,5); | |
| 618 | + //$data['etaTime'] = substr($line,135,5); | |
| 619 | + $data['format_source'] = 'shipplotter'; | |
| 620 | + $data['id_source'] = $id_source; | |
| 621 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 622 | + //print_r($data); | |
| 623 | + echo 'Add...'."\n"; | |
| 624 | + $MI->add($data); | |
| 625 | + unset($data); | |
| 626 | 626 | } | 
| 627 | - } | |
| 628 | - $last_exec[$id]['last'] = time(); | |
| 627 | + } | |
| 628 | + $last_exec[$id]['last'] = time(); | |
| 629 | 629 |  	//} elseif (($value == 'whazzup' && (time() - $last_exec['whazzup'] > $globalMinFetch)) || ($value == 'vatsimtxt' && (time() - $last_exec['vatsimtxt'] > $globalMinFetch))) { | 
| 630 | 630 |  	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { | 
| 631 | - //$buffer = $Common->getData($hosts[$id]); | |
| 632 | - $buffer = $Common->getData($value['host']); | |
| 633 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 634 | -	    $buffer = explode('\n',$buffer); | |
| 635 | - $reset = 0; | |
| 636 | -	    foreach ($buffer as $line) { | |
| 637 | -    		if ($line != '') { | |
| 638 | -    		    $line = explode(':', $line); | |
| 639 | -    		    if (count($line) > 30 && $line[0] != 'callsign') { | |
| 631 | + //$buffer = $Common->getData($hosts[$id]); | |
| 632 | + $buffer = $Common->getData($value['host']); | |
| 633 | +			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 634 | +		$buffer = explode('\n',$buffer); | |
| 635 | + $reset = 0; | |
| 636 | +		foreach ($buffer as $line) { | |
| 637 | +			if ($line != '') { | |
| 638 | +				$line = explode(':', $line); | |
| 639 | +				if (count($line) > 30 && $line[0] != 'callsign') { | |
| 640 | 640 | $data = array(); | 
| 641 | 641 | if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | 
| 642 | 642 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | 
| @@ -649,37 +649,37 @@ discard block | ||
| 649 | 649 | if (isset($line[45])) $data['heading'] = $line[45]; // heading | 
| 650 | 650 | elseif (isset($line[38])) $data['heading'] = $line[38]; // heading | 
| 651 | 651 | $data['latitude'] = $line[5]; // lat | 
| 652 | - $data['longitude'] = $line[6]; // long | |
| 653 | - $data['verticalrate'] = ''; // vertical rate | |
| 654 | - $data['squawk'] = ''; // squawk | |
| 655 | - $data['emergency'] = ''; // emergency | |
| 656 | - $data['waypoints'] = $line[30]; | |
| 652 | + $data['longitude'] = $line[6]; // long | |
| 653 | + $data['verticalrate'] = ''; // vertical rate | |
| 654 | + $data['squawk'] = ''; // squawk | |
| 655 | + $data['emergency'] = ''; // emergency | |
| 656 | + $data['waypoints'] = $line[30]; | |
| 657 | 657 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 658 | 658 |  			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); | 
| 659 | 659 | //if (isset($line[37])) $data['last_update'] = $line[37]; | 
| 660 | - $data['departure_airport_icao'] = $line[11]; | |
| 661 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); | |
| 662 | - $data['arrival_airport_icao'] = $line[13]; | |
| 660 | + $data['departure_airport_icao'] = $line[11]; | |
| 661 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); | |
| 662 | + $data['arrival_airport_icao'] = $line[13]; | |
| 663 | 663 | $data['frequency'] = $line[4]; | 
| 664 | 664 | $data['type'] = $line[18]; | 
| 665 | 665 | $data['range'] = $line[19]; | 
| 666 | 666 | if (isset($line[35])) $data['info'] = $line[35]; | 
| 667 | - $data['id_source'] = $id_source; | |
| 668 | - //$data['arrival_airport_time'] = ; | |
| 669 | -	    		if ($line[9] != '') { | |
| 670 | -	    		    $aircraft_data = explode('/',$line[9]); | |
| 671 | -	    		    if (isset($aircraft_data[1])) { | |
| 672 | - $data['aircraft_icao'] = $aircraft_data[1]; | |
| 673 | - } | |
| 674 | - } | |
| 675 | - /* | |
| 667 | + $data['id_source'] = $id_source; | |
| 668 | + //$data['arrival_airport_time'] = ; | |
| 669 | +				if ($line[9] != '') { | |
| 670 | +					$aircraft_data = explode('/',$line[9]); | |
| 671 | +					if (isset($aircraft_data[1])) { | |
| 672 | + $data['aircraft_icao'] = $aircraft_data[1]; | |
| 673 | + } | |
| 674 | + } | |
| 675 | + /* | |
| 676 | 676 | if ($value == 'whazzup') $data['format_source'] = 'whazzup'; | 
| 677 | 677 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; | 
| 678 | 678 | */ | 
| 679 | - $data['format_source'] = $value['format']; | |
| 679 | + $data['format_source'] = $value['format']; | |
| 680 | 680 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 681 | 681 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | 
| 682 | - if ($line[3] == 'PILOT') $SI->add($data); | |
| 682 | + if ($line[3] == 'PILOT') $SI->add($data); | |
| 683 | 683 |  			elseif ($line[3] == 'ATC') { | 
| 684 | 684 | //print_r($data); | 
| 685 | 685 |  				$data['info'] = str_replace('^§','<br />',$data['info']); | 
| @@ -700,16 +700,16 @@ discard block | ||
| 700 | 700 | 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']); | 
| 701 | 701 | } | 
| 702 | 702 | } | 
| 703 | - unset($data); | |
| 704 | - } | |
| 705 | - } | |
| 706 | - } | |
| 707 | - //if ($value == 'whazzup') $last_exec['whazzup'] = time(); | |
| 708 | - //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); | |
| 709 | - $last_exec[$id]['last'] = time(); | |
| 710 | -    	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 711 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); | |
| 712 | -	    if ($buffer != '') { | |
| 703 | + unset($data); | |
| 704 | + } | |
| 705 | + } | |
| 706 | + } | |
| 707 | + //if ($value == 'whazzup') $last_exec['whazzup'] = time(); | |
| 708 | + //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); | |
| 709 | + $last_exec[$id]['last'] = time(); | |
| 710 | +		} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 711 | +		$buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); | |
| 712 | +		if ($buffer != '') { | |
| 713 | 713 | $all_data = simplexml_load_string($buffer); | 
| 714 | 714 |  		foreach($all_data->children() as $childdata) { | 
| 715 | 715 | $data = array(); | 
| @@ -730,10 +730,10 @@ discard block | ||
| 730 | 730 | $SI->add($data); | 
| 731 | 731 | unset($data); | 
| 732 | 732 | } | 
| 733 | - } | |
| 734 | -	    $Source->deleteOldLocationByType('gs'); | |
| 735 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); | |
| 736 | -	    if ($buffer != '') { | |
| 733 | + } | |
| 734 | +		$Source->deleteOldLocationByType('gs'); | |
| 735 | +		$buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); | |
| 736 | +		if ($buffer != '') { | |
| 737 | 737 | $all_data = simplexml_load_string($buffer); | 
| 738 | 738 |  		foreach($all_data->children() as $childdata) { | 
| 739 | 739 | $data = array(); | 
| @@ -750,249 +750,249 @@ discard block | ||
| 750 | 750 | } | 
| 751 | 751 | unset($data); | 
| 752 | 752 | } | 
| 753 | - } | |
| 754 | - $last_exec[$id]['last'] = time(); | |
| 753 | + } | |
| 754 | + $last_exec[$id]['last'] = time(); | |
| 755 | 755 |  	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 756 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 757 | -	    if ($buffer != '') { | |
| 758 | - $all_data = json_decode($buffer,true); | |
| 759 | -	    if (isset($all_data['acList'])) { | |
| 756 | + $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 757 | +		if ($buffer != '') { | |
| 758 | + $all_data = json_decode($buffer,true); | |
| 759 | +		if (isset($all_data['acList'])) { | |
| 760 | 760 | $reset = 0; | 
| 761 | 761 |  		foreach ($all_data['acList'] as $line) { | 
| 762 | - $data = array(); | |
| 763 | - $data['hex'] = $line['Icao']; // hex | |
| 764 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 765 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 766 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 767 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 768 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 769 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 770 | - //$data['verticalrate'] = $line['']; // verticale rate | |
| 771 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 772 | - $data['emergency'] = ''; // emergency | |
| 773 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 762 | + $data = array(); | |
| 763 | + $data['hex'] = $line['Icao']; // hex | |
| 764 | + if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 765 | + if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 766 | + if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 767 | + if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 768 | + if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 769 | + if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 770 | + //$data['verticalrate'] = $line['']; // verticale rate | |
| 771 | + if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 772 | + $data['emergency'] = ''; // emergency | |
| 773 | + if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 774 | 774 | |
| 775 | -		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 776 | -		    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 775 | +			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 776 | +			else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 777 | 777 | |
| 778 | -		    //$data['datetime'] = date('Y-m-d H:i:s'); | |
| 779 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 780 | - $data['format_source'] = 'aircraftlistjson'; | |
| 781 | - $data['id_source'] = $id_source; | |
| 782 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 783 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 784 | - if (isset($data['latitude'])) $SI->add($data); | |
| 785 | - unset($data); | |
| 778 | +			//$data['datetime'] = date('Y-m-d H:i:s'); | |
| 779 | + if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 780 | + $data['format_source'] = 'aircraftlistjson'; | |
| 781 | + $data['id_source'] = $id_source; | |
| 782 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 783 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 784 | + if (isset($data['latitude'])) $SI->add($data); | |
| 785 | + unset($data); | |
| 786 | 786 | } | 
| 787 | -	    } elseif (is_array($all_data)) { | |
| 787 | +		} elseif (is_array($all_data)) { | |
| 788 | 788 | $reset = 0; | 
| 789 | 789 |  		foreach ($all_data as $line) { | 
| 790 | - $data = array(); | |
| 791 | - $data['hex'] = $line['hex']; // hex | |
| 792 | - $data['ident'] = $line['flight']; // ident | |
| 793 | - $data['altitude'] = $line['altitude']; // altitude | |
| 794 | - $data['speed'] = $line['speed']; // speed | |
| 795 | - $data['heading'] = $line['track']; // heading | |
| 796 | - $data['latitude'] = $line['lat']; // lat | |
| 797 | - $data['longitude'] = $line['lon']; // long | |
| 798 | - $data['verticalrate'] = $line['vrt']; // verticale rate | |
| 799 | - $data['squawk'] = $line['squawk']; // squawk | |
| 800 | - $data['emergency'] = ''; // emergency | |
| 801 | -		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 802 | -		    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 803 | - $data['format_source'] = 'aircraftlistjson'; | |
| 804 | - $data['id_source'] = $id_source; | |
| 805 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 806 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 807 | - $SI->add($data); | |
| 808 | - unset($data); | |
| 790 | + $data = array(); | |
| 791 | + $data['hex'] = $line['hex']; // hex | |
| 792 | + $data['ident'] = $line['flight']; // ident | |
| 793 | + $data['altitude'] = $line['altitude']; // altitude | |
| 794 | + $data['speed'] = $line['speed']; // speed | |
| 795 | + $data['heading'] = $line['track']; // heading | |
| 796 | + $data['latitude'] = $line['lat']; // lat | |
| 797 | + $data['longitude'] = $line['lon']; // long | |
| 798 | + $data['verticalrate'] = $line['vrt']; // verticale rate | |
| 799 | + $data['squawk'] = $line['squawk']; // squawk | |
| 800 | + $data['emergency'] = ''; // emergency | |
| 801 | +			if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 802 | +			else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 803 | + $data['format_source'] = 'aircraftlistjson'; | |
| 804 | + $data['id_source'] = $id_source; | |
| 805 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 806 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 807 | + $SI->add($data); | |
| 808 | + unset($data); | |
| 809 | + } | |
| 810 | + } | |
| 809 | 811 | } | 
| 810 | - } | |
| 811 | - } | |
| 812 | - //$last_exec['aircraftlistjson'] = time(); | |
| 813 | - $last_exec[$id]['last'] = time(); | |
| 814 | -    	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { | |
| 815 | -    	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 816 | - $buffer = $Common->getData($value['host']); | |
| 817 | - $all_data = json_decode($buffer,true); | |
| 818 | -	    if (isset($all_data['planes'])) { | |
| 812 | + //$last_exec['aircraftlistjson'] = time(); | |
| 813 | + $last_exec[$id]['last'] = time(); | |
| 814 | +		//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { | |
| 815 | +		} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 816 | + $buffer = $Common->getData($value['host']); | |
| 817 | + $all_data = json_decode($buffer,true); | |
| 818 | +		if (isset($all_data['planes'])) { | |
| 819 | 819 | $reset = 0; | 
| 820 | 820 |  		foreach ($all_data['planes'] as $key => $line) { | 
| 821 | - $data = array(); | |
| 822 | - $data['hex'] = $key; // hex | |
| 823 | - $data['ident'] = $line[3]; // ident | |
| 824 | - $data['altitude'] = $line[6]; // altitude | |
| 825 | - $data['speed'] = $line[8]; // speed | |
| 826 | - $data['heading'] = $line[7]; // heading | |
| 827 | - $data['latitude'] = $line[4]; // lat | |
| 828 | - $data['longitude'] = $line[5]; // long | |
| 829 | - //$data['verticalrate'] = $line[]; // verticale rate | |
| 830 | - $data['squawk'] = $line[10]; // squawk | |
| 831 | - $data['emergency'] = ''; // emergency | |
| 832 | - $data['registration'] = $line[2]; | |
| 833 | - $data['aircraft_icao'] = $line[0]; | |
| 834 | -		    $deparr = explode('-',$line[1]); | |
| 835 | -		    if (count($deparr) == 2) { | |
| 821 | + $data = array(); | |
| 822 | + $data['hex'] = $key; // hex | |
| 823 | + $data['ident'] = $line[3]; // ident | |
| 824 | + $data['altitude'] = $line[6]; // altitude | |
| 825 | + $data['speed'] = $line[8]; // speed | |
| 826 | + $data['heading'] = $line[7]; // heading | |
| 827 | + $data['latitude'] = $line[4]; // lat | |
| 828 | + $data['longitude'] = $line[5]; // long | |
| 829 | + //$data['verticalrate'] = $line[]; // verticale rate | |
| 830 | + $data['squawk'] = $line[10]; // squawk | |
| 831 | + $data['emergency'] = ''; // emergency | |
| 832 | + $data['registration'] = $line[2]; | |
| 833 | + $data['aircraft_icao'] = $line[0]; | |
| 834 | +			$deparr = explode('-',$line[1]); | |
| 835 | +			if (count($deparr) == 2) { | |
| 836 | 836 | $data['departure_airport_icao'] = $deparr[0]; | 
| 837 | 837 | $data['arrival_airport_icao'] = $deparr[1]; | 
| 838 | - } | |
| 839 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | |
| 840 | - $data['format_source'] = 'planeupdatefaa'; | |
| 841 | - $data['id_source'] = $id_source; | |
| 842 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 843 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 844 | - $SI->add($data); | |
| 845 | - unset($data); | |
| 838 | + } | |
| 839 | +			$data['datetime'] = date('Y-m-d H:i:s',$line[9]); | |
| 840 | + $data['format_source'] = 'planeupdatefaa'; | |
| 841 | + $data['id_source'] = $id_source; | |
| 842 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 843 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 844 | + $SI->add($data); | |
| 845 | + unset($data); | |
| 846 | + } | |
| 846 | 847 | } | 
| 847 | - } | |
| 848 | - //$last_exec['planeupdatefaa'] = time(); | |
| 849 | - $last_exec[$id]['last'] = time(); | |
| 850 | -    	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 851 | - $buffer = $Common->getData($value['host']); | |
| 852 | - $all_data = json_decode($buffer,true); | |
| 853 | -	    if (isset($all_data['states'])) { | |
| 848 | + //$last_exec['planeupdatefaa'] = time(); | |
| 849 | + $last_exec[$id]['last'] = time(); | |
| 850 | +		} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 851 | + $buffer = $Common->getData($value['host']); | |
| 852 | + $all_data = json_decode($buffer,true); | |
| 853 | +		if (isset($all_data['states'])) { | |
| 854 | 854 | $reset = 0; | 
| 855 | 855 |  		foreach ($all_data['states'] as $key => $line) { | 
| 856 | - $data = array(); | |
| 857 | - $data['hex'] = $line[0]; // hex | |
| 858 | - $data['ident'] = trim($line[1]); // ident | |
| 859 | - $data['altitude'] = round($line[7]*3.28084); // altitude | |
| 860 | - $data['speed'] = round($line[9]*1.94384); // speed | |
| 861 | - $data['heading'] = round($line[10]); // heading | |
| 862 | - $data['latitude'] = $line[6]; // lat | |
| 863 | - $data['longitude'] = $line[5]; // long | |
| 864 | - $data['verticalrate'] = $line[11]; // verticale rate | |
| 865 | - //$data['squawk'] = $line[10]; // squawk | |
| 866 | - //$data['emergency'] = ''; // emergency | |
| 867 | - //$data['registration'] = $line[2]; | |
| 868 | - //$data['aircraft_icao'] = $line[0]; | |
| 869 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | |
| 870 | - $data['format_source'] = 'opensky'; | |
| 871 | - $data['id_source'] = $id_source; | |
| 872 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 873 | - $SI->add($data); | |
| 874 | - unset($data); | |
| 856 | + $data = array(); | |
| 857 | + $data['hex'] = $line[0]; // hex | |
| 858 | + $data['ident'] = trim($line[1]); // ident | |
| 859 | + $data['altitude'] = round($line[7]*3.28084); // altitude | |
| 860 | + $data['speed'] = round($line[9]*1.94384); // speed | |
| 861 | + $data['heading'] = round($line[10]); // heading | |
| 862 | + $data['latitude'] = $line[6]; // lat | |
| 863 | + $data['longitude'] = $line[5]; // long | |
| 864 | + $data['verticalrate'] = $line[11]; // verticale rate | |
| 865 | + //$data['squawk'] = $line[10]; // squawk | |
| 866 | + //$data['emergency'] = ''; // emergency | |
| 867 | + //$data['registration'] = $line[2]; | |
| 868 | + //$data['aircraft_icao'] = $line[0]; | |
| 869 | +			$data['datetime'] = date('Y-m-d H:i:s',$line[3]); | |
| 870 | + $data['format_source'] = 'opensky'; | |
| 871 | + $data['id_source'] = $id_source; | |
| 872 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 873 | + $SI->add($data); | |
| 874 | + unset($data); | |
| 875 | 875 | } | 
| 876 | - } | |
| 877 | - //$last_exec['planeupdatefaa'] = time(); | |
| 878 | - $last_exec[$id]['last'] = time(); | |
| 879 | -    	//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { | |
| 880 | -    	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 881 | - //$buffer = $Common->getData($hosts[$id]); | |
| 882 | - $buffer = $Common->getData($value['host']); | |
| 883 | - $all_data = json_decode($buffer,true); | |
| 884 | - if (!empty($all_data)) $reset = 0; | |
| 885 | -	    foreach ($all_data as $key => $line) { | |
| 876 | + } | |
| 877 | + //$last_exec['planeupdatefaa'] = time(); | |
| 878 | + $last_exec[$id]['last'] = time(); | |
| 879 | +		//} elseif ($value == 'fr24json' && (time() - $last_exec['fr24json'] > $globalMinFetch)) { | |
| 880 | +		} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 881 | + //$buffer = $Common->getData($hosts[$id]); | |
| 882 | + $buffer = $Common->getData($value['host']); | |
| 883 | + $all_data = json_decode($buffer,true); | |
| 884 | + if (!empty($all_data)) $reset = 0; | |
| 885 | +		foreach ($all_data as $key => $line) { | |
| 886 | 886 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| 887 | - $data = array(); | |
| 888 | - $data['hex'] = $line[0]; | |
| 889 | - $data['ident'] = $line[16]; //$line[13] | |
| 890 | - $data['altitude'] = $line[4]; // altitude | |
| 891 | - $data['speed'] = $line[5]; // speed | |
| 892 | - $data['heading'] = $line[3]; // heading | |
| 893 | - $data['latitude'] = $line[1]; // lat | |
| 894 | - $data['longitude'] = $line[2]; // long | |
| 895 | - $data['verticalrate'] = $line[15]; // verticale rate | |
| 896 | - $data['squawk'] = $line[6]; // squawk | |
| 897 | - $data['aircraft_icao'] = $line[8]; | |
| 898 | - $data['registration'] = $line[9]; | |
| 899 | - $data['departure_airport_iata'] = $line[11]; | |
| 900 | - $data['arrival_airport_iata'] = $line[12]; | |
| 901 | - $data['emergency'] = ''; // emergency | |
| 902 | -		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] | |
| 903 | - $data['format_source'] = 'fr24json'; | |
| 904 | - $data['id_source'] = $id_source; | |
| 905 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 906 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 907 | - $SI->add($data); | |
| 908 | - unset($data); | |
| 887 | + $data = array(); | |
| 888 | + $data['hex'] = $line[0]; | |
| 889 | + $data['ident'] = $line[16]; //$line[13] | |
| 890 | + $data['altitude'] = $line[4]; // altitude | |
| 891 | + $data['speed'] = $line[5]; // speed | |
| 892 | + $data['heading'] = $line[3]; // heading | |
| 893 | + $data['latitude'] = $line[1]; // lat | |
| 894 | + $data['longitude'] = $line[2]; // long | |
| 895 | + $data['verticalrate'] = $line[15]; // verticale rate | |
| 896 | + $data['squawk'] = $line[6]; // squawk | |
| 897 | + $data['aircraft_icao'] = $line[8]; | |
| 898 | + $data['registration'] = $line[9]; | |
| 899 | + $data['departure_airport_iata'] = $line[11]; | |
| 900 | + $data['arrival_airport_iata'] = $line[12]; | |
| 901 | + $data['emergency'] = ''; // emergency | |
| 902 | +			$data['datetime'] = date('Y-m-d H:i:s'); //$line[10] | |
| 903 | + $data['format_source'] = 'fr24json'; | |
| 904 | + $data['id_source'] = $id_source; | |
| 905 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 906 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 907 | + $SI->add($data); | |
| 908 | + unset($data); | |
| 909 | + } | |
| 909 | 910 | } | 
| 910 | - } | |
| 911 | - //$last_exec['fr24json'] = time(); | |
| 912 | - $last_exec[$id]['last'] = time(); | |
| 913 | -    	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { | |
| 914 | -    	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 915 | - //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); | |
| 916 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); | |
| 917 | - //echo $buffer; | |
| 918 | -	    $buffer = str_replace(array("\n","\r"),"",$buffer); | |
| 919 | -	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer); | |
| 920 | - $all_data = json_decode($buffer,true); | |
| 921 | -	    if (json_last_error() != JSON_ERROR_NONE) { | |
| 911 | + //$last_exec['fr24json'] = time(); | |
| 912 | + $last_exec[$id]['last'] = time(); | |
| 913 | +		//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { | |
| 914 | +		} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 915 | + //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); | |
| 916 | + $buffer = $Common->getData($value['host'],'get','','','','','150'); | |
| 917 | + //echo $buffer; | |
| 918 | +		$buffer = str_replace(array("\n","\r"),"",$buffer); | |
| 919 | +		$buffer = preg_replace('/,"num":(.+)/','}',$buffer); | |
| 920 | + $all_data = json_decode($buffer,true); | |
| 921 | +		if (json_last_error() != JSON_ERROR_NONE) { | |
| 922 | 922 | die(json_last_error_msg()); | 
| 923 | - } | |
| 924 | -	    if (isset($all_data['mrkrs'])) { | |
| 923 | + } | |
| 924 | +		if (isset($all_data['mrkrs'])) { | |
| 925 | 925 | $reset = 0; | 
| 926 | 926 |  		foreach ($all_data['mrkrs'] as $key => $line) { | 
| 927 | -		    if (isset($line['inf'])) { | |
| 927 | +			if (isset($line['inf'])) { | |
| 928 | 928 | $data = array(); | 
| 929 | 929 | $data['hex'] = $line['inf']['ia']; | 
| 930 | 930 | if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] | 
| 931 | - $data['altitude'] = round($line['inf']['al']*3.28084); // altitude | |
| 932 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed | |
| 933 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading | |
| 934 | - $data['latitude'] = $line['pt'][0]; // lat | |
| 935 | - $data['longitude'] = $line['pt'][1]; // long | |
| 936 | - //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate | |
| 937 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk | |
| 938 | - //$data['aircraft_icao'] = $line[8]; | |
| 939 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; | |
| 931 | + $data['altitude'] = round($line['inf']['al']*3.28084); // altitude | |
| 932 | + if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed | |
| 933 | + if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading | |
| 934 | + $data['latitude'] = $line['pt'][0]; // lat | |
| 935 | + $data['longitude'] = $line['pt'][1]; // long | |
| 936 | + //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate | |
| 937 | + if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk | |
| 938 | + //$data['aircraft_icao'] = $line[8]; | |
| 939 | + if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; | |
| 940 | 940 | //$data['departure_airport_iata'] = $line[11]; | 
| 941 | 941 | //$data['arrival_airport_iata'] = $line[12]; | 
| 942 | - //$data['emergency'] = ''; // emergency | |
| 942 | + //$data['emergency'] = ''; // emergency | |
| 943 | 943 |  			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | 
| 944 | - $data['format_source'] = 'radarvirtueljson'; | |
| 945 | - $data['id_source'] = $id_source; | |
| 944 | + $data['format_source'] = 'radarvirtueljson'; | |
| 945 | + $data['id_source'] = $id_source; | |
| 946 | 946 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 947 | 947 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | 
| 948 | 948 | $SI->add($data); | 
| 949 | 949 | unset($data); | 
| 950 | - } | |
| 950 | + } | |
| 951 | 951 | } | 
| 952 | - } | |
| 953 | - //$last_exec['radarvirtueljson'] = time(); | |
| 954 | - $last_exec[$id]['last'] = time(); | |
| 955 | -    	//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { | |
| 956 | -    	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 957 | - //$buffer = $Common->getData($hosts[$id]); | |
| 958 | - $buffer = $Common->getData($value['host'].'?'.time()); | |
| 959 | - $all_data = json_decode(utf8_encode($buffer),true); | |
| 952 | + } | |
| 953 | + //$last_exec['radarvirtueljson'] = time(); | |
| 954 | + $last_exec[$id]['last'] = time(); | |
| 955 | +		//} elseif ($value == 'pirepsjson' && (time() - $last_exec['pirepsjson'] > $globalMinFetch)) { | |
| 956 | +		} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 957 | + //$buffer = $Common->getData($hosts[$id]); | |
| 958 | + $buffer = $Common->getData($value['host'].'?'.time()); | |
| 959 | + $all_data = json_decode(utf8_encode($buffer),true); | |
| 960 | 960 | |
| 961 | -	    if (isset($all_data['pireps'])) { | |
| 961 | +		if (isset($all_data['pireps'])) { | |
| 962 | 962 | $reset = 0; | 
| 963 | -	        foreach ($all_data['pireps'] as $line) { | |
| 964 | - $data = array(); | |
| 965 | - $data['id'] = $line['id']; | |
| 966 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | |
| 967 | - $data['ident'] = $line['callsign']; // ident | |
| 968 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | |
| 969 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | |
| 970 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude | |
| 971 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed | |
| 972 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 973 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 974 | - $data['latitude'] = $line['lat']; // lat | |
| 975 | - $data['longitude'] = $line['lon']; // long | |
| 976 | - //$data['verticalrate'] = $line['vrt']; // verticale rate | |
| 977 | - //$data['squawk'] = $line['squawk']; // squawk | |
| 978 | - //$data['emergency'] = ''; // emergency | |
| 979 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; | |
| 980 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; | |
| 981 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; | |
| 982 | - //$data['arrival_airport_time'] = $line['arrtime']; | |
| 983 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; | |
| 984 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; | |
| 985 | - if (isset($line['atis'])) $data['info'] = $line['atis']; | |
| 986 | - else $data['info'] = ''; | |
| 987 | - $data['format_source'] = 'pireps'; | |
| 988 | - $data['id_source'] = $id_source; | |
| 989 | -		    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 990 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 991 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 992 | -		    if ($line['icon'] == 'plane') { | |
| 963 | +			foreach ($all_data['pireps'] as $line) { | |
| 964 | + $data = array(); | |
| 965 | + $data['id'] = $line['id']; | |
| 966 | + $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | |
| 967 | + $data['ident'] = $line['callsign']; // ident | |
| 968 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | |
| 969 | + if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | |
| 970 | + if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude | |
| 971 | + if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed | |
| 972 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 973 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 974 | + $data['latitude'] = $line['lat']; // lat | |
| 975 | + $data['longitude'] = $line['lon']; // long | |
| 976 | + //$data['verticalrate'] = $line['vrt']; // verticale rate | |
| 977 | + //$data['squawk'] = $line['squawk']; // squawk | |
| 978 | + //$data['emergency'] = ''; // emergency | |
| 979 | + if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; | |
| 980 | + if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; | |
| 981 | + if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; | |
| 982 | + //$data['arrival_airport_time'] = $line['arrtime']; | |
| 983 | + if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; | |
| 984 | + if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; | |
| 985 | + if (isset($line['atis'])) $data['info'] = $line['atis']; | |
| 986 | + else $data['info'] = ''; | |
| 987 | + $data['format_source'] = 'pireps'; | |
| 988 | + $data['id_source'] = $id_source; | |
| 989 | +			$data['datetime'] = date('Y-m-d H:i:s'); | |
| 990 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 991 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 992 | +			if ($line['icon'] == 'plane') { | |
| 993 | 993 | $SI->add($data); | 
| 994 | - // print_r($data); | |
| 995 | -    		    } elseif ($line['icon'] == 'ct') { | |
| 994 | + // print_r($data); | |
| 995 | +				} elseif ($line['icon'] == 'ct') { | |
| 996 | 996 |  			$data['info'] = str_replace('^§','<br />',$data['info']); | 
| 997 | 997 |  			$data['info'] = str_replace('&sect;','',$data['info']); | 
| 998 | 998 | $typec = substr($data['ident'],-3); | 
| @@ -1007,199 +1007,199 @@ discard block | ||
| 1007 | 1007 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; | 
| 1008 | 1008 | else $data['type'] = 'Observer'; | 
| 1009 | 1009 | 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']); | 
| 1010 | - } | |
| 1011 | - unset($data); | |
| 1010 | + } | |
| 1011 | + unset($data); | |
| 1012 | 1012 | } | 
| 1013 | - } | |
| 1014 | - //$last_exec['pirepsjson'] = time(); | |
| 1015 | - $last_exec[$id]['last'] = time(); | |
| 1016 | -    	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { | |
| 1017 | -    	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 1018 | - //$buffer = $Common->getData($hosts[$id]); | |
| 1019 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1020 | - $buffer = $Common->getData($value['host']); | |
| 1021 | - $all_data = json_decode($buffer,true); | |
| 1022 | -	    if ($buffer != '' && is_array($all_data)) { | |
| 1013 | + } | |
| 1014 | + //$last_exec['pirepsjson'] = time(); | |
| 1015 | + $last_exec[$id]['last'] = time(); | |
| 1016 | +		//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { | |
| 1017 | +		} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 1018 | + //$buffer = $Common->getData($hosts[$id]); | |
| 1019 | + if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1020 | + $buffer = $Common->getData($value['host']); | |
| 1021 | + $all_data = json_decode($buffer,true); | |
| 1022 | +		if ($buffer != '' && is_array($all_data)) { | |
| 1023 | 1023 | $reset = 0; | 
| 1024 | 1024 |  		foreach ($all_data as $line) { | 
| 1025 | - $data = array(); | |
| 1026 | - //$data['id'] = $line['id']; // id not usable | |
| 1027 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1028 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1029 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | |
| 1030 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | |
| 1031 | - $data['ident'] = $line['flightnum']; // ident | |
| 1032 | - $data['altitude'] = $line['alt']; // altitude | |
| 1033 | - $data['speed'] = $line['gs']; // speed | |
| 1034 | - $data['heading'] = $line['heading']; // heading | |
| 1035 | - $data['latitude'] = $line['lat']; // lat | |
| 1036 | - $data['longitude'] = $line['lng']; // long | |
| 1037 | - $data['verticalrate'] = ''; // verticale rate | |
| 1038 | - $data['squawk'] = ''; // squawk | |
| 1039 | - $data['emergency'] = ''; // emergency | |
| 1040 | - //$data['datetime'] = $line['lastupdate']; | |
| 1041 | - $data['last_update'] = $line['lastupdate']; | |
| 1042 | -		    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1043 | - $data['departure_airport_icao'] = $line['depicao']; | |
| 1044 | - $data['departure_airport_time'] = $line['deptime']; | |
| 1045 | - $data['arrival_airport_icao'] = $line['arricao']; | |
| 1046 | - $data['arrival_airport_time'] = $line['arrtime']; | |
| 1047 | - $data['registration'] = $line['aircraft']; | |
| 1048 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1049 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1050 | -		    if (isset($line['aircraftname'])) { | |
| 1025 | + $data = array(); | |
| 1026 | + //$data['id'] = $line['id']; // id not usable | |
| 1027 | + if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1028 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1029 | + if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | |
| 1030 | + if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | |
| 1031 | + $data['ident'] = $line['flightnum']; // ident | |
| 1032 | + $data['altitude'] = $line['alt']; // altitude | |
| 1033 | + $data['speed'] = $line['gs']; // speed | |
| 1034 | + $data['heading'] = $line['heading']; // heading | |
| 1035 | + $data['latitude'] = $line['lat']; // lat | |
| 1036 | + $data['longitude'] = $line['lng']; // long | |
| 1037 | + $data['verticalrate'] = ''; // verticale rate | |
| 1038 | + $data['squawk'] = ''; // squawk | |
| 1039 | + $data['emergency'] = ''; // emergency | |
| 1040 | + //$data['datetime'] = $line['lastupdate']; | |
| 1041 | + $data['last_update'] = $line['lastupdate']; | |
| 1042 | +			$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1043 | + $data['departure_airport_icao'] = $line['depicao']; | |
| 1044 | + $data['departure_airport_time'] = $line['deptime']; | |
| 1045 | + $data['arrival_airport_icao'] = $line['arricao']; | |
| 1046 | + $data['arrival_airport_time'] = $line['arrtime']; | |
| 1047 | + $data['registration'] = $line['aircraft']; | |
| 1048 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1049 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1050 | +			if (isset($line['aircraftname'])) { | |
| 1051 | 1051 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1052 | 1052 |  			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | 
| 1053 | -	    		$aircraft_data = explode('-',$line['aircraftname']); | |
| 1054 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1055 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1056 | -	    		else { | |
| 1057 | -	    		    $aircraft_data = explode(' ',$line['aircraftname']); | |
| 1058 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1059 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1060 | - } | |
| 1061 | - } | |
| 1062 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; | |
| 1063 | - $data['id_source'] = $id_source; | |
| 1064 | - $data['format_source'] = 'phpvmacars'; | |
| 1065 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1066 | - $SI->add($data); | |
| 1067 | - unset($data); | |
| 1053 | +				$aircraft_data = explode('-',$line['aircraftname']); | |
| 1054 | + if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1055 | + elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1056 | +				else { | |
| 1057 | +					$aircraft_data = explode(' ',$line['aircraftname']); | |
| 1058 | +					if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1059 | +					else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1060 | + } | |
| 1061 | + } | |
| 1062 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; | |
| 1063 | + $data['id_source'] = $id_source; | |
| 1064 | + $data['format_source'] = 'phpvmacars'; | |
| 1065 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1066 | + $SI->add($data); | |
| 1067 | + unset($data); | |
| 1068 | 1068 | } | 
| 1069 | 1069 | if ($globalDebug) echo 'No more data...'."\n"; | 
| 1070 | 1070 | unset($buffer); | 
| 1071 | 1071 | unset($all_data); | 
| 1072 | - } | |
| 1073 | - //$last_exec['phpvmacars'] = time(); | |
| 1074 | - $last_exec[$id]['last'] = time(); | |
| 1075 | -    	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 1076 | - //$buffer = $Common->getData($hosts[$id]); | |
| 1077 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1078 | - $buffer = $Common->getData($value['host']); | |
| 1079 | - $all_data = json_decode($buffer,true); | |
| 1080 | -	    if ($buffer != '' && is_array($all_data)) { | |
| 1072 | + } | |
| 1073 | + //$last_exec['phpvmacars'] = time(); | |
| 1074 | + $last_exec[$id]['last'] = time(); | |
| 1075 | +		} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | |
| 1076 | + //$buffer = $Common->getData($hosts[$id]); | |
| 1077 | + if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1078 | + $buffer = $Common->getData($value['host']); | |
| 1079 | + $all_data = json_decode($buffer,true); | |
| 1080 | +		if ($buffer != '' && is_array($all_data)) { | |
| 1081 | 1081 | $reset = 0; | 
| 1082 | 1082 |  		foreach ($all_data as $line) { | 
| 1083 | - $data = array(); | |
| 1084 | - //$data['id'] = $line['id']; // id not usable | |
| 1085 | - $data['id'] = trim($line['flight_id']); | |
| 1086 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1087 | - $data['pilot_name'] = $line['pilot_name']; | |
| 1088 | - $data['pilot_id'] = $line['pilot_id']; | |
| 1089 | - $data['ident'] = trim($line['callsign']); // ident | |
| 1090 | - $data['altitude'] = $line['altitude']; // altitude | |
| 1091 | - $data['speed'] = $line['gs']; // speed | |
| 1092 | - $data['heading'] = $line['heading']; // heading | |
| 1093 | - $data['latitude'] = $line['latitude']; // lat | |
| 1094 | - $data['longitude'] = $line['longitude']; // long | |
| 1095 | - $data['verticalrate'] = ''; // verticale rate | |
| 1096 | - $data['squawk'] = ''; // squawk | |
| 1097 | - $data['emergency'] = ''; // emergency | |
| 1098 | - //$data['datetime'] = $line['lastupdate']; | |
| 1099 | - $data['last_update'] = $line['last_update']; | |
| 1100 | -		    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1101 | - $data['departure_airport_icao'] = $line['departure']; | |
| 1102 | - //$data['departure_airport_time'] = $line['departure_time']; | |
| 1103 | - $data['arrival_airport_icao'] = $line['arrival']; | |
| 1104 | - //$data['arrival_airport_time'] = $line['arrival_time']; | |
| 1105 | - //$data['registration'] = $line['aircraft']; | |
| 1106 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1107 | - $data['aircraft_icao'] = $line['plane_type']; | |
| 1108 | - $data['id_source'] = $id_source; | |
| 1109 | - $data['format_source'] = 'vam'; | |
| 1110 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1111 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1112 | - $SI->add($data); | |
| 1113 | - unset($data); | |
| 1083 | + $data = array(); | |
| 1084 | + //$data['id'] = $line['id']; // id not usable | |
| 1085 | + $data['id'] = trim($line['flight_id']); | |
| 1086 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1087 | + $data['pilot_name'] = $line['pilot_name']; | |
| 1088 | + $data['pilot_id'] = $line['pilot_id']; | |
| 1089 | + $data['ident'] = trim($line['callsign']); // ident | |
| 1090 | + $data['altitude'] = $line['altitude']; // altitude | |
| 1091 | + $data['speed'] = $line['gs']; // speed | |
| 1092 | + $data['heading'] = $line['heading']; // heading | |
| 1093 | + $data['latitude'] = $line['latitude']; // lat | |
| 1094 | + $data['longitude'] = $line['longitude']; // long | |
| 1095 | + $data['verticalrate'] = ''; // verticale rate | |
| 1096 | + $data['squawk'] = ''; // squawk | |
| 1097 | + $data['emergency'] = ''; // emergency | |
| 1098 | + //$data['datetime'] = $line['lastupdate']; | |
| 1099 | + $data['last_update'] = $line['last_update']; | |
| 1100 | +			$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1101 | + $data['departure_airport_icao'] = $line['departure']; | |
| 1102 | + //$data['departure_airport_time'] = $line['departure_time']; | |
| 1103 | + $data['arrival_airport_icao'] = $line['arrival']; | |
| 1104 | + //$data['arrival_airport_time'] = $line['arrival_time']; | |
| 1105 | + //$data['registration'] = $line['aircraft']; | |
| 1106 | + if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1107 | + $data['aircraft_icao'] = $line['plane_type']; | |
| 1108 | + $data['id_source'] = $id_source; | |
| 1109 | + $data['format_source'] = 'vam'; | |
| 1110 | + if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1111 | + if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1112 | + $SI->add($data); | |
| 1113 | + unset($data); | |
| 1114 | 1114 | } | 
| 1115 | 1115 | if ($globalDebug) echo 'No more data...'."\n"; | 
| 1116 | 1116 | unset($buffer); | 
| 1117 | 1117 | unset($all_data); | 
| 1118 | - } | |
| 1119 | - //$last_exec['phpvmacars'] = time(); | |
| 1120 | - $last_exec[$id]['last'] = time(); | |
| 1118 | + } | |
| 1119 | + //$last_exec['phpvmacars'] = time(); | |
| 1120 | + $last_exec[$id]['last'] = time(); | |
| 1121 | 1121 |  	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { | 
| 1122 | 1122 |  	} 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') { | 
| 1123 | -	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1124 | - //$last_exec[$id]['last'] = time(); | |
| 1123 | +		if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1124 | + //$last_exec[$id]['last'] = time(); | |
| 1125 | 1125 | |
| 1126 | - //$read = array( $sockets[$id] ); | |
| 1127 | - $read = $sockets; | |
| 1128 | - $write = NULL; | |
| 1129 | - $e = NULL; | |
| 1130 | - $n = socket_select($read, $write, $e, $timeout); | |
| 1131 | - if ($e != NULL) var_dump($e); | |
| 1132 | -	    if ($n > 0) { | |
| 1126 | + //$read = array( $sockets[$id] ); | |
| 1127 | + $read = $sockets; | |
| 1128 | + $write = NULL; | |
| 1129 | + $e = NULL; | |
| 1130 | + $n = socket_select($read, $write, $e, $timeout); | |
| 1131 | + if ($e != NULL) var_dump($e); | |
| 1132 | +		if ($n > 0) { | |
| 1133 | 1133 | $reset = 0; | 
| 1134 | 1134 |  		foreach ($read as $nb => $r) { | 
| 1135 | - //$value = $formats[$nb]; | |
| 1136 | - $format = $globalSources[$nb]['format']; | |
| 1137 | -		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { | |
| 1135 | + //$value = $formats[$nb]; | |
| 1136 | + $format = $globalSources[$nb]['format']; | |
| 1137 | +			if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { | |
| 1138 | 1138 | $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); | 
| 1139 | -		    } elseif ($format == 'vrstcp') { | |
| 1139 | +			} elseif ($format == 'vrstcp') { | |
| 1140 | 1140 | $buffer = @socket_read($r, 6000); | 
| 1141 | -		    } else { | |
| 1141 | +			} else { | |
| 1142 | 1142 | $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); | 
| 1143 | - } | |
| 1144 | - //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); | |
| 1145 | - //echo $buffer."\n"; | |
| 1146 | - // lets play nice and handle signals such as ctrl-c/kill properly | |
| 1147 | -		    //if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1148 | - $error = false; | |
| 1149 | - //$SI::del(); | |
| 1150 | -		    if ($format == 'vrstcp') { | |
| 1143 | + } | |
| 1144 | + //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); | |
| 1145 | + //echo $buffer."\n"; | |
| 1146 | + // lets play nice and handle signals such as ctrl-c/kill properly | |
| 1147 | +			//if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1148 | + $error = false; | |
| 1149 | + //$SI::del(); | |
| 1150 | +			if ($format == 'vrstcp') { | |
| 1151 | 1151 |  			$buffer = explode('},{',$buffer); | 
| 1152 | -		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1153 | - // SBS format is CSV format | |
| 1154 | -		    if ($buffer !== FALSE && $buffer != '') { | |
| 1152 | +			} else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1153 | + // SBS format is CSV format | |
| 1154 | +			if ($buffer !== FALSE && $buffer != '') { | |
| 1155 | 1155 | $tt[$format] = 0; | 
| 1156 | 1156 |  			if ($format == 'acarssbs3') { | 
| 1157 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1158 | - $ACARS->add(trim($buffer)); | |
| 1159 | - $ACARS->deleteLiveAcarsData(); | |
| 1157 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1158 | + $ACARS->add(trim($buffer)); | |
| 1159 | + $ACARS->deleteLiveAcarsData(); | |
| 1160 | 1160 |  			} elseif ($format == 'raw') { | 
| 1161 | - // AVR format | |
| 1162 | - $data = $SBS->parse($buffer); | |
| 1163 | -			    if (is_array($data)) { | |
| 1161 | + // AVR format | |
| 1162 | + $data = $SBS->parse($buffer); | |
| 1163 | +				if (is_array($data)) { | |
| 1164 | 1164 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1165 | 1165 | $data['format_source'] = 'raw'; | 
| 1166 | 1166 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | 
| 1167 | 1167 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | 
| 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 | + } | |
| 1171 | 1171 |  			} elseif ($format == 'ais') { | 
| 1172 | - $ais_data = $AIS->parse_line(trim($buffer)); | |
| 1173 | - $data = array(); | |
| 1174 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 1175 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 1176 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 1177 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 1178 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 1179 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 1180 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 1181 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 1182 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 1183 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 1184 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 1185 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 1186 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1187 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1188 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1189 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1172 | + $ais_data = $AIS->parse_line(trim($buffer)); | |
| 1173 | + $data = array(); | |
| 1174 | + if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 1175 | + if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 1176 | + if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 1177 | + if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 1178 | + if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 1179 | + if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 1180 | + if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 1181 | + if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 1182 | + if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 1183 | + if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 1184 | + if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 1185 | + if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 1186 | +				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1187 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1188 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1189 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1190 | 1190 | |
| 1191 | -			    if (isset($ais_data['timestamp'])) { | |
| 1191 | +				if (isset($ais_data['timestamp'])) { | |
| 1192 | 1192 |  				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 1193 | -			    } else { | |
| 1193 | +				} else { | |
| 1194 | 1194 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1195 | - } | |
| 1196 | - $data['format_source'] = 'aisnmea'; | |
| 1197 | - $data['id_source'] = $id_source; | |
| 1198 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 1199 | - unset($data); | |
| 1200 | -                        } elseif ($format == 'flightgearsp') { | |
| 1201 | - //echo $buffer."\n"; | |
| 1202 | -                    	    if (strlen($buffer) > 5) { | |
| 1195 | + } | |
| 1196 | + $data['format_source'] = 'aisnmea'; | |
| 1197 | + $data['id_source'] = $id_source; | |
| 1198 | + if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 1199 | + unset($data); | |
| 1200 | +						} elseif ($format == 'flightgearsp') { | |
| 1201 | + //echo $buffer."\n"; | |
| 1202 | +							if (strlen($buffer) > 5) { | |
| 1203 | 1203 |  				$line = explode(',',$buffer); | 
| 1204 | 1204 | $data = array(); | 
| 1205 | 1205 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p | 
| @@ -1216,38 +1216,38 @@ discard block | ||
| 1216 | 1216 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1217 | 1217 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | 
| 1218 | 1218 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | 
| 1219 | - } | |
| 1220 | -                        } elseif ($format == 'acars') { | |
| 1221 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1222 | - $ACARS->add(trim($buffer)); | |
| 1223 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | |
| 1224 | - $ACARS->deleteLiveAcarsData(); | |
| 1219 | + } | |
| 1220 | +						} elseif ($format == 'acars') { | |
| 1221 | + if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1222 | + $ACARS->add(trim($buffer)); | |
| 1223 | + socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | |
| 1224 | + $ACARS->deleteLiveAcarsData(); | |
| 1225 | 1225 |  			} elseif ($format == 'flightgearmp') { | 
| 1226 | -			    if (substr($buffer,0,1) != '#') { | |
| 1226 | +				if (substr($buffer,0,1) != '#') { | |
| 1227 | 1227 | $data = array(); | 
| 1228 | 1228 | //echo $buffer."\n"; | 
| 1229 | 1229 |  				$line = explode(' ',$buffer); | 
| 1230 | 1230 |  				if (count($line) == 11) { | 
| 1231 | -				    $userserver = explode('@',$line[0]); | |
| 1232 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex | |
| 1233 | - $data['ident'] = $userserver[0]; | |
| 1234 | - $data['registration'] = $userserver[0]; | |
| 1235 | - $data['latitude'] = $line[4]; | |
| 1236 | - $data['longitude'] = $line[5]; | |
| 1237 | - $data['altitude'] = $line[6]; | |
| 1238 | -				    $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1239 | - $aircraft_type = $line[10]; | |
| 1240 | -				    $aircraft_type = preg_split(':/:',$aircraft_type); | |
| 1241 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | |
| 1242 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1243 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1231 | +					$userserver = explode('@',$line[0]); | |
| 1232 | + $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex | |
| 1233 | + $data['ident'] = $userserver[0]; | |
| 1234 | + $data['registration'] = $userserver[0]; | |
| 1235 | + $data['latitude'] = $line[4]; | |
| 1236 | + $data['longitude'] = $line[5]; | |
| 1237 | + $data['altitude'] = $line[6]; | |
| 1238 | +					$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1239 | + $aircraft_type = $line[10]; | |
| 1240 | +					$aircraft_type = preg_split(':/:',$aircraft_type); | |
| 1241 | + $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | |
| 1242 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1243 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1244 | + } | |
| 1244 | 1245 | } | 
| 1245 | - } | |
| 1246 | 1246 |  			} elseif ($format == 'beast') { | 
| 1247 | - echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; | |
| 1248 | - die; | |
| 1247 | + echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; | |
| 1248 | + die; | |
| 1249 | 1249 |  			} elseif ($format == 'vrstcp') { | 
| 1250 | -			    foreach($buffer as $all_data) { | |
| 1250 | +				foreach($buffer as $all_data) { | |
| 1251 | 1251 |  				$line = json_decode('{'.$all_data.'}',true); | 
| 1252 | 1252 | $data = array(); | 
| 1253 | 1253 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | 
| @@ -1267,123 +1267,123 @@ discard block | ||
| 1267 | 1267 | */ | 
| 1268 | 1268 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1269 | 1269 | if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | 
| 1270 | - $data['format_source'] = 'vrstcp'; | |
| 1270 | + $data['format_source'] = 'vrstcp'; | |
| 1271 | 1271 | $data['id_source'] = $id_source; | 
| 1272 | 1272 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1273 | 1273 | if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | 
| 1274 | 1274 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | 
| 1275 | 1275 | unset($data); | 
| 1276 | - } | |
| 1276 | + } | |
| 1277 | 1277 |  			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { | 
| 1278 | -			    $line = explode("\t", $buffer); | |
| 1279 | -			    for($k = 0; $k < count($line); $k=$k+2) { | |
| 1278 | +				$line = explode("\t", $buffer); | |
| 1279 | +				for($k = 0; $k < count($line); $k=$k+2) { | |
| 1280 | 1280 | $key = $line[$k]; | 
| 1281 | - $lined[$key] = $line[$k+1]; | |
| 1282 | - } | |
| 1283 | -    			    if (count($lined) > 3) { | |
| 1284 | - $data['hex'] = $lined['hexid']; | |
| 1285 | -    				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | |
| 1286 | -    				$data['datetime'] = date('Y-m-d H:i:s');; | |
| 1287 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | |
| 1288 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | |
| 1289 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | |
| 1290 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; | |
| 1291 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; | |
| 1292 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; | |
| 1293 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; | |
| 1294 | - $data['id_source'] = $id_source; | |
| 1295 | - $data['format_source'] = 'tsv'; | |
| 1296 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1297 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1281 | + $lined[$key] = $line[$k+1]; | |
| 1282 | + } | |
| 1283 | +					if (count($lined) > 3) { | |
| 1284 | + $data['hex'] = $lined['hexid']; | |
| 1285 | +					//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | |
| 1286 | +					$data['datetime'] = date('Y-m-d H:i:s');; | |
| 1287 | + if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | |
| 1288 | + if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | |
| 1289 | + if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | |
| 1290 | + if (isset($lined['speed'])) $data['speed'] = $lined['speed']; | |
| 1291 | + if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; | |
| 1292 | + if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; | |
| 1293 | + if (isset($lined['heading'])) $data['heading'] = $lined['heading']; | |
| 1294 | + $data['id_source'] = $id_source; | |
| 1295 | + $data['format_source'] = 'tsv'; | |
| 1296 | + if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1297 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1298 | 1298 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1299 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1300 | - unset($lined); | |
| 1301 | - unset($data); | |
| 1302 | - } else $error = true; | |
| 1299 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1300 | + unset($lined); | |
| 1301 | + unset($data); | |
| 1302 | + } else $error = true; | |
| 1303 | 1303 |  			} elseif ($format == 'aprs' && $use_aprs) { | 
| 1304 | -			    if ($aprs_connect == 0) { | |
| 1304 | +				if ($aprs_connect == 0) { | |
| 1305 | 1305 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | 
| 1306 | 1306 | $aprs_connect = 1; | 
| 1307 | - } | |
| 1307 | + } | |
| 1308 | 1308 | |
| 1309 | -			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { | |
| 1309 | +				if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { | |
| 1310 | 1310 | $aprs_last_tx = time(); | 
| 1311 | 1311 | $data_aprs = "# Keep alive"; | 
| 1312 | 1312 | $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | 
| 1313 | - } | |
| 1313 | + } | |
| 1314 | 1314 | |
| 1315 | - //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; | |
| 1316 | - //echo 'APRS data : '.$buffer."\n"; | |
| 1317 | -			    $buffer = str_replace('APRS <- ','',$buffer); | |
| 1318 | -			    $buffer = str_replace('APRS -> ','',$buffer); | |
| 1319 | - //echo $buffer."\n"; | |
| 1320 | -			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { | |
| 1315 | + //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; | |
| 1316 | + //echo 'APRS data : '.$buffer."\n"; | |
| 1317 | +				$buffer = str_replace('APRS <- ','',$buffer); | |
| 1318 | +				$buffer = str_replace('APRS -> ','',$buffer); | |
| 1319 | + //echo $buffer."\n"; | |
| 1320 | +				if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { | |
| 1321 | 1321 | $line = $APRS->parse($buffer); | 
| 1322 | 1322 |  				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { | 
| 1323 | 1323 |  				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { | 
| 1324 | - $aprs_last_tx = time(); | |
| 1325 | - $data = array(); | |
| 1326 | - //print_r($line); | |
| 1327 | - if (isset($line['address'])) $data['hex'] = $line['address']; | |
| 1328 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; | |
| 1329 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; | |
| 1330 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; | |
| 1331 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; | |
| 1332 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; | |
| 1333 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; | |
| 1334 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; | |
| 1335 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1336 | -				    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1337 | -				    //$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1338 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; | |
| 1339 | - $data['latitude'] = $line['latitude']; | |
| 1340 | - $data['longitude'] = $line['longitude']; | |
| 1341 | - //$data['verticalrate'] = $line[16]; | |
| 1342 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; | |
| 1343 | - else $data['speed'] = 0; | |
| 1344 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; | |
| 1345 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; | |
| 1346 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; | |
| 1347 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; | |
| 1348 | - //else $data['heading'] = 0; | |
| 1349 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; | |
| 1350 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; | |
| 1351 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1352 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; | |
| 1353 | - $data['id_source'] = $id_source; | |
| 1354 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; | |
| 1355 | - else $data['format_source'] = 'aprs'; | |
| 1356 | - $data['source_name'] = $line['source']; | |
| 1357 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; | |
| 1358 | - else $data['source_type'] = 'flarm'; | |
| 1359 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1360 | -				    $currentdate = date('Y-m-d H:i:s'); | |
| 1361 | - $aprsdate = strtotime($data['datetime']); | |
| 1362 | - // Accept data if time <= system time + 20s | |
| 1363 | -				    //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'])))) { | |
| 1364 | -				    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'])))) { | |
| 1324 | + $aprs_last_tx = time(); | |
| 1325 | + $data = array(); | |
| 1326 | + //print_r($line); | |
| 1327 | + if (isset($line['address'])) $data['hex'] = $line['address']; | |
| 1328 | + if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; | |
| 1329 | + if (isset($line['imo'])) $data['imo'] = $line['imo']; | |
| 1330 | + if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; | |
| 1331 | + if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; | |
| 1332 | + if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; | |
| 1333 | + if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; | |
| 1334 | + if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; | |
| 1335 | +					if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1336 | +					else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1337 | +					//$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1338 | + if (isset($line['ident'])) $data['ident'] = $line['ident']; | |
| 1339 | + $data['latitude'] = $line['latitude']; | |
| 1340 | + $data['longitude'] = $line['longitude']; | |
| 1341 | + //$data['verticalrate'] = $line[16]; | |
| 1342 | + if (isset($line['speed'])) $data['speed'] = $line['speed']; | |
| 1343 | + else $data['speed'] = 0; | |
| 1344 | + if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; | |
| 1345 | + if (isset($line['comment'])) $data['comment'] = $line['comment']; | |
| 1346 | + if (isset($line['symbol'])) $data['type'] = $line['symbol']; | |
| 1347 | + if (isset($line['heading'])) $data['heading'] = $line['heading']; | |
| 1348 | + //else $data['heading'] = 0; | |
| 1349 | + if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; | |
| 1350 | + if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; | |
| 1351 | + if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1352 | + elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; | |
| 1353 | + $data['id_source'] = $id_source; | |
| 1354 | + if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; | |
| 1355 | + else $data['format_source'] = 'aprs'; | |
| 1356 | + $data['source_name'] = $line['source']; | |
| 1357 | + if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; | |
| 1358 | + else $data['source_type'] = 'flarm'; | |
| 1359 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1360 | +					$currentdate = date('Y-m-d H:i:s'); | |
| 1361 | + $aprsdate = strtotime($data['datetime']); | |
| 1362 | + // Accept data if time <= system time + 20s | |
| 1363 | +					//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'])))) { | |
| 1364 | +					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'])))) { | |
| 1365 | 1365 | $send = $SI->add($data); | 
| 1366 | -				    } elseif ($data['source_type'] == 'ais') { | |
| 1366 | +					} elseif ($data['source_type'] == 'ais') { | |
| 1367 | 1367 | if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); | 
| 1368 | -				    } elseif (isset($line['stealth'])) { | |
| 1368 | +					} elseif (isset($line['stealth'])) { | |
| 1369 | 1369 | if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; | 
| 1370 | 1370 | else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; | 
| 1371 | -				    //} 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')) { | |
| 1372 | -				    } 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') { | |
| 1371 | +					//} 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')) { | |
| 1372 | +					} 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') { | |
| 1373 | 1373 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; | 
| 1374 | 1374 | if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); | 
| 1375 | -				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident'])) { | |
| 1375 | +					} elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident'])) { | |
| 1376 | 1376 |  					$Source->deleteOldLocationByType('gs'); | 
| 1377 | 1377 |  					if (count($Source->getLocationInfoByName($data['ident'])) > 0) { | 
| 1378 | 1378 | $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | 
| 1379 | 1379 |  					} else { | 
| 1380 | 1380 | $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | 
| 1381 | 1381 | } | 
| 1382 | -				    } else { | |
| 1383 | - echo '/!\ Not added'."\n"; | |
| 1384 | - print_r($data); | |
| 1385 | - } | |
| 1386 | - unset($data); | |
| 1382 | +					} else { | |
| 1383 | + echo '/!\ Not added'."\n"; | |
| 1384 | + print_r($data); | |
| 1385 | + } | |
| 1386 | + unset($data); | |
| 1387 | 1387 | } | 
| 1388 | 1388 |  				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { | 
| 1389 | 1389 | echo '!! Weather Station not yet supported'."\n"; | 
| @@ -1395,12 +1395,12 @@ discard block | ||
| 1395 | 1395 | */ | 
| 1396 | 1396 |  				elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; | 
| 1397 | 1397 | elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; | 
| 1398 | - } | |
| 1398 | + } | |
| 1399 | 1399 |  			} else { | 
| 1400 | -			    $line = explode(',', $buffer); | |
| 1401 | -    			    if (count($line) > 20) { | |
| 1402 | - $data['hex'] = $line[4]; | |
| 1403 | - /* | |
| 1400 | +				$line = explode(',', $buffer); | |
| 1401 | +					if (count($line) > 20) { | |
| 1402 | + $data['hex'] = $line[4]; | |
| 1403 | + /* | |
| 1404 | 1404 | $data['datetime'] = $line[6].' '.$line[7]; | 
| 1405 | 1405 | date_default_timezone_set($globalTimezone); | 
| 1406 | 1406 | $datetime = new DateTime($data['datetime']); | 
| @@ -1408,30 +1408,30 @@ discard block | ||
| 1408 | 1408 |      					$data['datetime'] = $datetime->format('Y-m-d H:i:s'); | 
| 1409 | 1409 |      					date_default_timezone_set('UTC'); | 
| 1410 | 1410 | */ | 
| 1411 | - // Force datetime to current UTC datetime | |
| 1412 | -    				date_default_timezone_set('UTC'); | |
| 1413 | -    				$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1414 | - $data['ident'] = trim($line[10]); | |
| 1415 | - $data['latitude'] = $line[14]; | |
| 1416 | - $data['longitude'] = $line[15]; | |
| 1417 | - $data['verticalrate'] = $line[16]; | |
| 1418 | - $data['emergency'] = $line[20]; | |
| 1419 | - $data['speed'] = $line[12]; | |
| 1420 | - $data['squawk'] = $line[17]; | |
| 1421 | - $data['altitude'] = $line[11]; | |
| 1422 | - $data['heading'] = $line[13]; | |
| 1423 | - $data['ground'] = $line[21]; | |
| 1424 | - $data['emergency'] = $line[19]; | |
| 1425 | - $data['format_source'] = 'sbs'; | |
| 1411 | + // Force datetime to current UTC datetime | |
| 1412 | +					date_default_timezone_set('UTC'); | |
| 1413 | +					$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1414 | + $data['ident'] = trim($line[10]); | |
| 1415 | + $data['latitude'] = $line[14]; | |
| 1416 | + $data['longitude'] = $line[15]; | |
| 1417 | + $data['verticalrate'] = $line[16]; | |
| 1418 | + $data['emergency'] = $line[20]; | |
| 1419 | + $data['speed'] = $line[12]; | |
| 1420 | + $data['squawk'] = $line[17]; | |
| 1421 | + $data['altitude'] = $line[11]; | |
| 1422 | + $data['heading'] = $line[13]; | |
| 1423 | + $data['ground'] = $line[21]; | |
| 1424 | + $data['emergency'] = $line[19]; | |
| 1425 | + $data['format_source'] = 'sbs'; | |
| 1426 | 1426 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | 
| 1427 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1427 | + if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1428 | 1428 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1429 | - $data['id_source'] = $id_source; | |
| 1430 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); | |
| 1431 | - else $error = true; | |
| 1432 | - unset($data); | |
| 1433 | - } else $error = true; | |
| 1434 | -			    if ($error) { | |
| 1429 | + $data['id_source'] = $id_source; | |
| 1430 | + if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); | |
| 1431 | + else $error = true; | |
| 1432 | + unset($data); | |
| 1433 | + } else $error = true; | |
| 1434 | +				if ($error) { | |
| 1435 | 1435 |  				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) {  | 
| 1436 | 1436 | if ($globalDebug) echo "Not a message. Ignoring... \n"; | 
| 1437 | 1437 |  				} else { | 
| @@ -1447,13 +1447,13 @@ discard block | ||
| 1447 | 1447 | connect_all($sourceer); | 
| 1448 | 1448 | $sourceer = array(); | 
| 1449 | 1449 | } | 
| 1450 | - } | |
| 1450 | + } | |
| 1451 | 1451 | } | 
| 1452 | 1452 | // Sleep for xxx microseconds | 
| 1453 | 1453 | if (isset($globalSBSSleep)) usleep($globalSBSSleep); | 
| 1454 | -		    } else { | |
| 1454 | +			} else { | |
| 1455 | 1455 |  			if ($format == 'flightgearmp') { | 
| 1456 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; | |
| 1456 | + if ($globalDebug) echo "Reconnect FlightGear MP..."; | |
| 1457 | 1457 | //@socket_close($r); | 
| 1458 | 1458 | sleep($globalMinFetch); | 
| 1459 | 1459 | $sourcefg[$nb] = $globalSources[$nb]; | 
| @@ -1462,9 +1462,9 @@ discard block | ||
| 1462 | 1462 | break; | 
| 1463 | 1463 | |
| 1464 | 1464 |  			} elseif ($format != 'acars' && $format != 'flightgearsp') { | 
| 1465 | - if (isset($tt[$format])) $tt[$format]++; | |
| 1466 | - else $tt[$format] = 0; | |
| 1467 | -			    if ($tt[$format] > 30) { | |
| 1465 | + if (isset($tt[$format])) $tt[$format]++; | |
| 1466 | + else $tt[$format] = 0; | |
| 1467 | +				if ($tt[$format] > 30) { | |
| 1468 | 1468 | if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; | 
| 1469 | 1469 | //@socket_close($r); | 
| 1470 | 1470 | sleep(2); | 
| @@ -1475,23 +1475,23 @@ discard block | ||
| 1475 | 1475 | //connect_all($globalSources); | 
| 1476 | 1476 | $tt[$format]=0; | 
| 1477 | 1477 | break; | 
| 1478 | - } | |
| 1478 | + } | |
| 1479 | + } | |
| 1479 | 1480 | } | 
| 1480 | - } | |
| 1481 | 1481 | } | 
| 1482 | -	    } else { | |
| 1482 | +		} else { | |
| 1483 | 1483 | $error = socket_strerror(socket_last_error()); | 
| 1484 | 1484 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 1485 | 1485 | if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | 
| 1486 | 1486 | if (isset($globalDebug)) echo "Restarting...\n"; | 
| 1487 | 1487 | // Restart the script if possible | 
| 1488 | 1488 |  			if (is_array($sockets)) { | 
| 1489 | - if ($globalDebug) echo "Shutdown all sockets..."; | |
| 1489 | + if ($globalDebug) echo "Shutdown all sockets..."; | |
| 1490 | 1490 | |
| 1491 | -			    foreach ($sockets as $sock) { | |
| 1491 | +				foreach ($sockets as $sock) { | |
| 1492 | 1492 | @socket_shutdown($sock,2); | 
| 1493 | 1493 | @socket_close($sock); | 
| 1494 | - } | |
| 1494 | + } | |
| 1495 | 1495 | |
| 1496 | 1496 | } | 
| 1497 | 1497 | if ($globalDebug) echo "Waiting..."; | 
| @@ -1506,13 +1506,13 @@ discard block | ||
| 1506 | 1506 | if ($globalDebug) echo "Restart all connections..."; | 
| 1507 | 1507 | connect_all($globalSources); | 
| 1508 | 1508 | } | 
| 1509 | - } | |
| 1509 | + } | |
| 1510 | 1510 | } | 
| 1511 | 1511 |  	if ($globalDaemon === false) { | 
| 1512 | - if ($globalDebug) echo 'Check all...'."\n"; | |
| 1513 | - $SI->checkAll(); | |
| 1512 | + if ($globalDebug) echo 'Check all...'."\n"; | |
| 1513 | + $SI->checkAll(); | |
| 1514 | + } | |
| 1514 | 1515 | } | 
| 1515 | - } | |
| 1516 | 1516 | } | 
| 1517 | 1517 | |
| 1518 | 1518 | ?> | 
| @@ -46,20 +46,20 @@ discard block | ||
| 46 | 46 | die; | 
| 47 | 47 | } | 
| 48 | 48 | //$hosts = array($globalSBS1Host.':'.$globalSBS1Port); | 
| 49 | -	$globalSources[] = array('host' => $globalSBS1Host,'port' => $globalSBS1Port); | |
| 49 | +	$globalSources[] = array('host' => $globalSBS1Host, 'port' => $globalSBS1Port); | |
| 50 | 50 | } | 
| 51 | 51 | } | 
| 52 | 52 | |
| 53 | -$options = getopt('s::',array('source::','server','nodaemon','idsource::','aprsserverssid::','aprsserverpass::','aprsserverhost::','aprsserverport::','format::','noaprsserver')); | |
| 53 | +$options = getopt('s::', array('source::', 'server', 'nodaemon', 'idsource::', 'aprsserverssid::', 'aprsserverpass::', 'aprsserverhost::', 'aprsserverport::', 'format::', 'noaprsserver')); | |
| 54 | 54 | //if (isset($options['s'])) $hosts = array($options['s']); | 
| 55 | 55 | //elseif (isset($options['source'])) $hosts = array($options['source']); | 
| 56 | 56 |  if (isset($options['s'])) { | 
| 57 | 57 | $globalSources = array(); | 
| 58 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 58 | +    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'], 'format' => $options['format']); | |
| 59 | 59 |      else $globalSources[] = array('host' => $options['s']); | 
| 60 | 60 |  } elseif (isset($options['source'])) { | 
| 61 | 61 | $globalSources = array(); | 
| 62 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 62 | +    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'], 'format' => $options['format']); | |
| 63 | 63 |      else $globalSources[] = array('host' => $options['source']); | 
| 64 | 64 | } | 
| 65 | 65 |  if (isset($options['aprsserverhost'])) { | 
| @@ -76,28 +76,28 @@ discard block | ||
| 76 | 76 | else $id_source = 1; | 
| 77 | 77 |  if (isset($globalServer) && $globalServer) { | 
| 78 | 78 | if ($globalDebug) echo "Using Server Mode\n"; | 
| 79 | - $SI=new SpotterServer(); | |
| 79 | + $SI = new SpotterServer(); | |
| 80 | 80 | /* | 
| 81 | 81 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 82 | 82 | $SI = new adsb2aprs(); | 
| 83 | 83 | $SI->connect(); | 
| 84 | 84 | */ | 
| 85 | -} else $SI=new SpotterImport($Connection->db); | |
| 85 | +} else $SI = new SpotterImport($Connection->db); | |
| 86 | 86 | if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); | 
| 87 | 87 |  if (isset($globalMarine) && $globalMarine) { | 
| 88 | 88 | $AIS = new AIS(); | 
| 89 | 89 | $MI = new MarineImport($Connection->db); | 
| 90 | 90 | } | 
| 91 | 91 | //$APRS=new APRS($Connection->db); | 
| 92 | -$SBS=new SBS(); | |
| 93 | -$ACARS=new ACARS($Connection->db); | |
| 94 | -$Source=new Source($Connection->db); | |
| 95 | -$Common=new Common(); | |
| 92 | +$SBS = new SBS(); | |
| 93 | +$ACARS = new ACARS($Connection->db); | |
| 94 | +$Source = new Source($Connection->db); | |
| 95 | +$Common = new Common(); | |
| 96 | 96 |  date_default_timezone_set('UTC'); | 
| 97 | 97 |  //$servertz = system('date +%Z'); | 
| 98 | 98 | // signal handler - playing nice with sockets and dump1090 | 
| 99 | 99 |  if (function_exists('pcntl_fork')) { | 
| 100 | -    pcntl_signal(SIGINT,  function() { | |
| 100 | +    pcntl_signal(SIGINT, function() { | |
| 101 | 101 | global $sockets; | 
| 102 | 102 | echo "\n\nctrl-c or kill signal received. Tidying up ... "; | 
| 103 | 103 |          die("Bye!\n"); | 
| @@ -113,30 +113,30 @@ discard block | ||
| 113 | 113 | |
| 114 | 114 |  function connect_all($hosts) { | 
| 115 | 115 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | 
| 116 | - global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | |
| 116 | + global $sockets, $httpfeeds, $globalSources, $globalDebug, $aprs_connect, $last_exec, $globalSourcesRights, $use_aprs, $reset, $context; | |
| 117 | 117 | $reset++; | 
| 118 | 118 | if ($globalDebug) echo 'Connect to all...'."\n"; | 
| 119 | 119 |      foreach ($hosts as $id => $value) { | 
| 120 | 120 | $host = $value['host']; | 
| 121 | 121 | $globalSources[$id]['last_exec'] = 0; | 
| 122 | 122 | // Here we check type of source(s) | 
| 123 | -	if (filter_var($host,FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { | |
| 124 | -            if (preg_match('/deltadb.txt$/i',$host)) { | |
| 123 | +	if (filter_var($host, FILTER_VALIDATE_URL) && (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto')) { | |
| 124 | +            if (preg_match('/deltadb.txt$/i', $host)) { | |
| 125 | 125 | //$formats[$id] = 'deltadbtxt'; | 
| 126 | 126 | $globalSources[$id]['format'] = 'deltadbtxt'; | 
| 127 | 127 | //$last_exec['deltadbtxt'] = 0; | 
| 128 | 128 |          	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | 
| 129 | -            } else if (preg_match('/vatsim-data.txt$/i',$host)) { | |
| 129 | +            } else if (preg_match('/vatsim-data.txt$/i', $host)) { | |
| 130 | 130 | //$formats[$id] = 'vatsimtxt'; | 
| 131 | 131 | $globalSources[$id]['format'] = 'vatsimtxt'; | 
| 132 | 132 | //$last_exec['vatsimtxt'] = 0; | 
| 133 | 133 |          	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | 
| 134 | -    	    } else if (preg_match('/aircraftlist.json$/i',$host)) { | |
| 134 | +    	    } else if (preg_match('/aircraftlist.json$/i', $host)) { | |
| 135 | 135 | //$formats[$id] = 'aircraftlistjson'; | 
| 136 | 136 | $globalSources[$id]['format'] = 'aircraftlistjson'; | 
| 137 | 137 | //$last_exec['aircraftlistjson'] = 0; | 
| 138 | 138 |          	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | 
| 139 | -    	    } else if (preg_match('/opensky/i',$host)) { | |
| 139 | +    	    } else if (preg_match('/opensky/i', $host)) { | |
| 140 | 140 | //$formats[$id] = 'aircraftlistjson'; | 
| 141 | 141 | $globalSources[$id]['format'] = 'opensky'; | 
| 142 | 142 | //$last_exec['aircraftlistjson'] = 0; | 
| @@ -153,7 +153,7 @@ discard block | ||
| 153 | 153 | exit(0); | 
| 154 | 154 | } | 
| 155 | 155 | */ | 
| 156 | -    	    } else if (preg_match('/planeUpdateFAA.php$/i',$host)) { | |
| 156 | +    	    } else if (preg_match('/planeUpdateFAA.php$/i', $host)) { | |
| 157 | 157 | //$formats[$id] = 'planeupdatefaa'; | 
| 158 | 158 | $globalSources[$id]['format'] = 'planeupdatefaa'; | 
| 159 | 159 | //$last_exec['planeupdatefaa'] = 0; | 
| @@ -162,29 +162,29 @@ discard block | ||
| 162 | 162 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 163 | 163 | exit(0); | 
| 164 | 164 | } | 
| 165 | -            } else if (preg_match('/\/action.php\/acars\/data$/i',$host)) { | |
| 165 | +            } else if (preg_match('/\/action.php\/acars\/data$/i', $host)) { | |
| 166 | 166 | //$formats[$id] = 'phpvmacars'; | 
| 167 | 167 | $globalSources[$id]['format'] = 'phpvmacars'; | 
| 168 | 168 | //$last_exec['phpvmacars'] = 0; | 
| 169 | 169 |          	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | 
| 170 | -            } else if (preg_match('/VAM-json.php$/i',$host)) { | |
| 170 | +            } else if (preg_match('/VAM-json.php$/i', $host)) { | |
| 171 | 171 | //$formats[$id] = 'phpvmacars'; | 
| 172 | 172 | $globalSources[$id]['format'] = 'vam'; | 
| 173 | 173 |          	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | 
| 174 | -            } else if (preg_match('/whazzup/i',$host)) { | |
| 174 | +            } else if (preg_match('/whazzup/i', $host)) { | |
| 175 | 175 | //$formats[$id] = 'whazzup'; | 
| 176 | 176 | $globalSources[$id]['format'] = 'whazzup'; | 
| 177 | 177 | //$last_exec['whazzup'] = 0; | 
| 178 | 178 |          	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | 
| 179 | -            } else if (preg_match('/airwhere/i',$host)) { | |
| 179 | +            } else if (preg_match('/airwhere/i', $host)) { | |
| 180 | 180 | $globalSources[$id]['format'] = 'airwhere'; | 
| 181 | 181 |          	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | 
| 182 | -            } else if (preg_match('/recentpireps/i',$host)) { | |
| 182 | +            } else if (preg_match('/recentpireps/i', $host)) { | |
| 183 | 183 | //$formats[$id] = 'pirepsjson'; | 
| 184 | 184 | $globalSources[$id]['format'] = 'pirepsjson'; | 
| 185 | 185 | //$last_exec['pirepsjson'] = 0; | 
| 186 | 186 |          	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | 
| 187 | -            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | |
| 187 | +            } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i', $host)) { | |
| 188 | 188 | //$formats[$id] = 'fr24json'; | 
| 189 | 189 | $globalSources[$id]['format'] = 'fr24json'; | 
| 190 | 190 | //$last_exec['fr24json'] = 0; | 
| @@ -193,7 +193,7 @@ discard block | ||
| 193 | 193 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 194 | 194 | exit(0); | 
| 195 | 195 | } | 
| 196 | -            } else if (preg_match(':myshiptracking.com/:i',$host)) { | |
| 196 | +            } else if (preg_match(':myshiptracking.com/:i', $host)) { | |
| 197 | 197 | //$formats[$id] = 'fr24json'; | 
| 198 | 198 | $globalSources[$id]['format'] = 'myshiptracking'; | 
| 199 | 199 | //$last_exec['fr24json'] = 0; | 
| @@ -203,22 +203,22 @@ discard block | ||
| 203 | 203 | exit(0); | 
| 204 | 204 | } | 
| 205 | 205 |              //} else if (preg_match('/10001/',$host)) { | 
| 206 | -            } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 206 | +            } else if (preg_match('/10001/', $host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | |
| 207 | 207 | //$formats[$id] = 'tsv'; | 
| 208 | 208 | $globalSources[$id]['format'] = 'tsv'; | 
| 209 | 209 |          	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | 
| 210 | 210 | } | 
| 211 | -        } elseif (filter_var($host,FILTER_VALIDATE_URL)) { | |
| 211 | +        } elseif (filter_var($host, FILTER_VALIDATE_URL)) { | |
| 212 | 212 |      		if ($globalSources[$id]['format'] == 'aisnmeahttp') { | 
| 213 | - $idf = fopen($globalSources[$id]['host'],'r',false,$context); | |
| 213 | + $idf = fopen($globalSources[$id]['host'], 'r', false, $context); | |
| 214 | 214 |      		    if ($idf !== false) { | 
| 215 | 215 | $httpfeeds[$id] = $idf; | 
| 216 | 216 |          		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | 
| 217 | 217 | } | 
| 218 | 218 | elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | 
| 219 | 219 |      		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | 
| 220 | -        } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | |
| 221 | -	    $hostport = explode(':',$host); | |
| 220 | +        } elseif (!filter_var($host, FILTER_VALIDATE_URL)) { | |
| 221 | +	    $hostport = explode(':', $host); | |
| 222 | 222 |  	    if (isset($hostport[1])) { | 
| 223 | 223 | $port = $hostport[1]; | 
| 224 | 224 | $hostn = $hostport[0]; | 
| @@ -228,19 +228,19 @@ discard block | ||
| 228 | 228 | } | 
| 229 | 229 | $Common = new Common(); | 
| 230 | 230 |  	    if (!isset($globalSources[$id]['format']) || ($globalSources[$id]['format'] != 'acars' && $globalSources[$id]['format'] != 'flightgearsp')) { | 
| 231 | - $s = $Common->create_socket($hostn,$port, $errno, $errstr); | |
| 231 | + $s = $Common->create_socket($hostn, $port, $errno, $errstr); | |
| 232 | 232 |      	    } else { | 
| 233 | - $s = $Common->create_socket_udp($hostn,$port, $errno, $errstr); | |
| 233 | + $s = $Common->create_socket_udp($hostn, $port, $errno, $errstr); | |
| 234 | 234 | } | 
| 235 | 235 |  	    if ($s) { | 
| 236 | 236 | $sockets[$id] = $s; | 
| 237 | 237 |      	        if (!isset($globalSources[$id]['format']) || strtolower($globalSources[$id]['format']) == 'auto') { | 
| 238 | -		    if (preg_match('/aprs/',$hostn) || $port == '10152' || $port == '14580') { | |
| 238 | +		    if (preg_match('/aprs/', $hostn) || $port == '10152' || $port == '14580') { | |
| 239 | 239 | //$formats[$id] = 'aprs'; | 
| 240 | 240 | $globalSources[$id]['format'] = 'aprs'; | 
| 241 | 241 | //$aprs_connect = 0; | 
| 242 | 242 | //$use_aprs = true; | 
| 243 | -		    } elseif (preg_match('/pub-vrs/',$hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 243 | +		    } elseif (preg_match('/pub-vrs/', $hostn) || $port == '32001' || $port == '32005' || $port == '32010' || $port == '32015' || $port == '32030') { | |
| 244 | 244 | $globalSources[$id]['format'] = 'vrstcp'; | 
| 245 | 245 |      		    } elseif ($port == '10001') { | 
| 246 | 246 | //$formats[$id] = 'tsv'; | 
| @@ -279,7 +279,7 @@ discard block | ||
| 279 | 279 | else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; | 
| 280 | 280 | else $timeout = 20; | 
| 281 | 281 | $errno = ''; | 
| 282 | -$errstr=''; | |
| 282 | +$errstr = ''; | |
| 283 | 283 | |
| 284 | 284 | if (!isset($globalDaemon)) $globalDaemon = TRUE; | 
| 285 | 285 | /* Initiate connections to all the hosts simultaneously */ | 
| @@ -287,7 +287,7 @@ discard block | ||
| 287 | 287 | //connect_all($globalSources); | 
| 288 | 288 | |
| 289 | 289 |  if (isset($globalProxy) && $globalProxy) { | 
| 290 | -    $context = stream_context_create(array('http' => array('timeout' => $timeout,'proxy' => $globalProxy,'request_fulluri' => true))); | |
| 290 | +    $context = stream_context_create(array('http' => array('timeout' => $timeout, 'proxy' => $globalProxy, 'request_fulluri' => true))); | |
| 291 | 291 |  } else { | 
| 292 | 292 |      $context = stream_context_create(array('http' => array('timeout' => $timeout))); | 
| 293 | 293 | } | 
| @@ -314,16 +314,16 @@ discard block | ||
| 314 | 314 | |
| 315 | 315 |  if ($use_aprs) { | 
| 316 | 316 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 317 | - $APRS=new APRS(); | |
| 317 | + $APRS = new APRS(); | |
| 318 | 318 | $aprs_connect = 0; | 
| 319 | 319 | $aprs_keep = 120; | 
| 320 | 320 | $aprs_last_tx = time(); | 
| 321 | 321 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | 
| 322 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 322 | +	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); | |
| 323 | 323 | if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; | 
| 324 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 324 | +	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); | |
| 325 | 325 | if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; | 
| 326 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 326 | + else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 327 | 327 | if ($aprs_full) $aprs_filter = ''; | 
| 328 | 328 | if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; | 
| 329 | 329 | else $aprs_pass = '-1'; | 
| @@ -337,12 +337,12 @@ discard block | ||
| 337 | 337 | sleep(1); | 
| 338 | 338 | if ($globalDebug) echo "SCAN MODE \n\n"; | 
| 339 | 339 | if (!isset($globalCronEnd)) $globalCronEnd = 60; | 
| 340 | -$endtime = time()+$globalCronEnd; | |
| 340 | +$endtime = time() + $globalCronEnd; | |
| 341 | 341 | $i = 1; | 
| 342 | 342 | $tt = array(); | 
| 343 | 343 | // Delete all ATC | 
| 344 | 344 |  if ((isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM)) { | 
| 345 | - $ATC=new ATC($Connection->db); | |
| 345 | + $ATC = new ATC($Connection->db); | |
| 346 | 346 | } | 
| 347 | 347 |  if (!$globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 348 | 348 | $ATC->deleteAll(); | 
| @@ -350,7 +350,7 @@ discard block | ||
| 350 | 350 | |
| 351 | 351 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. | 
| 352 | 352 |  while ($i > 0) { | 
| 353 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 353 | + if (!$globalDaemon) $i = $endtime - time(); | |
| 354 | 354 | // Delete old ATC | 
| 355 | 355 |      if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 356 | 356 | if ($globalDebug) echo 'Delete old ATC...'."\n"; | 
| @@ -364,7 +364,7 @@ discard block | ||
| 364 | 364 | } | 
| 365 | 365 |  	if ($max != $globalMinFetch) { | 
| 366 | 366 | if ($globalDebug) echo 'Sleeping...'."\n"; | 
| 367 | - sleep($globalMinFetch-$max+2); | |
| 367 | + sleep($globalMinFetch - $max + 2); | |
| 368 | 368 | } | 
| 369 | 369 | } | 
| 370 | 370 | |
| @@ -377,8 +377,8 @@ discard block | ||
| 377 | 377 | //$buffer = $Common->getData($hosts[$id]); | 
| 378 | 378 | $buffer = $Common->getData($value['host']); | 
| 379 | 379 | if ($buffer != '') $reset = 0; | 
| 380 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 381 | -	    $buffer = explode('\n',$buffer); | |
| 380 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 381 | +	    $buffer = explode('\n', $buffer); | |
| 382 | 382 |  	    foreach ($buffer as $line) { | 
| 383 | 383 |      		if ($line != '' && count($line) > 7) { | 
| 384 | 384 |      		    $line = explode(',', $line); | 
| @@ -406,11 +406,11 @@ discard block | ||
| 406 | 406 | $last_exec[$id]['last'] = time(); | 
| 407 | 407 |  	} elseif ($value['format'] == 'aisnmeatxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 408 | 408 |  	    date_default_timezone_set('CET'); | 
| 409 | -	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | |
| 409 | +	    $buffer = $Common->getData(str_replace('{date}', date('Ymd'), $value['host'])); | |
| 410 | 410 |  	    date_default_timezone_set('UTC'); | 
| 411 | 411 | if ($buffer != '') $reset = 0; | 
| 412 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 413 | -	    $buffer = explode('\n',$buffer); | |
| 412 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 413 | +	    $buffer = explode('\n', $buffer); | |
| 414 | 414 |  	    foreach ($buffer as $line) { | 
| 415 | 415 |  		if ($line != '') { | 
| 416 | 416 | echo "'".$line."'\n"; | 
| @@ -428,7 +428,7 @@ discard block | ||
| 428 | 428 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 429 | 429 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 430 | 430 |  		    if (isset($ais_data['timestamp'])) { | 
| 431 | -			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 431 | +			$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 432 | 432 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| 433 | 433 | $last_exec[$id]['timestamp'] = $ais_data['timestamp']; | 
| 434 | 434 | $add = true; | 
| @@ -451,12 +451,12 @@ discard block | ||
| 451 | 451 | $w = $e = null; | 
| 452 | 452 | |
| 453 | 453 |  	    if (isset($arr[$id])) { | 
| 454 | - $nn = stream_select($arr,$w,$e,$timeout); | |
| 454 | + $nn = stream_select($arr, $w, $e, $timeout); | |
| 455 | 455 |  		if ($nn > 0) { | 
| 456 | 456 |  		    foreach ($httpfeeds as $feed) { | 
| 457 | - $buffer = stream_get_line($feed,2000,"\n"); | |
| 458 | -			$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 459 | -			$buffer = explode('\n',$buffer); | |
| 457 | + $buffer = stream_get_line($feed, 2000, "\n"); | |
| 458 | +			$buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 459 | +			$buffer = explode('\n', $buffer); | |
| 460 | 460 |  			foreach ($buffer as $line) { | 
| 461 | 461 |  			    if ($line != '') { | 
| 462 | 462 | $ais_data = $AIS->parse_line(trim($line)); | 
| @@ -474,9 +474,9 @@ discard block | ||
| 474 | 474 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 475 | 475 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 476 | 476 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | 
| 477 | -				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 477 | +				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); | |
| 478 | 478 |  				if (isset($ais_data['timestamp'])) { | 
| 479 | -				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 479 | +				    $data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 480 | 480 |  				} else { | 
| 481 | 481 |  				    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 482 | 482 | } | 
| @@ -502,10 +502,10 @@ discard block | ||
| 502 | 502 | } | 
| 503 | 503 | } | 
| 504 | 504 |  	} elseif ($value['format'] == 'myshiptracking' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 505 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 505 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); | |
| 506 | 506 |  	    if ($buffer != '') { | 
| 507 | 507 | //echo $buffer; | 
| 508 | - $all_data = json_decode($buffer,true); | |
| 508 | + $all_data = json_decode($buffer, true); | |
| 509 | 509 | //print_r($all_data); | 
| 510 | 510 |  		if (isset($all_data[0]['DATA'])) { | 
| 511 | 511 |  		    foreach ($all_data[0]['DATA'] as $line) { | 
| @@ -520,7 +520,7 @@ discard block | ||
| 520 | 520 | // if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | 
| 521 | 521 | $data['imo'] = $line['IMO']; | 
| 522 | 522 | //$data['arrival_code'] = $ais_data['destination']; | 
| 523 | -			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | |
| 523 | +			    $data['datetime'] = date('Y-m-d H:i:s', $line['T']); | |
| 524 | 524 | $data['format_source'] = 'myshiptracking'; | 
| 525 | 525 | $data['id_source'] = $id_source; | 
| 526 | 526 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -532,9 +532,9 @@ discard block | ||
| 532 | 532 | } | 
| 533 | 533 | $last_exec[$id]['last'] = time(); | 
| 534 | 534 |  	} elseif ($value['format'] == 'boatbeaconapp' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 535 | -	    $buffer = $Common->getData(str_replace('{timestamp}',time(),$value['host'])); | |
| 535 | +	    $buffer = $Common->getData(str_replace('{timestamp}', time(), $value['host'])); | |
| 536 | 536 |  	    if ($buffer != '') { | 
| 537 | - $all_data = json_decode($buffer,true); | |
| 537 | + $all_data = json_decode($buffer, true); | |
| 538 | 538 |  		if (isset($all_data[0]['mmsi'])) { | 
| 539 | 539 |  		    foreach ($all_data as $line) { | 
| 540 | 540 |  			if ($line != '') { | 
| @@ -563,7 +563,7 @@ discard block | ||
| 563 | 563 |  	} elseif ($value['format'] == 'boatnerd' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 564 | 564 | $buffer = $Common->getData($value['host']); | 
| 565 | 565 |  	    if ($buffer != '') { | 
| 566 | - $all_data = json_decode($buffer,true); | |
| 566 | + $all_data = json_decode($buffer, true); | |
| 567 | 567 |  		if (isset($all_data['features'][0]['id'])) { | 
| 568 | 568 |  		    foreach ($all_data['features'] as $line) { | 
| 569 | 569 | $data = array(); | 
| @@ -591,27 +591,27 @@ discard block | ||
| 591 | 591 | $last_exec[$id]['last'] = time(); | 
| 592 | 592 |  	} elseif ($value['format'] == 'shipplotter' && (time() - $last_exec[$id]['last'] > $globalMinFetch*3)) { | 
| 593 | 593 | echo 'download...'; | 
| 594 | - $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | |
| 594 | + $buffer = $Common->getData($value['host'], 'post', $value['post'], '', '', '', '', 'ShipPlotter'); | |
| 595 | 595 | echo 'done !'."\n"; | 
| 596 | 596 | if ($buffer != '') $reset = 0; | 
| 597 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 598 | -	    $buffer = explode('\n',$buffer); | |
| 597 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 598 | +	    $buffer = explode('\n', $buffer); | |
| 599 | 599 |  	    foreach ($buffer as $line) { | 
| 600 | 600 |  		if ($line != '') { | 
| 601 | 601 | $data = array(); | 
| 602 | - $data['mmsi'] = (int)substr($line,0,9); | |
| 603 | -		    $data['datetime'] = date('Y-m-d H:i:s',substr($line,10,10)); | |
| 602 | + $data['mmsi'] = (int) substr($line, 0, 9); | |
| 603 | +		    $data['datetime'] = date('Y-m-d H:i:s', substr($line, 10, 10)); | |
| 604 | 604 | //$data['status'] = substr($line,21,2); | 
| 605 | 605 | //$data['type'] = substr($line,24,3); | 
| 606 | - $data['latitude'] = substr($line,29,9); | |
| 607 | - $data['longitude'] = substr($line,41,9); | |
| 608 | - $data['speed'] = round(substr($line,51,5)); | |
| 606 | + $data['latitude'] = substr($line, 29, 9); | |
| 607 | + $data['longitude'] = substr($line, 41, 9); | |
| 608 | + $data['speed'] = round(substr($line, 51, 5)); | |
| 609 | 609 | //$data['course'] = substr($line,57,5); | 
| 610 | - $data['heading'] = round(substr($line,63,3)); | |
| 610 | + $data['heading'] = round(substr($line, 63, 3)); | |
| 611 | 611 | //$data['draft'] = substr($line,67,4); | 
| 612 | 612 | //$data['length'] = substr($line,72,3); | 
| 613 | 613 | //$data['beam'] = substr($line,76,2); | 
| 614 | - $data['ident'] = trim(utf8_encode(substr($line,79,20))); | |
| 614 | + $data['ident'] = trim(utf8_encode(substr($line, 79, 20))); | |
| 615 | 615 | //$data['callsign'] = trim(substr($line,100,7); | 
| 616 | 616 | //$data['dest'] = substr($line,108,20); | 
| 617 | 617 | //$data['etaDate'] = substr($line,129,5); | 
| @@ -630,8 +630,8 @@ discard block | ||
| 630 | 630 |  	} elseif (($value['format'] == 'whazzup' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) || ($value['format'] == 'vatsimtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch))) { | 
| 631 | 631 | //$buffer = $Common->getData($hosts[$id]); | 
| 632 | 632 | $buffer = $Common->getData($value['host']); | 
| 633 | -    	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | |
| 634 | -	    $buffer = explode('\n',$buffer); | |
| 633 | +    	    $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '\n', $buffer)); | |
| 634 | +	    $buffer = explode('\n', $buffer); | |
| 635 | 635 | $reset = 0; | 
| 636 | 636 |  	    foreach ($buffer as $line) { | 
| 637 | 637 |      		if ($line != '') { | 
| @@ -642,7 +642,7 @@ discard block | ||
| 642 | 642 | else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | 
| 643 | 643 | $data['pilot_id'] = $line[1]; | 
| 644 | 644 | $data['pilot_name'] = $line[2]; | 
| 645 | - $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); | |
| 645 | + $data['hex'] = str_pad(dechex($Common->str2int($line[1])), 6, '000000', STR_PAD_LEFT); | |
| 646 | 646 | $data['ident'] = $line[0]; // ident | 
| 647 | 647 | if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude | 
| 648 | 648 | $data['speed'] = $line[8]; // speed | 
| @@ -658,7 +658,7 @@ discard block | ||
| 658 | 658 |  			//$data['datetime'] = date('Y-m-d H:i:s',strtotime($line[37])); | 
| 659 | 659 | //if (isset($line[37])) $data['last_update'] = $line[37]; | 
| 660 | 660 | $data['departure_airport_icao'] = $line[11]; | 
| 661 | - $data['departure_airport_time'] = rtrim(chunk_split($line[22],2,':'),':'); | |
| 661 | + $data['departure_airport_time'] = rtrim(chunk_split($line[22], 2, ':'), ':'); | |
| 662 | 662 | $data['arrival_airport_icao'] = $line[13]; | 
| 663 | 663 | $data['frequency'] = $line[4]; | 
| 664 | 664 | $data['type'] = $line[18]; | 
| @@ -667,7 +667,7 @@ discard block | ||
| 667 | 667 | $data['id_source'] = $id_source; | 
| 668 | 668 | //$data['arrival_airport_time'] = ; | 
| 669 | 669 |  	    		if ($line[9] != '') { | 
| 670 | -	    		    $aircraft_data = explode('/',$line[9]); | |
| 670 | +	    		    $aircraft_data = explode('/', $line[9]); | |
| 671 | 671 |  	    		    if (isset($aircraft_data[1])) { | 
| 672 | 672 | $data['aircraft_icao'] = $aircraft_data[1]; | 
| 673 | 673 | } | 
| @@ -682,9 +682,9 @@ discard block | ||
| 682 | 682 | if ($line[3] == 'PILOT') $SI->add($data); | 
| 683 | 683 |  			elseif ($line[3] == 'ATC') { | 
| 684 | 684 | //print_r($data); | 
| 685 | -				$data['info'] = str_replace('^§','<br />',$data['info']); | |
| 686 | -				$data['info'] = str_replace('&sect;','',$data['info']); | |
| 687 | - $typec = substr($data['ident'],-3); | |
| 685 | +				$data['info'] = str_replace('^§', '<br />', $data['info']); | |
| 686 | +				$data['info'] = str_replace('&sect;', '', $data['info']); | |
| 687 | + $typec = substr($data['ident'], -3); | |
| 688 | 688 | if ($typec == 'APP') $data['type'] = 'Approach'; | 
| 689 | 689 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; | 
| 690 | 690 | elseif ($typec == 'OBS') $data['type'] = 'Observer'; | 
| @@ -696,8 +696,8 @@ discard block | ||
| 696 | 696 | elseif ($data['type'] == '') $data['type'] = 'Observer'; | 
| 697 | 697 | if (!isset($data['source_name'])) $data['source_name'] = ''; | 
| 698 | 698 |  				if (isset($ATC)) { | 
| 699 | - 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']); | |
| 700 | - 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']); | |
| 699 | + 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']); | |
| 700 | + 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']); | |
| 701 | 701 | } | 
| 702 | 702 | } | 
| 703 | 703 | unset($data); | 
| @@ -708,23 +708,23 @@ discard block | ||
| 708 | 708 | //elseif ($value == 'vatsimtxt') $last_exec['vatsimtxt'] = time(); | 
| 709 | 709 | $last_exec[$id]['last'] = time(); | 
| 710 | 710 |      	} elseif ($value['format'] == 'airwhere' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 711 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php','get','','','','','20'); | |
| 711 | +	    $buffer = $Common->getData('http://www.airwhere.co.uk/pilots.php', 'get', '', '', '', '', '20'); | |
| 712 | 712 |  	    if ($buffer != '') { | 
| 713 | 713 | $all_data = simplexml_load_string($buffer); | 
| 714 | -		foreach($all_data->children() as $childdata) { | |
| 714 | +		foreach ($all_data->children() as $childdata) { | |
| 715 | 715 | $data = array(); | 
| 716 | 716 | $line = $childdata; | 
| 717 | 717 | //$data['hex'] = str_pad(dechex((int)$line['pktPilotID']),6,'000000',STR_PAD_LEFT); | 
| 718 | -			$data['id'] = date('Ymd').(int)$line['pktPilotID']; | |
| 719 | -			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); | |
| 720 | - $data['latitude'] = (float)$line['pktLatitude']; | |
| 721 | - $data['longitude'] = (float)$line['pktLongitude']; | |
| 722 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; | |
| 723 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; | |
| 724 | - $data['altitude'] = (int)$line['pktAltitude']; | |
| 725 | - $data['pilot_id'] = (int)$line['pktPilotID']; | |
| 718 | +			$data['id'] = date('Ymd').(int) $line['pktPilotID']; | |
| 719 | +			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['entryTime'].' BST')); | |
| 720 | + $data['latitude'] = (float) $line['pktLatitude']; | |
| 721 | + $data['longitude'] = (float) $line['pktLongitude']; | |
| 722 | + if ((float) $line['pktTrack'] != 0) $data['heading'] = (float) $line['pktTrack']; | |
| 723 | + if ((int) $line['pktSpeed'] != 0) $data['speed'] = (int) $line['pktSpeed']; | |
| 724 | + $data['altitude'] = (int) $line['pktAltitude']; | |
| 725 | + $data['pilot_id'] = (int) $line['pktPilotID']; | |
| 726 | 726 | $data['aircraft_icao'] = 'PARAGLIDER'; | 
| 727 | -			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | |
| 727 | +			$pilot_data = explode(',', $Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | |
| 728 | 728 | if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; | 
| 729 | 729 | $data['format_source'] = $value['format']; | 
| 730 | 730 | $SI->add($data); | 
| @@ -732,30 +732,30 @@ discard block | ||
| 732 | 732 | } | 
| 733 | 733 | } | 
| 734 | 734 |  	    $Source->deleteOldLocationByType('gs'); | 
| 735 | -	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php','get','','','','','20'); | |
| 735 | +	    $buffer = $Common->getData('http://www.airwhere.co.uk/gspositions.php', 'get', '', '', '', '', '20'); | |
| 736 | 736 |  	    if ($buffer != '') { | 
| 737 | 737 | $all_data = simplexml_load_string($buffer); | 
| 738 | -		foreach($all_data->children() as $childdata) { | |
| 738 | +		foreach ($all_data->children() as $childdata) { | |
| 739 | 739 | $data = array(); | 
| 740 | 740 | $line = $childdata; | 
| 741 | - $data['id'] = (int)$line['gsID']; | |
| 742 | - $data['latitude'] = (float)$line['gsLatitude']; | |
| 743 | - $data['longitude'] = (float)$line['gsLongitude']; | |
| 744 | - $data['altitude'] = (int)$line['gsHeight']; | |
| 745 | -			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['gsLastUpdate'].' BST')); | |
| 741 | + $data['id'] = (int) $line['gsID']; | |
| 742 | + $data['latitude'] = (float) $line['gsLatitude']; | |
| 743 | + $data['longitude'] = (float) $line['gsLongitude']; | |
| 744 | + $data['altitude'] = (int) $line['gsHeight']; | |
| 745 | +			$data['datetime'] = date('Y-m-d H:i:s', strtotime((string) $line['gsLastUpdate'].' BST')); | |
| 746 | 746 |  			if (count($Source->getLocationInfoByLocationID($data['id'])) > 0) { | 
| 747 | -				$Source->updateLocationByLocationID('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); | |
| 747 | +				$Source->updateLocationByLocationID('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); | |
| 748 | 748 |  			} else { | 
| 749 | -				$Source->addLocation('',$data['latitude'],$data['longitude'],$data['altitude'],'','','airwhere','antenna.png','gs',$id,$data['id'],$data['datetime']); | |
| 749 | +				$Source->addLocation('', $data['latitude'], $data['longitude'], $data['altitude'], '', '', 'airwhere', 'antenna.png', 'gs', $id, $data['id'], $data['datetime']); | |
| 750 | 750 | } | 
| 751 | 751 | unset($data); | 
| 752 | 752 | } | 
| 753 | 753 | } | 
| 754 | 754 | $last_exec[$id]['last'] = time(); | 
| 755 | 755 |  	} elseif ($value['format'] == 'aircraftlistjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 756 | - $buffer = $Common->getData($value['host'],'get','','','','','20'); | |
| 756 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '20'); | |
| 757 | 757 |  	    if ($buffer != '') { | 
| 758 | - $all_data = json_decode($buffer,true); | |
| 758 | + $all_data = json_decode($buffer, true); | |
| 759 | 759 |  	    if (isset($all_data['acList'])) { | 
| 760 | 760 | $reset = 0; | 
| 761 | 761 |  		foreach ($all_data['acList'] as $line) { | 
| @@ -772,7 +772,7 @@ discard block | ||
| 772 | 772 | $data['emergency'] = ''; // emergency | 
| 773 | 773 | if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | 
| 774 | 774 | |
| 775 | -		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 775 | +		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); | |
| 776 | 776 |  		    else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 777 | 777 | |
| 778 | 778 |  		    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| @@ -798,7 +798,7 @@ discard block | ||
| 798 | 798 | $data['verticalrate'] = $line['vrt']; // verticale rate | 
| 799 | 799 | $data['squawk'] = $line['squawk']; // squawk | 
| 800 | 800 | $data['emergency'] = ''; // emergency | 
| 801 | -		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 801 | +		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s', round($line['PosTime']/1000)); | |
| 802 | 802 |  		    else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 803 | 803 | $data['format_source'] = 'aircraftlistjson'; | 
| 804 | 804 | $data['id_source'] = $id_source; | 
| @@ -814,7 +814,7 @@ discard block | ||
| 814 | 814 |      	//} elseif ($value == 'planeupdatefaa' && (time() - $last_exec['planeupdatefaa'] > $globalMinFetch)) { | 
| 815 | 815 |      	} elseif ($value['format'] == 'planeupdatefaa' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 816 | 816 | $buffer = $Common->getData($value['host']); | 
| 817 | - $all_data = json_decode($buffer,true); | |
| 817 | + $all_data = json_decode($buffer, true); | |
| 818 | 818 |  	    if (isset($all_data['planes'])) { | 
| 819 | 819 | $reset = 0; | 
| 820 | 820 |  		foreach ($all_data['planes'] as $key => $line) { | 
| @@ -831,12 +831,12 @@ discard block | ||
| 831 | 831 | $data['emergency'] = ''; // emergency | 
| 832 | 832 | $data['registration'] = $line[2]; | 
| 833 | 833 | $data['aircraft_icao'] = $line[0]; | 
| 834 | -		    $deparr = explode('-',$line[1]); | |
| 834 | +		    $deparr = explode('-', $line[1]); | |
| 835 | 835 |  		    if (count($deparr) == 2) { | 
| 836 | 836 | $data['departure_airport_icao'] = $deparr[0]; | 
| 837 | 837 | $data['arrival_airport_icao'] = $deparr[1]; | 
| 838 | 838 | } | 
| 839 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | |
| 839 | +		    $data['datetime'] = date('Y-m-d H:i:s', $line[9]); | |
| 840 | 840 | $data['format_source'] = 'planeupdatefaa'; | 
| 841 | 841 | $data['id_source'] = $id_source; | 
| 842 | 842 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -849,7 +849,7 @@ discard block | ||
| 849 | 849 | $last_exec[$id]['last'] = time(); | 
| 850 | 850 |      	} elseif ($value['format'] == 'opensky' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 851 | 851 | $buffer = $Common->getData($value['host']); | 
| 852 | - $all_data = json_decode($buffer,true); | |
| 852 | + $all_data = json_decode($buffer, true); | |
| 853 | 853 |  	    if (isset($all_data['states'])) { | 
| 854 | 854 | $reset = 0; | 
| 855 | 855 |  		foreach ($all_data['states'] as $key => $line) { | 
| @@ -866,7 +866,7 @@ discard block | ||
| 866 | 866 | //$data['emergency'] = ''; // emergency | 
| 867 | 867 | //$data['registration'] = $line[2]; | 
| 868 | 868 | //$data['aircraft_icao'] = $line[0]; | 
| 869 | -		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | |
| 869 | +		    $data['datetime'] = date('Y-m-d H:i:s', $line[3]); | |
| 870 | 870 | $data['format_source'] = 'opensky'; | 
| 871 | 871 | $data['id_source'] = $id_source; | 
| 872 | 872 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -880,7 +880,7 @@ discard block | ||
| 880 | 880 |      	} elseif ($value['format'] == 'fr24json' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 881 | 881 | //$buffer = $Common->getData($hosts[$id]); | 
| 882 | 882 | $buffer = $Common->getData($value['host']); | 
| 883 | - $all_data = json_decode($buffer,true); | |
| 883 | + $all_data = json_decode($buffer, true); | |
| 884 | 884 | if (!empty($all_data)) $reset = 0; | 
| 885 | 885 |  	    foreach ($all_data as $key => $line) { | 
| 886 | 886 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| @@ -913,11 +913,11 @@ discard block | ||
| 913 | 913 |      	//} elseif ($value == 'radarvirtueljson' && (time() - $last_exec['radarvirtueljson'] > $globalMinFetch)) { | 
| 914 | 914 |      	} elseif ($value['format'] == 'radarvirtueljson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 915 | 915 | //$buffer = $Common->getData($hosts[$id],'get','','','','','150'); | 
| 916 | - $buffer = $Common->getData($value['host'],'get','','','','','150'); | |
| 916 | + $buffer = $Common->getData($value['host'], 'get', '', '', '', '', '150'); | |
| 917 | 917 | //echo $buffer; | 
| 918 | -	    $buffer = str_replace(array("\n","\r"),"",$buffer); | |
| 919 | -	    $buffer = preg_replace('/,"num":(.+)/','}',$buffer); | |
| 920 | - $all_data = json_decode($buffer,true); | |
| 918 | +	    $buffer = str_replace(array("\n", "\r"), "", $buffer); | |
| 919 | +	    $buffer = preg_replace('/,"num":(.+)/', '}', $buffer); | |
| 920 | + $all_data = json_decode($buffer, true); | |
| 921 | 921 |  	    if (json_last_error() != JSON_ERROR_NONE) { | 
| 922 | 922 | die(json_last_error_msg()); | 
| 923 | 923 | } | 
| @@ -940,7 +940,7 @@ discard block | ||
| 940 | 940 | //$data['departure_airport_iata'] = $line[11]; | 
| 941 | 941 | //$data['arrival_airport_iata'] = $line[12]; | 
| 942 | 942 | //$data['emergency'] = ''; // emergency | 
| 943 | -			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | |
| 943 | +			$data['datetime'] = date('Y-m-d H:i:s', $line['inf']['dt']); //$line[10] | |
| 944 | 944 | $data['format_source'] = 'radarvirtueljson'; | 
| 945 | 945 | $data['id_source'] = $id_source; | 
| 946 | 946 | if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | 
| @@ -956,14 +956,14 @@ discard block | ||
| 956 | 956 |      	} elseif ($value['format'] == 'pirepsjson' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 957 | 957 | //$buffer = $Common->getData($hosts[$id]); | 
| 958 | 958 | $buffer = $Common->getData($value['host'].'?'.time()); | 
| 959 | - $all_data = json_decode(utf8_encode($buffer),true); | |
| 959 | + $all_data = json_decode(utf8_encode($buffer), true); | |
| 960 | 960 | |
| 961 | 961 |  	    if (isset($all_data['pireps'])) { | 
| 962 | 962 | $reset = 0; | 
| 963 | 963 |  	        foreach ($all_data['pireps'] as $line) { | 
| 964 | 964 | $data = array(); | 
| 965 | 965 | $data['id'] = $line['id']; | 
| 966 | - $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | |
| 966 | + $data['hex'] = substr(str_pad(dechex($line['id']), 6, '000000', STR_PAD_LEFT), 0, 6); | |
| 967 | 967 | $data['ident'] = $line['callsign']; // ident | 
| 968 | 968 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | 
| 969 | 969 | if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | 
| @@ -993,9 +993,9 @@ discard block | ||
| 993 | 993 | $SI->add($data); | 
| 994 | 994 | // print_r($data); | 
| 995 | 995 |      		    } elseif ($line['icon'] == 'ct') { | 
| 996 | -			$data['info'] = str_replace('^§','<br />',$data['info']); | |
| 997 | -			$data['info'] = str_replace('&sect;','',$data['info']); | |
| 998 | - $typec = substr($data['ident'],-3); | |
| 996 | +			$data['info'] = str_replace('^§', '<br />', $data['info']); | |
| 997 | +			$data['info'] = str_replace('&sect;', '', $data['info']); | |
| 998 | + $typec = substr($data['ident'], -3); | |
| 999 | 999 | $data['type'] = ''; | 
| 1000 | 1000 | if ($typec == 'APP') $data['type'] = 'Approach'; | 
| 1001 | 1001 | elseif ($typec == 'TWR') $data['type'] = 'Tower'; | 
| @@ -1006,7 +1006,7 @@ discard block | ||
| 1006 | 1006 | elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; | 
| 1007 | 1007 | elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; | 
| 1008 | 1008 | else $data['type'] = 'Observer'; | 
| 1009 | - 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']); | |
| 1009 | + 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']); | |
| 1010 | 1010 | } | 
| 1011 | 1011 | unset($data); | 
| 1012 | 1012 | } | 
| @@ -1018,14 +1018,14 @@ discard block | ||
| 1018 | 1018 | //$buffer = $Common->getData($hosts[$id]); | 
| 1019 | 1019 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1020 | 1020 | $buffer = $Common->getData($value['host']); | 
| 1021 | - $all_data = json_decode($buffer,true); | |
| 1021 | + $all_data = json_decode($buffer, true); | |
| 1022 | 1022 |  	    if ($buffer != '' && is_array($all_data)) { | 
| 1023 | 1023 | $reset = 0; | 
| 1024 | 1024 |  		foreach ($all_data as $line) { | 
| 1025 | 1025 | $data = array(); | 
| 1026 | 1026 | //$data['id'] = $line['id']; // id not usable | 
| 1027 | 1027 | if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | 
| 1028 | - $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1028 | + $data['hex'] = substr(str_pad(bin2hex($line['flightnum']), 6, '000000', STR_PAD_LEFT), -6); // hex | |
| 1029 | 1029 | if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | 
| 1030 | 1030 | if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | 
| 1031 | 1031 | $data['ident'] = $line['flightnum']; // ident | 
| @@ -1049,14 +1049,14 @@ discard block | ||
| 1049 | 1049 | if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | 
| 1050 | 1050 |  		    if (isset($line['aircraftname'])) { | 
| 1051 | 1051 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1052 | -			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | |
| 1053 | -	    		$aircraft_data = explode('-',$line['aircraftname']); | |
| 1052 | +			$line['aircraftname'] = str_replace('BOEING ', 'B', $line['aircraftname']); | |
| 1053 | +	    		$aircraft_data = explode('-', $line['aircraftname']); | |
| 1054 | 1054 | if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | 
| 1055 | 1055 | elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | 
| 1056 | 1056 |  	    		else { | 
| 1057 | -	    		    $aircraft_data = explode(' ',$line['aircraftname']); | |
| 1058 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1059 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1057 | +	    		    $aircraft_data = explode(' ', $line['aircraftname']); | |
| 1058 | +	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-', '', $aircraft_data[1]); | |
| 1059 | +	    		    else $data['aircraft_icao'] = str_replace('-', '', $line['aircraftname']); | |
| 1060 | 1060 | } | 
| 1061 | 1061 | } | 
| 1062 | 1062 | if (isset($line['route'])) $data['waypoints'] = $line['route']; | 
| @@ -1076,14 +1076,14 @@ discard block | ||
| 1076 | 1076 | //$buffer = $Common->getData($hosts[$id]); | 
| 1077 | 1077 | if ($globalDebug) echo 'Get Data...'."\n"; | 
| 1078 | 1078 | $buffer = $Common->getData($value['host']); | 
| 1079 | - $all_data = json_decode($buffer,true); | |
| 1079 | + $all_data = json_decode($buffer, true); | |
| 1080 | 1080 |  	    if ($buffer != '' && is_array($all_data)) { | 
| 1081 | 1081 | $reset = 0; | 
| 1082 | 1082 |  		foreach ($all_data as $line) { | 
| 1083 | 1083 | $data = array(); | 
| 1084 | 1084 | //$data['id'] = $line['id']; // id not usable | 
| 1085 | 1085 | $data['id'] = trim($line['flight_id']); | 
| 1086 | - $data['hex'] = substr(str_pad(bin2hex($line['callsign']),6,'000000',STR_PAD_LEFT),-6); // hex | |
| 1086 | + $data['hex'] = substr(str_pad(bin2hex($line['callsign']), 6, '000000', STR_PAD_LEFT), -6); // hex | |
| 1087 | 1087 | $data['pilot_name'] = $line['pilot_name']; | 
| 1088 | 1088 | $data['pilot_id'] = $line['pilot_id']; | 
| 1089 | 1089 | $data['ident'] = trim($line['callsign']); // ident | 
| @@ -1135,11 +1135,11 @@ discard block | ||
| 1135 | 1135 | //$value = $formats[$nb]; | 
| 1136 | 1136 | $format = $globalSources[$nb]['format']; | 
| 1137 | 1137 |  		    if ($format == 'sbs' || $format == 'aprs' || $format == 'famaprs' || $format == 'raw' || $format == 'tsv' || $format == 'acarssbs3') { | 
| 1138 | - $buffer = @socket_read($r, 6000,PHP_NORMAL_READ); | |
| 1138 | + $buffer = @socket_read($r, 6000, PHP_NORMAL_READ); | |
| 1139 | 1139 |  		    } elseif ($format == 'vrstcp') { | 
| 1140 | 1140 | $buffer = @socket_read($r, 6000); | 
| 1141 | 1141 |  		    } else { | 
| 1142 | - $az = socket_recvfrom($r,$buffer,6000,0,$remote_ip,$remote_port); | |
| 1142 | + $az = socket_recvfrom($r, $buffer, 6000, 0, $remote_ip, $remote_port); | |
| 1143 | 1143 | } | 
| 1144 | 1144 | //$buffer = socket_read($r, 60000,PHP_NORMAL_READ); | 
| 1145 | 1145 | //echo $buffer."\n"; | 
| @@ -1148,8 +1148,8 @@ discard block | ||
| 1148 | 1148 | $error = false; | 
| 1149 | 1149 | //$SI::del(); | 
| 1150 | 1150 |  		    if ($format == 'vrstcp') { | 
| 1151 | -			$buffer = explode('},{',$buffer); | |
| 1152 | -		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1151 | +			$buffer = explode('},{', $buffer); | |
| 1152 | +		    } else $buffer = trim(str_replace(array("\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"), '', $buffer)); | |
| 1153 | 1153 | // SBS format is CSV format | 
| 1154 | 1154 |  		    if ($buffer !== FALSE && $buffer != '') { | 
| 1155 | 1155 | $tt[$format] = 0; | 
| @@ -1183,13 +1183,13 @@ discard block | ||
| 1183 | 1183 | if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | 
| 1184 | 1184 | if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | 
| 1185 | 1185 | if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | 
| 1186 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1186 | +			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s', $ais_data['eta_ts']); | |
| 1187 | 1187 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1188 | 1188 | if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | 
| 1189 | 1189 | if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | 
| 1190 | 1190 | |
| 1191 | 1191 |  			    if (isset($ais_data['timestamp'])) { | 
| 1192 | -				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | |
| 1192 | +				$data['datetime'] = date('Y-m-d H:i:s', $ais_data['timestamp']); | |
| 1193 | 1193 |  			    } else { | 
| 1194 | 1194 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1195 | 1195 | } | 
| @@ -1200,10 +1200,10 @@ discard block | ||
| 1200 | 1200 |                          } elseif ($format == 'flightgearsp') { | 
| 1201 | 1201 | //echo $buffer."\n"; | 
| 1202 | 1202 |                      	    if (strlen($buffer) > 5) { | 
| 1203 | -				$line = explode(',',$buffer); | |
| 1203 | +				$line = explode(',', $buffer); | |
| 1204 | 1204 | $data = array(); | 
| 1205 | 1205 | //XGPS,2.0947,41.3093,-3047.6953,198.930,0.000,callsign,c172p | 
| 1206 | - $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]),6,'000000',STR_PAD_LEFT),0,6); | |
| 1206 | + $data['hex'] = substr(str_pad(bin2hex($line[6].$line[7]), 6, '000000', STR_PAD_LEFT), 0, 6); | |
| 1207 | 1207 | $data['ident'] = $line[6]; | 
| 1208 | 1208 | $data['aircraft_name'] = $line[7]; | 
| 1209 | 1209 | $data['longitude'] = $line[1]; | 
| @@ -1220,16 +1220,16 @@ discard block | ||
| 1220 | 1220 |                          } elseif ($format == 'acars') { | 
| 1221 | 1221 | if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | 
| 1222 | 1222 | $ACARS->add(trim($buffer)); | 
| 1223 | - socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | |
| 1223 | + socket_sendto($r, "OK ".$buffer, 100, 0, $remote_ip, $remote_port); | |
| 1224 | 1224 | $ACARS->deleteLiveAcarsData(); | 
| 1225 | 1225 |  			} elseif ($format == 'flightgearmp') { | 
| 1226 | -			    if (substr($buffer,0,1) != '#') { | |
| 1226 | +			    if (substr($buffer, 0, 1) != '#') { | |
| 1227 | 1227 | $data = array(); | 
| 1228 | 1228 | //echo $buffer."\n"; | 
| 1229 | -				$line = explode(' ',$buffer); | |
| 1229 | +				$line = explode(' ', $buffer); | |
| 1230 | 1230 |  				if (count($line) == 11) { | 
| 1231 | -				    $userserver = explode('@',$line[0]); | |
| 1232 | - $data['hex'] = substr(str_pad(bin2hex($line[0]),6,'000000',STR_PAD_LEFT),0,6); // hex | |
| 1231 | +				    $userserver = explode('@', $line[0]); | |
| 1232 | + $data['hex'] = substr(str_pad(bin2hex($line[0]), 6, '000000', STR_PAD_LEFT), 0, 6); // hex | |
| 1233 | 1233 | $data['ident'] = $userserver[0]; | 
| 1234 | 1234 | $data['registration'] = $userserver[0]; | 
| 1235 | 1235 | $data['latitude'] = $line[4]; | 
| @@ -1237,8 +1237,8 @@ discard block | ||
| 1237 | 1237 | $data['altitude'] = $line[6]; | 
| 1238 | 1238 |  				    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1239 | 1239 | $aircraft_type = $line[10]; | 
| 1240 | -				    $aircraft_type = preg_split(':/:',$aircraft_type); | |
| 1241 | - $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | |
| 1240 | +				    $aircraft_type = preg_split(':/:', $aircraft_type); | |
| 1241 | + $data['aircraft_name'] = substr(end($aircraft_type), 0, -4); | |
| 1242 | 1242 | if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | 
| 1243 | 1243 | if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | 
| 1244 | 1244 | } | 
| @@ -1247,8 +1247,8 @@ discard block | ||
| 1247 | 1247 | echo 'Beast Binary format not yet supported. Beast AVR format is supported in alpha state'."\n"; | 
| 1248 | 1248 | die; | 
| 1249 | 1249 |  			} elseif ($format == 'vrstcp') { | 
| 1250 | -			    foreach($buffer as $all_data) { | |
| 1251 | -				$line = json_decode('{'.$all_data.'}',true); | |
| 1250 | +			    foreach ($buffer as $all_data) { | |
| 1251 | +				$line = json_decode('{'.$all_data.'}', true); | |
| 1252 | 1252 | $data = array(); | 
| 1253 | 1253 | if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | 
| 1254 | 1254 | if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | 
| @@ -1274,16 +1274,16 @@ discard block | ||
| 1274 | 1274 | if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | 
| 1275 | 1275 | unset($data); | 
| 1276 | 1276 | } | 
| 1277 | -			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { | |
| 1277 | +			} elseif ($format == 'tsv' || substr($buffer, 0, 4) == 'clock') { | |
| 1278 | 1278 |  			    $line = explode("\t", $buffer); | 
| 1279 | -			    for($k = 0; $k < count($line); $k=$k+2) { | |
| 1279 | +			    for ($k = 0; $k < count($line); $k = $k + 2) { | |
| 1280 | 1280 | $key = $line[$k]; | 
| 1281 | - $lined[$key] = $line[$k+1]; | |
| 1281 | + $lined[$key] = $line[$k + 1]; | |
| 1282 | 1282 | } | 
| 1283 | 1283 |      			    if (count($lined) > 3) { | 
| 1284 | 1284 | $data['hex'] = $lined['hexid']; | 
| 1285 | 1285 |      				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | 
| 1286 | -    				$data['datetime'] = date('Y-m-d H:i:s');; | |
| 1286 | +    				$data['datetime'] = date('Y-m-d H:i:s'); ; | |
| 1287 | 1287 | if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | 
| 1288 | 1288 | if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | 
| 1289 | 1289 | if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | 
| @@ -1302,22 +1302,22 @@ discard block | ||
| 1302 | 1302 | } else $error = true; | 
| 1303 | 1303 |  			} elseif ($format == 'aprs' && $use_aprs) { | 
| 1304 | 1304 |  			    if ($aprs_connect == 0) { | 
| 1305 | - $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | |
| 1305 | + $send = @ socket_send($r, $aprs_login, strlen($aprs_login), 0); | |
| 1306 | 1306 | $aprs_connect = 1; | 
| 1307 | 1307 | } | 
| 1308 | 1308 | |
| 1309 | -			    if ( $aprs_keep>60 && time() - $aprs_last_tx > $aprs_keep ) { | |
| 1309 | +			    if ($aprs_keep > 60 && time() - $aprs_last_tx > $aprs_keep) { | |
| 1310 | 1310 | $aprs_last_tx = time(); | 
| 1311 | 1311 | $data_aprs = "# Keep alive"; | 
| 1312 | - $send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | |
| 1312 | + $send = @ socket_send($r, $data_aprs, strlen($data_aprs), 0); | |
| 1313 | 1313 | } | 
| 1314 | 1314 | |
| 1315 | 1315 | //echo 'Connect : '.$aprs_connect.' '.$buffer."\n"; | 
| 1316 | 1316 | //echo 'APRS data : '.$buffer."\n"; | 
| 1317 | -			    $buffer = str_replace('APRS <- ','',$buffer); | |
| 1318 | -			    $buffer = str_replace('APRS -> ','',$buffer); | |
| 1317 | +			    $buffer = str_replace('APRS <- ', '', $buffer); | |
| 1318 | +			    $buffer = str_replace('APRS -> ', '', $buffer); | |
| 1319 | 1319 | //echo $buffer."\n"; | 
| 1320 | -			    if (substr($buffer,0,1) != '#' && substr($buffer,0,1) != '@' && substr($buffer,0,5) != 'APRS ') { | |
| 1320 | +			    if (substr($buffer, 0, 1) != '#' && substr($buffer, 0, 1) != '@' && substr($buffer, 0, 5) != 'APRS ') { | |
| 1321 | 1321 | $line = $APRS->parse($buffer); | 
| 1322 | 1322 |  				//if (is_array($line) && isset($line['address']) && $line['address'] != '' && isset($line['ident'])) { | 
| 1323 | 1323 |  				if (is_array($line) && isset($line['latitude']) && isset($line['longitude']) && (isset($line['ident']) || isset($line['address']) || isset($line['mmsi']))) { | 
| @@ -1332,7 +1332,7 @@ discard block | ||
| 1332 | 1332 | if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; | 
| 1333 | 1333 | if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; | 
| 1334 | 1334 | if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; | 
| 1335 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1335 | +				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s', $line['timestamp']); | |
| 1336 | 1336 |  				    else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1337 | 1337 |  				    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1338 | 1338 | if (isset($line['ident'])) $data['ident'] = $line['ident']; | 
| @@ -1375,9 +1375,9 @@ discard block | ||
| 1375 | 1375 |  				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident'])) { | 
| 1376 | 1376 |  					$Source->deleteOldLocationByType('gs'); | 
| 1377 | 1377 |  					if (count($Source->getLocationInfoByName($data['ident'])) > 0) { | 
| 1378 | - $Source->updateLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | |
| 1378 | + $Source->updateLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); | |
| 1379 | 1379 |  					} else { | 
| 1380 | - $Source->addLocation($data['ident'],$data['latitude'],$data['longitude'],$data['altitude'],'','',$data['source_name'],'antenna.png','gs',$id,0,$data['datetime']); | |
| 1380 | + $Source->addLocation($data['ident'], $data['latitude'], $data['longitude'], $data['altitude'], '', '', $data['source_name'], 'antenna.png', 'gs', $id, 0, $data['datetime']); | |
| 1381 | 1381 | } | 
| 1382 | 1382 |  				    } else { | 
| 1383 | 1383 | echo '/!\ Not added'."\n"; | 
| @@ -1473,7 +1473,7 @@ discard block | ||
| 1473 | 1473 | connect_all($sourceee); | 
| 1474 | 1474 | $sourceee = array(); | 
| 1475 | 1475 | //connect_all($globalSources); | 
| 1476 | - $tt[$format]=0; | |
| 1476 | + $tt[$format] = 0; | |
| 1477 | 1477 | break; | 
| 1478 | 1478 | } | 
| 1479 | 1479 | } | 
| @@ -1482,14 +1482,14 @@ discard block | ||
| 1482 | 1482 |  	    } else { | 
| 1483 | 1483 | $error = socket_strerror(socket_last_error()); | 
| 1484 | 1484 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 1485 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 1485 | + if ($globalDebug) echo "ERROR : socket_select give this error ".$error."\n"; | |
| 1486 | 1486 | if (isset($globalDebug)) echo "Restarting...\n"; | 
| 1487 | 1487 | // Restart the script if possible | 
| 1488 | 1488 |  			if (is_array($sockets)) { | 
| 1489 | 1489 | if ($globalDebug) echo "Shutdown all sockets..."; | 
| 1490 | 1490 | |
| 1491 | 1491 |  			    foreach ($sockets as $sock) { | 
| 1492 | - @socket_shutdown($sock,2); | |
| 1492 | + @socket_shutdown($sock, 2); | |
| 1493 | 1493 | @socket_close($sock); | 
| 1494 | 1494 | } | 
| 1495 | 1495 | |
| @@ -14,13 +14,17 @@ discard block | ||
| 14 | 14 | require_once(dirname(__FILE__).'/../require/class.Source.php'); | 
| 15 | 15 | require_once(dirname(__FILE__).'/../require/class.Connection.php'); | 
| 16 | 16 | require_once(dirname(__FILE__).'/../require/class.Common.php'); | 
| 17 | -if (isset($globalTracker) && $globalTracker) require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | |
| 17 | +if (isset($globalTracker) && $globalTracker) { | |
| 18 | + require_once(dirname(__FILE__).'/../require/class.TrackerImport.php'); | |
| 19 | +} | |
| 18 | 20 |  if (isset($globalMarine) && $globalMarine) { | 
| 19 | 21 | require_once(dirname(__FILE__).'/../require/class.AIS.php'); | 
| 20 | 22 | require_once(dirname(__FILE__).'/../require/class.MarineImport.php'); | 
| 21 | 23 | } | 
| 22 | 24 | |
| 23 | -if (!isset($globalDebug)) $globalDebug = FALSE; | |
| 25 | +if (!isset($globalDebug)) { | |
| 26 | + $globalDebug = FALSE; | |
| 27 | +} | |
| 24 | 28 | |
| 25 | 29 | // Check if schema is at latest version | 
| 26 | 30 | $Connection = new Connection(); | 
| @@ -55,35 +59,62 @@ discard block | ||
| 55 | 59 | //elseif (isset($options['source'])) $hosts = array($options['source']); | 
| 56 | 60 |  if (isset($options['s'])) { | 
| 57 | 61 | $globalSources = array(); | 
| 58 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 59 | -    else $globalSources[] = array('host' => $options['s']); | |
| 60 | -} elseif (isset($options['source'])) { | |
| 62 | +    if (isset($options['format'])) { | |
| 63 | +    	$globalSources[] = array('host' => $options['s'],'format' => $options['format']); | |
| 64 | +    } else { | |
| 65 | +    	$globalSources[] = array('host' => $options['s']); | |
| 66 | + } | |
| 67 | +    } elseif (isset($options['source'])) { | |
| 61 | 68 | $globalSources = array(); | 
| 62 | -    if (isset($options['format'])) $globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 63 | -    else $globalSources[] = array('host' => $options['source']); | |
| 64 | -} | |
| 69 | +    if (isset($options['format'])) { | |
| 70 | +    	$globalSources[] = array('host' => $options['source'],'format' => $options['format']); | |
| 71 | +    } else { | |
| 72 | +    	$globalSources[] = array('host' => $options['source']); | |
| 73 | + } | |
| 74 | + } | |
| 65 | 75 |  if (isset($options['aprsserverhost'])) { | 
| 66 | 76 | $globalServerAPRS = TRUE; | 
| 67 | 77 | $globalServerAPRShost = $options['aprsserverhost']; | 
| 68 | 78 | } | 
| 69 | -if (isset($options['aprsserverport'])) $globalServerAPRSport = $options['aprsserverport']; | |
| 70 | -if (isset($options['aprsserverssid'])) $globalServerAPRSssid = $options['aprsserverssid']; | |
| 71 | -if (isset($options['aprsserverpass'])) $globalServerAPRSpass = $options['aprsserverpass']; | |
| 72 | -if (isset($options['noaprsserver'])) $globalServerAPRS = FALSE; | |
| 73 | -if (isset($options['nodaemon'])) $globalDaemon = FALSE; | |
| 74 | -if (isset($options['server'])) $globalServer = TRUE; | |
| 75 | -if (isset($options['idsource'])) $id_source = $options['idsource']; | |
| 76 | -else $id_source = 1; | |
| 79 | +if (isset($options['aprsserverport'])) { | |
| 80 | + $globalServerAPRSport = $options['aprsserverport']; | |
| 81 | +} | |
| 82 | +if (isset($options['aprsserverssid'])) { | |
| 83 | + $globalServerAPRSssid = $options['aprsserverssid']; | |
| 84 | +} | |
| 85 | +if (isset($options['aprsserverpass'])) { | |
| 86 | + $globalServerAPRSpass = $options['aprsserverpass']; | |
| 87 | +} | |
| 88 | +if (isset($options['noaprsserver'])) { | |
| 89 | + $globalServerAPRS = FALSE; | |
| 90 | +} | |
| 91 | +if (isset($options['nodaemon'])) { | |
| 92 | + $globalDaemon = FALSE; | |
| 93 | +} | |
| 94 | +if (isset($options['server'])) { | |
| 95 | + $globalServer = TRUE; | |
| 96 | +} | |
| 97 | +if (isset($options['idsource'])) { | |
| 98 | + $id_source = $options['idsource']; | |
| 99 | +} else { | |
| 100 | + $id_source = 1; | |
| 101 | +} | |
| 77 | 102 |  if (isset($globalServer) && $globalServer) { | 
| 78 | - if ($globalDebug) echo "Using Server Mode\n"; | |
| 103 | +    if ($globalDebug) { | |
| 104 | + echo "Using Server Mode\n"; | |
| 105 | + } | |
| 79 | 106 | $SI=new SpotterServer(); | 
| 80 | 107 | /* | 
| 81 | 108 | require_once(dirname(__FILE__).'/../require/class.APRS.php'); | 
| 82 | 109 | $SI = new adsb2aprs(); | 
| 83 | 110 | $SI->connect(); | 
| 84 | 111 | */ | 
| 85 | -} else $SI=new SpotterImport($Connection->db); | |
| 86 | -if (isset($globalTracker) && $globalTracker) $TI = new TrackerImport($Connection->db); | |
| 112 | +} else { | |
| 113 | + $SI=new SpotterImport($Connection->db); | |
| 114 | +} | |
| 115 | +if (isset($globalTracker) && $globalTracker) { | |
| 116 | + $TI = new TrackerImport($Connection->db); | |
| 117 | +} | |
| 87 | 118 |  if (isset($globalMarine) && $globalMarine) { | 
| 88 | 119 | $AIS = new AIS(); | 
| 89 | 120 | $MI = new MarineImport($Connection->db); | 
| @@ -106,7 +137,9 @@ discard block | ||
| 106 | 137 | } | 
| 107 | 138 | |
| 108 | 139 | // let's try and connect | 
| 109 | -if ($globalDebug) echo "Connecting...\n"; | |
| 140 | +if ($globalDebug) { | |
| 141 | + echo "Connecting...\n"; | |
| 142 | +} | |
| 110 | 143 | $use_aprs = false; | 
| 111 | 144 | $aprs_full = false; | 
| 112 | 145 | $reset = 0; | 
| @@ -115,7 +148,9 @@ discard block | ||
| 115 | 148 | //global $sockets, $formats, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs; | 
| 116 | 149 | global $sockets,$httpfeeds, $globalSources, $globalDebug,$aprs_connect,$last_exec, $globalSourcesRights, $use_aprs, $reset,$context; | 
| 117 | 150 | $reset++; | 
| 118 | - if ($globalDebug) echo 'Connect to all...'."\n"; | |
| 151 | +    if ($globalDebug) { | |
| 152 | + echo 'Connect to all...'."\n"; | |
| 153 | + } | |
| 119 | 154 |      foreach ($hosts as $id => $value) { | 
| 120 | 155 | $host = $value['host']; | 
| 121 | 156 | $globalSources[$id]['last_exec'] = 0; | 
| @@ -125,22 +160,30 @@ discard block | ||
| 125 | 160 | //$formats[$id] = 'deltadbtxt'; | 
| 126 | 161 | $globalSources[$id]['format'] = 'deltadbtxt'; | 
| 127 | 162 | //$last_exec['deltadbtxt'] = 0; | 
| 128 | -        	if ($globalDebug) echo "Connect to deltadb source (".$host.")...\n"; | |
| 163 | +        	if ($globalDebug) { | |
| 164 | +        		echo "Connect to deltadb source (".$host.")...\n"; | |
| 165 | + } | |
| 129 | 166 |              } else if (preg_match('/vatsim-data.txt$/i',$host)) { | 
| 130 | 167 | //$formats[$id] = 'vatsimtxt'; | 
| 131 | 168 | $globalSources[$id]['format'] = 'vatsimtxt'; | 
| 132 | 169 | //$last_exec['vatsimtxt'] = 0; | 
| 133 | -        	if ($globalDebug) echo "Connect to vatsim source (".$host.")...\n"; | |
| 170 | +        	if ($globalDebug) { | |
| 171 | +        		echo "Connect to vatsim source (".$host.")...\n"; | |
| 172 | + } | |
| 134 | 173 |      	    } else if (preg_match('/aircraftlist.json$/i',$host)) { | 
| 135 | 174 | //$formats[$id] = 'aircraftlistjson'; | 
| 136 | 175 | $globalSources[$id]['format'] = 'aircraftlistjson'; | 
| 137 | 176 | //$last_exec['aircraftlistjson'] = 0; | 
| 138 | -        	if ($globalDebug) echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 177 | +        	if ($globalDebug) { | |
| 178 | +        		echo "Connect to aircraftlist.json source (".$host.")...\n"; | |
| 179 | + } | |
| 139 | 180 |      	    } else if (preg_match('/opensky/i',$host)) { | 
| 140 | 181 | //$formats[$id] = 'aircraftlistjson'; | 
| 141 | 182 | $globalSources[$id]['format'] = 'opensky'; | 
| 142 | 183 | //$last_exec['aircraftlistjson'] = 0; | 
| 143 | -        	if ($globalDebug) echo "Connect to opensky source (".$host.")...\n"; | |
| 184 | +        	if ($globalDebug) { | |
| 185 | +        		echo "Connect to opensky source (".$host.")...\n"; | |
| 186 | + } | |
| 144 | 187 | /* | 
| 145 | 188 | // Disabled for now, site change source format | 
| 146 | 189 |      	    } else if (preg_match('/radarvirtuel.com\/list_aircrafts$/i',$host)) { | 
| @@ -157,7 +200,9 @@ discard block | ||
| 157 | 200 | //$formats[$id] = 'planeupdatefaa'; | 
| 158 | 201 | $globalSources[$id]['format'] = 'planeupdatefaa'; | 
| 159 | 202 | //$last_exec['planeupdatefaa'] = 0; | 
| 160 | -        	if ($globalDebug) echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 203 | +        	if ($globalDebug) { | |
| 204 | +        		echo "Connect to planeUpdateFAA.php source (".$host.")...\n"; | |
| 205 | + } | |
| 161 | 206 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 162 | 207 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 163 | 208 | exit(0); | 
| @@ -166,29 +211,41 @@ discard block | ||
| 166 | 211 | //$formats[$id] = 'phpvmacars'; | 
| 167 | 212 | $globalSources[$id]['format'] = 'phpvmacars'; | 
| 168 | 213 | //$last_exec['phpvmacars'] = 0; | 
| 169 | -        	if ($globalDebug) echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 214 | +        	if ($globalDebug) { | |
| 215 | +        		echo "Connect to phpvmacars source (".$host.")...\n"; | |
| 216 | + } | |
| 170 | 217 |              } else if (preg_match('/VAM-json.php$/i',$host)) { | 
| 171 | 218 | //$formats[$id] = 'phpvmacars'; | 
| 172 | 219 | $globalSources[$id]['format'] = 'vam'; | 
| 173 | -        	if ($globalDebug) echo "Connect to Vam source (".$host.")...\n"; | |
| 220 | +        	if ($globalDebug) { | |
| 221 | +        		echo "Connect to Vam source (".$host.")...\n"; | |
| 222 | + } | |
| 174 | 223 |              } else if (preg_match('/whazzup/i',$host)) { | 
| 175 | 224 | //$formats[$id] = 'whazzup'; | 
| 176 | 225 | $globalSources[$id]['format'] = 'whazzup'; | 
| 177 | 226 | //$last_exec['whazzup'] = 0; | 
| 178 | -        	if ($globalDebug) echo "Connect to whazzup source (".$host.")...\n"; | |
| 227 | +        	if ($globalDebug) { | |
| 228 | +        		echo "Connect to whazzup source (".$host.")...\n"; | |
| 229 | + } | |
| 179 | 230 |              } else if (preg_match('/airwhere/i',$host)) { | 
| 180 | 231 | $globalSources[$id]['format'] = 'airwhere'; | 
| 181 | -        	if ($globalDebug) echo "Connect to airwhere source (".$host.")...\n"; | |
| 232 | +        	if ($globalDebug) { | |
| 233 | +        		echo "Connect to airwhere source (".$host.")...\n"; | |
| 234 | + } | |
| 182 | 235 |              } else if (preg_match('/recentpireps/i',$host)) { | 
| 183 | 236 | //$formats[$id] = 'pirepsjson'; | 
| 184 | 237 | $globalSources[$id]['format'] = 'pirepsjson'; | 
| 185 | 238 | //$last_exec['pirepsjson'] = 0; | 
| 186 | -        	if ($globalDebug) echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 239 | +        	if ($globalDebug) { | |
| 240 | +        		echo "Connect to pirepsjson source (".$host.")...\n"; | |
| 241 | + } | |
| 187 | 242 |              } else if (preg_match(':data.fr24.com/zones/fcgi/feed.js:i',$host)) { | 
| 188 | 243 | //$formats[$id] = 'fr24json'; | 
| 189 | 244 | $globalSources[$id]['format'] = 'fr24json'; | 
| 190 | 245 | //$last_exec['fr24json'] = 0; | 
| 191 | -        	if ($globalDebug) echo "Connect to fr24 source (".$host.")...\n"; | |
| 246 | +        	if ($globalDebug) { | |
| 247 | +        		echo "Connect to fr24 source (".$host.")...\n"; | |
| 248 | + } | |
| 192 | 249 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 193 | 250 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 194 | 251 | exit(0); | 
| @@ -197,7 +254,9 @@ discard block | ||
| 197 | 254 | //$formats[$id] = 'fr24json'; | 
| 198 | 255 | $globalSources[$id]['format'] = 'myshiptracking'; | 
| 199 | 256 | //$last_exec['fr24json'] = 0; | 
| 200 | -        	if ($globalDebug) echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 257 | +        	if ($globalDebug) { | |
| 258 | +        		echo "Connect to myshiptracking source (".$host.")...\n"; | |
| 259 | + } | |
| 201 | 260 |          	if (!isset($globalSourcesRights) || (isset($globalSourcesRights) && !$globalSourcesRights)) { | 
| 202 | 261 | echo '!!! You MUST set $globalSourcesRights = TRUE in settings.php if you have the right to use this feed !!!'."\n"; | 
| 203 | 262 | exit(0); | 
| @@ -206,17 +265,24 @@ discard block | ||
| 206 | 265 |              } else if (preg_match('/10001/',$host) || (isset($globalSources[$id]['port']) && $globalSources[$id]['port'] == '10001')) { | 
| 207 | 266 | //$formats[$id] = 'tsv'; | 
| 208 | 267 | $globalSources[$id]['format'] = 'tsv'; | 
| 209 | -        	if ($globalDebug) echo "Connect to tsv source (".$host.")...\n"; | |
| 268 | +        	if ($globalDebug) { | |
| 269 | +        		echo "Connect to tsv source (".$host.")...\n"; | |
| 270 | + } | |
| 210 | 271 | } | 
| 211 | 272 |          } elseif (filter_var($host,FILTER_VALIDATE_URL)) { | 
| 212 | 273 |      		if ($globalSources[$id]['format'] == 'aisnmeahttp') { | 
| 213 | 274 | $idf = fopen($globalSources[$id]['host'],'r',false,$context); | 
| 214 | 275 |      		    if ($idf !== false) { | 
| 215 | 276 | $httpfeeds[$id] = $idf; | 
| 216 | -        		if ($globalDebug) echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 277 | +        		if ($globalDebug) { | |
| 278 | +        			echo "Connected to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 279 | + } | |
| 280 | +    		    } elseif ($globalDebug) { | |
| 281 | + echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 217 | 282 | } | 
| 218 | - elseif ($globalDebug) echo "Can't connect to ".$globalSources[$id]['host']."\n"; | |
| 219 | -    		} elseif ($globalDebug) echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 283 | +    		} elseif ($globalDebug) { | |
| 284 | +    			echo "Connect to ".$globalSources[$id]['format']." source (".$host.")...\n"; | |
| 285 | + } | |
| 220 | 286 |          } elseif (!filter_var($host,FILTER_VALIDATE_URL)) { | 
| 221 | 287 |  	    $hostport = explode(':',$host); | 
| 222 | 288 |  	    if (isset($hostport[1])) { | 
| @@ -256,17 +322,25 @@ discard block | ||
| 256 | 322 | //$formats[$id] = 'beast'; | 
| 257 | 323 | $globalSources[$id]['format'] = 'beast'; | 
| 258 | 324 | //} else $formats[$id] = 'sbs'; | 
| 259 | - } else $globalSources[$id]['format'] = 'sbs'; | |
| 325 | +		    } else { | |
| 326 | + $globalSources[$id]['format'] = 'sbs'; | |
| 327 | + } | |
| 260 | 328 |  		    //if ($globalDebug) echo 'Connection in progress to '.$host.'('.$formats[$id].')....'."\n"; | 
| 261 | 329 | } | 
| 262 | -		if ($globalDebug) echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 330 | +		if ($globalDebug) { | |
| 331 | +			echo 'Connection in progress to '.$hostn.':'.$port.' ('.$globalSources[$id]['format'].')....'."\n"; | |
| 332 | + } | |
| 263 | 333 |              } else { | 
| 264 | - if ($globalDebug) echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | |
| 334 | +		if ($globalDebug) { | |
| 335 | + echo 'Connection failed to '.$hostn.':'.$port.' : '.$errno.' '.$errstr."\n"; | |
| 336 | + } | |
| 265 | 337 | } | 
| 266 | 338 | } | 
| 267 | 339 | } | 
| 268 | 340 | } | 
| 269 | -if (!isset($globalMinFetch)) $globalMinFetch = 15; | |
| 341 | +if (!isset($globalMinFetch)) { | |
| 342 | + $globalMinFetch = 15; | |
| 343 | +} | |
| 270 | 344 | |
| 271 | 345 | // Initialize all | 
| 272 | 346 | $status = array(); | 
| @@ -275,13 +349,19 @@ discard block | ||
| 275 | 349 | $formats = array(); | 
| 276 | 350 | $last_exec = array(); | 
| 277 | 351 | $time = time(); | 
| 278 | -if (isset($globalSourcesTimeout)) $timeout = $globalSourcesTimeOut; | |
| 279 | -else if (isset($globalSBS1TimeOut)) $timeout = $globalSBS1TimeOut; | |
| 280 | -else $timeout = 20; | |
| 352 | +if (isset($globalSourcesTimeout)) { | |
| 353 | + $timeout = $globalSourcesTimeOut; | |
| 354 | +} else if (isset($globalSBS1TimeOut)) { | |
| 355 | + $timeout = $globalSBS1TimeOut; | |
| 356 | +} else { | |
| 357 | + $timeout = 20; | |
| 358 | +} | |
| 281 | 359 | $errno = ''; | 
| 282 | 360 | $errstr=''; | 
| 283 | 361 | |
| 284 | -if (!isset($globalDaemon)) $globalDaemon = TRUE; | |
| 362 | +if (!isset($globalDaemon)) { | |
| 363 | + $globalDaemon = TRUE; | |
| 364 | +} | |
| 285 | 365 | /* Initiate connections to all the hosts simultaneously */ | 
| 286 | 366 | //connect_all($hosts); | 
| 287 | 367 | //connect_all($globalSources); | 
| @@ -307,7 +387,9 @@ discard block | ||
| 307 | 387 |      if (isset($source['format']) && $source['format'] == 'aprs') { | 
| 308 | 388 | $aprs_connect = 0; | 
| 309 | 389 | $use_aprs = true; | 
| 310 | - if (isset($source['port']) && $source['port'] == '10152') $aprs_full = true; | |
| 390 | +	if (isset($source['port']) && $source['port'] == '10152') { | |
| 391 | + $aprs_full = true; | |
| 392 | + } | |
| 311 | 393 | break; | 
| 312 | 394 | } | 
| 313 | 395 | } | 
| @@ -318,25 +400,48 @@ discard block | ||
| 318 | 400 | $aprs_connect = 0; | 
| 319 | 401 | $aprs_keep = 120; | 
| 320 | 402 | $aprs_last_tx = time(); | 
| 321 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | |
| 322 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 323 | - if (isset($globalAPRSssid)) $aprs_ssid = $globalAPRSssid; | |
| 324 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 325 | - if (isset($globalAPRSfilter)) $aprs_filter = $globalAPRSfilter; | |
| 326 | - else $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 327 | - if ($aprs_full) $aprs_filter = ''; | |
| 328 | - if (isset($globalAPRSpass)) $aprs_pass = $globalAPRSpass; | |
| 329 | - else $aprs_pass = '-1'; | |
| 403 | +	if (isset($globalAPRSversion)) { | |
| 404 | + $aprs_version = $globalAPRSversion; | |
| 405 | +	} else { | |
| 406 | +		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 407 | + } | |
| 408 | +	if (isset($globalAPRSssid)) { | |
| 409 | + $aprs_ssid = $globalAPRSssid; | |
| 410 | +	} else { | |
| 411 | +		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 412 | + } | |
| 413 | +	if (isset($globalAPRSfilter)) { | |
| 414 | + $aprs_filter = $globalAPRSfilter; | |
| 415 | +	} else { | |
| 416 | + $aprs_filter = 'r/'.$globalCenterLatitude.'/'.$globalCenterLongitude.'/250.0'; | |
| 417 | + } | |
| 418 | +	if ($aprs_full) { | |
| 419 | + $aprs_filter = ''; | |
| 420 | + } | |
| 421 | +	if (isset($globalAPRSpass)) { | |
| 422 | + $aprs_pass = $globalAPRSpass; | |
| 423 | +	} else { | |
| 424 | + $aprs_pass = '-1'; | |
| 425 | + } | |
| 330 | 426 | |
| 331 | -	if ($aprs_filter != '') $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; | |
| 332 | -	else $aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | |
| 333 | -} | |
| 427 | +	if ($aprs_filter != '') { | |
| 428 | +		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version} filter {$aprs_filter}\n"; | |
| 429 | +	} else { | |
| 430 | +		$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | |
| 431 | + } | |
| 432 | + } | |
| 334 | 433 | |
| 335 | 434 | // connected - lets do some work | 
| 336 | -if ($globalDebug) echo "Connected!\n"; | |
| 435 | +if ($globalDebug) { | |
| 436 | + echo "Connected!\n"; | |
| 437 | +} | |
| 337 | 438 | sleep(1); | 
| 338 | -if ($globalDebug) echo "SCAN MODE \n\n"; | |
| 339 | -if (!isset($globalCronEnd)) $globalCronEnd = 60; | |
| 439 | +if ($globalDebug) { | |
| 440 | + echo "SCAN MODE \n\n"; | |
| 441 | +} | |
| 442 | +if (!isset($globalCronEnd)) { | |
| 443 | + $globalCronEnd = 60; | |
| 444 | +} | |
| 340 | 445 | $endtime = time()+$globalCronEnd; | 
| 341 | 446 | $i = 1; | 
| 342 | 447 | $tt = array(); | 
| @@ -350,20 +455,28 @@ discard block | ||
| 350 | 455 | |
| 351 | 456 | // Infinite loop if daemon, else work for time defined in $globalCronEnd or only one time. | 
| 352 | 457 |  while ($i > 0) { | 
| 353 | - if (!$globalDaemon) $i = $endtime-time(); | |
| 458 | +    if (!$globalDaemon) { | |
| 459 | + $i = $endtime-time(); | |
| 460 | + } | |
| 354 | 461 | // Delete old ATC | 
| 355 | 462 |      if ($globalDaemon && ((isset($globalVA) && $globalVA) || (isset($globalIVAO) && $globalIVAO) || (isset($globalVATSIM) && $globalVATSIM))) { | 
| 356 | - if ($globalDebug) echo 'Delete old ATC...'."\n"; | |
| 463 | +	if ($globalDebug) { | |
| 464 | + echo 'Delete old ATC...'."\n"; | |
| 465 | + } | |
| 357 | 466 | $ATC->deleteOldATC(); | 
| 358 | 467 | } | 
| 359 | 468 | |
| 360 | 469 |      if (count($last_exec) == count($globalSources)) { | 
| 361 | 470 | $max = $globalMinFetch; | 
| 362 | 471 |  	foreach ($last_exec as $last) { | 
| 363 | - if ((time() - $last['last']) < $max) $max = time() - $last['last']; | |
| 472 | +	    if ((time() - $last['last']) < $max) { | |
| 473 | + $max = time() - $last['last']; | |
| 474 | + } | |
| 364 | 475 | } | 
| 365 | 476 |  	if ($max != $globalMinFetch) { | 
| 366 | - if ($globalDebug) echo 'Sleeping...'."\n"; | |
| 477 | +	    if ($globalDebug) { | |
| 478 | + echo 'Sleeping...'."\n"; | |
| 479 | + } | |
| 367 | 480 | sleep($globalMinFetch-$max+2); | 
| 368 | 481 | } | 
| 369 | 482 | } | 
| @@ -372,11 +485,15 @@ discard block | ||
| 372 | 485 |      //foreach ($formats as $id => $value) { | 
| 373 | 486 |      foreach ($globalSources as $id => $value) { | 
| 374 | 487 |  	date_default_timezone_set('UTC'); | 
| 375 | - if (!isset($last_exec[$id]['last'])) $last_exec[$id]['last'] = 0; | |
| 488 | +	if (!isset($last_exec[$id]['last'])) { | |
| 489 | + $last_exec[$id]['last'] = 0; | |
| 490 | + } | |
| 376 | 491 |  	if ($value['format'] == 'deltadbtxt' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 377 | 492 | //$buffer = $Common->getData($hosts[$id]); | 
| 378 | 493 | $buffer = $Common->getData($value['host']); | 
| 379 | - if ($buffer != '') $reset = 0; | |
| 494 | +	    if ($buffer != '') { | |
| 495 | + $reset = 0; | |
| 496 | + } | |
| 380 | 497 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 381 | 498 |  	    $buffer = explode('\n',$buffer); | 
| 382 | 499 |  	    foreach ($buffer as $line) { | 
| @@ -385,20 +502,41 @@ discard block | ||
| 385 | 502 | $data = array(); | 
| 386 | 503 | $data['hex'] = $line[1]; // hex | 
| 387 | 504 | $data['ident'] = $line[2]; // ident | 
| 388 | - if (isset($line[3])) $data['altitude'] = $line[3]; // altitude | |
| 389 | - if (isset($line[4])) $data['speed'] = $line[4]; // speed | |
| 390 | - if (isset($line[5])) $data['heading'] = $line[5]; // heading | |
| 391 | - if (isset($line[6])) $data['latitude'] = $line[6]; // lat | |
| 392 | - if (isset($line[7])) $data['longitude'] = $line[7]; // long | |
| 505 | +	            if (isset($line[3])) { | |
| 506 | + $data['altitude'] = $line[3]; | |
| 507 | + } | |
| 508 | + // altitude | |
| 509 | +	            if (isset($line[4])) { | |
| 510 | + $data['speed'] = $line[4]; | |
| 511 | + } | |
| 512 | + // speed | |
| 513 | +	            if (isset($line[5])) { | |
| 514 | + $data['heading'] = $line[5]; | |
| 515 | + } | |
| 516 | + // heading | |
| 517 | +	            if (isset($line[6])) { | |
| 518 | + $data['latitude'] = $line[6]; | |
| 519 | + } | |
| 520 | + // lat | |
| 521 | +	            if (isset($line[7])) { | |
| 522 | + $data['longitude'] = $line[7]; | |
| 523 | + } | |
| 524 | + // long | |
| 393 | 525 | $data['verticalrate'] = ''; // vertical rate | 
| 394 | 526 | //if (isset($line[9])) $data['squawk'] = $line[9]; // squawk | 
| 395 | 527 | $data['emergency'] = ''; // emergency | 
| 396 | 528 |  		    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 397 | 529 | $data['format_source'] = 'deltadbtxt'; | 
| 398 | 530 | $data['id_source'] = $id_source; | 
| 399 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 400 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 401 | - if (isset($value['sourcestats'])) $data['sourcestats'] = $value['sourcestats']; | |
| 531 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 532 | + $data['source_name'] = $value['name']; | |
| 533 | + } | |
| 534 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 535 | + $data['noarchive'] = true; | |
| 536 | + } | |
| 537 | +		    if (isset($value['sourcestats'])) { | |
| 538 | + $data['sourcestats'] = $value['sourcestats']; | |
| 539 | + } | |
| 402 | 540 | $SI->add($data); | 
| 403 | 541 | unset($data); | 
| 404 | 542 | } | 
| @@ -408,7 +546,9 @@ discard block | ||
| 408 | 546 |  	    date_default_timezone_set('CET'); | 
| 409 | 547 |  	    $buffer = $Common->getData(str_replace('{date}',date('Ymd'),$value['host'])); | 
| 410 | 548 |  	    date_default_timezone_set('UTC'); | 
| 411 | - if ($buffer != '') $reset = 0; | |
| 549 | +	    if ($buffer != '') { | |
| 550 | + $reset = 0; | |
| 551 | + } | |
| 412 | 552 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 413 | 553 |  	    $buffer = explode('\n',$buffer); | 
| 414 | 554 |  	    foreach ($buffer as $line) { | 
| @@ -417,16 +557,36 @@ discard block | ||
| 417 | 557 | $add = false; | 
| 418 | 558 | $ais_data = $AIS->parse_line(trim($line)); | 
| 419 | 559 | $data = array(); | 
| 420 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 421 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 422 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 423 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 424 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 425 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 426 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 427 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 428 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 429 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 560 | +		    if (isset($ais_data['ident'])) { | |
| 561 | + $data['ident'] = $ais_data['ident']; | |
| 562 | + } | |
| 563 | +		    if (isset($ais_data['mmsi'])) { | |
| 564 | + $data['mmsi'] = $ais_data['mmsi']; | |
| 565 | + } | |
| 566 | +		    if (isset($ais_data['speed'])) { | |
| 567 | + $data['speed'] = $ais_data['speed']; | |
| 568 | + } | |
| 569 | +		    if (isset($ais_data['heading'])) { | |
| 570 | + $data['heading'] = $ais_data['heading']; | |
| 571 | + } | |
| 572 | +		    if (isset($ais_data['latitude'])) { | |
| 573 | + $data['latitude'] = $ais_data['latitude']; | |
| 574 | + } | |
| 575 | +		    if (isset($ais_data['longitude'])) { | |
| 576 | + $data['longitude'] = $ais_data['longitude']; | |
| 577 | + } | |
| 578 | +		    if (isset($ais_data['status'])) { | |
| 579 | + $data['status'] = $ais_data['status']; | |
| 580 | + } | |
| 581 | +		    if (isset($ais_data['type'])) { | |
| 582 | + $data['type'] = $ais_data['type']; | |
| 583 | + } | |
| 584 | +		    if (isset($ais_data['imo'])) { | |
| 585 | + $data['imo'] = $ais_data['imo']; | |
| 586 | + } | |
| 587 | +		    if (isset($ais_data['callsign'])) { | |
| 588 | + $data['callsign'] = $ais_data['callsign']; | |
| 589 | + } | |
| 430 | 590 |  		    if (isset($ais_data['timestamp'])) { | 
| 431 | 591 |  			$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 432 | 592 |  			if (!isset($last_exec[$id]['timestamp']) || $ais_data['timestamp'] >= $last_exec[$id]['timestamp']) { | 
| @@ -440,8 +600,12 @@ discard block | ||
| 440 | 600 | $data['format_source'] = 'aisnmeatxt'; | 
| 441 | 601 | $data['id_source'] = $id_source; | 
| 442 | 602 | //print_r($data); | 
| 443 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 444 | - if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 603 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 604 | + $data['noarchive'] = true; | |
| 605 | + } | |
| 606 | +		    if ($add && isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { | |
| 607 | + $MI->add($data); | |
| 608 | + } | |
| 445 | 609 | unset($data); | 
| 446 | 610 | } | 
| 447 | 611 | } | 
| @@ -461,20 +625,48 @@ discard block | ||
| 461 | 625 |  			    if ($line != '') { | 
| 462 | 626 | $ais_data = $AIS->parse_line(trim($line)); | 
| 463 | 627 | $data = array(); | 
| 464 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 465 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 466 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 467 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 468 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 469 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 470 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 471 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 472 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 473 | - if (isset($ais_data['typeid'])) $data['type_id'] = $ais_data['typeid']; | |
| 474 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 475 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 476 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 477 | -				if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 628 | +				if (isset($ais_data['ident'])) { | |
| 629 | + $data['ident'] = $ais_data['ident']; | |
| 630 | + } | |
| 631 | +				if (isset($ais_data['mmsi'])) { | |
| 632 | + $data['mmsi'] = $ais_data['mmsi']; | |
| 633 | + } | |
| 634 | +				if (isset($ais_data['speed'])) { | |
| 635 | + $data['speed'] = $ais_data['speed']; | |
| 636 | + } | |
| 637 | +				if (isset($ais_data['heading'])) { | |
| 638 | + $data['heading'] = $ais_data['heading']; | |
| 639 | + } | |
| 640 | +				if (isset($ais_data['latitude'])) { | |
| 641 | + $data['latitude'] = $ais_data['latitude']; | |
| 642 | + } | |
| 643 | +				if (isset($ais_data['longitude'])) { | |
| 644 | + $data['longitude'] = $ais_data['longitude']; | |
| 645 | + } | |
| 646 | +				if (isset($ais_data['status'])) { | |
| 647 | + $data['status'] = $ais_data['status']; | |
| 648 | + } | |
| 649 | +				if (isset($ais_data['statusid'])) { | |
| 650 | + $data['status_id'] = $ais_data['statusid']; | |
| 651 | + } | |
| 652 | +				if (isset($ais_data['type'])) { | |
| 653 | + $data['type'] = $ais_data['type']; | |
| 654 | + } | |
| 655 | +				if (isset($ais_data['typeid'])) { | |
| 656 | + $data['type_id'] = $ais_data['typeid']; | |
| 657 | + } | |
| 658 | +				if (isset($ais_data['imo'])) { | |
| 659 | + $data['imo'] = $ais_data['imo']; | |
| 660 | + } | |
| 661 | +				if (isset($ais_data['callsign'])) { | |
| 662 | + $data['callsign'] = $ais_data['callsign']; | |
| 663 | + } | |
| 664 | +				if (isset($ais_data['destination'])) { | |
| 665 | + $data['arrival_code'] = $ais_data['destination']; | |
| 666 | + } | |
| 667 | +				if (isset($ais_data['eta_ts'])) { | |
| 668 | +					$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 669 | + } | |
| 478 | 670 |  				if (isset($ais_data['timestamp'])) { | 
| 479 | 671 |  				    $data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| 480 | 672 |  				} else { | 
| @@ -482,18 +674,27 @@ discard block | ||
| 482 | 674 | } | 
| 483 | 675 | $data['format_source'] = 'aisnmeahttp'; | 
| 484 | 676 | $data['id_source'] = $id_source; | 
| 485 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 486 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 677 | +				if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 678 | + $data['noarchive'] = true; | |
| 679 | + } | |
| 680 | +				if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { | |
| 681 | + $MI->add($data); | |
| 682 | + } | |
| 487 | 683 | unset($data); | 
| 488 | 684 | } | 
| 489 | 685 | } | 
| 490 | 686 | } | 
| 491 | 687 |  		} else { | 
| 492 | 688 | $format = $value['format']; | 
| 493 | - if (isset($tt[$format])) $tt[$format]++; | |
| 494 | - else $tt[$format] = 0; | |
| 689 | +		    if (isset($tt[$format])) { | |
| 690 | + $tt[$format]++; | |
| 691 | +		    } else { | |
| 692 | + $tt[$format] = 0; | |
| 693 | + } | |
| 495 | 694 |  		    if ($tt[$format] > 30) { | 
| 496 | - if ($globalDebug) echo 'Reconnect...'."\n"; | |
| 695 | +			if ($globalDebug) { | |
| 696 | + echo 'Reconnect...'."\n"; | |
| 697 | + } | |
| 497 | 698 | sleep(2); | 
| 498 | 699 | $sourceeen[] = $value; | 
| 499 | 700 | connect_all($sourceeen); | 
| @@ -523,7 +724,9 @@ discard block | ||
| 523 | 724 |  			    $data['datetime'] = date('Y-m-d H:i:s',$line['T']); | 
| 524 | 725 | $data['format_source'] = 'myshiptracking'; | 
| 525 | 726 | $data['id_source'] = $id_source; | 
| 526 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 727 | +			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 728 | + $data['noarchive'] = true; | |
| 729 | + } | |
| 527 | 730 | $MI->add($data); | 
| 528 | 731 | unset($data); | 
| 529 | 732 | } | 
| @@ -543,7 +746,9 @@ discard block | ||
| 543 | 746 | $data['callsign'] = $line['callsign']; | 
| 544 | 747 | $data['mmsi'] = $line['mmsi']; | 
| 545 | 748 | $data['speed'] = $line['sog']; | 
| 546 | - if ($line['heading'] != '511') $data['heading'] = $line['heading']; | |
| 749 | +			    if ($line['heading'] != '511') { | |
| 750 | + $data['heading'] = $line['heading']; | |
| 751 | + } | |
| 547 | 752 | $data['latitude'] = $line['latitude']; | 
| 548 | 753 | $data['longitude'] = $line['longitude']; | 
| 549 | 754 | $data['type_id'] = $line['shiptype']; | 
| @@ -551,7 +756,9 @@ discard block | ||
| 551 | 756 | $data['datetime'] = $line['time']; | 
| 552 | 757 | $data['format_source'] = 'boatbeaconapp'; | 
| 553 | 758 | $data['id_source'] = $id_source; | 
| 554 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 759 | +			    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 760 | + $data['noarchive'] = true; | |
| 761 | + } | |
| 555 | 762 | $MI->add($data); | 
| 556 | 763 | unset($data); | 
| 557 | 764 | } | 
| @@ -567,22 +774,44 @@ discard block | ||
| 567 | 774 |  		if (isset($all_data['features'][0]['id'])) { | 
| 568 | 775 |  		    foreach ($all_data['features'] as $line) { | 
| 569 | 776 | $data = array(); | 
| 570 | - if (isset($line['properties']['name'])) $data['ident'] = $line['properties']['name']; | |
| 571 | - if (isset($line['properties']['callsign'])) $data['callsign'] = $line['properties']['callsign']; | |
| 572 | - if (isset($line['properties']['mmsi'])) $data['mmsi'] = $line['properties']['mmsi']; | |
| 573 | - if (isset($line['properties']['imo'])) $data['mmsi'] = $line['properties']['imo']; | |
| 574 | - if (isset($line['properties']['speed'])) $data['speed'] = $line['properties']['speed']; | |
| 575 | - if (isset($line['properties']['heading'])) $data['heading'] = $line['properties']['heading']; | |
| 777 | +			if (isset($line['properties']['name'])) { | |
| 778 | + $data['ident'] = $line['properties']['name']; | |
| 779 | + } | |
| 780 | +			if (isset($line['properties']['callsign'])) { | |
| 781 | + $data['callsign'] = $line['properties']['callsign']; | |
| 782 | + } | |
| 783 | +			if (isset($line['properties']['mmsi'])) { | |
| 784 | + $data['mmsi'] = $line['properties']['mmsi']; | |
| 785 | + } | |
| 786 | +			if (isset($line['properties']['imo'])) { | |
| 787 | + $data['mmsi'] = $line['properties']['imo']; | |
| 788 | + } | |
| 789 | +			if (isset($line['properties']['speed'])) { | |
| 790 | + $data['speed'] = $line['properties']['speed']; | |
| 791 | + } | |
| 792 | +			if (isset($line['properties']['heading'])) { | |
| 793 | + $data['heading'] = $line['properties']['heading']; | |
| 794 | + } | |
| 576 | 795 | $data['latitude'] = $line['geometry']['coordinates'][1]; | 
| 577 | 796 | $data['longitude'] = $line['geometry']['coordinates'][0]; | 
| 578 | - if (isset($line['properties']['vesselType'])) $data['type'] = $line['properties']['vesselType']; | |
| 579 | - if (isset($line['properties']['destination'])) $data['arrival_code'] = $line['properties']['destination']; | |
| 580 | - if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') $data['arrival_date'] = $line['properties']['eta']; | |
| 797 | +			if (isset($line['properties']['vesselType'])) { | |
| 798 | + $data['type'] = $line['properties']['vesselType']; | |
| 799 | + } | |
| 800 | +			if (isset($line['properties']['destination'])) { | |
| 801 | + $data['arrival_code'] = $line['properties']['destination']; | |
| 802 | + } | |
| 803 | +			if (isset($line['properties']['eta']) && $line['properties']['eta'] != '') { | |
| 804 | + $data['arrival_date'] = $line['properties']['eta']; | |
| 805 | + } | |
| 581 | 806 | $data['format_source'] = 'boatnerd'; | 
| 582 | 807 | $data['id_source'] = $id_source; | 
| 583 | 808 |  			$data['datetime'] = date('Y-m-d H:i:s'); | 
| 584 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 585 | - if ($line['properties']['vesselType'] != 'Navigation Aid') $MI->add($data); | |
| 809 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 810 | + $data['noarchive'] = true; | |
| 811 | + } | |
| 812 | +			if ($line['properties']['vesselType'] != 'Navigation Aid') { | |
| 813 | + $MI->add($data); | |
| 814 | + } | |
| 586 | 815 | unset($data); | 
| 587 | 816 | } | 
| 588 | 817 | } | 
| @@ -593,7 +822,9 @@ discard block | ||
| 593 | 822 | echo 'download...'; | 
| 594 | 823 | $buffer = $Common->getData($value['host'],'post',$value['post'],'','','','','ShipPlotter'); | 
| 595 | 824 | echo 'done !'."\n"; | 
| 596 | - if ($buffer != '') $reset = 0; | |
| 825 | +	    if ($buffer != '') { | |
| 826 | + $reset = 0; | |
| 827 | + } | |
| 597 | 828 |      	    $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'\n',$buffer)); | 
| 598 | 829 |  	    $buffer = explode('\n',$buffer); | 
| 599 | 830 |  	    foreach ($buffer as $line) { | 
| @@ -618,7 +849,9 @@ discard block | ||
| 618 | 849 | //$data['etaTime'] = substr($line,135,5); | 
| 619 | 850 | $data['format_source'] = 'shipplotter'; | 
| 620 | 851 | $data['id_source'] = $id_source; | 
| 621 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 852 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 853 | + $data['noarchive'] = true; | |
| 854 | + } | |
| 622 | 855 | //print_r($data); | 
| 623 | 856 | echo 'Add...'."\n"; | 
| 624 | 857 | $MI->add($data); | 
| @@ -638,16 +871,28 @@ discard block | ||
| 638 | 871 |      		    $line = explode(':', $line); | 
| 639 | 872 |      		    if (count($line) > 30 && $line[0] != 'callsign') { | 
| 640 | 873 | $data = array(); | 
| 641 | - if (isset($line[37]) && $line[37] != '') $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | |
| 642 | - else $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | |
| 874 | +			if (isset($line[37]) && $line[37] != '') { | |
| 875 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0].'-'.$line[37]; | |
| 876 | +			} else { | |
| 877 | + $data['id'] = $value['format'].'-'.$line[1].'-'.$line[0]; | |
| 878 | + } | |
| 643 | 879 | $data['pilot_id'] = $line[1]; | 
| 644 | 880 | $data['pilot_name'] = $line[2]; | 
| 645 | 881 | $data['hex'] = str_pad(dechex($Common->str2int($line[1])),6,'000000',STR_PAD_LEFT); | 
| 646 | 882 | $data['ident'] = $line[0]; // ident | 
| 647 | - if ($line[7] != '' && $line[7] != 0) $data['altitude'] = $line[7]; // altitude | |
| 883 | +			if ($line[7] != '' && $line[7] != 0) { | |
| 884 | + $data['altitude'] = $line[7]; | |
| 885 | + } | |
| 886 | + // altitude | |
| 648 | 887 | $data['speed'] = $line[8]; // speed | 
| 649 | - if (isset($line[45])) $data['heading'] = $line[45]; // heading | |
| 650 | - elseif (isset($line[38])) $data['heading'] = $line[38]; // heading | |
| 888 | +			if (isset($line[45])) { | |
| 889 | + $data['heading'] = $line[45]; | |
| 890 | + } | |
| 891 | + // heading | |
| 892 | +			elseif (isset($line[38])) { | |
| 893 | + $data['heading'] = $line[38]; | |
| 894 | + } | |
| 895 | + // heading | |
| 651 | 896 | $data['latitude'] = $line[5]; // lat | 
| 652 | 897 | $data['longitude'] = $line[6]; // long | 
| 653 | 898 | $data['verticalrate'] = ''; // vertical rate | 
| @@ -663,7 +908,9 @@ discard block | ||
| 663 | 908 | $data['frequency'] = $line[4]; | 
| 664 | 909 | $data['type'] = $line[18]; | 
| 665 | 910 | $data['range'] = $line[19]; | 
| 666 | - if (isset($line[35])) $data['info'] = $line[35]; | |
| 911 | +			if (isset($line[35])) { | |
| 912 | + $data['info'] = $line[35]; | |
| 913 | + } | |
| 667 | 914 | $data['id_source'] = $id_source; | 
| 668 | 915 | //$data['arrival_airport_time'] = ; | 
| 669 | 916 |  	    		if ($line[9] != '') { | 
| @@ -677,27 +924,47 @@ discard block | ||
| 677 | 924 | elseif ($value == 'vatsimtxt') $data['format_source'] = 'vatsimtxt'; | 
| 678 | 925 | */ | 
| 679 | 926 | $data['format_source'] = $value['format']; | 
| 680 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 681 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 682 | - if ($line[3] == 'PILOT') $SI->add($data); | |
| 683 | -			elseif ($line[3] == 'ATC') { | |
| 927 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 928 | + $data['noarchive'] = true; | |
| 929 | + } | |
| 930 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 931 | + $data['source_name'] = $value['name']; | |
| 932 | + } | |
| 933 | +    			if ($line[3] == 'PILOT') { | |
| 934 | + $SI->add($data); | |
| 935 | +    			} elseif ($line[3] == 'ATC') { | |
| 684 | 936 | //print_r($data); | 
| 685 | 937 |  				$data['info'] = str_replace('^§','<br />',$data['info']); | 
| 686 | 938 |  				$data['info'] = str_replace('&sect;','',$data['info']); | 
| 687 | 939 | $typec = substr($data['ident'],-3); | 
| 688 | - if ($typec == 'APP') $data['type'] = 'Approach'; | |
| 689 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; | |
| 690 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; | |
| 691 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; | |
| 692 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; | |
| 693 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; | |
| 694 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; | |
| 695 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; | |
| 696 | - elseif ($data['type'] == '') $data['type'] = 'Observer'; | |
| 697 | - if (!isset($data['source_name'])) $data['source_name'] = ''; | |
| 940 | +				if ($typec == 'APP') { | |
| 941 | + $data['type'] = 'Approach'; | |
| 942 | +				} elseif ($typec == 'TWR') { | |
| 943 | + $data['type'] = 'Tower'; | |
| 944 | +				} elseif ($typec == 'OBS') { | |
| 945 | + $data['type'] = 'Observer'; | |
| 946 | +				} elseif ($typec == 'GND') { | |
| 947 | + $data['type'] = 'Ground'; | |
| 948 | +				} elseif ($typec == 'DEL') { | |
| 949 | + $data['type'] = 'Delivery'; | |
| 950 | +				} elseif ($typec == 'DEP') { | |
| 951 | + $data['type'] = 'Departure'; | |
| 952 | +				} elseif ($typec == 'FSS') { | |
| 953 | + $data['type'] = 'Flight Service Station'; | |
| 954 | +				} elseif ($typec == 'CTR') { | |
| 955 | + $data['type'] = 'Control Radar or Centre'; | |
| 956 | +				} elseif ($data['type'] == '') { | |
| 957 | + $data['type'] = 'Observer'; | |
| 958 | + } | |
| 959 | +				if (!isset($data['source_name'])) { | |
| 960 | + $data['source_name'] = ''; | |
| 961 | + } | |
| 698 | 962 |  				if (isset($ATC)) { | 
| 699 | - 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']); | |
| 700 | - 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']); | |
| 963 | +					if (count($ATC->getByIdent($data['ident'],$data['format_source'])) > 0) { | |
| 964 | + 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']); | |
| 965 | +					} else { | |
| 966 | + 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']); | |
| 967 | + } | |
| 701 | 968 | } | 
| 702 | 969 | } | 
| 703 | 970 | unset($data); | 
| @@ -719,13 +986,19 @@ discard block | ||
| 719 | 986 |  			$data['datetime'] = date('Y-m-d H:i:s',strtotime((string)$line['entryTime'].' BST')); | 
| 720 | 987 | $data['latitude'] = (float)$line['pktLatitude']; | 
| 721 | 988 | $data['longitude'] = (float)$line['pktLongitude']; | 
| 722 | - if ((float)$line['pktTrack'] != 0) $data['heading'] = (float)$line['pktTrack']; | |
| 723 | - if ((int)$line['pktSpeed'] != 0) $data['speed'] = (int)$line['pktSpeed']; | |
| 989 | +			if ((float)$line['pktTrack'] != 0) { | |
| 990 | + $data['heading'] = (float)$line['pktTrack']; | |
| 991 | + } | |
| 992 | +			if ((int)$line['pktSpeed'] != 0) { | |
| 993 | + $data['speed'] = (int)$line['pktSpeed']; | |
| 994 | + } | |
| 724 | 995 | $data['altitude'] = (int)$line['pktAltitude']; | 
| 725 | 996 | $data['pilot_id'] = (int)$line['pktPilotID']; | 
| 726 | 997 | $data['aircraft_icao'] = 'PARAGLIDER'; | 
| 727 | 998 |  			$pilot_data = explode(',',$Common->getData('http://www.airwhere.co.uk/pilotdetails.php?pilot='.$data['pilot_id'])); | 
| 728 | - if (isset($pilot_data[4])) $data['pilot_name'] = $pilot_data[4]; | |
| 999 | +			if (isset($pilot_data[4])) { | |
| 1000 | + $data['pilot_name'] = $pilot_data[4]; | |
| 1001 | + } | |
| 729 | 1002 | $data['format_source'] = $value['format']; | 
| 730 | 1003 | $SI->add($data); | 
| 731 | 1004 | unset($data); | 
| @@ -761,27 +1034,61 @@ discard block | ||
| 761 | 1034 |  		foreach ($all_data['acList'] as $line) { | 
| 762 | 1035 | $data = array(); | 
| 763 | 1036 | $data['hex'] = $line['Icao']; // hex | 
| 764 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 765 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 766 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 767 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 768 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 769 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 1037 | +		    if (isset($line['Call'])) { | |
| 1038 | + $data['ident'] = $line['Call']; | |
| 1039 | + } | |
| 1040 | + // ident | |
| 1041 | +		    if (isset($line['Alt'])) { | |
| 1042 | + $data['altitude'] = $line['Alt']; | |
| 1043 | + } | |
| 1044 | + // altitude | |
| 1045 | +		    if (isset($line['Spd'])) { | |
| 1046 | + $data['speed'] = $line['Spd']; | |
| 1047 | + } | |
| 1048 | + // speed | |
| 1049 | +		    if (isset($line['Trak'])) { | |
| 1050 | + $data['heading'] = $line['Trak']; | |
| 1051 | + } | |
| 1052 | + // heading | |
| 1053 | +		    if (isset($line['Lat'])) { | |
| 1054 | + $data['latitude'] = $line['Lat']; | |
| 1055 | + } | |
| 1056 | + // lat | |
| 1057 | +		    if (isset($line['Long'])) { | |
| 1058 | + $data['longitude'] = $line['Long']; | |
| 1059 | + } | |
| 1060 | + // long | |
| 770 | 1061 | //$data['verticalrate'] = $line['']; // verticale rate | 
| 771 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 1062 | +		    if (isset($line['Sqk'])) { | |
| 1063 | + $data['squawk'] = $line['Sqk']; | |
| 1064 | + } | |
| 1065 | + // squawk | |
| 772 | 1066 | $data['emergency'] = ''; // emergency | 
| 773 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 1067 | +		    if (isset($line['Reg'])) { | |
| 1068 | + $data['registration'] = $line['Reg']; | |
| 1069 | + } | |
| 774 | 1070 | |
| 775 | -		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 776 | -		    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1071 | +		    if (isset($line['PosTime'])) { | |
| 1072 | +		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1073 | +		    } else { | |
| 1074 | +		    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1075 | + } | |
| 777 | 1076 | |
| 778 | 1077 |  		    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| 779 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 1078 | +		    if (isset($line['Type'])) { | |
| 1079 | + $data['aircraft_icao'] = $line['Type']; | |
| 1080 | + } | |
| 780 | 1081 | $data['format_source'] = 'aircraftlistjson'; | 
| 781 | 1082 | $data['id_source'] = $id_source; | 
| 782 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 783 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 784 | - if (isset($data['latitude'])) $SI->add($data); | |
| 1083 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1084 | + $data['source_name'] = $value['name']; | |
| 1085 | + } | |
| 1086 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1087 | + $data['noarchive'] = true; | |
| 1088 | + } | |
| 1089 | +		    if (isset($data['latitude'])) { | |
| 1090 | + $SI->add($data); | |
| 1091 | + } | |
| 785 | 1092 | unset($data); | 
| 786 | 1093 | } | 
| 787 | 1094 |  	    } elseif (is_array($all_data)) { | 
| @@ -798,12 +1105,19 @@ discard block | ||
| 798 | 1105 | $data['verticalrate'] = $line['vrt']; // verticale rate | 
| 799 | 1106 | $data['squawk'] = $line['squawk']; // squawk | 
| 800 | 1107 | $data['emergency'] = ''; // emergency | 
| 801 | -		    if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 802 | -		    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1108 | +		    if (isset($line['PosTime'])) { | |
| 1109 | +		    	$data['datetime'] = date('Y-m-d H:i:s',round($line['PosTime']/1000)); | |
| 1110 | +		    } else { | |
| 1111 | +		    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1112 | + } | |
| 803 | 1113 | $data['format_source'] = 'aircraftlistjson'; | 
| 804 | 1114 | $data['id_source'] = $id_source; | 
| 805 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 806 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1115 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1116 | + $data['noarchive'] = true; | |
| 1117 | + } | |
| 1118 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1119 | + $data['source_name'] = $value['name']; | |
| 1120 | + } | |
| 807 | 1121 | $SI->add($data); | 
| 808 | 1122 | unset($data); | 
| 809 | 1123 | } | 
| @@ -839,8 +1153,12 @@ discard block | ||
| 839 | 1153 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line[9]); | 
| 840 | 1154 | $data['format_source'] = 'planeupdatefaa'; | 
| 841 | 1155 | $data['id_source'] = $id_source; | 
| 842 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 843 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1156 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1157 | + $data['noarchive'] = true; | |
| 1158 | + } | |
| 1159 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1160 | + $data['source_name'] = $value['name']; | |
| 1161 | + } | |
| 844 | 1162 | $SI->add($data); | 
| 845 | 1163 | unset($data); | 
| 846 | 1164 | } | 
| @@ -869,7 +1187,9 @@ discard block | ||
| 869 | 1187 |  		    $data['datetime'] = date('Y-m-d H:i:s',$line[3]); | 
| 870 | 1188 | $data['format_source'] = 'opensky'; | 
| 871 | 1189 | $data['id_source'] = $id_source; | 
| 872 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1190 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1191 | + $data['noarchive'] = true; | |
| 1192 | + } | |
| 873 | 1193 | $SI->add($data); | 
| 874 | 1194 | unset($data); | 
| 875 | 1195 | } | 
| @@ -881,7 +1201,9 @@ discard block | ||
| 881 | 1201 | //$buffer = $Common->getData($hosts[$id]); | 
| 882 | 1202 | $buffer = $Common->getData($value['host']); | 
| 883 | 1203 | $all_data = json_decode($buffer,true); | 
| 884 | - if (!empty($all_data)) $reset = 0; | |
| 1204 | +	    if (!empty($all_data)) { | |
| 1205 | + $reset = 0; | |
| 1206 | + } | |
| 885 | 1207 |  	    foreach ($all_data as $key => $line) { | 
| 886 | 1208 |  		if ($key != 'full_count' && $key != 'version' && $key != 'stats') { | 
| 887 | 1209 | $data = array(); | 
| @@ -902,8 +1224,12 @@ discard block | ||
| 902 | 1224 |  		    $data['datetime'] = date('Y-m-d H:i:s'); //$line[10] | 
| 903 | 1225 | $data['format_source'] = 'fr24json'; | 
| 904 | 1226 | $data['id_source'] = $id_source; | 
| 905 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 906 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1227 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1228 | + $data['noarchive'] = true; | |
| 1229 | + } | |
| 1230 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1231 | + $data['source_name'] = $value['name']; | |
| 1232 | + } | |
| 907 | 1233 | $SI->add($data); | 
| 908 | 1234 | unset($data); | 
| 909 | 1235 | } | 
| @@ -927,24 +1253,42 @@ discard block | ||
| 927 | 1253 |  		    if (isset($line['inf'])) { | 
| 928 | 1254 | $data = array(); | 
| 929 | 1255 | $data['hex'] = $line['inf']['ia']; | 
| 930 | - if (isset($line['inf']['cs'])) $data['ident'] = $line['inf']['cs']; //$line[13] | |
| 1256 | +			if (isset($line['inf']['cs'])) { | |
| 1257 | + $data['ident'] = $line['inf']['cs']; | |
| 1258 | + } | |
| 1259 | + //$line[13] | |
| 931 | 1260 | $data['altitude'] = round($line['inf']['al']*3.28084); // altitude | 
| 932 | - if (isset($line['inf']['gs'])) $data['speed'] = round($line['inf']['gs']*0.539957); // speed | |
| 933 | - if (isset($line['inf']['tr'])) $data['heading'] = $line['inf']['tr']; // heading | |
| 1261 | +	    		if (isset($line['inf']['gs'])) { | |
| 1262 | + $data['speed'] = round($line['inf']['gs']*0.539957); | |
| 1263 | + } | |
| 1264 | + // speed | |
| 1265 | +	    		if (isset($line['inf']['tr'])) { | |
| 1266 | + $data['heading'] = $line['inf']['tr']; | |
| 1267 | + } | |
| 1268 | + // heading | |
| 934 | 1269 | $data['latitude'] = $line['pt'][0]; // lat | 
| 935 | 1270 | $data['longitude'] = $line['pt'][1]; // long | 
| 936 | 1271 | //if (isset($line['inf']['vs'])) $data['verticalrate'] = $line['inf']['vs']; // verticale rate | 
| 937 | - if (isset($line['inf']['sq'])) $data['squawk'] = $line['inf']['sq']; // squawk | |
| 1272 | +	    		if (isset($line['inf']['sq'])) { | |
| 1273 | + $data['squawk'] = $line['inf']['sq']; | |
| 1274 | + } | |
| 1275 | + // squawk | |
| 938 | 1276 | //$data['aircraft_icao'] = $line[8]; | 
| 939 | - if (isset($line['inf']['rc'])) $data['registration'] = $line['inf']['rc']; | |
| 1277 | +	    		if (isset($line['inf']['rc'])) { | |
| 1278 | + $data['registration'] = $line['inf']['rc']; | |
| 1279 | + } | |
| 940 | 1280 | //$data['departure_airport_iata'] = $line[11]; | 
| 941 | 1281 | //$data['arrival_airport_iata'] = $line[12]; | 
| 942 | 1282 | //$data['emergency'] = ''; // emergency | 
| 943 | 1283 |  			$data['datetime'] = date('Y-m-d H:i:s',$line['inf']['dt']); //$line[10] | 
| 944 | 1284 | $data['format_source'] = 'radarvirtueljson'; | 
| 945 | 1285 | $data['id_source'] = $id_source; | 
| 946 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 947 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1286 | +			if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1287 | + $data['noarchive'] = true; | |
| 1288 | + } | |
| 1289 | +			if (isset($value['name']) && $value['name'] != '') { | |
| 1290 | + $data['source_name'] = $value['name']; | |
| 1291 | + } | |
| 948 | 1292 | $SI->add($data); | 
| 949 | 1293 | unset($data); | 
| 950 | 1294 | } | 
| @@ -965,30 +1309,65 @@ discard block | ||
| 965 | 1309 | $data['id'] = $line['id']; | 
| 966 | 1310 | $data['hex'] = substr(str_pad(dechex($line['id']),6,'000000',STR_PAD_LEFT),0,6); | 
| 967 | 1311 | $data['ident'] = $line['callsign']; // ident | 
| 968 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; // pilot id | |
| 969 | - if (isset($line['name'])) $data['pilot_name'] = $line['name']; // pilot name | |
| 970 | - if (isset($line['alt'])) $data['altitude'] = $line['alt']; // altitude | |
| 971 | - if (isset($line['gs'])) $data['speed'] = $line['gs']; // speed | |
| 972 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; // heading | |
| 973 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1312 | +		    if (isset($line['pilotid'])) { | |
| 1313 | + $data['pilot_id'] = $line['pilotid']; | |
| 1314 | + } | |
| 1315 | + // pilot id | |
| 1316 | +		    if (isset($line['name'])) { | |
| 1317 | + $data['pilot_name'] = $line['name']; | |
| 1318 | + } | |
| 1319 | + // pilot name | |
| 1320 | +		    if (isset($line['alt'])) { | |
| 1321 | + $data['altitude'] = $line['alt']; | |
| 1322 | + } | |
| 1323 | + // altitude | |
| 1324 | +		    if (isset($line['gs'])) { | |
| 1325 | + $data['speed'] = $line['gs']; | |
| 1326 | + } | |
| 1327 | + // speed | |
| 1328 | +		    if (isset($line['heading'])) { | |
| 1329 | + $data['heading'] = $line['heading']; | |
| 1330 | + } | |
| 1331 | + // heading | |
| 1332 | +		    if (isset($line['route'])) { | |
| 1333 | + $data['waypoints'] = $line['route']; | |
| 1334 | + } | |
| 1335 | + // route | |
| 974 | 1336 | $data['latitude'] = $line['lat']; // lat | 
| 975 | 1337 | $data['longitude'] = $line['lon']; // long | 
| 976 | 1338 | //$data['verticalrate'] = $line['vrt']; // verticale rate | 
| 977 | 1339 | //$data['squawk'] = $line['squawk']; // squawk | 
| 978 | 1340 | //$data['emergency'] = ''; // emergency | 
| 979 | - if (isset($line['depicao'])) $data['departure_airport_icao'] = $line['depicao']; | |
| 980 | - if (isset($line['deptime'])) $data['departure_airport_time'] = $line['deptime']; | |
| 981 | - if (isset($line['arricao'])) $data['arrival_airport_icao'] = $line['arricao']; | |
| 1341 | +		    if (isset($line['depicao'])) { | |
| 1342 | + $data['departure_airport_icao'] = $line['depicao']; | |
| 1343 | + } | |
| 1344 | +		    if (isset($line['deptime'])) { | |
| 1345 | + $data['departure_airport_time'] = $line['deptime']; | |
| 1346 | + } | |
| 1347 | +		    if (isset($line['arricao'])) { | |
| 1348 | + $data['arrival_airport_icao'] = $line['arricao']; | |
| 1349 | + } | |
| 982 | 1350 | //$data['arrival_airport_time'] = $line['arrtime']; | 
| 983 | - if (isset($line['aircraft'])) $data['aircraft_icao'] = $line['aircraft']; | |
| 984 | - if (isset($line['transponder'])) $data['squawk'] = $line['transponder']; | |
| 985 | - if (isset($line['atis'])) $data['info'] = $line['atis']; | |
| 986 | - else $data['info'] = ''; | |
| 1351 | +		    if (isset($line['aircraft'])) { | |
| 1352 | + $data['aircraft_icao'] = $line['aircraft']; | |
| 1353 | + } | |
| 1354 | +		    if (isset($line['transponder'])) { | |
| 1355 | + $data['squawk'] = $line['transponder']; | |
| 1356 | + } | |
| 1357 | +		    if (isset($line['atis'])) { | |
| 1358 | + $data['info'] = $line['atis']; | |
| 1359 | +		    } else { | |
| 1360 | + $data['info'] = ''; | |
| 1361 | + } | |
| 987 | 1362 | $data['format_source'] = 'pireps'; | 
| 988 | 1363 | $data['id_source'] = $id_source; | 
| 989 | 1364 |  		    $data['datetime'] = date('Y-m-d H:i:s'); | 
| 990 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 991 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1365 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1366 | + $data['noarchive'] = true; | |
| 1367 | + } | |
| 1368 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1369 | + $data['source_name'] = $value['name']; | |
| 1370 | + } | |
| 992 | 1371 |  		    if ($line['icon'] == 'plane') { | 
| 993 | 1372 | $SI->add($data); | 
| 994 | 1373 | // print_r($data); | 
| @@ -997,16 +1376,28 @@ discard block | ||
| 997 | 1376 |  			$data['info'] = str_replace('&sect;','',$data['info']); | 
| 998 | 1377 | $typec = substr($data['ident'],-3); | 
| 999 | 1378 | $data['type'] = ''; | 
| 1000 | - if ($typec == 'APP') $data['type'] = 'Approach'; | |
| 1001 | - elseif ($typec == 'TWR') $data['type'] = 'Tower'; | |
| 1002 | - elseif ($typec == 'OBS') $data['type'] = 'Observer'; | |
| 1003 | - elseif ($typec == 'GND') $data['type'] = 'Ground'; | |
| 1004 | - elseif ($typec == 'DEL') $data['type'] = 'Delivery'; | |
| 1005 | - elseif ($typec == 'DEP') $data['type'] = 'Departure'; | |
| 1006 | - elseif ($typec == 'FSS') $data['type'] = 'Flight Service Station'; | |
| 1007 | - elseif ($typec == 'CTR') $data['type'] = 'Control Radar or Centre'; | |
| 1008 | - else $data['type'] = 'Observer'; | |
| 1009 | - 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']); | |
| 1379 | +			if ($typec == 'APP') { | |
| 1380 | + $data['type'] = 'Approach'; | |
| 1381 | +			} elseif ($typec == 'TWR') { | |
| 1382 | + $data['type'] = 'Tower'; | |
| 1383 | +			} elseif ($typec == 'OBS') { | |
| 1384 | + $data['type'] = 'Observer'; | |
| 1385 | +			} elseif ($typec == 'GND') { | |
| 1386 | + $data['type'] = 'Ground'; | |
| 1387 | +			} elseif ($typec == 'DEL') { | |
| 1388 | + $data['type'] = 'Delivery'; | |
| 1389 | +			} elseif ($typec == 'DEP') { | |
| 1390 | + $data['type'] = 'Departure'; | |
| 1391 | +			} elseif ($typec == 'FSS') { | |
| 1392 | + $data['type'] = 'Flight Service Station'; | |
| 1393 | +			} elseif ($typec == 'CTR') { | |
| 1394 | + $data['type'] = 'Control Radar or Centre'; | |
| 1395 | +			} else { | |
| 1396 | + $data['type'] = 'Observer'; | |
| 1397 | + } | |
| 1398 | +			if (isset($ATC)) { | |
| 1399 | + 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']); | |
| 1400 | + } | |
| 1010 | 1401 | } | 
| 1011 | 1402 | unset($data); | 
| 1012 | 1403 | } | 
| @@ -1016,7 +1407,9 @@ discard block | ||
| 1016 | 1407 |      	//} elseif ($value == 'phpvmacars' && (time() - $last_exec['phpvmacars'] > $globalMinFetch)) { | 
| 1017 | 1408 |      	} elseif ($value['format'] == 'phpvmacars' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 1018 | 1409 | //$buffer = $Common->getData($hosts[$id]); | 
| 1019 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1410 | +	    if ($globalDebug) { | |
| 1411 | + echo 'Get Data...'."\n"; | |
| 1412 | + } | |
| 1020 | 1413 | $buffer = $Common->getData($value['host']); | 
| 1021 | 1414 | $all_data = json_decode($buffer,true); | 
| 1022 | 1415 |  	    if ($buffer != '' && is_array($all_data)) { | 
| @@ -1024,10 +1417,16 @@ discard block | ||
| 1024 | 1417 |  		foreach ($all_data as $line) { | 
| 1025 | 1418 | $data = array(); | 
| 1026 | 1419 | //$data['id'] = $line['id']; // id not usable | 
| 1027 | - if (isset($line['pilotid'])) $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1420 | +	    	    if (isset($line['pilotid'])) { | |
| 1421 | + $data['id'] = $line['pilotid'].$line['flightnum']; | |
| 1422 | + } | |
| 1028 | 1423 | $data['hex'] = substr(str_pad(bin2hex($line['flightnum']),6,'000000',STR_PAD_LEFT),-6); // hex | 
| 1029 | - if (isset($line['pilotname'])) $data['pilot_name'] = $line['pilotname']; | |
| 1030 | - if (isset($line['pilotid'])) $data['pilot_id'] = $line['pilotid']; | |
| 1424 | +	    	    if (isset($line['pilotname'])) { | |
| 1425 | + $data['pilot_name'] = $line['pilotname']; | |
| 1426 | + } | |
| 1427 | +	    	    if (isset($line['pilotid'])) { | |
| 1428 | + $data['pilot_id'] = $line['pilotid']; | |
| 1429 | + } | |
| 1031 | 1430 | $data['ident'] = $line['flightnum']; // ident | 
| 1032 | 1431 | $data['altitude'] = $line['alt']; // altitude | 
| 1033 | 1432 | $data['speed'] = $line['gs']; // speed | 
| @@ -1045,28 +1444,44 @@ discard block | ||
| 1045 | 1444 | $data['arrival_airport_icao'] = $line['arricao']; | 
| 1046 | 1445 | $data['arrival_airport_time'] = $line['arrtime']; | 
| 1047 | 1446 | $data['registration'] = $line['aircraft']; | 
| 1048 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1049 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1447 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1448 | + $data['noarchive'] = true; | |
| 1449 | + } | |
| 1450 | +		    if (isset($line['route'])) { | |
| 1451 | + $data['waypoints'] = $line['route']; | |
| 1452 | + } | |
| 1453 | + // route | |
| 1050 | 1454 |  		    if (isset($line['aircraftname'])) { | 
| 1051 | 1455 | $line['aircraftname'] = strtoupper($line['aircraftname']); | 
| 1052 | 1456 |  			$line['aircraftname'] = str_replace('BOEING ','B',$line['aircraftname']); | 
| 1053 | 1457 |  	    		$aircraft_data = explode('-',$line['aircraftname']); | 
| 1054 | - if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1055 | - elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1056 | -	    		else { | |
| 1458 | +	    		if (isset($aircraft_data[1]) && strlen($aircraft_data[0]) >= 3 && strlen($aircraft_data[0]) <= 4) { | |
| 1459 | + $data['aircraft_icao'] = $aircraft_data[0]; | |
| 1460 | +	    		} elseif (isset($aircraft_data[1]) && strlen($aircraft_data[1]) >= 3 && strlen($aircraft_data[1]) <= 4) { | |
| 1461 | + $data['aircraft_icao'] = $aircraft_data[1]; | |
| 1462 | +	    		} else { | |
| 1057 | 1463 |  	    		    $aircraft_data = explode(' ',$line['aircraftname']); | 
| 1058 | -	    		    if (isset($aircraft_data[1])) $data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1059 | -	    		    else $data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1464 | +	    		    if (isset($aircraft_data[1])) { | |
| 1465 | +	    		    	$data['aircraft_icao'] = str_replace('-','',$aircraft_data[1]); | |
| 1466 | +	    		    } else { | |
| 1467 | +	    		    	$data['aircraft_icao'] = str_replace('-','',$line['aircraftname']); | |
| 1468 | + } | |
| 1060 | 1469 | } | 
| 1061 | 1470 | } | 
| 1062 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; | |
| 1471 | +    		    if (isset($line['route'])) { | |
| 1472 | + $data['waypoints'] = $line['route']; | |
| 1473 | + } | |
| 1063 | 1474 | $data['id_source'] = $id_source; | 
| 1064 | 1475 | $data['format_source'] = 'phpvmacars'; | 
| 1065 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1476 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1477 | + $data['source_name'] = $value['name']; | |
| 1478 | + } | |
| 1066 | 1479 | $SI->add($data); | 
| 1067 | 1480 | unset($data); | 
| 1068 | 1481 | } | 
| 1069 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 1482 | +		if ($globalDebug) { | |
| 1483 | + echo 'No more data...'."\n"; | |
| 1484 | + } | |
| 1070 | 1485 | unset($buffer); | 
| 1071 | 1486 | unset($all_data); | 
| 1072 | 1487 | } | 
| @@ -1074,7 +1489,9 @@ discard block | ||
| 1074 | 1489 | $last_exec[$id]['last'] = time(); | 
| 1075 | 1490 |      	} elseif ($value['format'] == 'vam' && (time() - $last_exec[$id]['last'] > $globalMinFetch)) { | 
| 1076 | 1491 | //$buffer = $Common->getData($hosts[$id]); | 
| 1077 | - if ($globalDebug) echo 'Get Data...'."\n"; | |
| 1492 | +	    if ($globalDebug) { | |
| 1493 | + echo 'Get Data...'."\n"; | |
| 1494 | + } | |
| 1078 | 1495 | $buffer = $Common->getData($value['host']); | 
| 1079 | 1496 | $all_data = json_decode($buffer,true); | 
| 1080 | 1497 |  	    if ($buffer != '' && is_array($all_data)) { | 
| @@ -1103,16 +1520,25 @@ discard block | ||
| 1103 | 1520 | $data['arrival_airport_icao'] = $line['arrival']; | 
| 1104 | 1521 | //$data['arrival_airport_time'] = $line['arrival_time']; | 
| 1105 | 1522 | //$data['registration'] = $line['aircraft']; | 
| 1106 | - if (isset($line['route'])) $data['waypoints'] = $line['route']; // route | |
| 1523 | +		    if (isset($line['route'])) { | |
| 1524 | + $data['waypoints'] = $line['route']; | |
| 1525 | + } | |
| 1526 | + // route | |
| 1107 | 1527 | $data['aircraft_icao'] = $line['plane_type']; | 
| 1108 | 1528 | $data['id_source'] = $id_source; | 
| 1109 | 1529 | $data['format_source'] = 'vam'; | 
| 1110 | - if (isset($value['noarchive']) && $value['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1111 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1530 | +		    if (isset($value['noarchive']) && $value['noarchive'] === TRUE) { | |
| 1531 | + $data['noarchive'] = true; | |
| 1532 | + } | |
| 1533 | +		    if (isset($value['name']) && $value['name'] != '') { | |
| 1534 | + $data['source_name'] = $value['name']; | |
| 1535 | + } | |
| 1112 | 1536 | $SI->add($data); | 
| 1113 | 1537 | unset($data); | 
| 1114 | 1538 | } | 
| 1115 | - if ($globalDebug) echo 'No more data...'."\n"; | |
| 1539 | +		if ($globalDebug) { | |
| 1540 | + echo 'No more data...'."\n"; | |
| 1541 | + } | |
| 1116 | 1542 | unset($buffer); | 
| 1117 | 1543 | unset($all_data); | 
| 1118 | 1544 | } | 
| @@ -1120,7 +1546,9 @@ discard block | ||
| 1120 | 1546 | $last_exec[$id]['last'] = time(); | 
| 1121 | 1547 |  	//} elseif ($value == 'sbs' || $value == 'tsv' || $value == 'raw' || $value == 'aprs' || $value == 'beast') { | 
| 1122 | 1548 |  	} 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') { | 
| 1123 | -	    if (function_exists('pcntl_fork')) pcntl_signal_dispatch(); | |
| 1549 | +	    if (function_exists('pcntl_fork')) { | |
| 1550 | + pcntl_signal_dispatch(); | |
| 1551 | + } | |
| 1124 | 1552 | //$last_exec[$id]['last'] = time(); | 
| 1125 | 1553 | |
| 1126 | 1554 | //$read = array( $sockets[$id] ); | 
| @@ -1128,7 +1556,9 @@ discard block | ||
| 1128 | 1556 | $write = NULL; | 
| 1129 | 1557 | $e = NULL; | 
| 1130 | 1558 | $n = socket_select($read, $write, $e, $timeout); | 
| 1131 | - if ($e != NULL) var_dump($e); | |
| 1559 | +	    if ($e != NULL) { | |
| 1560 | + var_dump($e); | |
| 1561 | + } | |
| 1132 | 1562 |  	    if ($n > 0) { | 
| 1133 | 1563 | $reset = 0; | 
| 1134 | 1564 |  		foreach ($read as $nb => $r) { | 
| @@ -1149,12 +1579,16 @@ discard block | ||
| 1149 | 1579 | //$SI::del(); | 
| 1150 | 1580 |  		    if ($format == 'vrstcp') { | 
| 1151 | 1581 |  			$buffer = explode('},{',$buffer); | 
| 1152 | -		    } else $buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1582 | +		    } else { | |
| 1583 | +		    	$buffer=trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$buffer)); | |
| 1584 | + } | |
| 1153 | 1585 | // SBS format is CSV format | 
| 1154 | 1586 |  		    if ($buffer !== FALSE && $buffer != '') { | 
| 1155 | 1587 | $tt[$format] = 0; | 
| 1156 | 1588 |  			if ($format == 'acarssbs3') { | 
| 1157 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1589 | +			    if ($globalDebug) { | |
| 1590 | + echo 'ACARS : '.$buffer."\n"; | |
| 1591 | + } | |
| 1158 | 1592 | $ACARS->add(trim($buffer)); | 
| 1159 | 1593 | $ACARS->deleteLiveAcarsData(); | 
| 1160 | 1594 |  			} elseif ($format == 'raw') { | 
| @@ -1163,30 +1597,70 @@ discard block | ||
| 1163 | 1597 |  			    if (is_array($data)) { | 
| 1164 | 1598 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1165 | 1599 | $data['format_source'] = 'raw'; | 
| 1166 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1167 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 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); | |
| 1600 | +				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 1601 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 1602 | + } | |
| 1603 | +				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 1604 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1605 | + } | |
| 1606 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1607 | + $data['noarchive'] = true; | |
| 1608 | + } | |
| 1609 | +				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 1610 | + $SI->add($data); | |
| 1611 | + } | |
| 1170 | 1612 | } | 
| 1171 | 1613 |  			} elseif ($format == 'ais') { | 
| 1172 | 1614 | $ais_data = $AIS->parse_line(trim($buffer)); | 
| 1173 | 1615 | $data = array(); | 
| 1174 | - if (isset($ais_data['ident'])) $data['ident'] = $ais_data['ident']; | |
| 1175 | - if (isset($ais_data['mmsi'])) $data['mmsi'] = $ais_data['mmsi']; | |
| 1176 | - if (isset($ais_data['speed'])) $data['speed'] = $ais_data['speed']; | |
| 1177 | - if (isset($ais_data['heading'])) $data['heading'] = $ais_data['heading']; | |
| 1178 | - if (isset($ais_data['latitude'])) $data['latitude'] = $ais_data['latitude']; | |
| 1179 | - if (isset($ais_data['longitude'])) $data['longitude'] = $ais_data['longitude']; | |
| 1180 | - if (isset($ais_data['status'])) $data['status'] = $ais_data['status']; | |
| 1181 | - if (isset($ais_data['statusid'])) $data['status_id'] = $ais_data['statusid']; | |
| 1182 | - if (isset($ais_data['type'])) $data['type'] = $ais_data['type']; | |
| 1183 | - if (isset($ais_data['imo'])) $data['imo'] = $ais_data['imo']; | |
| 1184 | - if (isset($ais_data['callsign'])) $data['callsign'] = $ais_data['callsign']; | |
| 1185 | - if (isset($ais_data['destination'])) $data['arrival_code'] = $ais_data['destination']; | |
| 1186 | -			    if (isset($ais_data['eta_ts'])) $data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1187 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1188 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1189 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1616 | +			    if (isset($ais_data['ident'])) { | |
| 1617 | + $data['ident'] = $ais_data['ident']; | |
| 1618 | + } | |
| 1619 | +			    if (isset($ais_data['mmsi'])) { | |
| 1620 | + $data['mmsi'] = $ais_data['mmsi']; | |
| 1621 | + } | |
| 1622 | +			    if (isset($ais_data['speed'])) { | |
| 1623 | + $data['speed'] = $ais_data['speed']; | |
| 1624 | + } | |
| 1625 | +			    if (isset($ais_data['heading'])) { | |
| 1626 | + $data['heading'] = $ais_data['heading']; | |
| 1627 | + } | |
| 1628 | +			    if (isset($ais_data['latitude'])) { | |
| 1629 | + $data['latitude'] = $ais_data['latitude']; | |
| 1630 | + } | |
| 1631 | +			    if (isset($ais_data['longitude'])) { | |
| 1632 | + $data['longitude'] = $ais_data['longitude']; | |
| 1633 | + } | |
| 1634 | +			    if (isset($ais_data['status'])) { | |
| 1635 | + $data['status'] = $ais_data['status']; | |
| 1636 | + } | |
| 1637 | +			    if (isset($ais_data['statusid'])) { | |
| 1638 | + $data['status_id'] = $ais_data['statusid']; | |
| 1639 | + } | |
| 1640 | +			    if (isset($ais_data['type'])) { | |
| 1641 | + $data['type'] = $ais_data['type']; | |
| 1642 | + } | |
| 1643 | +			    if (isset($ais_data['imo'])) { | |
| 1644 | + $data['imo'] = $ais_data['imo']; | |
| 1645 | + } | |
| 1646 | +			    if (isset($ais_data['callsign'])) { | |
| 1647 | + $data['callsign'] = $ais_data['callsign']; | |
| 1648 | + } | |
| 1649 | +			    if (isset($ais_data['destination'])) { | |
| 1650 | + $data['arrival_code'] = $ais_data['destination']; | |
| 1651 | + } | |
| 1652 | +			    if (isset($ais_data['eta_ts'])) { | |
| 1653 | +			    	$data['arrival_date'] = date('Y-m-d H:i:s',$ais_data['eta_ts']); | |
| 1654 | + } | |
| 1655 | +			    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1656 | + $data['noarchive'] = true; | |
| 1657 | + } | |
| 1658 | +			    if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 1659 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 1660 | + } | |
| 1661 | +			    if (isset($globalSources[$nb]['sourcestats'])) { | |
| 1662 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1663 | + } | |
| 1190 | 1664 | |
| 1191 | 1665 |  			    if (isset($ais_data['timestamp'])) { | 
| 1192 | 1666 |  				$data['datetime'] = date('Y-m-d H:i:s',$ais_data['timestamp']); | 
| @@ -1195,7 +1669,9 @@ discard block | ||
| 1195 | 1669 | } | 
| 1196 | 1670 | $data['format_source'] = 'aisnmea'; | 
| 1197 | 1671 | $data['id_source'] = $id_source; | 
| 1198 | - if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') $MI->add($data); | |
| 1672 | +			    if (isset($ais_data['mmsi_type']) && $ais_data['mmsi_type'] == 'Ship') { | |
| 1673 | + $MI->add($data); | |
| 1674 | + } | |
| 1199 | 1675 | unset($data); | 
| 1200 | 1676 |                          } elseif ($format == 'flightgearsp') { | 
| 1201 | 1677 | //echo $buffer."\n"; | 
| @@ -1213,12 +1689,18 @@ discard block | ||
| 1213 | 1689 | $data['speed'] = round($line[5]*1.94384); | 
| 1214 | 1690 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1215 | 1691 | $data['format_source'] = 'flightgearsp'; | 
| 1216 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1217 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1692 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1693 | + $data['noarchive'] = true; | |
| 1694 | + } | |
| 1695 | +				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 1696 | + $SI->add($data); | |
| 1697 | + } | |
| 1218 | 1698 | //$send = @ socket_send( $r , $data_aprs , strlen($data_aprs) , 0 ); | 
| 1219 | 1699 | } | 
| 1220 | 1700 |                          } elseif ($format == 'acars') { | 
| 1221 | - if ($globalDebug) echo 'ACARS : '.$buffer."\n"; | |
| 1701 | +                    	    if ($globalDebug) { | |
| 1702 | + echo 'ACARS : '.$buffer."\n"; | |
| 1703 | + } | |
| 1222 | 1704 | $ACARS->add(trim($buffer)); | 
| 1223 | 1705 | socket_sendto($r, "OK " . $buffer , 100 , 0 , $remote_ip , $remote_port); | 
| 1224 | 1706 | $ACARS->deleteLiveAcarsData(); | 
| @@ -1239,8 +1721,12 @@ discard block | ||
| 1239 | 1721 | $aircraft_type = $line[10]; | 
| 1240 | 1722 |  				    $aircraft_type = preg_split(':/:',$aircraft_type); | 
| 1241 | 1723 | $data['aircraft_name'] = substr(end($aircraft_type),0,-4); | 
| 1242 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1243 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1724 | +				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1725 | + $data['noarchive'] = true; | |
| 1726 | + } | |
| 1727 | +				    if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 1728 | + $SI->add($data); | |
| 1729 | + } | |
| 1244 | 1730 | } | 
| 1245 | 1731 | } | 
| 1246 | 1732 |  			} elseif ($format == 'beast') { | 
| @@ -1250,28 +1736,62 @@ discard block | ||
| 1250 | 1736 |  			    foreach($buffer as $all_data) { | 
| 1251 | 1737 |  				$line = json_decode('{'.$all_data.'}',true); | 
| 1252 | 1738 | $data = array(); | 
| 1253 | - if (isset($line['Icao'])) $data['hex'] = $line['Icao']; // hex | |
| 1254 | - if (isset($line['Call'])) $data['ident'] = $line['Call']; // ident | |
| 1255 | - if (isset($line['Alt'])) $data['altitude'] = $line['Alt']; // altitude | |
| 1256 | - if (isset($line['Spd'])) $data['speed'] = $line['Spd']; // speed | |
| 1257 | - if (isset($line['Trak'])) $data['heading'] = $line['Trak']; // heading | |
| 1258 | - if (isset($line['Lat'])) $data['latitude'] = $line['Lat']; // lat | |
| 1259 | - if (isset($line['Long'])) $data['longitude'] = $line['Long']; // long | |
| 1739 | +				if (isset($line['Icao'])) { | |
| 1740 | + $data['hex'] = $line['Icao']; | |
| 1741 | + } | |
| 1742 | + // hex | |
| 1743 | +				if (isset($line['Call'])) { | |
| 1744 | + $data['ident'] = $line['Call']; | |
| 1745 | + } | |
| 1746 | + // ident | |
| 1747 | +				if (isset($line['Alt'])) { | |
| 1748 | + $data['altitude'] = $line['Alt']; | |
| 1749 | + } | |
| 1750 | + // altitude | |
| 1751 | +				if (isset($line['Spd'])) { | |
| 1752 | + $data['speed'] = $line['Spd']; | |
| 1753 | + } | |
| 1754 | + // speed | |
| 1755 | +				if (isset($line['Trak'])) { | |
| 1756 | + $data['heading'] = $line['Trak']; | |
| 1757 | + } | |
| 1758 | + // heading | |
| 1759 | +				if (isset($line['Lat'])) { | |
| 1760 | + $data['latitude'] = $line['Lat']; | |
| 1761 | + } | |
| 1762 | + // lat | |
| 1763 | +				if (isset($line['Long'])) { | |
| 1764 | + $data['longitude'] = $line['Long']; | |
| 1765 | + } | |
| 1766 | + // long | |
| 1260 | 1767 | //$data['verticalrate'] = $line['']; // verticale rate | 
| 1261 | - if (isset($line['Sqk'])) $data['squawk'] = $line['Sqk']; // squawk | |
| 1768 | +				if (isset($line['Sqk'])) { | |
| 1769 | + $data['squawk'] = $line['Sqk']; | |
| 1770 | + } | |
| 1771 | + // squawk | |
| 1262 | 1772 | $data['emergency'] = ''; // emergency | 
| 1263 | - if (isset($line['Reg'])) $data['registration'] = $line['Reg']; | |
| 1773 | +				if (isset($line['Reg'])) { | |
| 1774 | + $data['registration'] = $line['Reg']; | |
| 1775 | + } | |
| 1264 | 1776 | /* | 
| 1265 | 1777 |  				if (isset($line['PosTime'])) $data['datetime'] = date('Y-m-d H:i:s',$line['PosTime']/1000); | 
| 1266 | 1778 |  				else $data['datetime'] = date('Y-m-d H:i:s'); | 
| 1267 | 1779 | */ | 
| 1268 | 1780 |  				$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1269 | - if (isset($line['Type'])) $data['aircraft_icao'] = $line['Type']; | |
| 1781 | +				if (isset($line['Type'])) { | |
| 1782 | + $data['aircraft_icao'] = $line['Type']; | |
| 1783 | + } | |
| 1270 | 1784 | $data['format_source'] = 'vrstcp'; | 
| 1271 | 1785 | $data['id_source'] = $id_source; | 
| 1272 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1273 | - if (isset($value['name']) && $value['name'] != '') $data['source_name'] = $value['name']; | |
| 1274 | - if (isset($data['latitude']) && isset($data['hex'])) $SI->add($data); | |
| 1786 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1787 | + $data['noarchive'] = true; | |
| 1788 | + } | |
| 1789 | +				if (isset($value['name']) && $value['name'] != '') { | |
| 1790 | + $data['source_name'] = $value['name']; | |
| 1791 | + } | |
| 1792 | +				if (isset($data['latitude']) && isset($data['hex'])) { | |
| 1793 | + $SI->add($data); | |
| 1794 | + } | |
| 1275 | 1795 | unset($data); | 
| 1276 | 1796 | } | 
| 1277 | 1797 |  			} elseif ($format == 'tsv' || substr($buffer,0,4) == 'clock') { | 
| @@ -1284,22 +1804,46 @@ discard block | ||
| 1284 | 1804 | $data['hex'] = $lined['hexid']; | 
| 1285 | 1805 |      				//$data['datetime'] = date('Y-m-d H:i:s',strtotime($lined['clock']));; | 
| 1286 | 1806 |      				$data['datetime'] = date('Y-m-d H:i:s');; | 
| 1287 | - if (isset($lined['ident'])) $data['ident'] = $lined['ident']; | |
| 1288 | - if (isset($lined['lat'])) $data['latitude'] = $lined['lat']; | |
| 1289 | - if (isset($lined['lon'])) $data['longitude'] = $lined['lon']; | |
| 1290 | - if (isset($lined['speed'])) $data['speed'] = $lined['speed']; | |
| 1291 | - if (isset($lined['squawk'])) $data['squawk'] = $lined['squawk']; | |
| 1292 | - if (isset($lined['alt'])) $data['altitude'] = $lined['alt']; | |
| 1293 | - if (isset($lined['heading'])) $data['heading'] = $lined['heading']; | |
| 1807 | +    				if (isset($lined['ident'])) { | |
| 1808 | + $data['ident'] = $lined['ident']; | |
| 1809 | + } | |
| 1810 | +    				if (isset($lined['lat'])) { | |
| 1811 | + $data['latitude'] = $lined['lat']; | |
| 1812 | + } | |
| 1813 | +    				if (isset($lined['lon'])) { | |
| 1814 | + $data['longitude'] = $lined['lon']; | |
| 1815 | + } | |
| 1816 | +    				if (isset($lined['speed'])) { | |
| 1817 | + $data['speed'] = $lined['speed']; | |
| 1818 | + } | |
| 1819 | +    				if (isset($lined['squawk'])) { | |
| 1820 | + $data['squawk'] = $lined['squawk']; | |
| 1821 | + } | |
| 1822 | +    				if (isset($lined['alt'])) { | |
| 1823 | + $data['altitude'] = $lined['alt']; | |
| 1824 | + } | |
| 1825 | +    				if (isset($lined['heading'])) { | |
| 1826 | + $data['heading'] = $lined['heading']; | |
| 1827 | + } | |
| 1294 | 1828 | $data['id_source'] = $id_source; | 
| 1295 | 1829 | $data['format_source'] = 'tsv'; | 
| 1296 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1297 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1298 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1299 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $SI->add($data); | |
| 1830 | +    				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 1831 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 1832 | + } | |
| 1833 | +    				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 1834 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1835 | + } | |
| 1836 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1837 | + $data['noarchive'] = true; | |
| 1838 | + } | |
| 1839 | +    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 1840 | + $SI->add($data); | |
| 1841 | + } | |
| 1300 | 1842 | unset($lined); | 
| 1301 | 1843 | unset($data); | 
| 1302 | - } else $error = true; | |
| 1844 | +    			    } else { | |
| 1845 | + $error = true; | |
| 1846 | + } | |
| 1303 | 1847 |  			} elseif ($format == 'aprs' && $use_aprs) { | 
| 1304 | 1848 |  			    if ($aprs_connect == 0) { | 
| 1305 | 1849 | $send = @ socket_send( $r , $aprs_login , strlen($aprs_login) , 0 ); | 
| @@ -1324,39 +1868,86 @@ discard block | ||
| 1324 | 1868 | $aprs_last_tx = time(); | 
| 1325 | 1869 | $data = array(); | 
| 1326 | 1870 | //print_r($line); | 
| 1327 | - if (isset($line['address'])) $data['hex'] = $line['address']; | |
| 1328 | - if (isset($line['mmsi'])) $data['mmsi'] = $line['mmsi']; | |
| 1329 | - if (isset($line['imo'])) $data['imo'] = $line['imo']; | |
| 1330 | - if (isset($line['squawk'])) $data['squawk'] = $line['squawk']; | |
| 1331 | - if (isset($line['arrival_code'])) $data['arrical_code'] = $line['arrival_code']; | |
| 1332 | - if (isset($line['arrival_date'])) $data['arrical_date'] = $line['arrival_date']; | |
| 1333 | - if (isset($line['type_id'])) $data['type_id'] = $line['typeid']; | |
| 1334 | - if (isset($line['status_id'])) $data['status_id'] = $line['statusid']; | |
| 1335 | -				    if (isset($line['timestamp'])) $data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1336 | -				    else $data['datetime'] = date('Y-m-d H:i:s'); | |
| 1871 | +				    if (isset($line['address'])) { | |
| 1872 | + $data['hex'] = $line['address']; | |
| 1873 | + } | |
| 1874 | +				    if (isset($line['mmsi'])) { | |
| 1875 | + $data['mmsi'] = $line['mmsi']; | |
| 1876 | + } | |
| 1877 | +				    if (isset($line['imo'])) { | |
| 1878 | + $data['imo'] = $line['imo']; | |
| 1879 | + } | |
| 1880 | +				    if (isset($line['squawk'])) { | |
| 1881 | + $data['squawk'] = $line['squawk']; | |
| 1882 | + } | |
| 1883 | +				    if (isset($line['arrival_code'])) { | |
| 1884 | + $data['arrical_code'] = $line['arrival_code']; | |
| 1885 | + } | |
| 1886 | +				    if (isset($line['arrival_date'])) { | |
| 1887 | + $data['arrical_date'] = $line['arrival_date']; | |
| 1888 | + } | |
| 1889 | +				    if (isset($line['type_id'])) { | |
| 1890 | + $data['type_id'] = $line['typeid']; | |
| 1891 | + } | |
| 1892 | +				    if (isset($line['status_id'])) { | |
| 1893 | + $data['status_id'] = $line['statusid']; | |
| 1894 | + } | |
| 1895 | +				    if (isset($line['timestamp'])) { | |
| 1896 | +				    	$data['datetime'] = date('Y-m-d H:i:s',$line['timestamp']); | |
| 1897 | +				    } else { | |
| 1898 | +				    	$data['datetime'] = date('Y-m-d H:i:s'); | |
| 1899 | + } | |
| 1337 | 1900 |  				    //$data['datetime'] = date('Y-m-d H:i:s'); | 
| 1338 | - if (isset($line['ident'])) $data['ident'] = $line['ident']; | |
| 1901 | +				    if (isset($line['ident'])) { | |
| 1902 | + $data['ident'] = $line['ident']; | |
| 1903 | + } | |
| 1339 | 1904 | $data['latitude'] = $line['latitude']; | 
| 1340 | 1905 | $data['longitude'] = $line['longitude']; | 
| 1341 | 1906 | //$data['verticalrate'] = $line[16]; | 
| 1342 | - if (isset($line['speed'])) $data['speed'] = $line['speed']; | |
| 1343 | - else $data['speed'] = 0; | |
| 1344 | - if (isset($line['altitude'])) $data['altitude'] = $line['altitude']; | |
| 1345 | - if (isset($line['comment'])) $data['comment'] = $line['comment']; | |
| 1346 | - if (isset($line['symbol'])) $data['type'] = $line['symbol']; | |
| 1347 | - if (isset($line['heading'])) $data['heading'] = $line['heading']; | |
| 1907 | +				    if (isset($line['speed'])) { | |
| 1908 | + $data['speed'] = $line['speed']; | |
| 1909 | +				    } else { | |
| 1910 | + $data['speed'] = 0; | |
| 1911 | + } | |
| 1912 | +				    if (isset($line['altitude'])) { | |
| 1913 | + $data['altitude'] = $line['altitude']; | |
| 1914 | + } | |
| 1915 | +				    if (isset($line['comment'])) { | |
| 1916 | + $data['comment'] = $line['comment']; | |
| 1917 | + } | |
| 1918 | +				    if (isset($line['symbol'])) { | |
| 1919 | + $data['type'] = $line['symbol']; | |
| 1920 | + } | |
| 1921 | +				    if (isset($line['heading'])) { | |
| 1922 | + $data['heading'] = $line['heading']; | |
| 1923 | + } | |
| 1348 | 1924 | //else $data['heading'] = 0; | 
| 1349 | - if (isset($line['stealth'])) $data['aircraft_type'] = $line['stealth']; | |
| 1350 | - if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) $data['noarchive'] = true; | |
| 1351 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 1352 | - elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) $data['noarchive'] = false; | |
| 1925 | +				    if (isset($line['stealth'])) { | |
| 1926 | + $data['aircraft_type'] = $line['stealth']; | |
| 1927 | + } | |
| 1928 | +				    if (!isset($line['source_type']) && (!isset($globalAPRSarchive) || (isset($globalAPRSarchive) && $globalAPRSarchive === FALSE))) { | |
| 1929 | + $data['noarchive'] = true; | |
| 1930 | + } | |
| 1931 | +				    if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 1932 | + $data['noarchive'] = true; | |
| 1933 | +				    } elseif (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === FALSE) { | |
| 1934 | + $data['noarchive'] = false; | |
| 1935 | + } | |
| 1353 | 1936 | $data['id_source'] = $id_source; | 
| 1354 | - if (isset($line['format_source'])) $data['format_source'] = $line['format_source']; | |
| 1355 | - else $data['format_source'] = 'aprs'; | |
| 1937 | +    				    if (isset($line['format_source'])) { | |
| 1938 | + $data['format_source'] = $line['format_source']; | |
| 1939 | +    				    } else { | |
| 1940 | + $data['format_source'] = 'aprs'; | |
| 1941 | + } | |
| 1356 | 1942 | $data['source_name'] = $line['source']; | 
| 1357 | - if (isset($line['source_type'])) $data['source_type'] = $line['source_type']; | |
| 1358 | - else $data['source_type'] = 'flarm'; | |
| 1359 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1943 | +				    if (isset($line['source_type'])) { | |
| 1944 | + $data['source_type'] = $line['source_type']; | |
| 1945 | +				    } else { | |
| 1946 | + $data['source_type'] = 'flarm'; | |
| 1947 | + } | |
| 1948 | +    				    if (isset($globalSources[$nb]['sourcestats'])) { | |
| 1949 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1950 | + } | |
| 1360 | 1951 |  				    $currentdate = date('Y-m-d H:i:s'); | 
| 1361 | 1952 | $aprsdate = strtotime($data['datetime']); | 
| 1362 | 1953 | // Accept data if time <= system time + 20s | 
| @@ -1364,14 +1955,21 @@ discard block | ||
| 1364 | 1955 |  				    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'])))) { | 
| 1365 | 1956 | $send = $SI->add($data); | 
| 1366 | 1957 |  				    } elseif ($data['source_type'] == 'ais') { | 
| 1367 | - if (isset($globalMarine) && $globalMarine) $send = $MI->add($data); | |
| 1958 | +					if (isset($globalMarine) && $globalMarine) { | |
| 1959 | + $send = $MI->add($data); | |
| 1960 | + } | |
| 1368 | 1961 |  				    } elseif (isset($line['stealth'])) { | 
| 1369 | - if ($line['stealth'] != 0) echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; | |
| 1370 | - else echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; | |
| 1962 | +					if ($line['stealth'] != 0) { | |
| 1963 | + echo '-------- '.$data['ident'].' : APRS stealth ON => not adding'."\n"; | |
| 1964 | +					} else { | |
| 1965 | + echo '--------- '.$data['ident'].' : Date APRS : '.$data['datetime'].' - Current date : '.$currentdate.' => not adding future event'."\n"; | |
| 1966 | + } | |
| 1371 | 1967 |  				    //} 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')) { | 
| 1372 | 1968 |  				    } 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') { | 
| 1373 | 1969 | //echo '!!!!!!!!!!!!!!!! SEND !!!!!!!!!!!!!!!!!!!!'."\n"; | 
| 1374 | - if (isset($globalTracker) && $globalTracker) $send = $TI->add($data); | |
| 1970 | +					if (isset($globalTracker) && $globalTracker) { | |
| 1971 | + $send = $TI->add($data); | |
| 1972 | + } | |
| 1375 | 1973 |  				    } elseif (!isset($line['stealth']) && is_numeric($data['latitude']) && is_numeric($data['longitude']) && isset($data['ident'])) { | 
| 1376 | 1974 |  					$Source->deleteOldLocationByType('gs'); | 
| 1377 | 1975 |  					if (count($Source->getLocationInfoByName($data['ident'])) > 0) { | 
| @@ -1384,8 +1982,7 @@ discard block | ||
| 1384 | 1982 | print_r($data); | 
| 1385 | 1983 | } | 
| 1386 | 1984 | unset($data); | 
| 1387 | - } | |
| 1388 | -				elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { | |
| 1985 | +				} elseif (is_array($line) && $globalDebug && isset($line['symbol']) && $line['symbol'] == 'Weather Station') { | |
| 1389 | 1986 | echo '!! Weather Station not yet supported'."\n"; | 
| 1390 | 1987 | } | 
| 1391 | 1988 | /* | 
| @@ -1393,8 +1990,11 @@ discard block | ||
| 1393 | 1990 | echo '!! Car & Trucks not yet supported'."\n"; | 
| 1394 | 1991 | } | 
| 1395 | 1992 | */ | 
| 1396 | -				elseif ($line == false && $globalDebug) echo 'Ignored ('.$buffer.")\n"; | |
| 1397 | - elseif ($line == true && $globalDebug) echo '!! Failed : '.$buffer."!!\n"; | |
| 1993 | +				elseif ($line == false && $globalDebug) { | |
| 1994 | +					echo 'Ignored ('.$buffer.")\n"; | |
| 1995 | +				} elseif ($line == true && $globalDebug) { | |
| 1996 | + echo '!! Failed : '.$buffer."!!\n"; | |
| 1997 | + } | |
| 1398 | 1998 | } | 
| 1399 | 1999 |  			} else { | 
| 1400 | 2000 |  			    $line = explode(',', $buffer); | 
| @@ -1423,26 +2023,45 @@ discard block | ||
| 1423 | 2023 | $data['ground'] = $line[21]; | 
| 1424 | 2024 | $data['emergency'] = $line[19]; | 
| 1425 | 2025 | $data['format_source'] = 'sbs'; | 
| 1426 | - if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') $data['source_name'] = $globalSources[$nb]['name']; | |
| 1427 | - if (isset($globalSources[$nb]['sourcestats'])) $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 1428 | - if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) $data['noarchive'] = true; | |
| 2026 | +				if (isset($globalSources[$nb]['name']) && $globalSources[$nb]['name'] != '') { | |
| 2027 | + $data['source_name'] = $globalSources[$nb]['name']; | |
| 2028 | + } | |
| 2029 | +    				if (isset($globalSources[$nb]['sourcestats'])) { | |
| 2030 | + $data['sourcestats'] = $globalSources[$nb]['sourcestats']; | |
| 2031 | + } | |
| 2032 | +				if (isset($globalSources[$nb]['noarchive']) && $globalSources[$nb]['noarchive'] === TRUE) { | |
| 2033 | + $data['noarchive'] = true; | |
| 2034 | + } | |
| 1429 | 2035 | $data['id_source'] = $id_source; | 
| 1430 | - if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) $send = $SI->add($data); | |
| 1431 | - else $error = true; | |
| 2036 | +    				if (($data['latitude'] == '' && $data['longitude'] == '') || (is_numeric($data['latitude']) && is_numeric($data['longitude']))) { | |
| 2037 | + $send = $SI->add($data); | |
| 2038 | +    				} else { | |
| 2039 | + $error = true; | |
| 2040 | + } | |
| 1432 | 2041 | unset($data); | 
| 1433 | - } else $error = true; | |
| 2042 | +    			    } else { | |
| 2043 | + $error = true; | |
| 2044 | + } | |
| 1434 | 2045 |  			    if ($error) { | 
| 1435 | 2046 |  				if (count($line) > 1 && ($line[0] == 'STA' || $line[0] == 'AIR' || $line[0] == 'SEL' || $line[0] == 'ID' || $line[0] == 'CLK')) {  | 
| 1436 | - if ($globalDebug) echo "Not a message. Ignoring... \n"; | |
| 2047 | +					if ($globalDebug) { | |
| 2048 | + echo "Not a message. Ignoring... \n"; | |
| 2049 | + } | |
| 1437 | 2050 |  				} else { | 
| 1438 | - if ($globalDebug) echo "Wrong line format. Ignoring... \n"; | |
| 2051 | +					if ($globalDebug) { | |
| 2052 | + echo "Wrong line format. Ignoring... \n"; | |
| 2053 | + } | |
| 1439 | 2054 |  					if ($globalDebug) { | 
| 1440 | 2055 | echo $buffer; | 
| 1441 | 2056 | //print_r($line); | 
| 1442 | 2057 | } | 
| 1443 | 2058 | //socket_close($r); | 
| 1444 | - if ($globalDebug) echo "Reconnect after an error...\n"; | |
| 1445 | - if ($format == 'aprs') $aprs_connect = 0; | |
| 2059 | +					if ($globalDebug) { | |
| 2060 | + echo "Reconnect after an error...\n"; | |
| 2061 | + } | |
| 2062 | +					if ($format == 'aprs') { | |
| 2063 | + $aprs_connect = 0; | |
| 2064 | + } | |
| 1446 | 2065 | $sourceer[$nb] = $globalSources[$nb]; | 
| 1447 | 2066 | connect_all($sourceer); | 
| 1448 | 2067 | $sourceer = array(); | 
| @@ -1450,10 +2069,14 @@ discard block | ||
| 1450 | 2069 | } | 
| 1451 | 2070 | } | 
| 1452 | 2071 | // Sleep for xxx microseconds | 
| 1453 | - if (isset($globalSBSSleep)) usleep($globalSBSSleep); | |
| 2072 | +			if (isset($globalSBSSleep)) { | |
| 2073 | + usleep($globalSBSSleep); | |
| 2074 | + } | |
| 1454 | 2075 |  		    } else { | 
| 1455 | 2076 |  			if ($format == 'flightgearmp') { | 
| 1456 | - if ($globalDebug) echo "Reconnect FlightGear MP..."; | |
| 2077 | +			    	if ($globalDebug) { | |
| 2078 | + echo "Reconnect FlightGear MP..."; | |
| 2079 | + } | |
| 1457 | 2080 | //@socket_close($r); | 
| 1458 | 2081 | sleep($globalMinFetch); | 
| 1459 | 2082 | $sourcefg[$nb] = $globalSources[$nb]; | 
| @@ -1462,10 +2085,15 @@ discard block | ||
| 1462 | 2085 | break; | 
| 1463 | 2086 | |
| 1464 | 2087 |  			} elseif ($format != 'acars' && $format != 'flightgearsp') { | 
| 1465 | - if (isset($tt[$format])) $tt[$format]++; | |
| 1466 | - else $tt[$format] = 0; | |
| 2088 | +			    if (isset($tt[$format])) { | |
| 2089 | + $tt[$format]++; | |
| 2090 | +			    } else { | |
| 2091 | + $tt[$format] = 0; | |
| 2092 | + } | |
| 1467 | 2093 |  			    if ($tt[$format] > 30) { | 
| 1468 | - if ($globalDebug) echo "ERROR : Reconnect ".$format."..."; | |
| 2094 | +				if ($globalDebug) { | |
| 2095 | + echo "ERROR : Reconnect ".$format."..."; | |
| 2096 | + } | |
| 1469 | 2097 | //@socket_close($r); | 
| 1470 | 2098 | sleep(2); | 
| 1471 | 2099 | $aprs_connect = 0; | 
| @@ -1482,11 +2110,17 @@ discard block | ||
| 1482 | 2110 |  	    } else { | 
| 1483 | 2111 | $error = socket_strerror(socket_last_error()); | 
| 1484 | 2112 |  		if (($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY && $error != 'Success') || (time() - $time >= $timeout && $error != 'Success')) { | 
| 1485 | - if ($globalDebug) echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 1486 | - if (isset($globalDebug)) echo "Restarting...\n"; | |
| 2113 | +			if ($globalDebug) { | |
| 2114 | + echo "ERROR : socket_select give this error ".$error . "\n"; | |
| 2115 | + } | |
| 2116 | +			if (isset($globalDebug)) { | |
| 2117 | + echo "Restarting...\n"; | |
| 2118 | + } | |
| 1487 | 2119 | // Restart the script if possible | 
| 1488 | 2120 |  			if (is_array($sockets)) { | 
| 1489 | - if ($globalDebug) echo "Shutdown all sockets..."; | |
| 2121 | +			    if ($globalDebug) { | |
| 2122 | + echo "Shutdown all sockets..."; | |
| 2123 | + } | |
| 1490 | 2124 | |
| 1491 | 2125 |  			    foreach ($sockets as $sock) { | 
| 1492 | 2126 | @socket_shutdown($sock,2); | 
| @@ -1494,22 +2128,36 @@ discard block | ||
| 1494 | 2128 | } | 
| 1495 | 2129 | |
| 1496 | 2130 | } | 
| 1497 | - if ($globalDebug) echo "Waiting..."; | |
| 2131 | +			if ($globalDebug) { | |
| 2132 | + echo "Waiting..."; | |
| 2133 | + } | |
| 1498 | 2134 | sleep(2); | 
| 1499 | 2135 | $time = time(); | 
| 1500 | 2136 | //connect_all($hosts); | 
| 1501 | 2137 | $aprs_connect = 0; | 
| 1502 | - if ($reset%5 == 0) sleep(20); | |
| 1503 | - if ($reset%10 == 0) sleep(100); | |
| 1504 | - if ($reset%20 == 0) sleep(200); | |
| 1505 | -			if ($reset > 100) exit('Too many attempts...'); | |
| 1506 | - if ($globalDebug) echo "Restart all connections..."; | |
| 2138 | +			if ($reset%5 == 0) { | |
| 2139 | + sleep(20); | |
| 2140 | + } | |
| 2141 | +			if ($reset%10 == 0) { | |
| 2142 | + sleep(100); | |
| 2143 | + } | |
| 2144 | +			if ($reset%20 == 0) { | |
| 2145 | + sleep(200); | |
| 2146 | + } | |
| 2147 | +			if ($reset > 100) { | |
| 2148 | +				exit('Too many attempts...'); | |
| 2149 | + } | |
| 2150 | +			if ($globalDebug) { | |
| 2151 | + echo "Restart all connections..."; | |
| 2152 | + } | |
| 1507 | 2153 | connect_all($globalSources); | 
| 1508 | 2154 | } | 
| 1509 | 2155 | } | 
| 1510 | 2156 | } | 
| 1511 | 2157 |  	if ($globalDaemon === false) { | 
| 1512 | - if ($globalDebug) echo 'Check all...'."\n"; | |
| 2158 | +	    if ($globalDebug) { | |
| 2159 | + echo 'Check all...'."\n"; | |
| 2160 | + } | |
| 1513 | 2161 | $SI->checkAll(); | 
| 1514 | 2162 | } | 
| 1515 | 2163 | } | 
| @@ -8,18 +8,18 @@ discard block | ||
| 8 | 8 |  class update_schema { | 
| 9 | 9 | |
| 10 | 10 |  	public static function update_schedule() { | 
| 11 | - $Connection = new Connection(); | |
| 12 | - $Schedule = new Schedule(); | |
| 13 | - $query = "SELECT * FROM schedule"; | |
| 14 | -            try { | |
| 15 | - $sth = $Connection->db->prepare($query); | |
| 11 | + $Connection = new Connection(); | |
| 12 | + $Schedule = new Schedule(); | |
| 13 | + $query = "SELECT * FROM schedule"; | |
| 14 | +			try { | |
| 15 | + $sth = $Connection->db->prepare($query); | |
| 16 | 16 | $sth->execute(); | 
| 17 | -    	    } catch(PDOException $e) { | |
| 17 | +			} catch(PDOException $e) { | |
| 18 | 18 | return "error : ".$e->getMessage()."\n"; | 
| 19 | - } | |
| 20 | -    	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { | |
| 21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); | |
| 22 | - } | |
| 19 | + } | |
| 20 | +			while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { | |
| 21 | + $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); | |
| 22 | + } | |
| 23 | 23 | |
| 24 | 24 | } | 
| 25 | 25 | /* | 
| @@ -43,198 +43,198 @@ discard block | ||
| 43 | 43 | } | 
| 44 | 44 | */ | 
| 45 | 45 |  	private static function update_from_1() { | 
| 46 | - $Connection = new Connection(); | |
| 47 | - // Add new column to routes table | |
| 48 | - //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; | |
| 46 | + $Connection = new Connection(); | |
| 47 | + // Add new column to routes table | |
| 48 | + //$query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10),`ToAirport_Time` VARCHAR(10),`Source` VARCHAR(255),`date_added` DATETIME DEFAULT CURRENT TIMESTAMP,`date_modified` DATETIME,`date_lastseen` DATETIME"; | |
| 49 | 49 | $query = "ALTER TABLE `routes` ADD `FromAirport_Time` VARCHAR(10) NULL , ADD `ToAirport_Time` VARCHAR(10) NULL , ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP, ADD `date_modified` timestamp NULL, ADD `date_lastseen` timestamp NULL"; | 
| 50 | -        	try { | |
| 51 | - $sth = $Connection->db->prepare($query); | |
| 52 | - $sth->execute(); | |
| 53 | -    		} catch(PDOException $e) { | |
| 54 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; | |
| 55 | - } | |
| 56 | - // Copy schedules data to routes table | |
| 57 | - self::update_schedule(); | |
| 58 | - // Delete schedule table | |
| 50 | +			try { | |
| 51 | + $sth = $Connection->db->prepare($query); | |
| 52 | + $sth->execute(); | |
| 53 | +			} catch(PDOException $e) { | |
| 54 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; | |
| 55 | + } | |
| 56 | + // Copy schedules data to routes table | |
| 57 | + self::update_schedule(); | |
| 58 | + // Delete schedule table | |
| 59 | 59 | $query = "DROP TABLE `schedule`"; | 
| 60 | -        	try { | |
| 61 | - $sth = $Connection->db->prepare($query); | |
| 62 | - $sth->execute(); | |
| 63 | -    		} catch(PDOException $e) { | |
| 64 | - return "error (delete schedule table) : ".$e->getMessage()."\n"; | |
| 65 | - } | |
| 66 | - // Add source column | |
| 67 | - $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; | |
| 68 | -    		try { | |
| 69 | - $sth = $Connection->db->prepare($query); | |
| 70 | - $sth->execute(); | |
| 71 | -    		} catch(PDOException $e) { | |
| 72 | - return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; | |
| 73 | - } | |
| 60 | +			try { | |
| 61 | + $sth = $Connection->db->prepare($query); | |
| 62 | + $sth->execute(); | |
| 63 | +			} catch(PDOException $e) { | |
| 64 | + return "error (delete schedule table) : ".$e->getMessage()."\n"; | |
| 65 | + } | |
| 66 | + // Add source column | |
| 67 | + $query = "ALTER TABLE `aircraft_modes` ADD `Source` VARCHAR(255) NULL"; | |
| 68 | +			try { | |
| 69 | + $sth = $Connection->db->prepare($query); | |
| 70 | + $sth->execute(); | |
| 71 | +			} catch(PDOException $e) { | |
| 72 | + return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; | |
| 73 | + } | |
| 74 | 74 | // Delete unused column | 
| 75 | 75 | $query = "ALTER TABLE `aircraft_modes` DROP `SerialNo`, DROP `OperatorFlagCode`, DROP `Manufacturer`, DROP `Type`, DROP `FirstRegDate`, DROP `CurrentRegDate`, DROP `Country`, DROP `PreviousID`, DROP `DeRegDate`, DROP `Status`, DROP `PopularName`, DROP `GenericName`, DROP `AircraftClass`, DROP `Engines`, DROP `OwnershipStatus`, DROP `RegisteredOwners`, DROP `MTOW`, DROP `TotalHours`, DROP `YearBuilt`, DROP `CofACategory`, DROP `CofAExpiry`, DROP `UserNotes`, DROP `Interested`, DROP `UserTag`, DROP `InfoUrl`, DROP `PictureUrl1`, DROP `PictureUrl2`, DROP `PictureUrl3`, DROP `UserBool1`, DROP `UserBool2`, DROP `UserBool3`, DROP `UserBool4`, DROP `UserBool5`, DROP `UserString1`, DROP `UserString2`, DROP `UserString3`, DROP `UserString4`, DROP `UserString5`, DROP `UserInt1`, DROP `UserInt2`, DROP `UserInt3`, DROP `UserInt4`, DROP `UserInt5`"; | 
| 76 | -    		try { | |
| 77 | - $sth = $Connection->db->prepare($query); | |
| 78 | - $sth->execute(); | |
| 79 | -    		} catch(PDOException $e) { | |
| 80 | - return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; | |
| 81 | - } | |
| 76 | +			try { | |
| 77 | + $sth = $Connection->db->prepare($query); | |
| 78 | + $sth->execute(); | |
| 79 | +			} catch(PDOException $e) { | |
| 80 | + return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; | |
| 81 | + } | |
| 82 | 82 | // Add ModeS column | 
| 83 | 83 | $query = "ALTER TABLE `spotter_output` ADD `ModeS` VARCHAR(255) NULL"; | 
| 84 | -    		try { | |
| 85 | - $sth = $Connection->db->prepare($query); | |
| 86 | - $sth->execute(); | |
| 87 | -    		} catch(PDOException $e) { | |
| 88 | - return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; | |
| 89 | - } | |
| 84 | +			try { | |
| 85 | + $sth = $Connection->db->prepare($query); | |
| 86 | + $sth->execute(); | |
| 87 | +			} catch(PDOException $e) { | |
| 88 | + return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; | |
| 89 | + } | |
| 90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; | 
| 91 | -    		try { | |
| 92 | - $sth = $Connection->db->prepare($query); | |
| 93 | - $sth->execute(); | |
| 94 | -    		} catch(PDOException $e) { | |
| 95 | - return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; | |
| 96 | - } | |
| 97 | - // Add auto_increment for aircraft_modes | |
| 98 | - $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; | |
| 99 | -    		try { | |
| 100 | - $sth = $Connection->db->prepare($query); | |
| 101 | - $sth->execute(); | |
| 102 | -    		} catch(PDOException $e) { | |
| 103 | - return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; | |
| 104 | - } | |
| 105 | - $error = ''; | |
| 91 | +			try { | |
| 92 | + $sth = $Connection->db->prepare($query); | |
| 93 | + $sth->execute(); | |
| 94 | +			} catch(PDOException $e) { | |
| 95 | + return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; | |
| 96 | + } | |
| 97 | + // Add auto_increment for aircraft_modes | |
| 98 | + $query = "ALTER TABLE `aircraft_modes` CHANGE `AircraftID` `AircraftID` INT(11) NOT NULL AUTO_INCREMENT"; | |
| 99 | +			try { | |
| 100 | + $sth = $Connection->db->prepare($query); | |
| 101 | + $sth->execute(); | |
| 102 | +			} catch(PDOException $e) { | |
| 103 | + return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; | |
| 104 | + } | |
| 105 | + $error = ''; | |
| 106 | 106 |  		$error .= create_db::import_file('../db/acars_live.sql'); | 
| 107 | 107 |  		$error .= create_db::import_file('../db/config.sql'); | 
| 108 | 108 | // Update schema_version to 2 | 
| 109 | 109 | $query = "UPDATE `config` SET `value` = '2' WHERE `name` = 'schema_version'"; | 
| 110 | -        	try { | |
| 111 | - $sth = $Connection->db->prepare($query); | |
| 112 | - $sth->execute(); | |
| 113 | -    		} catch(PDOException $e) { | |
| 114 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 115 | - } | |
| 110 | +			try { | |
| 111 | + $sth = $Connection->db->prepare($query); | |
| 112 | + $sth->execute(); | |
| 113 | +			} catch(PDOException $e) { | |
| 114 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 115 | + } | |
| 116 | 116 | return $error; | 
| 117 | - } | |
| 117 | + } | |
| 118 | 118 | |
| 119 | 119 |  	private static function update_from_2() { | 
| 120 | - $Connection = new Connection(); | |
| 121 | - // Add new column decode to acars_live table | |
| 120 | + $Connection = new Connection(); | |
| 121 | + // Add new column decode to acars_live table | |
| 122 | 122 | $query = "ALTER TABLE `acars_live` ADD `decode` TEXT"; | 
| 123 | -        	try { | |
| 124 | - $sth = $Connection->db->prepare($query); | |
| 125 | - $sth->execute(); | |
| 126 | -    		} catch(PDOException $e) { | |
| 127 | - return "error (add new columns to routes table) : ".$e->getMessage()."\n"; | |
| 128 | - } | |
| 129 | - $error = ''; | |
| 130 | - // Create table acars_archive | |
| 123 | +			try { | |
| 124 | + $sth = $Connection->db->prepare($query); | |
| 125 | + $sth->execute(); | |
| 126 | +			} catch(PDOException $e) { | |
| 127 | + return "error (add new columns to routes table) : ".$e->getMessage()."\n"; | |
| 128 | + } | |
| 129 | + $error = ''; | |
| 130 | + // Create table acars_archive | |
| 131 | 131 |  		$error .= create_db::import_file('../db/acars_archive.sql'); | 
| 132 | 132 | // Update schema_version to 3 | 
| 133 | 133 | $query = "UPDATE `config` SET `value` = '3' WHERE `name` = 'schema_version'"; | 
| 134 | -        	try { | |
| 135 | - $sth = $Connection->db->prepare($query); | |
| 136 | - $sth->execute(); | |
| 137 | -    		} catch(PDOException $e) { | |
| 138 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 139 | - } | |
| 134 | +			try { | |
| 135 | + $sth = $Connection->db->prepare($query); | |
| 136 | + $sth->execute(); | |
| 137 | +			} catch(PDOException $e) { | |
| 138 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 139 | + } | |
| 140 | 140 | return $error; | 
| 141 | 141 | } | 
| 142 | 142 | |
| 143 | 143 |  	private static function update_from_3() { | 
| 144 | - $Connection = new Connection(); | |
| 145 | - // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated | |
| 144 | + $Connection = new Connection(); | |
| 145 | + // Add default CURRENT_TIMESTAMP to aircraft_modes column FirstCreated | |
| 146 | 146 | $query = "ALTER TABLE `aircraft_modes` CHANGE `FirstCreated` `FirstCreated` timestamp DEFAULT CURRENT_TIMESTAMP"; | 
| 147 | -        	try { | |
| 148 | - $sth = $Connection->db->prepare($query); | |
| 149 | - $sth->execute(); | |
| 150 | -    		} catch(PDOException $e) { | |
| 151 | - return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; | |
| 152 | - } | |
| 153 | - // Add image_source_website column to spotter_image | |
| 147 | +			try { | |
| 148 | + $sth = $Connection->db->prepare($query); | |
| 149 | + $sth->execute(); | |
| 150 | +			} catch(PDOException $e) { | |
| 151 | + return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; | |
| 152 | + } | |
| 153 | + // Add image_source_website column to spotter_image | |
| 154 | 154 | $query = "ALTER TABLE `spotter_image` ADD `image_source_website` VARCHAR(999) NULL"; | 
| 155 | -        	try { | |
| 156 | - $sth = $Connection->db->prepare($query); | |
| 157 | - $sth->execute(); | |
| 158 | -    		} catch(PDOException $e) { | |
| 159 | - return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; | |
| 160 | - } | |
| 161 | - $error = ''; | |
| 155 | +			try { | |
| 156 | + $sth = $Connection->db->prepare($query); | |
| 157 | + $sth->execute(); | |
| 158 | +			} catch(PDOException $e) { | |
| 159 | + return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; | |
| 160 | + } | |
| 161 | + $error = ''; | |
| 162 | 162 | // Update schema_version to 4 | 
| 163 | 163 | $query = "UPDATE `config` SET `value` = '4' WHERE `name` = 'schema_version'"; | 
| 164 | -        	try { | |
| 165 | - $sth = $Connection->db->prepare($query); | |
| 166 | - $sth->execute(); | |
| 167 | -    		} catch(PDOException $e) { | |
| 168 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 169 | - } | |
| 164 | +			try { | |
| 165 | + $sth = $Connection->db->prepare($query); | |
| 166 | + $sth->execute(); | |
| 167 | +			} catch(PDOException $e) { | |
| 168 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 169 | + } | |
| 170 | 170 | return $error; | 
| 171 | 171 | } | 
| 172 | 172 | |
| 173 | 173 |  	private static function update_from_4() { | 
| 174 | - $Connection = new Connection(); | |
| 174 | + $Connection = new Connection(); | |
| 175 | 175 | |
| 176 | - $error = ''; | |
| 177 | - // Create table acars_label | |
| 176 | + $error = ''; | |
| 177 | + // Create table acars_label | |
| 178 | 178 |  		$error .= create_db::import_file('../db/acars_label.sql'); | 
| 179 | 179 |  		if ($error == '') { | 
| 180 | - // Update schema_version to 5 | |
| 181 | - $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; | |
| 182 | -        	    try { | |
| 183 | - $sth = $Connection->db->prepare($query); | |
| 180 | + // Update schema_version to 5 | |
| 181 | + $query = "UPDATE `config` SET `value` = '5' WHERE `name` = 'schema_version'"; | |
| 182 | +				try { | |
| 183 | + $sth = $Connection->db->prepare($query); | |
| 184 | 184 | $sth->execute(); | 
| 185 | -    		    } catch(PDOException $e) { | |
| 185 | +				} catch(PDOException $e) { | |
| 186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 187 | - } | |
| 188 | - } | |
| 187 | + } | |
| 188 | + } | |
| 189 | 189 | return $error; | 
| 190 | 190 | } | 
| 191 | 191 | |
| 192 | 192 |  	private static function update_from_5() { | 
| 193 | - $Connection = new Connection(); | |
| 194 | - // Add columns to translation | |
| 193 | + $Connection = new Connection(); | |
| 194 | + // Add columns to translation | |
| 195 | 195 | $query = "ALTER TABLE `translation` ADD `Source` VARCHAR(255) NULL, ADD `date_added` timestamp DEFAULT CURRENT_TIMESTAMP , ADD `date_modified` timestamp DEFAULT CURRENT_TIMESTAMP ;"; | 
| 196 | -        	try { | |
| 197 | - $sth = $Connection->db->prepare($query); | |
| 198 | - $sth->execute(); | |
| 199 | -    		} catch(PDOException $e) { | |
| 200 | - return "error (add new columns to translation) : ".$e->getMessage()."\n"; | |
| 201 | - } | |
| 202 | - // Add aircraft_shadow column to aircraft | |
| 203 | - $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; | |
| 204 | -        	try { | |
| 205 | - $sth = $Connection->db->prepare($query); | |
| 206 | - $sth->execute(); | |
| 207 | -    		} catch(PDOException $e) { | |
| 208 | - return "error (add new column to aircraft) : ".$e->getMessage()."\n"; | |
| 209 | - } | |
| 210 | - // Add aircraft_shadow column to spotter_live | |
| 211 | - $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; | |
| 212 | -        	try { | |
| 213 | - $sth = $Connection->db->prepare($query); | |
| 214 | - $sth->execute(); | |
| 215 | -    		} catch(PDOException $e) { | |
| 216 | - return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; | |
| 217 | - } | |
| 218 | - $error = ''; | |
| 219 | - // Update table aircraft | |
| 196 | +			try { | |
| 197 | + $sth = $Connection->db->prepare($query); | |
| 198 | + $sth->execute(); | |
| 199 | +			} catch(PDOException $e) { | |
| 200 | + return "error (add new columns to translation) : ".$e->getMessage()."\n"; | |
| 201 | + } | |
| 202 | + // Add aircraft_shadow column to aircraft | |
| 203 | + $query = "ALTER TABLE `aircraft` ADD `aircraft_shadow` VARCHAR(255) NULL"; | |
| 204 | +			try { | |
| 205 | + $sth = $Connection->db->prepare($query); | |
| 206 | + $sth->execute(); | |
| 207 | +			} catch(PDOException $e) { | |
| 208 | + return "error (add new column to aircraft) : ".$e->getMessage()."\n"; | |
| 209 | + } | |
| 210 | + // Add aircraft_shadow column to spotter_live | |
| 211 | + $query = "ALTER TABLE `spotter_live` ADD `aircraft_shadow` VARCHAR(255) NULL"; | |
| 212 | +			try { | |
| 213 | + $sth = $Connection->db->prepare($query); | |
| 214 | + $sth->execute(); | |
| 215 | +			} catch(PDOException $e) { | |
| 216 | + return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; | |
| 217 | + } | |
| 218 | + $error = ''; | |
| 219 | + // Update table aircraft | |
| 220 | 220 |  		$error .= create_db::import_file('../db/aircraft.sql'); | 
| 221 | 221 |  		$error .= create_db::import_file('../db/spotter_archive.sql'); | 
| 222 | 222 | |
| 223 | 223 | // Update schema_version to 6 | 
| 224 | 224 | $query = "UPDATE `config` SET `value` = '6' WHERE `name` = 'schema_version'"; | 
| 225 | -        	try { | |
| 226 | - $sth = $Connection->db->prepare($query); | |
| 227 | - $sth->execute(); | |
| 228 | -    		} catch(PDOException $e) { | |
| 229 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 230 | - } | |
| 225 | +			try { | |
| 226 | + $sth = $Connection->db->prepare($query); | |
| 227 | + $sth->execute(); | |
| 228 | +			} catch(PDOException $e) { | |
| 229 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 230 | + } | |
| 231 | 231 | return $error; | 
| 232 | 232 | } | 
| 233 | 233 | |
| 234 | 234 |  	private static function update_from_6() { | 
| 235 | - $Connection = new Connection(); | |
| 236 | -    		if (!$Connection->indexExists('spotter_output','flightaware_id')) { | |
| 237 | - $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); | |
| 235 | + $Connection = new Connection(); | |
| 236 | +			if (!$Connection->indexExists('spotter_output','flightaware_id')) { | |
| 237 | + $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); | |
| 238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); | 
| 239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); | 
| 240 | 240 | ALTER TABLE spotter_live ADD INDEX(flightaware_id); | 
| @@ -247,147 +247,147 @@ discard block | ||
| 247 | 247 | ALTER TABLE aircraft ADD INDEX(icao); | 
| 248 | 248 | ALTER TABLE airport ADD INDEX(icao); | 
| 249 | 249 | ALTER TABLE translation ADD INDEX(Operator);"; | 
| 250 | -        	    try { | |
| 251 | - $sth = $Connection->db->prepare($query); | |
| 250 | +				try { | |
| 251 | + $sth = $Connection->db->prepare($query); | |
| 252 | 252 | $sth->execute(); | 
| 253 | -    		    } catch(PDOException $e) { | |
| 253 | +				} catch(PDOException $e) { | |
| 254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; | 
| 255 | - } | |
| 256 | - } | |
| 257 | - $error = ''; | |
| 258 | - // Update table countries | |
| 259 | -    		if ($Connection->tableExists('airspace')) { | |
| 260 | - $error .= update_db::update_countries(); | |
| 261 | - if ($error != '') return $error; | |
| 255 | + } | |
| 256 | + } | |
| 257 | + $error = ''; | |
| 258 | + // Update table countries | |
| 259 | +			if ($Connection->tableExists('airspace')) { | |
| 260 | + $error .= update_db::update_countries(); | |
| 261 | + if ($error != '') return $error; | |
| 262 | 262 | } | 
| 263 | 263 | // Update schema_version to 7 | 
| 264 | 264 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; | 
| 265 | -        	try { | |
| 266 | - $sth = $Connection->db->prepare($query); | |
| 267 | - $sth->execute(); | |
| 268 | -    		} catch(PDOException $e) { | |
| 269 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 270 | - } | |
| 265 | +			try { | |
| 266 | + $sth = $Connection->db->prepare($query); | |
| 267 | + $sth->execute(); | |
| 268 | +			} catch(PDOException $e) { | |
| 269 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 270 | + } | |
| 271 | 271 | return $error; | 
| 272 | - } | |
| 272 | + } | |
| 273 | 273 | |
| 274 | 274 |  	private static function update_from_7() { | 
| 275 | 275 | global $globalDBname, $globalDBdriver; | 
| 276 | - $Connection = new Connection(); | |
| 277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; | |
| 276 | + $Connection = new Connection(); | |
| 277 | + $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; | |
| 278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; | 
| 279 | -        	try { | |
| 280 | - $sth = $Connection->db->prepare($query); | |
| 281 | - $sth->execute(); | |
| 282 | -    		} catch(PDOException $e) { | |
| 283 | - return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; | |
| 284 | - } | |
| 285 | -    		if ($globalDBdriver == 'mysql') { | |
| 286 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; | |
| 287 | -		    try { | |
| 288 | - $sth = $Connection->db->prepare($query); | |
| 289 | - $sth->execute(); | |
| 290 | -    		    } catch(PDOException $e) { | |
| 279 | +			try { | |
| 280 | + $sth = $Connection->db->prepare($query); | |
| 281 | + $sth->execute(); | |
| 282 | +			} catch(PDOException $e) { | |
| 283 | + return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; | |
| 284 | + } | |
| 285 | +			if ($globalDBdriver == 'mysql') { | |
| 286 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; | |
| 287 | +			try { | |
| 288 | + $sth = $Connection->db->prepare($query); | |
| 289 | + $sth->execute(); | |
| 290 | +				} catch(PDOException $e) { | |
| 291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; | 
| 292 | - } | |
| 293 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 294 | -    		    if ($row['engine'] == 'ARCHIVE') { | |
| 292 | + } | |
| 293 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 294 | +				if ($row['engine'] == 'ARCHIVE') { | |
| 295 | 295 | $query = "CREATE TABLE copy LIKE spotter_archive; | 
| 296 | 296 | ALTER TABLE copy ENGINE=ARCHIVE; | 
| 297 | 297 | ALTER TABLE copy ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; | 
| 298 | 298 | INSERT INTO copy SELECT *, '' as pilot_name, '' as pilot_id FROM spotter_archive ORDER BY `spotter_archive_id`; | 
| 299 | 299 | DROP TABLE spotter_archive; | 
| 300 | 300 | RENAME TABLE copy TO spotter_archive;"; | 
| 301 | -            	    } else { | |
| 302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; | |
| 303 | - } | |
| 304 | -                } else { | |
| 305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; | |
| 306 | - } | |
| 307 | -        	try { | |
| 308 | - $sth = $Connection->db->prepare($query); | |
| 309 | - $sth->execute(); | |
| 310 | -    		} catch(PDOException $e) { | |
| 311 | - return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; | |
| 312 | - } | |
| 301 | +					} else { | |
| 302 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; | |
| 303 | + } | |
| 304 | +				} else { | |
| 305 | + $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; | |
| 306 | + } | |
| 307 | +			try { | |
| 308 | + $sth = $Connection->db->prepare($query); | |
| 309 | + $sth->execute(); | |
| 310 | +			} catch(PDOException $e) { | |
| 311 | + return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; | |
| 312 | + } | |
| 313 | 313 | |
| 314 | - $error = ''; | |
| 315 | - // Update table aircraft | |
| 314 | + $error = ''; | |
| 315 | + // Update table aircraft | |
| 316 | 316 |  		$error .= create_db::import_file('../db/source_location.sql'); | 
| 317 | 317 | if ($error != '') return $error; | 
| 318 | 318 | // Update schema_version to 6 | 
| 319 | 319 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; | 
| 320 | -        	try { | |
| 321 | - $sth = $Connection->db->prepare($query); | |
| 322 | - $sth->execute(); | |
| 323 | -    		} catch(PDOException $e) { | |
| 324 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 325 | - } | |
| 320 | +			try { | |
| 321 | + $sth = $Connection->db->prepare($query); | |
| 322 | + $sth->execute(); | |
| 323 | +			} catch(PDOException $e) { | |
| 324 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 325 | + } | |
| 326 | 326 | return $error; | 
| 327 | 327 | } | 
| 328 | 328 | |
| 329 | 329 |  	private static function update_from_8() { | 
| 330 | - $Connection = new Connection(); | |
| 331 | - $error = ''; | |
| 332 | - // Update table aircraft | |
| 330 | + $Connection = new Connection(); | |
| 331 | + $error = ''; | |
| 332 | + // Update table aircraft | |
| 333 | 333 |  		$error .= create_db::import_file('../db/notam.sql'); | 
| 334 | 334 | if ($error != '') return $error; | 
| 335 | 335 | $query = "DELETE FROM config WHERE name = 'last_update_db'; | 
| 336 | 336 |                          INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); | 
| 337 | 337 | DELETE FROM config WHERE name = 'last_update_notam_db'; | 
| 338 | 338 |                          INSERT INTO config (name,value) VALUES ('last_update_notam_db',NOW());"; | 
| 339 | -        	try { | |
| 340 | - $sth = $Connection->db->prepare($query); | |
| 341 | - $sth->execute(); | |
| 342 | -    		} catch(PDOException $e) { | |
| 343 | - return "error (insert last_update values) : ".$e->getMessage()."\n"; | |
| 344 | - } | |
| 339 | +			try { | |
| 340 | + $sth = $Connection->db->prepare($query); | |
| 341 | + $sth->execute(); | |
| 342 | +			} catch(PDOException $e) { | |
| 343 | + return "error (insert last_update values) : ".$e->getMessage()."\n"; | |
| 344 | + } | |
| 345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; | 
| 346 | -        	try { | |
| 347 | - $sth = $Connection->db->prepare($query); | |
| 348 | - $sth->execute(); | |
| 349 | -    		} catch(PDOException $e) { | |
| 350 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 351 | - } | |
| 346 | +			try { | |
| 347 | + $sth = $Connection->db->prepare($query); | |
| 348 | + $sth->execute(); | |
| 349 | +			} catch(PDOException $e) { | |
| 350 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 351 | + } | |
| 352 | 352 | return $error; | 
| 353 | 353 | } | 
| 354 | 354 | |
| 355 | 355 |  	private static function update_from_9() { | 
| 356 | - $Connection = new Connection(); | |
| 357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; | |
| 356 | + $Connection = new Connection(); | |
| 357 | + $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; | |
| 358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; | 
| 359 | -        	try { | |
| 360 | - $sth = $Connection->db->prepare($query); | |
| 361 | - $sth->execute(); | |
| 362 | -    		} catch(PDOException $e) { | |
| 363 | - return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; | |
| 364 | - } | |
| 359 | +			try { | |
| 360 | + $sth = $Connection->db->prepare($query); | |
| 361 | + $sth->execute(); | |
| 362 | +			} catch(PDOException $e) { | |
| 363 | + return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; | |
| 364 | + } | |
| 365 | 365 | $error = ''; | 
| 366 | - // Update table atc | |
| 366 | + // Update table atc | |
| 367 | 367 |  		$error .= create_db::import_file('../db/atc.sql'); | 
| 368 | 368 | if ($error != '') return $error; | 
| 369 | 369 | |
| 370 | 370 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; | 
| 371 | -        	try { | |
| 372 | - $sth = $Connection->db->prepare($query); | |
| 373 | - $sth->execute(); | |
| 374 | -    		} catch(PDOException $e) { | |
| 375 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 376 | - } | |
| 371 | +			try { | |
| 372 | + $sth = $Connection->db->prepare($query); | |
| 373 | + $sth->execute(); | |
| 374 | +			} catch(PDOException $e) { | |
| 375 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 376 | + } | |
| 377 | 377 | return $error; | 
| 378 | 378 | } | 
| 379 | 379 | |
| 380 | 380 |  	private static function update_from_10() { | 
| 381 | - $Connection = new Connection(); | |
| 382 | -    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; | |
| 383 | -        	try { | |
| 384 | - $sth = $Connection->db->prepare($query); | |
| 385 | - $sth->execute(); | |
| 386 | -    		} catch(PDOException $e) { | |
| 387 | - return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; | |
| 388 | - } | |
| 381 | + $Connection = new Connection(); | |
| 382 | +			$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; | |
| 383 | +			try { | |
| 384 | + $sth = $Connection->db->prepare($query); | |
| 385 | + $sth->execute(); | |
| 386 | +			} catch(PDOException $e) { | |
| 387 | + return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; | |
| 388 | + } | |
| 389 | 389 | $error = ''; | 
| 390 | - // Add tables | |
| 390 | + // Add tables | |
| 391 | 391 |  		$error .= create_db::import_file('../db/aircraft_owner.sql'); | 
| 392 | 392 | if ($error != '') return $error; | 
| 393 | 393 |  		$error .= create_db::import_file('../db/metar.sql'); | 
| @@ -398,76 +398,76 @@ discard block | ||
| 398 | 398 | if ($error != '') return $error; | 
| 399 | 399 | |
| 400 | 400 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; | 
| 401 | -        	try { | |
| 402 | - $sth = $Connection->db->prepare($query); | |
| 403 | - $sth->execute(); | |
| 404 | -    		} catch(PDOException $e) { | |
| 405 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 406 | - } | |
| 401 | +			try { | |
| 402 | + $sth = $Connection->db->prepare($query); | |
| 403 | + $sth->execute(); | |
| 404 | +			} catch(PDOException $e) { | |
| 405 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 406 | + } | |
| 407 | 407 | return $error; | 
| 408 | 408 | } | 
| 409 | 409 | |
| 410 | 410 |  	private static function update_from_11() { | 
| 411 | 411 | global $globalDBdriver, $globalDBname; | 
| 412 | - $Connection = new Connection(); | |
| 413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; | |
| 414 | -        	try { | |
| 415 | - $sth = $Connection->db->prepare($query); | |
| 416 | - $sth->execute(); | |
| 417 | -    		} catch(PDOException $e) { | |
| 418 | - return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; | |
| 419 | - } | |
| 420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 421 | -        	try { | |
| 422 | - $sth = $Connection->db->prepare($query); | |
| 423 | - $sth->execute(); | |
| 424 | -    		} catch(PDOException $e) { | |
| 425 | - return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; | |
| 426 | - } | |
| 427 | -    		if ($globalDBdriver == 'mysql') { | |
| 428 | - $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; | |
| 429 | -		    try { | |
| 430 | - $sth = $Connection->db->prepare($query); | |
| 431 | - $sth->execute(); | |
| 432 | -    		    } catch(PDOException $e) { | |
| 412 | + $Connection = new Connection(); | |
| 413 | + $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; | |
| 414 | +			try { | |
| 415 | + $sth = $Connection->db->prepare($query); | |
| 416 | + $sth->execute(); | |
| 417 | +			} catch(PDOException $e) { | |
| 418 | + return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; | |
| 419 | + } | |
| 420 | + $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 421 | +			try { | |
| 422 | + $sth = $Connection->db->prepare($query); | |
| 423 | + $sth->execute(); | |
| 424 | +			} catch(PDOException $e) { | |
| 425 | + return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; | |
| 426 | + } | |
| 427 | +			if ($globalDBdriver == 'mysql') { | |
| 428 | + $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; | |
| 429 | +			try { | |
| 430 | + $sth = $Connection->db->prepare($query); | |
| 431 | + $sth->execute(); | |
| 432 | +				} catch(PDOException $e) { | |
| 433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; | 
| 434 | - } | |
| 435 | - $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 436 | -    		    if ($row['engine'] == 'ARCHIVE') { | |
| 434 | + } | |
| 435 | + $row = $sth->fetch(PDO::FETCH_ASSOC); | |
| 436 | +				if ($row['engine'] == 'ARCHIVE') { | |
| 437 | 437 | $query = "CREATE TABLE copy LIKE spotter_archive; | 
| 438 | 438 | ALTER TABLE copy ENGINE=ARCHIVE; | 
| 439 | 439 | ALTER TABLE copy ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE; | 
| 440 | 440 | INSERT INTO copy SELECT *, '' as verticalrate, '' as format_source, '0' as ground FROM spotter_archive ORDER BY `spotter_archive_id`; | 
| 441 | 441 | DROP TABLE spotter_archive; | 
| 442 | 442 | RENAME TABLE copy TO spotter_archive;"; | 
| 443 | -            	    } else { | |
| 444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 445 | - } | |
| 446 | -                } else { | |
| 447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 448 | - } | |
| 449 | -        	try { | |
| 450 | - $sth = $Connection->db->prepare($query); | |
| 451 | - $sth->execute(); | |
| 452 | -    		} catch(PDOException $e) { | |
| 453 | - return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; | |
| 454 | - } | |
| 443 | +					} else { | |
| 444 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 445 | + } | |
| 446 | +				} else { | |
| 447 | + $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 448 | + } | |
| 449 | +			try { | |
| 450 | + $sth = $Connection->db->prepare($query); | |
| 451 | + $sth->execute(); | |
| 452 | +			} catch(PDOException $e) { | |
| 453 | + return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; | |
| 454 | + } | |
| 455 | 455 | |
| 456 | 456 | $error = ''; | 
| 457 | 457 | |
| 458 | 458 | $query = "UPDATE `config` SET `value` = '12' WHERE `name` = 'schema_version'"; | 
| 459 | -        	try { | |
| 460 | - $sth = $Connection->db->prepare($query); | |
| 461 | - $sth->execute(); | |
| 462 | -    		} catch(PDOException $e) { | |
| 463 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 464 | - } | |
| 459 | +			try { | |
| 460 | + $sth = $Connection->db->prepare($query); | |
| 461 | + $sth->execute(); | |
| 462 | +			} catch(PDOException $e) { | |
| 463 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 464 | + } | |
| 465 | 465 | return $error; | 
| 466 | 466 | } | 
| 467 | 467 |  	private static function update_from_12() { | 
| 468 | - $Connection = new Connection(); | |
| 468 | + $Connection = new Connection(); | |
| 469 | 469 | $error = ''; | 
| 470 | - // Add tables | |
| 470 | + // Add tables | |
| 471 | 471 |  		$error .= create_db::import_file('../db/stats.sql'); | 
| 472 | 472 | if ($error != '') return $error; | 
| 473 | 473 |  		$error .= create_db::import_file('../db/stats_aircraft.sql'); | 
| @@ -484,166 +484,166 @@ discard block | ||
| 484 | 484 | if ($error != '') return $error; | 
| 485 | 485 | |
| 486 | 486 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; | 
| 487 | -        	try { | |
| 488 | - $sth = $Connection->db->prepare($query); | |
| 489 | - $sth->execute(); | |
| 490 | -    		} catch(PDOException $e) { | |
| 491 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 492 | - } | |
| 487 | +			try { | |
| 488 | + $sth = $Connection->db->prepare($query); | |
| 489 | + $sth->execute(); | |
| 490 | +			} catch(PDOException $e) { | |
| 491 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 492 | + } | |
| 493 | 493 | return $error; | 
| 494 | 494 | } | 
| 495 | 495 | |
| 496 | 496 |  	private static function update_from_13() { | 
| 497 | - $Connection = new Connection(); | |
| 498 | -    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { | |
| 499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; | |
| 497 | + $Connection = new Connection(); | |
| 498 | +			if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { | |
| 499 | + $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; | |
| 500 | 500 |  			try { | 
| 501 | 501 | $sth = $Connection->db->prepare($query); | 
| 502 | 502 | $sth->execute(); | 
| 503 | -	    		} catch(PDOException $e) { | |
| 503 | +				} catch(PDOException $e) { | |
| 504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; | 
| 505 | - } | |
| 505 | + } | |
| 506 | 506 | } | 
| 507 | - $error = ''; | |
| 507 | + $error = ''; | |
| 508 | 508 | $query = "UPDATE `config` SET `value` = '14' WHERE `name` = 'schema_version'"; | 
| 509 | -        	try { | |
| 510 | - $sth = $Connection->db->prepare($query); | |
| 511 | - $sth->execute(); | |
| 512 | -    		} catch(PDOException $e) { | |
| 513 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 514 | - } | |
| 509 | +			try { | |
| 510 | + $sth = $Connection->db->prepare($query); | |
| 511 | + $sth->execute(); | |
| 512 | +			} catch(PDOException $e) { | |
| 513 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 514 | + } | |
| 515 | 515 | return $error; | 
| 516 | 516 | } | 
| 517 | 517 | |
| 518 | 518 |  	private static function update_from_14() { | 
| 519 | - $Connection = new Connection(); | |
| 519 | + $Connection = new Connection(); | |
| 520 | 520 | $error = ''; | 
| 521 | - // Add tables | |
| 522 | -    		if (!$Connection->tableExists('stats_flight')) { | |
| 521 | + // Add tables | |
| 522 | +			if (!$Connection->tableExists('stats_flight')) { | |
| 523 | 523 |  			$error .= create_db::import_file('../db/stats_flight.sql'); | 
| 524 | 524 | if ($error != '') return $error; | 
| 525 | 525 | } | 
| 526 | 526 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; | 
| 527 | -        	try { | |
| 528 | - $sth = $Connection->db->prepare($query); | |
| 529 | - $sth->execute(); | |
| 530 | -    		} catch(PDOException $e) { | |
| 531 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 532 | - } | |
| 527 | +			try { | |
| 528 | + $sth = $Connection->db->prepare($query); | |
| 529 | + $sth->execute(); | |
| 530 | +			} catch(PDOException $e) { | |
| 531 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 532 | + } | |
| 533 | 533 | return $error; | 
| 534 | 534 | } | 
| 535 | 535 | |
| 536 | 536 | |
| 537 | 537 |  	private static function update_from_15() { | 
| 538 | - $Connection = new Connection(); | |
| 538 | + $Connection = new Connection(); | |
| 539 | 539 | $error = ''; | 
| 540 | - // Add tables | |
| 541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; | |
| 542 | -        	try { | |
| 543 | - $sth = $Connection->db->prepare($query); | |
| 544 | - $sth->execute(); | |
| 545 | -    		} catch(PDOException $e) { | |
| 546 | - return "error (update stats) : ".$e->getMessage()."\n"; | |
| 547 | - } | |
| 540 | + // Add tables | |
| 541 | + $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; | |
| 542 | +			try { | |
| 543 | + $sth = $Connection->db->prepare($query); | |
| 544 | + $sth->execute(); | |
| 545 | +			} catch(PDOException $e) { | |
| 546 | + return "error (update stats) : ".$e->getMessage()."\n"; | |
| 547 | + } | |
| 548 | 548 | if ($error != '') return $error; | 
| 549 | 549 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; | 
| 550 | -        	try { | |
| 551 | - $sth = $Connection->db->prepare($query); | |
| 552 | - $sth->execute(); | |
| 553 | -    		} catch(PDOException $e) { | |
| 554 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 555 | - } | |
| 550 | +			try { | |
| 551 | + $sth = $Connection->db->prepare($query); | |
| 552 | + $sth->execute(); | |
| 553 | +			} catch(PDOException $e) { | |
| 554 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 555 | + } | |
| 556 | 556 | return $error; | 
| 557 | 557 | } | 
| 558 | 558 | |
| 559 | 559 |  	private static function update_from_16() { | 
| 560 | - $Connection = new Connection(); | |
| 560 | + $Connection = new Connection(); | |
| 561 | 561 | $error = ''; | 
| 562 | - // Add tables | |
| 563 | -    		if (!$Connection->tableExists('stats_registration')) { | |
| 562 | + // Add tables | |
| 563 | +			if (!$Connection->tableExists('stats_registration')) { | |
| 564 | 564 |  			$error .= create_db::import_file('../db/stats_registration.sql'); | 
| 565 | 565 | } | 
| 566 | -    		if (!$Connection->tableExists('stats_callsign')) { | |
| 566 | +			if (!$Connection->tableExists('stats_callsign')) { | |
| 567 | 567 |  			$error .= create_db::import_file('../db/stats_callsign.sql'); | 
| 568 | 568 | } | 
| 569 | 569 | if ($error != '') return $error; | 
| 570 | 570 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; | 
| 571 | -        	try { | |
| 572 | - $sth = $Connection->db->prepare($query); | |
| 573 | - $sth->execute(); | |
| 574 | -    		} catch(PDOException $e) { | |
| 575 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 576 | - } | |
| 571 | +			try { | |
| 572 | + $sth = $Connection->db->prepare($query); | |
| 573 | + $sth->execute(); | |
| 574 | +			} catch(PDOException $e) { | |
| 575 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 576 | + } | |
| 577 | 577 | return $error; | 
| 578 | 578 | } | 
| 579 | 579 | |
| 580 | 580 |  	private static function update_from_17() { | 
| 581 | - $Connection = new Connection(); | |
| 581 | + $Connection = new Connection(); | |
| 582 | 582 | $error = ''; | 
| 583 | - // Add tables | |
| 584 | -    		if (!$Connection->tableExists('stats_country')) { | |
| 583 | + // Add tables | |
| 584 | +			if (!$Connection->tableExists('stats_country')) { | |
| 585 | 585 |  			$error .= create_db::import_file('../db/stats_country.sql'); | 
| 586 | 586 | } | 
| 587 | 587 | if ($error != '') return $error; | 
| 588 | 588 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; | 
| 589 | -        	try { | |
| 590 | - $sth = $Connection->db->prepare($query); | |
| 591 | - $sth->execute(); | |
| 592 | -    		} catch(PDOException $e) { | |
| 593 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 594 | - } | |
| 589 | +			try { | |
| 590 | + $sth = $Connection->db->prepare($query); | |
| 591 | + $sth->execute(); | |
| 592 | +			} catch(PDOException $e) { | |
| 593 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 594 | + } | |
| 595 | 595 | return $error; | 
| 596 | 596 | } | 
| 597 | 597 |  	private static function update_from_18() { | 
| 598 | - $Connection = new Connection(); | |
| 598 | + $Connection = new Connection(); | |
| 599 | 599 | $error = ''; | 
| 600 | - // Modify stats_airport table | |
| 601 | -    		if (!$Connection->checkColumnName('stats_airport','airport_name')) { | |
| 602 | - $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; | |
| 603 | -    	        	try { | |
| 604 | - $sth = $Connection->db->prepare($query); | |
| 605 | - $sth->execute(); | |
| 606 | -    			} catch(PDOException $e) { | |
| 607 | - return "error (update stats) : ".$e->getMessage()."\n"; | |
| 608 | - } | |
| 609 | - } | |
| 600 | + // Modify stats_airport table | |
| 601 | +			if (!$Connection->checkColumnName('stats_airport','airport_name')) { | |
| 602 | + $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; | |
| 603 | +					try { | |
| 604 | + $sth = $Connection->db->prepare($query); | |
| 605 | + $sth->execute(); | |
| 606 | +				} catch(PDOException $e) { | |
| 607 | + return "error (update stats) : ".$e->getMessage()."\n"; | |
| 608 | + } | |
| 609 | + } | |
| 610 | 610 | if ($error != '') return $error; | 
| 611 | 611 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; | 
| 612 | -        	try { | |
| 613 | - $sth = $Connection->db->prepare($query); | |
| 614 | - $sth->execute(); | |
| 615 | -    		} catch(PDOException $e) { | |
| 616 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 617 | - } | |
| 612 | +			try { | |
| 613 | + $sth = $Connection->db->prepare($query); | |
| 614 | + $sth->execute(); | |
| 615 | +			} catch(PDOException $e) { | |
| 616 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 617 | + } | |
| 618 | 618 | return $error; | 
| 619 | 619 | } | 
| 620 | 620 | |
| 621 | 621 |  	private static function update_from_19() { | 
| 622 | - $Connection = new Connection(); | |
| 622 | + $Connection = new Connection(); | |
| 623 | 623 | $error = ''; | 
| 624 | - // Update airport table | |
| 624 | + // Update airport table | |
| 625 | 625 |  		$error .= create_db::import_file('../db/airport.sql'); | 
| 626 | 626 | if ($error != '') return 'Import airport.sql : '.$error; | 
| 627 | 627 | // Remove primary key on Spotter_Archive | 
| 628 | 628 | $query = "alter table spotter_archive drop spotter_archive_id"; | 
| 629 | -        	try { | |
| 630 | - $sth = $Connection->db->prepare($query); | |
| 631 | - $sth->execute(); | |
| 632 | -    		} catch(PDOException $e) { | |
| 633 | - return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; | |
| 634 | - } | |
| 629 | +			try { | |
| 630 | + $sth = $Connection->db->prepare($query); | |
| 631 | + $sth->execute(); | |
| 632 | +			} catch(PDOException $e) { | |
| 633 | + return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; | |
| 634 | + } | |
| 635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; | 
| 636 | -        	try { | |
| 637 | - $sth = $Connection->db->prepare($query); | |
| 638 | - $sth->execute(); | |
| 639 | -    		} catch(PDOException $e) { | |
| 640 | - return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; | |
| 641 | - } | |
| 636 | +			try { | |
| 637 | + $sth = $Connection->db->prepare($query); | |
| 638 | + $sth->execute(); | |
| 639 | +			} catch(PDOException $e) { | |
| 640 | + return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; | |
| 641 | + } | |
| 642 | 642 |  		if (!$Connection->checkColumnName('spotter_archive','over_country')) { | 
| 643 | 643 | // Add column over_country | 
| 644 | - $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; | |
| 644 | + $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; | |
| 645 | 645 |  			try { | 
| 646 | - $sth = $Connection->db->prepare($query); | |
| 646 | + $sth = $Connection->db->prepare($query); | |
| 647 | 647 | $sth->execute(); | 
| 648 | 648 |  			} catch(PDOException $e) { | 
| 649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; | 
| @@ -651,9 +651,9 @@ discard block | ||
| 651 | 651 | } | 
| 652 | 652 |  		if (!$Connection->checkColumnName('spotter_live','over_country')) { | 
| 653 | 653 | // Add column over_country | 
| 654 | - $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; | |
| 654 | + $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; | |
| 655 | 655 |  			try { | 
| 656 | - $sth = $Connection->db->prepare($query); | |
| 656 | + $sth = $Connection->db->prepare($query); | |
| 657 | 657 | $sth->execute(); | 
| 658 | 658 |  			} catch(PDOException $e) { | 
| 659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; | 
| @@ -661,74 +661,74 @@ discard block | ||
| 661 | 661 | } | 
| 662 | 662 |  		if (!$Connection->checkColumnName('spotter_output','source_name')) { | 
| 663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output | 
| 664 | - $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | |
| 664 | + $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | |
| 665 | 665 |  			try { | 
| 666 | 666 | $sth = $Connection->db->prepare($query); | 
| 667 | 667 | $sth->execute(); | 
| 668 | 668 |  			} catch(PDOException $e) { | 
| 669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 670 | - } | |
| 671 | - } | |
| 670 | + } | |
| 671 | + } | |
| 672 | 672 |  		if (!$Connection->checkColumnName('spotter_live','source_name')) { | 
| 673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output | 
| 674 | - $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | |
| 674 | + $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | |
| 675 | 675 |  			try { | 
| 676 | 676 | $sth = $Connection->db->prepare($query); | 
| 677 | 677 | $sth->execute(); | 
| 678 | 678 |  			} catch(PDOException $e) { | 
| 679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 680 | - } | |
| 681 | - } | |
| 680 | + } | |
| 681 | + } | |
| 682 | 682 |  		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { | 
| 683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output | 
| 684 | - $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | |
| 684 | + $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | |
| 685 | 685 |  			try { | 
| 686 | 686 | $sth = $Connection->db->prepare($query); | 
| 687 | 687 | $sth->execute(); | 
| 688 | 688 |  			} catch(PDOException $e) { | 
| 689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 690 | - } | |
| 691 | - } | |
| 690 | + } | |
| 691 | + } | |
| 692 | 692 |  		if (!$Connection->checkColumnName('spotter_archive','source_name')) { | 
| 693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output | 
| 694 | - $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; | |
| 694 | + $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; | |
| 695 | 695 |  			try { | 
| 696 | 696 | $sth = $Connection->db->prepare($query); | 
| 697 | 697 | $sth->execute(); | 
| 698 | 698 |  			} catch(PDOException $e) { | 
| 699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 700 | - } | |
| 701 | - } | |
| 700 | + } | |
| 701 | + } | |
| 702 | 702 | if ($error != '') return $error; | 
| 703 | 703 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; | 
| 704 | -        	try { | |
| 705 | - $sth = $Connection->db->prepare($query); | |
| 706 | - $sth->execute(); | |
| 707 | -    		} catch(PDOException $e) { | |
| 708 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 709 | - } | |
| 704 | +			try { | |
| 705 | + $sth = $Connection->db->prepare($query); | |
| 706 | + $sth->execute(); | |
| 707 | +			} catch(PDOException $e) { | |
| 708 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 709 | + } | |
| 710 | 710 | return $error; | 
| 711 | 711 | } | 
| 712 | 712 | |
| 713 | 713 |  	private static function update_from_20() { | 
| 714 | 714 | global $globalIVAO, $globalVATSIM, $globalphpVMS; | 
| 715 | - $Connection = new Connection(); | |
| 715 | + $Connection = new Connection(); | |
| 716 | 716 | $error = ''; | 
| 717 | - // Update airline table | |
| 718 | -    		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { | |
| 717 | + // Update airline table | |
| 718 | +			if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { | |
| 719 | 719 |  			$error .= create_db::import_file('../db/airlines.sql'); | 
| 720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; | 
| 721 | 721 | } | 
| 722 | 722 |  		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { | 
| 723 | 723 | // Add column over_country | 
| 724 | - $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; | |
| 725 | -        		try { | |
| 724 | + $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; | |
| 725 | +				try { | |
| 726 | 726 | $sth = $Connection->db->prepare($query); | 
| 727 | 727 | $sth->execute(); | 
| 728 | 728 |  			} catch(PDOException $e) { | 
| 729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; | 
| 730 | - } | |
| 731 | - } | |
| 730 | + } | |
| 731 | + } | |
| 732 | 732 | if ($error != '') return $error; | 
| 733 | 733 | /* | 
| 734 | 734 |      		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { | 
| @@ -738,12 +738,12 @@ discard block | ||
| 738 | 738 | } | 
| 739 | 739 | */ | 
| 740 | 740 | $query = "UPDATE `config` SET `value` = '21' WHERE `name` = 'schema_version'"; | 
| 741 | -        	try { | |
| 742 | - $sth = $Connection->db->prepare($query); | |
| 743 | - $sth->execute(); | |
| 744 | -    		} catch(PDOException $e) { | |
| 745 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 746 | - } | |
| 741 | +			try { | |
| 742 | + $sth = $Connection->db->prepare($query); | |
| 743 | + $sth->execute(); | |
| 744 | +			} catch(PDOException $e) { | |
| 745 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 746 | + } | |
| 747 | 747 | return $error; | 
| 748 | 748 | } | 
| 749 | 749 | |
| @@ -762,35 +762,35 @@ discard block | ||
| 762 | 762 | if ($error != '') return $error; | 
| 763 | 763 | } | 
| 764 | 764 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; | 
| 765 | -        	try { | |
| 766 | - $sth = $Connection->db->prepare($query); | |
| 767 | - $sth->execute(); | |
| 768 | -    		} catch(PDOException $e) { | |
| 769 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 770 | - } | |
| 765 | +			try { | |
| 766 | + $sth = $Connection->db->prepare($query); | |
| 767 | + $sth->execute(); | |
| 768 | +			} catch(PDOException $e) { | |
| 769 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 770 | + } | |
| 771 | 771 | return $error; | 
| 772 | 772 | } | 
| 773 | 773 | |
| 774 | 774 |  	private static function update_from_22() { | 
| 775 | 775 | global $globalDBdriver; | 
| 776 | - $Connection = new Connection(); | |
| 776 | + $Connection = new Connection(); | |
| 777 | 777 | $error = ''; | 
| 778 | 778 | // Add table stats polar | 
| 779 | -    		if (!$Connection->tableExists('stats_source')) { | |
| 779 | +			if (!$Connection->tableExists('stats_source')) { | |
| 780 | 780 |  			if ($globalDBdriver == 'mysql') { | 
| 781 | -    				$error .= create_db::import_file('../db/stats_source.sql'); | |
| 781 | +					$error .= create_db::import_file('../db/stats_source.sql'); | |
| 782 | 782 |  			} else { | 
| 783 | 783 |  				$error .= create_db::import_file('../db/pgsql/stats_source.sql'); | 
| 784 | 784 | } | 
| 785 | 785 | if ($error != '') return $error; | 
| 786 | 786 | } | 
| 787 | 787 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; | 
| 788 | -        	try { | |
| 789 | - $sth = $Connection->db->prepare($query); | |
| 790 | - $sth->execute(); | |
| 791 | -    		} catch(PDOException $e) { | |
| 792 | - return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 793 | - } | |
| 788 | +			try { | |
| 789 | + $sth = $Connection->db->prepare($query); | |
| 790 | + $sth->execute(); | |
| 791 | +			} catch(PDOException $e) { | |
| 792 | + return "error (update schema_version) : ".$e->getMessage()."\n"; | |
| 793 | + } | |
| 794 | 794 | return $error; | 
| 795 | 795 | } | 
| 796 | 796 | |
| @@ -821,14 +821,14 @@ discard block | ||
| 821 | 821 | } | 
| 822 | 822 |  		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { | 
| 823 | 823 | // Add aircraft_manufacturer to stats_aircraft | 
| 824 | - $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; | |
| 824 | + $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; | |
| 825 | 825 |  			try { | 
| 826 | 826 | $sth = $Connection->db->prepare($query); | 
| 827 | 827 | $sth->execute(); | 
| 828 | 828 |  			} catch(PDOException $e) { | 
| 829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; | 
| 830 | - } | |
| 831 | - } | |
| 830 | + } | |
| 831 | + } | |
| 832 | 832 | |
| 833 | 833 | $query = "UPDATE config SET value = '24' WHERE name = 'schema_version'"; | 
| 834 | 834 |  		try { | 
| @@ -1176,7 +1176,7 @@ discard block | ||
| 1176 | 1176 |  			} catch(PDOException $e) { | 
| 1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; | 
| 1178 | 1178 | } | 
| 1179 | - } | |
| 1179 | + } | |
| 1180 | 1180 |  		if (!$Connection->checkColumnName('aircraft','mfr')) { | 
| 1181 | 1181 | // Add mfr to aircraft | 
| 1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; | 
| @@ -1250,7 +1250,7 @@ discard block | ||
| 1250 | 1250 |  			} catch(PDOException $e) { | 
| 1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; | 
| 1252 | 1252 | } | 
| 1253 | - } | |
| 1253 | + } | |
| 1254 | 1254 |  		if (!$Connection->indexExists('accidents','registration_idx')) { | 
| 1255 | 1255 | // Add index key | 
| 1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; | 
| @@ -1260,7 +1260,7 @@ discard block | ||
| 1260 | 1260 |  			} catch(PDOException $e) { | 
| 1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; | 
| 1262 | 1262 | } | 
| 1263 | - } | |
| 1263 | + } | |
| 1264 | 1264 |  		if (!$Connection->indexExists('accidents','rdts')) { | 
| 1265 | 1265 | // Add index key | 
| 1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; | 
| @@ -1270,7 +1270,7 @@ discard block | ||
| 1270 | 1270 |  			} catch(PDOException $e) { | 
| 1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; | 
| 1272 | 1272 | } | 
| 1273 | - } | |
| 1273 | + } | |
| 1274 | 1274 | |
| 1275 | 1275 | $query = "UPDATE config SET value = '31' WHERE name = 'schema_version'"; | 
| 1276 | 1276 |  		try { | 
| @@ -1562,7 +1562,7 @@ discard block | ||
| 1562 | 1562 |  			} catch(PDOException $e) { | 
| 1563 | 1563 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; | 
| 1564 | 1564 | } | 
| 1565 | - } | |
| 1565 | + } | |
| 1566 | 1566 | $query = "UPDATE config SET value = '36' WHERE name = 'schema_version'"; | 
| 1567 | 1567 |  		try { | 
| 1568 | 1568 | $sth = $Connection->db->prepare($query); | 
| @@ -1719,7 +1719,7 @@ discard block | ||
| 1719 | 1719 |  			} catch(PDOException $e) { | 
| 1720 | 1720 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; | 
| 1721 | 1721 | } | 
| 1722 | - } | |
| 1722 | + } | |
| 1723 | 1723 | $query = "UPDATE config SET value = '38' WHERE name = 'schema_version'"; | 
| 1724 | 1724 |  		try { | 
| 1725 | 1725 | $sth = $Connection->db->prepare($query); | 
| @@ -2005,193 +2005,193 @@ discard block | ||
| 2005 | 2005 | |
| 2006 | 2006 | |
| 2007 | 2007 | |
| 2008 | -    	public static function check_version($update = false) { | |
| 2009 | - global $globalDBname; | |
| 2010 | - $version = 0; | |
| 2011 | - $Connection = new Connection(); | |
| 2012 | -    	    if ($Connection->tableExists('aircraft')) { | |
| 2013 | -    		if (!$Connection->tableExists('config')) { | |
| 2014 | - $version = '1'; | |
| 2015 | - if ($update) return self::update_from_1(); | |
| 2016 | - else return $version; | |
| 2008 | +		public static function check_version($update = false) { | |
| 2009 | + global $globalDBname; | |
| 2010 | + $version = 0; | |
| 2011 | + $Connection = new Connection(); | |
| 2012 | +			if ($Connection->tableExists('aircraft')) { | |
| 2013 | +			if (!$Connection->tableExists('config')) { | |
| 2014 | + $version = '1'; | |
| 2015 | + if ($update) return self::update_from_1(); | |
| 2016 | + else return $version; | |
| 2017 | 2017 |  		} else { | 
| 2018 | - $Connection = new Connection(); | |
| 2019 | - $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; | |
| 2020 | -		    try { | |
| 2021 | - $sth = $Connection->db->prepare($query); | |
| 2022 | - $sth->execute(); | |
| 2023 | -		    } catch(PDOException $e) { | |
| 2018 | + $Connection = new Connection(); | |
| 2019 | + $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; | |
| 2020 | +			try { | |
| 2021 | + $sth = $Connection->db->prepare($query); | |
| 2022 | + $sth->execute(); | |
| 2023 | +			} catch(PDOException $e) { | |
| 2024 | 2024 | return "error : ".$e->getMessage()."\n"; | 
| 2025 | - } | |
| 2026 | - $result = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2027 | -    		    if ($update) { | |
| 2028 | -    			if ($result['value'] == '2') { | |
| 2029 | - $error = self::update_from_2(); | |
| 2030 | - if ($error != '') return $error; | |
| 2031 | - else return self::check_version(true); | |
| 2032 | -    			} elseif ($result['value'] == '3') { | |
| 2033 | - $error = self::update_from_3(); | |
| 2034 | - if ($error != '') return $error; | |
| 2035 | - else return self::check_version(true); | |
| 2036 | -    			} elseif ($result['value'] == '4') { | |
| 2037 | - $error = self::update_from_4(); | |
| 2038 | - if ($error != '') return $error; | |
| 2039 | - else return self::check_version(true); | |
| 2040 | -    			} elseif ($result['value'] == '5') { | |
| 2041 | - $error = self::update_from_5(); | |
| 2042 | - if ($error != '') return $error; | |
| 2043 | - else return self::check_version(true); | |
| 2044 | -    			} elseif ($result['value'] == '6') { | |
| 2045 | - $error = self::update_from_6(); | |
| 2046 | - if ($error != '') return $error; | |
| 2047 | - else return self::check_version(true); | |
| 2048 | -    			} elseif ($result['value'] == '7') { | |
| 2049 | - $error = self::update_from_7(); | |
| 2050 | - if ($error != '') return $error; | |
| 2051 | - else return self::check_version(true); | |
| 2052 | -    			} elseif ($result['value'] == '8') { | |
| 2053 | - $error = self::update_from_8(); | |
| 2054 | - if ($error != '') return $error; | |
| 2055 | - else return self::check_version(true); | |
| 2056 | -    			} elseif ($result['value'] == '9') { | |
| 2057 | - $error = self::update_from_9(); | |
| 2058 | - if ($error != '') return $error; | |
| 2059 | - else return self::check_version(true); | |
| 2060 | -    			} elseif ($result['value'] == '10') { | |
| 2061 | - $error = self::update_from_10(); | |
| 2062 | - if ($error != '') return $error; | |
| 2063 | - else return self::check_version(true); | |
| 2064 | -    			} elseif ($result['value'] == '11') { | |
| 2065 | - $error = self::update_from_11(); | |
| 2066 | - if ($error != '') return $error; | |
| 2067 | - else return self::check_version(true); | |
| 2068 | -    			} elseif ($result['value'] == '12') { | |
| 2069 | - $error = self::update_from_12(); | |
| 2070 | - if ($error != '') return $error; | |
| 2071 | - else return self::check_version(true); | |
| 2072 | -    			} elseif ($result['value'] == '13') { | |
| 2073 | - $error = self::update_from_13(); | |
| 2074 | - if ($error != '') return $error; | |
| 2075 | - else return self::check_version(true); | |
| 2076 | -    			} elseif ($result['value'] == '14') { | |
| 2077 | - $error = self::update_from_14(); | |
| 2078 | - if ($error != '') return $error; | |
| 2079 | - else return self::check_version(true); | |
| 2080 | -    			} elseif ($result['value'] == '15') { | |
| 2081 | - $error = self::update_from_15(); | |
| 2082 | - if ($error != '') return $error; | |
| 2083 | - else return self::check_version(true); | |
| 2084 | -    			} elseif ($result['value'] == '16') { | |
| 2085 | - $error = self::update_from_16(); | |
| 2086 | - if ($error != '') return $error; | |
| 2087 | - else return self::check_version(true); | |
| 2088 | -    			} elseif ($result['value'] == '17') { | |
| 2089 | - $error = self::update_from_17(); | |
| 2090 | - if ($error != '') return $error; | |
| 2091 | - else return self::check_version(true); | |
| 2092 | -    			} elseif ($result['value'] == '18') { | |
| 2093 | - $error = self::update_from_18(); | |
| 2094 | - if ($error != '') return $error; | |
| 2095 | - else return self::check_version(true); | |
| 2096 | -    			} elseif ($result['value'] == '19') { | |
| 2097 | - $error = self::update_from_19(); | |
| 2098 | - if ($error != '') return $error; | |
| 2099 | - else return self::check_version(true); | |
| 2100 | -    			} elseif ($result['value'] == '20') { | |
| 2101 | - $error = self::update_from_20(); | |
| 2102 | - if ($error != '') return $error; | |
| 2103 | - else return self::check_version(true); | |
| 2104 | -    			} elseif ($result['value'] == '21') { | |
| 2105 | - $error = self::update_from_21(); | |
| 2106 | - if ($error != '') return $error; | |
| 2107 | - else return self::check_version(true); | |
| 2108 | -    			} elseif ($result['value'] == '22') { | |
| 2109 | - $error = self::update_from_22(); | |
| 2110 | - if ($error != '') return $error; | |
| 2111 | - else return self::check_version(true); | |
| 2112 | -    			} elseif ($result['value'] == '23') { | |
| 2113 | - $error = self::update_from_23(); | |
| 2114 | - if ($error != '') return $error; | |
| 2115 | - else return self::check_version(true); | |
| 2116 | -    			} elseif ($result['value'] == '24') { | |
| 2117 | - $error = self::update_from_24(); | |
| 2118 | - if ($error != '') return $error; | |
| 2119 | - else return self::check_version(true); | |
| 2120 | -    			} elseif ($result['value'] == '25') { | |
| 2121 | - $error = self::update_from_25(); | |
| 2122 | - if ($error != '') return $error; | |
| 2123 | - else return self::check_version(true); | |
| 2124 | -    			} elseif ($result['value'] == '26') { | |
| 2125 | - $error = self::update_from_26(); | |
| 2126 | - if ($error != '') return $error; | |
| 2127 | - else return self::check_version(true); | |
| 2128 | -    			} elseif ($result['value'] == '27') { | |
| 2129 | - $error = self::update_from_27(); | |
| 2130 | - if ($error != '') return $error; | |
| 2131 | - else return self::check_version(true); | |
| 2132 | -    			} elseif ($result['value'] == '28') { | |
| 2133 | - $error = self::update_from_28(); | |
| 2134 | - if ($error != '') return $error; | |
| 2135 | - else return self::check_version(true); | |
| 2136 | -    			} elseif ($result['value'] == '29') { | |
| 2137 | - $error = self::update_from_29(); | |
| 2138 | - if ($error != '') return $error; | |
| 2139 | - else return self::check_version(true); | |
| 2140 | -    			} elseif ($result['value'] == '30') { | |
| 2141 | - $error = self::update_from_30(); | |
| 2142 | - if ($error != '') return $error; | |
| 2143 | - else return self::check_version(true); | |
| 2144 | -    			} elseif ($result['value'] == '31') { | |
| 2145 | - $error = self::update_from_31(); | |
| 2146 | - if ($error != '') return $error; | |
| 2147 | - else return self::check_version(true); | |
| 2148 | -    			} elseif ($result['value'] == '32') { | |
| 2149 | - $error = self::update_from_32(); | |
| 2150 | - if ($error != '') return $error; | |
| 2151 | - else return self::check_version(true); | |
| 2152 | -    			} elseif ($result['value'] == '33') { | |
| 2153 | - $error = self::update_from_33(); | |
| 2154 | - if ($error != '') return $error; | |
| 2155 | - else return self::check_version(true); | |
| 2156 | -    			} elseif ($result['value'] == '34') { | |
| 2157 | - $error = self::update_from_34(); | |
| 2158 | - if ($error != '') return $error; | |
| 2159 | - else return self::check_version(true); | |
| 2160 | -    			} elseif ($result['value'] == '35') { | |
| 2161 | - $error = self::update_from_35(); | |
| 2162 | - if ($error != '') return $error; | |
| 2163 | - else return self::check_version(true); | |
| 2164 | -    			} elseif ($result['value'] == '36') { | |
| 2165 | - $error = self::update_from_36(); | |
| 2166 | - if ($error != '') return $error; | |
| 2167 | - else return self::check_version(true); | |
| 2168 | -    			} elseif ($result['value'] == '37') { | |
| 2169 | - $error = self::update_from_37(); | |
| 2170 | - if ($error != '') return $error; | |
| 2171 | - else return self::check_version(true); | |
| 2172 | -    			} elseif ($result['value'] == '38') { | |
| 2173 | - $error = self::update_from_38(); | |
| 2174 | - if ($error != '') return $error; | |
| 2175 | - else return self::check_version(true); | |
| 2176 | -    			} elseif ($result['value'] == '39') { | |
| 2177 | - $error = self::update_from_39(); | |
| 2178 | - if ($error != '') return $error; | |
| 2179 | - else return self::check_version(true); | |
| 2180 | -    			} elseif ($result['value'] == '40') { | |
| 2181 | - $error = self::update_from_40(); | |
| 2182 | - if ($error != '') return $error; | |
| 2183 | - else return self::check_version(true); | |
| 2184 | -    			} elseif ($result['value'] == '41') { | |
| 2185 | - $error = self::update_from_41(); | |
| 2186 | - if ($error != '') return $error; | |
| 2187 | - else return self::check_version(true); | |
| 2188 | - } else return ''; | |
| 2189 | - } | |
| 2190 | - else return $result['value']; | |
| 2025 | + } | |
| 2026 | + $result = $sth->fetch(PDO::FETCH_ASSOC); | |
| 2027 | +				if ($update) { | |
| 2028 | +				if ($result['value'] == '2') { | |
| 2029 | + $error = self::update_from_2(); | |
| 2030 | + if ($error != '') return $error; | |
| 2031 | + else return self::check_version(true); | |
| 2032 | +				} elseif ($result['value'] == '3') { | |
| 2033 | + $error = self::update_from_3(); | |
| 2034 | + if ($error != '') return $error; | |
| 2035 | + else return self::check_version(true); | |
| 2036 | +				} elseif ($result['value'] == '4') { | |
| 2037 | + $error = self::update_from_4(); | |
| 2038 | + if ($error != '') return $error; | |
| 2039 | + else return self::check_version(true); | |
| 2040 | +				} elseif ($result['value'] == '5') { | |
| 2041 | + $error = self::update_from_5(); | |
| 2042 | + if ($error != '') return $error; | |
| 2043 | + else return self::check_version(true); | |
| 2044 | +				} elseif ($result['value'] == '6') { | |
| 2045 | + $error = self::update_from_6(); | |
| 2046 | + if ($error != '') return $error; | |
| 2047 | + else return self::check_version(true); | |
| 2048 | +				} elseif ($result['value'] == '7') { | |
| 2049 | + $error = self::update_from_7(); | |
| 2050 | + if ($error != '') return $error; | |
| 2051 | + else return self::check_version(true); | |
| 2052 | +				} elseif ($result['value'] == '8') { | |
| 2053 | + $error = self::update_from_8(); | |
| 2054 | + if ($error != '') return $error; | |
| 2055 | + else return self::check_version(true); | |
| 2056 | +				} elseif ($result['value'] == '9') { | |
| 2057 | + $error = self::update_from_9(); | |
| 2058 | + if ($error != '') return $error; | |
| 2059 | + else return self::check_version(true); | |
| 2060 | +				} elseif ($result['value'] == '10') { | |
| 2061 | + $error = self::update_from_10(); | |
| 2062 | + if ($error != '') return $error; | |
| 2063 | + else return self::check_version(true); | |
| 2064 | +				} elseif ($result['value'] == '11') { | |
| 2065 | + $error = self::update_from_11(); | |
| 2066 | + if ($error != '') return $error; | |
| 2067 | + else return self::check_version(true); | |
| 2068 | +				} elseif ($result['value'] == '12') { | |
| 2069 | + $error = self::update_from_12(); | |
| 2070 | + if ($error != '') return $error; | |
| 2071 | + else return self::check_version(true); | |
| 2072 | +				} elseif ($result['value'] == '13') { | |
| 2073 | + $error = self::update_from_13(); | |
| 2074 | + if ($error != '') return $error; | |
| 2075 | + else return self::check_version(true); | |
| 2076 | +				} elseif ($result['value'] == '14') { | |
| 2077 | + $error = self::update_from_14(); | |
| 2078 | + if ($error != '') return $error; | |
| 2079 | + else return self::check_version(true); | |
| 2080 | +				} elseif ($result['value'] == '15') { | |
| 2081 | + $error = self::update_from_15(); | |
| 2082 | + if ($error != '') return $error; | |
| 2083 | + else return self::check_version(true); | |
| 2084 | +				} elseif ($result['value'] == '16') { | |
| 2085 | + $error = self::update_from_16(); | |
| 2086 | + if ($error != '') return $error; | |
| 2087 | + else return self::check_version(true); | |
| 2088 | +				} elseif ($result['value'] == '17') { | |
| 2089 | + $error = self::update_from_17(); | |
| 2090 | + if ($error != '') return $error; | |
| 2091 | + else return self::check_version(true); | |
| 2092 | +				} elseif ($result['value'] == '18') { | |
| 2093 | + $error = self::update_from_18(); | |
| 2094 | + if ($error != '') return $error; | |
| 2095 | + else return self::check_version(true); | |
| 2096 | +				} elseif ($result['value'] == '19') { | |
| 2097 | + $error = self::update_from_19(); | |
| 2098 | + if ($error != '') return $error; | |
| 2099 | + else return self::check_version(true); | |
| 2100 | +				} elseif ($result['value'] == '20') { | |
| 2101 | + $error = self::update_from_20(); | |
| 2102 | + if ($error != '') return $error; | |
| 2103 | + else return self::check_version(true); | |
| 2104 | +				} elseif ($result['value'] == '21') { | |
| 2105 | + $error = self::update_from_21(); | |
| 2106 | + if ($error != '') return $error; | |
| 2107 | + else return self::check_version(true); | |
| 2108 | +				} elseif ($result['value'] == '22') { | |
| 2109 | + $error = self::update_from_22(); | |
| 2110 | + if ($error != '') return $error; | |
| 2111 | + else return self::check_version(true); | |
| 2112 | +				} elseif ($result['value'] == '23') { | |
| 2113 | + $error = self::update_from_23(); | |
| 2114 | + if ($error != '') return $error; | |
| 2115 | + else return self::check_version(true); | |
| 2116 | +				} elseif ($result['value'] == '24') { | |
| 2117 | + $error = self::update_from_24(); | |
| 2118 | + if ($error != '') return $error; | |
| 2119 | + else return self::check_version(true); | |
| 2120 | +				} elseif ($result['value'] == '25') { | |
| 2121 | + $error = self::update_from_25(); | |
| 2122 | + if ($error != '') return $error; | |
| 2123 | + else return self::check_version(true); | |
| 2124 | +				} elseif ($result['value'] == '26') { | |
| 2125 | + $error = self::update_from_26(); | |
| 2126 | + if ($error != '') return $error; | |
| 2127 | + else return self::check_version(true); | |
| 2128 | +				} elseif ($result['value'] == '27') { | |
| 2129 | + $error = self::update_from_27(); | |
| 2130 | + if ($error != '') return $error; | |
| 2131 | + else return self::check_version(true); | |
| 2132 | +				} elseif ($result['value'] == '28') { | |
| 2133 | + $error = self::update_from_28(); | |
| 2134 | + if ($error != '') return $error; | |
| 2135 | + else return self::check_version(true); | |
| 2136 | +				} elseif ($result['value'] == '29') { | |
| 2137 | + $error = self::update_from_29(); | |
| 2138 | + if ($error != '') return $error; | |
| 2139 | + else return self::check_version(true); | |
| 2140 | +				} elseif ($result['value'] == '30') { | |
| 2141 | + $error = self::update_from_30(); | |
| 2142 | + if ($error != '') return $error; | |
| 2143 | + else return self::check_version(true); | |
| 2144 | +				} elseif ($result['value'] == '31') { | |
| 2145 | + $error = self::update_from_31(); | |
| 2146 | + if ($error != '') return $error; | |
| 2147 | + else return self::check_version(true); | |
| 2148 | +				} elseif ($result['value'] == '32') { | |
| 2149 | + $error = self::update_from_32(); | |
| 2150 | + if ($error != '') return $error; | |
| 2151 | + else return self::check_version(true); | |
| 2152 | +				} elseif ($result['value'] == '33') { | |
| 2153 | + $error = self::update_from_33(); | |
| 2154 | + if ($error != '') return $error; | |
| 2155 | + else return self::check_version(true); | |
| 2156 | +				} elseif ($result['value'] == '34') { | |
| 2157 | + $error = self::update_from_34(); | |
| 2158 | + if ($error != '') return $error; | |
| 2159 | + else return self::check_version(true); | |
| 2160 | +				} elseif ($result['value'] == '35') { | |
| 2161 | + $error = self::update_from_35(); | |
| 2162 | + if ($error != '') return $error; | |
| 2163 | + else return self::check_version(true); | |
| 2164 | +				} elseif ($result['value'] == '36') { | |
| 2165 | + $error = self::update_from_36(); | |
| 2166 | + if ($error != '') return $error; | |
| 2167 | + else return self::check_version(true); | |
| 2168 | +				} elseif ($result['value'] == '37') { | |
| 2169 | + $error = self::update_from_37(); | |
| 2170 | + if ($error != '') return $error; | |
| 2171 | + else return self::check_version(true); | |
| 2172 | +				} elseif ($result['value'] == '38') { | |
| 2173 | + $error = self::update_from_38(); | |
| 2174 | + if ($error != '') return $error; | |
| 2175 | + else return self::check_version(true); | |
| 2176 | +				} elseif ($result['value'] == '39') { | |
| 2177 | + $error = self::update_from_39(); | |
| 2178 | + if ($error != '') return $error; | |
| 2179 | + else return self::check_version(true); | |
| 2180 | +				} elseif ($result['value'] == '40') { | |
| 2181 | + $error = self::update_from_40(); | |
| 2182 | + if ($error != '') return $error; | |
| 2183 | + else return self::check_version(true); | |
| 2184 | +				} elseif ($result['value'] == '41') { | |
| 2185 | + $error = self::update_from_41(); | |
| 2186 | + if ($error != '') return $error; | |
| 2187 | + else return self::check_version(true); | |
| 2188 | + } else return ''; | |
| 2189 | + } | |
| 2190 | + else return $result['value']; | |
| 2191 | 2191 | } | 
| 2192 | 2192 | |
| 2193 | - } else return $version; | |
| 2194 | - } | |
| 2193 | + } else return $version; | |
| 2194 | + } | |
| 2195 | 2195 | |
| 2196 | 2196 | } | 
| 2197 | 2197 | //echo update_schema::check_version(); | 
| @@ -14,11 +14,11 @@ discard block | ||
| 14 | 14 |              try { | 
| 15 | 15 | $sth = $Connection->db->prepare($query); | 
| 16 | 16 | $sth->execute(); | 
| 17 | -    	    } catch(PDOException $e) { | |
| 17 | +    	    } catch (PDOException $e) { | |
| 18 | 18 | return "error : ".$e->getMessage()."\n"; | 
| 19 | 19 | } | 
| 20 | 20 |      	    while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { | 
| 21 | - $Schedule->addSchedule($row['ident'],$row['departure_airport_icao'],$row['departure_airport_time'],$row['arrival_airport_icao'],$row['arrival_airport_time']); | |
| 21 | + $Schedule->addSchedule($row['ident'], $row['departure_airport_icao'], $row['departure_airport_time'], $row['arrival_airport_icao'], $row['arrival_airport_time']); | |
| 22 | 22 | } | 
| 23 | 23 | |
| 24 | 24 | } | 
| @@ -50,7 +50,7 @@ discard block | ||
| 50 | 50 |          	try { | 
| 51 | 51 | $sth = $Connection->db->prepare($query); | 
| 52 | 52 | $sth->execute(); | 
| 53 | -    		} catch(PDOException $e) { | |
| 53 | +    		} catch (PDOException $e) { | |
| 54 | 54 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; | 
| 55 | 55 | } | 
| 56 | 56 | // Copy schedules data to routes table | 
| @@ -60,7 +60,7 @@ discard block | ||
| 60 | 60 |          	try { | 
| 61 | 61 | $sth = $Connection->db->prepare($query); | 
| 62 | 62 | $sth->execute(); | 
| 63 | -    		} catch(PDOException $e) { | |
| 63 | +    		} catch (PDOException $e) { | |
| 64 | 64 | return "error (delete schedule table) : ".$e->getMessage()."\n"; | 
| 65 | 65 | } | 
| 66 | 66 | // Add source column | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 |      		try { | 
| 69 | 69 | $sth = $Connection->db->prepare($query); | 
| 70 | 70 | $sth->execute(); | 
| 71 | -    		} catch(PDOException $e) { | |
| 71 | +    		} catch (PDOException $e) { | |
| 72 | 72 | return "error (add source column to aircraft_modes) : ".$e->getMessage()."\n"; | 
| 73 | 73 | } | 
| 74 | 74 | // Delete unused column | 
| @@ -76,7 +76,7 @@ discard block | ||
| 76 | 76 |      		try { | 
| 77 | 77 | $sth = $Connection->db->prepare($query); | 
| 78 | 78 | $sth->execute(); | 
| 79 | -    		} catch(PDOException $e) { | |
| 79 | +    		} catch (PDOException $e) { | |
| 80 | 80 | return "error (Delete unused column of aircraft_modes) : ".$e->getMessage()."\n"; | 
| 81 | 81 | } | 
| 82 | 82 | // Add ModeS column | 
| @@ -84,14 +84,14 @@ discard block | ||
| 84 | 84 |      		try { | 
| 85 | 85 | $sth = $Connection->db->prepare($query); | 
| 86 | 86 | $sth->execute(); | 
| 87 | -    		} catch(PDOException $e) { | |
| 87 | +    		} catch (PDOException $e) { | |
| 88 | 88 | return "error (Add ModeS column in spotter_output) : ".$e->getMessage()."\n"; | 
| 89 | 89 | } | 
| 90 | 90 | $query = "ALTER TABLE `spotter_live` ADD `ModeS` VARCHAR(255)"; | 
| 91 | 91 |      		try { | 
| 92 | 92 | $sth = $Connection->db->prepare($query); | 
| 93 | 93 | $sth->execute(); | 
| 94 | -    		} catch(PDOException $e) { | |
| 94 | +    		} catch (PDOException $e) { | |
| 95 | 95 | return "error (Add ModeS column in spotter_live) : ".$e->getMessage()."\n"; | 
| 96 | 96 | } | 
| 97 | 97 | // Add auto_increment for aircraft_modes | 
| @@ -99,7 +99,7 @@ discard block | ||
| 99 | 99 |      		try { | 
| 100 | 100 | $sth = $Connection->db->prepare($query); | 
| 101 | 101 | $sth->execute(); | 
| 102 | -    		} catch(PDOException $e) { | |
| 102 | +    		} catch (PDOException $e) { | |
| 103 | 103 | return "error (Add Auto increment in aircraft_modes) : ".$e->getMessage()."\n"; | 
| 104 | 104 | } | 
| 105 | 105 | $error = ''; | 
| @@ -110,7 +110,7 @@ discard block | ||
| 110 | 110 |          	try { | 
| 111 | 111 | $sth = $Connection->db->prepare($query); | 
| 112 | 112 | $sth->execute(); | 
| 113 | -    		} catch(PDOException $e) { | |
| 113 | +    		} catch (PDOException $e) { | |
| 114 | 114 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 115 | 115 | } | 
| 116 | 116 | return $error; | 
| @@ -123,7 +123,7 @@ discard block | ||
| 123 | 123 |          	try { | 
| 124 | 124 | $sth = $Connection->db->prepare($query); | 
| 125 | 125 | $sth->execute(); | 
| 126 | -    		} catch(PDOException $e) { | |
| 126 | +    		} catch (PDOException $e) { | |
| 127 | 127 | return "error (add new columns to routes table) : ".$e->getMessage()."\n"; | 
| 128 | 128 | } | 
| 129 | 129 | $error = ''; | 
| @@ -134,7 +134,7 @@ discard block | ||
| 134 | 134 |          	try { | 
| 135 | 135 | $sth = $Connection->db->prepare($query); | 
| 136 | 136 | $sth->execute(); | 
| 137 | -    		} catch(PDOException $e) { | |
| 137 | +    		} catch (PDOException $e) { | |
| 138 | 138 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 139 | 139 | } | 
| 140 | 140 | return $error; | 
| @@ -147,7 +147,7 @@ discard block | ||
| 147 | 147 |          	try { | 
| 148 | 148 | $sth = $Connection->db->prepare($query); | 
| 149 | 149 | $sth->execute(); | 
| 150 | -    		} catch(PDOException $e) { | |
| 150 | +    		} catch (PDOException $e) { | |
| 151 | 151 | return "error (add new columns to aircraft_modes) : ".$e->getMessage()."\n"; | 
| 152 | 152 | } | 
| 153 | 153 | // Add image_source_website column to spotter_image | 
| @@ -155,7 +155,7 @@ discard block | ||
| 155 | 155 |          	try { | 
| 156 | 156 | $sth = $Connection->db->prepare($query); | 
| 157 | 157 | $sth->execute(); | 
| 158 | -    		} catch(PDOException $e) { | |
| 158 | +    		} catch (PDOException $e) { | |
| 159 | 159 | return "error (add new columns to spotter_image) : ".$e->getMessage()."\n"; | 
| 160 | 160 | } | 
| 161 | 161 | $error = ''; | 
| @@ -164,7 +164,7 @@ discard block | ||
| 164 | 164 |          	try { | 
| 165 | 165 | $sth = $Connection->db->prepare($query); | 
| 166 | 166 | $sth->execute(); | 
| 167 | -    		} catch(PDOException $e) { | |
| 167 | +    		} catch (PDOException $e) { | |
| 168 | 168 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 169 | 169 | } | 
| 170 | 170 | return $error; | 
| @@ -182,7 +182,7 @@ discard block | ||
| 182 | 182 |          	    try { | 
| 183 | 183 | $sth = $Connection->db->prepare($query); | 
| 184 | 184 | $sth->execute(); | 
| 185 | -    		    } catch(PDOException $e) { | |
| 185 | +    		    } catch (PDOException $e) { | |
| 186 | 186 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 187 | 187 | } | 
| 188 | 188 | } | 
| @@ -196,7 +196,7 @@ discard block | ||
| 196 | 196 |          	try { | 
| 197 | 197 | $sth = $Connection->db->prepare($query); | 
| 198 | 198 | $sth->execute(); | 
| 199 | -    		} catch(PDOException $e) { | |
| 199 | +    		} catch (PDOException $e) { | |
| 200 | 200 | return "error (add new columns to translation) : ".$e->getMessage()."\n"; | 
| 201 | 201 | } | 
| 202 | 202 | // Add aircraft_shadow column to aircraft | 
| @@ -204,7 +204,7 @@ discard block | ||
| 204 | 204 |          	try { | 
| 205 | 205 | $sth = $Connection->db->prepare($query); | 
| 206 | 206 | $sth->execute(); | 
| 207 | -    		} catch(PDOException $e) { | |
| 207 | +    		} catch (PDOException $e) { | |
| 208 | 208 | return "error (add new column to aircraft) : ".$e->getMessage()."\n"; | 
| 209 | 209 | } | 
| 210 | 210 | // Add aircraft_shadow column to spotter_live | 
| @@ -212,7 +212,7 @@ discard block | ||
| 212 | 212 |          	try { | 
| 213 | 213 | $sth = $Connection->db->prepare($query); | 
| 214 | 214 | $sth->execute(); | 
| 215 | -    		} catch(PDOException $e) { | |
| 215 | +    		} catch (PDOException $e) { | |
| 216 | 216 | return "error (add new column to spotter_live) : ".$e->getMessage()."\n"; | 
| 217 | 217 | } | 
| 218 | 218 | $error = ''; | 
| @@ -225,7 +225,7 @@ discard block | ||
| 225 | 225 |          	try { | 
| 226 | 226 | $sth = $Connection->db->prepare($query); | 
| 227 | 227 | $sth->execute(); | 
| 228 | -    		} catch(PDOException $e) { | |
| 228 | +    		} catch (PDOException $e) { | |
| 229 | 229 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 230 | 230 | } | 
| 231 | 231 | return $error; | 
| @@ -233,7 +233,7 @@ discard block | ||
| 233 | 233 | |
| 234 | 234 |  	private static function update_from_6() { | 
| 235 | 235 | $Connection = new Connection(); | 
| 236 | -    		if (!$Connection->indexExists('spotter_output','flightaware_id')) { | |
| 236 | +    		if (!$Connection->indexExists('spotter_output', 'flightaware_id')) { | |
| 237 | 237 | $query = "ALTER TABLE spotter_output ADD INDEX(flightaware_id); | 
| 238 | 238 | ALTER TABLE spotter_output ADD INDEX(date); | 
| 239 | 239 | ALTER TABLE spotter_output ADD INDEX(ident); | 
| @@ -250,7 +250,7 @@ discard block | ||
| 250 | 250 |          	    try { | 
| 251 | 251 | $sth = $Connection->db->prepare($query); | 
| 252 | 252 | $sth->execute(); | 
| 253 | -    		    } catch(PDOException $e) { | |
| 253 | +    		    } catch (PDOException $e) { | |
| 254 | 254 | return "error (add some indexes) : ".$e->getMessage()."\n"; | 
| 255 | 255 | } | 
| 256 | 256 | } | 
| @@ -265,7 +265,7 @@ discard block | ||
| 265 | 265 |          	try { | 
| 266 | 266 | $sth = $Connection->db->prepare($query); | 
| 267 | 267 | $sth->execute(); | 
| 268 | -    		} catch(PDOException $e) { | |
| 268 | +    		} catch (PDOException $e) { | |
| 269 | 269 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 270 | 270 | } | 
| 271 | 271 | return $error; | 
| @@ -274,12 +274,12 @@ discard block | ||
| 274 | 274 |  	private static function update_from_7() { | 
| 275 | 275 | global $globalDBname, $globalDBdriver; | 
| 276 | 276 | $Connection = new Connection(); | 
| 277 | - $query="ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; | |
| 277 | + $query = "ALTER TABLE spotter_live ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL; | |
| 278 | 278 | ALTER TABLE spotter_output ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL;"; | 
| 279 | 279 |          	try { | 
| 280 | 280 | $sth = $Connection->db->prepare($query); | 
| 281 | 281 | $sth->execute(); | 
| 282 | -    		} catch(PDOException $e) { | |
| 282 | +    		} catch (PDOException $e) { | |
| 283 | 283 | return "error (add pilot column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; | 
| 284 | 284 | } | 
| 285 | 285 |      		if ($globalDBdriver == 'mysql') { | 
| @@ -287,7 +287,7 @@ discard block | ||
| 287 | 287 |  		    try { | 
| 288 | 288 | $sth = $Connection->db->prepare($query); | 
| 289 | 289 | $sth->execute(); | 
| 290 | -    		    } catch(PDOException $e) { | |
| 290 | +    		    } catch (PDOException $e) { | |
| 291 | 291 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; | 
| 292 | 292 | } | 
| 293 | 293 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -299,15 +299,15 @@ discard block | ||
| 299 | 299 | DROP TABLE spotter_archive; | 
| 300 | 300 | RENAME TABLE copy TO spotter_archive;"; | 
| 301 | 301 |              	    } else { | 
| 302 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; | |
| 302 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; | |
| 303 | 303 | } | 
| 304 | 304 |                  } else { | 
| 305 | - $query="ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; | |
| 305 | + $query = "ALTER TABLE spotter_archive ADD pilot_name VARCHAR(255) NULL, ADD pilot_id VARCHAR(255) NULL"; | |
| 306 | 306 | } | 
| 307 | 307 |          	try { | 
| 308 | 308 | $sth = $Connection->db->prepare($query); | 
| 309 | 309 | $sth->execute(); | 
| 310 | -    		} catch(PDOException $e) { | |
| 310 | +    		} catch (PDOException $e) { | |
| 311 | 311 | return "error (add pilot column to spotter_archive) : ".$e->getMessage()."\n"; | 
| 312 | 312 | } | 
| 313 | 313 | |
| @@ -320,7 +320,7 @@ discard block | ||
| 320 | 320 |          	try { | 
| 321 | 321 | $sth = $Connection->db->prepare($query); | 
| 322 | 322 | $sth->execute(); | 
| 323 | -    		} catch(PDOException $e) { | |
| 323 | +    		} catch (PDOException $e) { | |
| 324 | 324 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 325 | 325 | } | 
| 326 | 326 | return $error; | 
| @@ -339,14 +339,14 @@ discard block | ||
| 339 | 339 |          	try { | 
| 340 | 340 | $sth = $Connection->db->prepare($query); | 
| 341 | 341 | $sth->execute(); | 
| 342 | -    		} catch(PDOException $e) { | |
| 342 | +    		} catch (PDOException $e) { | |
| 343 | 343 | return "error (insert last_update values) : ".$e->getMessage()."\n"; | 
| 344 | 344 | } | 
| 345 | 345 | $query = "UPDATE `config` SET `value` = '9' WHERE `name` = 'schema_version'"; | 
| 346 | 346 |          	try { | 
| 347 | 347 | $sth = $Connection->db->prepare($query); | 
| 348 | 348 | $sth->execute(); | 
| 349 | -    		} catch(PDOException $e) { | |
| 349 | +    		} catch (PDOException $e) { | |
| 350 | 350 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 351 | 351 | } | 
| 352 | 352 | return $error; | 
| @@ -354,12 +354,12 @@ discard block | ||
| 354 | 354 | |
| 355 | 355 |  	private static function update_from_9() { | 
| 356 | 356 | $Connection = new Connection(); | 
| 357 | - $query="ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; | |
| 357 | + $query = "ALTER TABLE spotter_live ADD verticalrate INT(11) NULL; | |
| 358 | 358 | ALTER TABLE spotter_output ADD verticalrate INT(11) NULL;"; | 
| 359 | 359 |          	try { | 
| 360 | 360 | $sth = $Connection->db->prepare($query); | 
| 361 | 361 | $sth->execute(); | 
| 362 | -    		} catch(PDOException $e) { | |
| 362 | +    		} catch (PDOException $e) { | |
| 363 | 363 | return "error (add verticalrate column to spotter_live and spotter_output) : ".$e->getMessage()."\n"; | 
| 364 | 364 | } | 
| 365 | 365 | $error = ''; | 
| @@ -371,7 +371,7 @@ discard block | ||
| 371 | 371 |          	try { | 
| 372 | 372 | $sth = $Connection->db->prepare($query); | 
| 373 | 373 | $sth->execute(); | 
| 374 | -    		} catch(PDOException $e) { | |
| 374 | +    		} catch (PDOException $e) { | |
| 375 | 375 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 376 | 376 | } | 
| 377 | 377 | return $error; | 
| @@ -379,11 +379,11 @@ discard block | ||
| 379 | 379 | |
| 380 | 380 |  	private static function update_from_10() { | 
| 381 | 381 | $Connection = new Connection(); | 
| 382 | -    		$query="ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; | |
| 382 | +    		$query = "ALTER TABLE atc CHANGE `type` `type` ENUM('Observer','Flight Information','Delivery','Tower','Approach','ACC','Departure','Ground','Flight Service Station','Control Radar or Centre') CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL"; | |
| 383 | 383 |          	try { | 
| 384 | 384 | $sth = $Connection->db->prepare($query); | 
| 385 | 385 | $sth->execute(); | 
| 386 | -    		} catch(PDOException $e) { | |
| 386 | +    		} catch (PDOException $e) { | |
| 387 | 387 | return "error (add new enum to ATC table) : ".$e->getMessage()."\n"; | 
| 388 | 388 | } | 
| 389 | 389 | $error = ''; | 
| @@ -401,7 +401,7 @@ discard block | ||
| 401 | 401 |          	try { | 
| 402 | 402 | $sth = $Connection->db->prepare($query); | 
| 403 | 403 | $sth->execute(); | 
| 404 | -    		} catch(PDOException $e) { | |
| 404 | +    		} catch (PDOException $e) { | |
| 405 | 405 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 406 | 406 | } | 
| 407 | 407 | return $error; | 
| @@ -410,18 +410,18 @@ discard block | ||
| 410 | 410 |  	private static function update_from_11() { | 
| 411 | 411 | global $globalDBdriver, $globalDBname; | 
| 412 | 412 | $Connection = new Connection(); | 
| 413 | - $query="ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; | |
| 413 | + $query = "ALTER TABLE spotter_output ADD owner_name VARCHAR(255) NULL DEFAULT NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_ground BOOLEAN NOT NULL DEFAULT FALSE, ADD last_seen DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, ADD last_latitude FLOAT NULL, ADD last_longitude FLOAT NULL, ADD last_altitude INT(11) NULL, ADD last_ground_speed INT(11), ADD real_arrival_airport_icao VARCHAR(999), ADD real_arrival_airport_time VARCHAR(20),ADD real_departure_airport_icao VARCHAR(999), ADD real_departure_airport_time VARCHAR(20)"; | |
| 414 | 414 |          	try { | 
| 415 | 415 | $sth = $Connection->db->prepare($query); | 
| 416 | 416 | $sth->execute(); | 
| 417 | -    		} catch(PDOException $e) { | |
| 417 | +    		} catch (PDOException $e) { | |
| 418 | 418 | return "error (add owner_name & format_source column to spotter_output) : ".$e->getMessage()."\n"; | 
| 419 | 419 | } | 
| 420 | - $query="ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 420 | + $query = "ALTER TABLE spotter_live ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 421 | 421 |          	try { | 
| 422 | 422 | $sth = $Connection->db->prepare($query); | 
| 423 | 423 | $sth->execute(); | 
| 424 | -    		} catch(PDOException $e) { | |
| 424 | +    		} catch (PDOException $e) { | |
| 425 | 425 | return "error (format_source column to spotter_live) : ".$e->getMessage()."\n"; | 
| 426 | 426 | } | 
| 427 | 427 |      		if ($globalDBdriver == 'mysql') { | 
| @@ -429,7 +429,7 @@ discard block | ||
| 429 | 429 |  		    try { | 
| 430 | 430 | $sth = $Connection->db->prepare($query); | 
| 431 | 431 | $sth->execute(); | 
| 432 | -    		    } catch(PDOException $e) { | |
| 432 | +    		    } catch (PDOException $e) { | |
| 433 | 433 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; | 
| 434 | 434 | } | 
| 435 | 435 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -441,15 +441,15 @@ discard block | ||
| 441 | 441 | DROP TABLE spotter_archive; | 
| 442 | 442 | RENAME TABLE copy TO spotter_archive;"; | 
| 443 | 443 |              	    } else { | 
| 444 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 444 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 445 | 445 | } | 
| 446 | 446 |                  } else { | 
| 447 | - $query="ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 447 | + $query = "ALTER TABLE spotter_archive ADD verticalrate INT(11) NULL, ADD format_source VARCHAR(255) NULL DEFAULT NULL, ADD ground BOOLEAN NOT NULL DEFAULT FALSE"; | |
| 448 | 448 | } | 
| 449 | 449 |          	try { | 
| 450 | 450 | $sth = $Connection->db->prepare($query); | 
| 451 | 451 | $sth->execute(); | 
| 452 | -    		} catch(PDOException $e) { | |
| 452 | +    		} catch (PDOException $e) { | |
| 453 | 453 | return "error (add columns to spotter_archive) : ".$e->getMessage()."\n"; | 
| 454 | 454 | } | 
| 455 | 455 | |
| @@ -459,7 +459,7 @@ discard block | ||
| 459 | 459 |          	try { | 
| 460 | 460 | $sth = $Connection->db->prepare($query); | 
| 461 | 461 | $sth->execute(); | 
| 462 | -    		} catch(PDOException $e) { | |
| 462 | +    		} catch (PDOException $e) { | |
| 463 | 463 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 464 | 464 | } | 
| 465 | 465 | return $error; | 
| @@ -487,7 +487,7 @@ discard block | ||
| 487 | 487 |          	try { | 
| 488 | 488 | $sth = $Connection->db->prepare($query); | 
| 489 | 489 | $sth->execute(); | 
| 490 | -    		} catch(PDOException $e) { | |
| 490 | +    		} catch (PDOException $e) { | |
| 491 | 491 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 492 | 492 | } | 
| 493 | 493 | return $error; | 
| @@ -495,12 +495,12 @@ discard block | ||
| 495 | 495 | |
| 496 | 496 |  	private static function update_from_13() { | 
| 497 | 497 | $Connection = new Connection(); | 
| 498 | -    		if (!$Connection->checkColumnName('spotter_archive_output','real_departure_airport_icao')) { | |
| 499 | - $query="ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; | |
| 498 | +    		if (!$Connection->checkColumnName('spotter_archive_output', 'real_departure_airport_icao')) { | |
| 499 | + $query = "ALTER TABLE spotter_archive_output ADD real_departure_airport_icao VARCHAR(20), ADD real_departure_airport_time VARCHAR(20)"; | |
| 500 | 500 |  			try { | 
| 501 | 501 | $sth = $Connection->db->prepare($query); | 
| 502 | 502 | $sth->execute(); | 
| 503 | -	    		} catch(PDOException $e) { | |
| 503 | +	    		} catch (PDOException $e) { | |
| 504 | 504 | return "error (update spotter_archive_output) : ".$e->getMessage()."\n"; | 
| 505 | 505 | } | 
| 506 | 506 | } | 
| @@ -509,7 +509,7 @@ discard block | ||
| 509 | 509 |          	try { | 
| 510 | 510 | $sth = $Connection->db->prepare($query); | 
| 511 | 511 | $sth->execute(); | 
| 512 | -    		} catch(PDOException $e) { | |
| 512 | +    		} catch (PDOException $e) { | |
| 513 | 513 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 514 | 514 | } | 
| 515 | 515 | return $error; | 
| @@ -527,7 +527,7 @@ discard block | ||
| 527 | 527 |          	try { | 
| 528 | 528 | $sth = $Connection->db->prepare($query); | 
| 529 | 529 | $sth->execute(); | 
| 530 | -    		} catch(PDOException $e) { | |
| 530 | +    		} catch (PDOException $e) { | |
| 531 | 531 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 532 | 532 | } | 
| 533 | 533 | return $error; | 
| @@ -538,11 +538,11 @@ discard block | ||
| 538 | 538 | $Connection = new Connection(); | 
| 539 | 539 | $error = ''; | 
| 540 | 540 | // Add tables | 
| 541 | - $query="ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; | |
| 541 | + $query = "ALTER TABLE `stats` CHANGE `stats_date` `stats_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP"; | |
| 542 | 542 |          	try { | 
| 543 | 543 | $sth = $Connection->db->prepare($query); | 
| 544 | 544 | $sth->execute(); | 
| 545 | -    		} catch(PDOException $e) { | |
| 545 | +    		} catch (PDOException $e) { | |
| 546 | 546 | return "error (update stats) : ".$e->getMessage()."\n"; | 
| 547 | 547 | } | 
| 548 | 548 | if ($error != '') return $error; | 
| @@ -550,7 +550,7 @@ discard block | ||
| 550 | 550 |          	try { | 
| 551 | 551 | $sth = $Connection->db->prepare($query); | 
| 552 | 552 | $sth->execute(); | 
| 553 | -    		} catch(PDOException $e) { | |
| 553 | +    		} catch (PDOException $e) { | |
| 554 | 554 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 555 | 555 | } | 
| 556 | 556 | return $error; | 
| @@ -571,7 +571,7 @@ discard block | ||
| 571 | 571 |          	try { | 
| 572 | 572 | $sth = $Connection->db->prepare($query); | 
| 573 | 573 | $sth->execute(); | 
| 574 | -    		} catch(PDOException $e) { | |
| 574 | +    		} catch (PDOException $e) { | |
| 575 | 575 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 576 | 576 | } | 
| 577 | 577 | return $error; | 
| @@ -589,7 +589,7 @@ discard block | ||
| 589 | 589 |          	try { | 
| 590 | 590 | $sth = $Connection->db->prepare($query); | 
| 591 | 591 | $sth->execute(); | 
| 592 | -    		} catch(PDOException $e) { | |
| 592 | +    		} catch (PDOException $e) { | |
| 593 | 593 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 594 | 594 | } | 
| 595 | 595 | return $error; | 
| @@ -598,12 +598,12 @@ discard block | ||
| 598 | 598 | $Connection = new Connection(); | 
| 599 | 599 | $error = ''; | 
| 600 | 600 | // Modify stats_airport table | 
| 601 | -    		if (!$Connection->checkColumnName('stats_airport','airport_name')) { | |
| 601 | +    		if (!$Connection->checkColumnName('stats_airport', 'airport_name')) { | |
| 602 | 602 | $query = "ALTER TABLE `stats_airport` ADD `stats_type` VARCHAR(50) NOT NULL DEFAULT 'yearly', ADD `airport_name` VARCHAR(255) NOT NULL, ADD `date` DATE NULL DEFAULT NULL, DROP INDEX `airport_icao`, ADD UNIQUE `airport_icao` (`airport_icao`, `type`, `date`)"; | 
| 603 | 603 |      	        	try { | 
| 604 | 604 | $sth = $Connection->db->prepare($query); | 
| 605 | 605 | $sth->execute(); | 
| 606 | -    			} catch(PDOException $e) { | |
| 606 | +    			} catch (PDOException $e) { | |
| 607 | 607 | return "error (update stats) : ".$e->getMessage()."\n"; | 
| 608 | 608 | } | 
| 609 | 609 | } | 
| @@ -612,7 +612,7 @@ discard block | ||
| 612 | 612 |          	try { | 
| 613 | 613 | $sth = $Connection->db->prepare($query); | 
| 614 | 614 | $sth->execute(); | 
| 615 | -    		} catch(PDOException $e) { | |
| 615 | +    		} catch (PDOException $e) { | |
| 616 | 616 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 617 | 617 | } | 
| 618 | 618 | return $error; | 
| @@ -629,73 +629,73 @@ discard block | ||
| 629 | 629 |          	try { | 
| 630 | 630 | $sth = $Connection->db->prepare($query); | 
| 631 | 631 | $sth->execute(); | 
| 632 | -    		} catch(PDOException $e) { | |
| 632 | +    		} catch (PDOException $e) { | |
| 633 | 633 | return "error (remove primary key on spotter_archive) : ".$e->getMessage()."\n"; | 
| 634 | 634 | } | 
| 635 | 635 | $query = "alter table spotter_archive add spotter_archive_id INT(11)"; | 
| 636 | 636 |          	try { | 
| 637 | 637 | $sth = $Connection->db->prepare($query); | 
| 638 | 638 | $sth->execute(); | 
| 639 | -    		} catch(PDOException $e) { | |
| 639 | +    		} catch (PDOException $e) { | |
| 640 | 640 | return "error (add id again on spotter_archive) : ".$e->getMessage()."\n"; | 
| 641 | 641 | } | 
| 642 | -		if (!$Connection->checkColumnName('spotter_archive','over_country')) { | |
| 642 | +		if (!$Connection->checkColumnName('spotter_archive', 'over_country')) { | |
| 643 | 643 | // Add column over_country | 
| 644 | 644 | $query = "ALTER TABLE `spotter_archive` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; | 
| 645 | 645 |  			try { | 
| 646 | 646 | $sth = $Connection->db->prepare($query); | 
| 647 | 647 | $sth->execute(); | 
| 648 | -			} catch(PDOException $e) { | |
| 648 | +			} catch (PDOException $e) { | |
| 649 | 649 | return "error (add over_country) : ".$e->getMessage()."\n"; | 
| 650 | 650 | } | 
| 651 | 651 | } | 
| 652 | -		if (!$Connection->checkColumnName('spotter_live','over_country')) { | |
| 652 | +		if (!$Connection->checkColumnName('spotter_live', 'over_country')) { | |
| 653 | 653 | // Add column over_country | 
| 654 | 654 | $query = "ALTER TABLE `spotter_live` ADD `over_country` VARCHAR(5) NULL DEFAULT NULL"; | 
| 655 | 655 |  			try { | 
| 656 | 656 | $sth = $Connection->db->prepare($query); | 
| 657 | 657 | $sth->execute(); | 
| 658 | -			} catch(PDOException $e) { | |
| 658 | +			} catch (PDOException $e) { | |
| 659 | 659 | return "error (add over_country) : ".$e->getMessage()."\n"; | 
| 660 | 660 | } | 
| 661 | 661 | } | 
| 662 | -		if (!$Connection->checkColumnName('spotter_output','source_name')) { | |
| 662 | +		if (!$Connection->checkColumnName('spotter_output', 'source_name')) { | |
| 663 | 663 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output | 
| 664 | 664 | $query = "ALTER TABLE `spotter_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | 
| 665 | 665 |  			try { | 
| 666 | 666 | $sth = $Connection->db->prepare($query); | 
| 667 | 667 | $sth->execute(); | 
| 668 | -			} catch(PDOException $e) { | |
| 668 | +			} catch (PDOException $e) { | |
| 669 | 669 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 670 | 670 | } | 
| 671 | 671 | } | 
| 672 | -		if (!$Connection->checkColumnName('spotter_live','source_name')) { | |
| 672 | +		if (!$Connection->checkColumnName('spotter_live', 'source_name')) { | |
| 673 | 673 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output | 
| 674 | 674 | $query = "ALTER TABLE `spotter_live` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | 
| 675 | 675 |  			try { | 
| 676 | 676 | $sth = $Connection->db->prepare($query); | 
| 677 | 677 | $sth->execute(); | 
| 678 | -			} catch(PDOException $e) { | |
| 678 | +			} catch (PDOException $e) { | |
| 679 | 679 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 680 | 680 | } | 
| 681 | 681 | } | 
| 682 | -		if (!$Connection->checkColumnName('spotter_archive_output','source_name')) { | |
| 682 | +		if (!$Connection->checkColumnName('spotter_archive_output', 'source_name')) { | |
| 683 | 683 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output | 
| 684 | 684 | $query = "ALTER TABLE `spotter_archive_output` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`"; | 
| 685 | 685 |  			try { | 
| 686 | 686 | $sth = $Connection->db->prepare($query); | 
| 687 | 687 | $sth->execute(); | 
| 688 | -			} catch(PDOException $e) { | |
| 688 | +			} catch (PDOException $e) { | |
| 689 | 689 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 690 | 690 | } | 
| 691 | 691 | } | 
| 692 | -		if (!$Connection->checkColumnName('spotter_archive','source_name')) { | |
| 692 | +		if (!$Connection->checkColumnName('spotter_archive', 'source_name')) { | |
| 693 | 693 | // Add source_name to spotter_output, spotter_live, spotter_archive, spotter_archive_output | 
| 694 | 694 | $query = "ALTER TABLE `spotter_archive` ADD `source_name` VARCHAR(255) NULL AFTER `format_source`;"; | 
| 695 | 695 |  			try { | 
| 696 | 696 | $sth = $Connection->db->prepare($query); | 
| 697 | 697 | $sth->execute(); | 
| 698 | -			} catch(PDOException $e) { | |
| 698 | +			} catch (PDOException $e) { | |
| 699 | 699 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 700 | 700 | } | 
| 701 | 701 | } | 
| @@ -704,7 +704,7 @@ discard block | ||
| 704 | 704 |          	try { | 
| 705 | 705 | $sth = $Connection->db->prepare($query); | 
| 706 | 706 | $sth->execute(); | 
| 707 | -    		} catch(PDOException $e) { | |
| 707 | +    		} catch (PDOException $e) { | |
| 708 | 708 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 709 | 709 | } | 
| 710 | 710 | return $error; | 
| @@ -719,13 +719,13 @@ discard block | ||
| 719 | 719 |  			$error .= create_db::import_file('../db/airlines.sql'); | 
| 720 | 720 | if ($error != '') return 'Import airlines.sql : '.$error; | 
| 721 | 721 | } | 
| 722 | -		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { | |
| 722 | +		if (!$Connection->checkColumnName('aircraft_modes', 'type_flight')) { | |
| 723 | 723 | // Add column over_country | 
| 724 | 724 | $query = "ALTER TABLE `aircraft_modes` ADD `type_flight` VARCHAR(50) NULL DEFAULT NULL;"; | 
| 725 | 725 |          		try { | 
| 726 | 726 | $sth = $Connection->db->prepare($query); | 
| 727 | 727 | $sth->execute(); | 
| 728 | -			} catch(PDOException $e) { | |
| 728 | +			} catch (PDOException $e) { | |
| 729 | 729 | return "error (add over_country) : ".$e->getMessage()."\n"; | 
| 730 | 730 | } | 
| 731 | 731 | } | 
| @@ -741,7 +741,7 @@ discard block | ||
| 741 | 741 |          	try { | 
| 742 | 742 | $sth = $Connection->db->prepare($query); | 
| 743 | 743 | $sth->execute(); | 
| 744 | -    		} catch(PDOException $e) { | |
| 744 | +    		} catch (PDOException $e) { | |
| 745 | 745 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 746 | 746 | } | 
| 747 | 747 | return $error; | 
| @@ -750,13 +750,13 @@ discard block | ||
| 750 | 750 |  	private static function update_from_21() { | 
| 751 | 751 | $Connection = new Connection(); | 
| 752 | 752 | $error = ''; | 
| 753 | -		if (!$Connection->checkColumnName('stats_airport','stats_type')) { | |
| 753 | +		if (!$Connection->checkColumnName('stats_airport', 'stats_type')) { | |
| 754 | 754 | // Rename type to stats_type | 
| 755 | 755 | $query = "ALTER TABLE `stats_airport` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats` CHANGE `type` `stats_type` VARCHAR(50);ALTER TABLE `stats_flight` CHANGE `type` `stats_type` VARCHAR(50);"; | 
| 756 | 756 |  			try { | 
| 757 | 757 | $sth = $Connection->db->prepare($query); | 
| 758 | 758 | $sth->execute(); | 
| 759 | -			} catch(PDOException $e) { | |
| 759 | +			} catch (PDOException $e) { | |
| 760 | 760 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; | 
| 761 | 761 | } | 
| 762 | 762 | if ($error != '') return $error; | 
| @@ -765,7 +765,7 @@ discard block | ||
| 765 | 765 |          	try { | 
| 766 | 766 | $sth = $Connection->db->prepare($query); | 
| 767 | 767 | $sth->execute(); | 
| 768 | -    		} catch(PDOException $e) { | |
| 768 | +    		} catch (PDOException $e) { | |
| 769 | 769 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 770 | 770 | } | 
| 771 | 771 | return $error; | 
| @@ -788,7 +788,7 @@ discard block | ||
| 788 | 788 |          	try { | 
| 789 | 789 | $sth = $Connection->db->prepare($query); | 
| 790 | 790 | $sth->execute(); | 
| 791 | -    		} catch(PDOException $e) { | |
| 791 | +    		} catch (PDOException $e) { | |
| 792 | 792 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 793 | 793 | } | 
| 794 | 794 | return $error; | 
| @@ -815,17 +815,17 @@ discard block | ||
| 815 | 815 |  			try { | 
| 816 | 816 | $sth = $Connection->db->prepare($query); | 
| 817 | 817 | $sth->execute(); | 
| 818 | -			} catch(PDOException $e) { | |
| 818 | +			} catch (PDOException $e) { | |
| 819 | 819 | return "error (create index on spotter_archive) : ".$e->getMessage()."\n"; | 
| 820 | 820 | } | 
| 821 | 821 | } | 
| 822 | -		if (!$Connection->checkColumnName('stats_aircraft','aircraft_manufacturer')) { | |
| 822 | +		if (!$Connection->checkColumnName('stats_aircraft', 'aircraft_manufacturer')) { | |
| 823 | 823 | // Add aircraft_manufacturer to stats_aircraft | 
| 824 | 824 | $query = "ALTER TABLE stats_aircraft ADD aircraft_manufacturer VARCHAR(255) NULL"; | 
| 825 | 825 |  			try { | 
| 826 | 826 | $sth = $Connection->db->prepare($query); | 
| 827 | 827 | $sth->execute(); | 
| 828 | -			} catch(PDOException $e) { | |
| 828 | +			} catch (PDOException $e) { | |
| 829 | 829 | return "error (add aircraft_manufacturer column) : ".$e->getMessage()."\n"; | 
| 830 | 830 | } | 
| 831 | 831 | } | 
| @@ -834,7 +834,7 @@ discard block | ||
| 834 | 834 |  		try { | 
| 835 | 835 | $sth = $Connection->db->prepare($query); | 
| 836 | 836 | $sth->execute(); | 
| 837 | -		} catch(PDOException $e) { | |
| 837 | +		} catch (PDOException $e) { | |
| 838 | 838 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 839 | 839 | } | 
| 840 | 840 | return $error; | 
| @@ -850,23 +850,23 @@ discard block | ||
| 850 | 850 |  			$error .= create_db::import_file('../db/pgsql/airlines.sql'); | 
| 851 | 851 | } | 
| 852 | 852 | if ($error != '') return 'Import airlines.sql : '.$error; | 
| 853 | -		if (!$Connection->checkColumnName('airlines','forsource')) { | |
| 853 | +		if (!$Connection->checkColumnName('airlines', 'forsource')) { | |
| 854 | 854 | // Add forsource to airlines | 
| 855 | 855 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; | 
| 856 | 856 |  			try { | 
| 857 | 857 | $sth = $Connection->db->prepare($query); | 
| 858 | 858 | $sth->execute(); | 
| 859 | -			} catch(PDOException $e) { | |
| 859 | +			} catch (PDOException $e) { | |
| 860 | 860 | return "error (add forsource column) : ".$e->getMessage()."\n"; | 
| 861 | 861 | } | 
| 862 | 862 | } | 
| 863 | -		if (!$Connection->checkColumnName('stats_aircraft','stats_airline')) { | |
| 863 | +		if (!$Connection->checkColumnName('stats_aircraft', 'stats_airline')) { | |
| 864 | 864 | // Add forsource to airlines | 
| 865 | 865 | $query = "ALTER TABLE stats_aircraft ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 866 | 866 |  			try { | 
| 867 | 867 | $sth = $Connection->db->prepare($query); | 
| 868 | 868 | $sth->execute(); | 
| 869 | -			} catch(PDOException $e) { | |
| 869 | +			} catch (PDOException $e) { | |
| 870 | 870 | return "error (add stats_airline & filter_name column in stats_aircraft) : ".$e->getMessage()."\n"; | 
| 871 | 871 | } | 
| 872 | 872 | // Add unique key | 
| @@ -878,17 +878,17 @@ discard block | ||
| 878 | 878 |  			try { | 
| 879 | 879 | $sth = $Connection->db->prepare($query); | 
| 880 | 880 | $sth->execute(); | 
| 881 | -			} catch(PDOException $e) { | |
| 881 | +			} catch (PDOException $e) { | |
| 882 | 882 | return "error (add unique key in stats_aircraft) : ".$e->getMessage()."\n"; | 
| 883 | 883 | } | 
| 884 | 884 | } | 
| 885 | -		if (!$Connection->checkColumnName('stats_airport','stats_airline')) { | |
| 885 | +		if (!$Connection->checkColumnName('stats_airport', 'stats_airline')) { | |
| 886 | 886 | // Add forsource to airlines | 
| 887 | 887 | $query = "ALTER TABLE stats_airport ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 888 | 888 |  			try { | 
| 889 | 889 | $sth = $Connection->db->prepare($query); | 
| 890 | 890 | $sth->execute(); | 
| 891 | -			} catch(PDOException $e) { | |
| 891 | +			} catch (PDOException $e) { | |
| 892 | 892 | return "error (add filter_name column in stats_airport) : ".$e->getMessage()."\n"; | 
| 893 | 893 | } | 
| 894 | 894 | // Add unique key | 
| @@ -900,17 +900,17 @@ discard block | ||
| 900 | 900 |  			try { | 
| 901 | 901 | $sth = $Connection->db->prepare($query); | 
| 902 | 902 | $sth->execute(); | 
| 903 | -			} catch(PDOException $e) { | |
| 903 | +			} catch (PDOException $e) { | |
| 904 | 904 | return "error (add unique key in stats_airport) : ".$e->getMessage()."\n"; | 
| 905 | 905 | } | 
| 906 | 906 | } | 
| 907 | -		if (!$Connection->checkColumnName('stats_country','stats_airline')) { | |
| 907 | +		if (!$Connection->checkColumnName('stats_country', 'stats_airline')) { | |
| 908 | 908 | // Add forsource to airlines | 
| 909 | 909 | $query = "ALTER TABLE stats_country ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 910 | 910 |  			try { | 
| 911 | 911 | $sth = $Connection->db->prepare($query); | 
| 912 | 912 | $sth->execute(); | 
| 913 | -			} catch(PDOException $e) { | |
| 913 | +			} catch (PDOException $e) { | |
| 914 | 914 | return "error (add stats_airline & filter_name column in stats_country) : ".$e->getMessage()."\n"; | 
| 915 | 915 | } | 
| 916 | 916 | // Add unique key | 
| @@ -922,36 +922,36 @@ discard block | ||
| 922 | 922 |  			try { | 
| 923 | 923 | $sth = $Connection->db->prepare($query); | 
| 924 | 924 | $sth->execute(); | 
| 925 | -			} catch(PDOException $e) { | |
| 925 | +			} catch (PDOException $e) { | |
| 926 | 926 | return "error (add unique key in stats_airline) : ".$e->getMessage()."\n"; | 
| 927 | 927 | } | 
| 928 | 928 | } | 
| 929 | -		if (!$Connection->checkColumnName('stats_flight','stats_airline')) { | |
| 929 | +		if (!$Connection->checkColumnName('stats_flight', 'stats_airline')) { | |
| 930 | 930 | // Add forsource to airlines | 
| 931 | 931 | $query = "ALTER TABLE stats_flight ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 932 | 932 |  			try { | 
| 933 | 933 | $sth = $Connection->db->prepare($query); | 
| 934 | 934 | $sth->execute(); | 
| 935 | -			} catch(PDOException $e) { | |
| 935 | +			} catch (PDOException $e) { | |
| 936 | 936 | return "error (add stats_airline & filter_name column in stats_flight) : ".$e->getMessage()."\n"; | 
| 937 | 937 | } | 
| 938 | 938 | } | 
| 939 | -		if (!$Connection->checkColumnName('stats','stats_airline')) { | |
| 939 | +		if (!$Connection->checkColumnName('stats', 'stats_airline')) { | |
| 940 | 940 | // Add forsource to airlines | 
| 941 | 941 | $query = "ALTER TABLE stats ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 942 | 942 |  			try { | 
| 943 | 943 | $sth = $Connection->db->prepare($query); | 
| 944 | 944 | $sth->execute(); | 
| 945 | -			} catch(PDOException $e) { | |
| 945 | +			} catch (PDOException $e) { | |
| 946 | 946 | return "error (add stats_airline & filter_name column in stats) : ".$e->getMessage()."\n"; | 
| 947 | 947 | } | 
| 948 | -			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats','type')) { | |
| 948 | +			if ($globalDBdriver == 'mysql' && $Connection->indexExists('stats', 'type')) { | |
| 949 | 949 | // Add unique key | 
| 950 | 950 | $query = "drop index type on stats;ALTER TABLE stats ADD UNIQUE stats_type (stats_type,stats_date,stats_airline,filter_name);"; | 
| 951 | 951 |  				try { | 
| 952 | 952 | $sth = $Connection->db->prepare($query); | 
| 953 | 953 | $sth->execute(); | 
| 954 | -				} catch(PDOException $e) { | |
| 954 | +				} catch (PDOException $e) { | |
| 955 | 955 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; | 
| 956 | 956 | } | 
| 957 | 957 |  			} else { | 
| @@ -964,18 +964,18 @@ discard block | ||
| 964 | 964 |  				try { | 
| 965 | 965 | $sth = $Connection->db->prepare($query); | 
| 966 | 966 | $sth->execute(); | 
| 967 | -				} catch(PDOException $e) { | |
| 967 | +				} catch (PDOException $e) { | |
| 968 | 968 | return "error (add unique key in stats) : ".$e->getMessage()."\n"; | 
| 969 | 969 | } | 
| 970 | 970 | } | 
| 971 | 971 | } | 
| 972 | -		if (!$Connection->checkColumnName('stats_registration','stats_airline')) { | |
| 972 | +		if (!$Connection->checkColumnName('stats_registration', 'stats_airline')) { | |
| 973 | 973 | // Add forsource to airlines | 
| 974 | 974 | $query = "ALTER TABLE stats_registration ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 975 | 975 |  			try { | 
| 976 | 976 | $sth = $Connection->db->prepare($query); | 
| 977 | 977 | $sth->execute(); | 
| 978 | -			} catch(PDOException $e) { | |
| 978 | +			} catch (PDOException $e) { | |
| 979 | 979 | return "error (add stats_airline & filter_name column in stats_registration) : ".$e->getMessage()."\n"; | 
| 980 | 980 | } | 
| 981 | 981 | // Add unique key | 
| @@ -987,17 +987,17 @@ discard block | ||
| 987 | 987 |  			try { | 
| 988 | 988 | $sth = $Connection->db->prepare($query); | 
| 989 | 989 | $sth->execute(); | 
| 990 | -			} catch(PDOException $e) { | |
| 990 | +			} catch (PDOException $e) { | |
| 991 | 991 | return "error (add unique key in stats_registration) : ".$e->getMessage()."\n"; | 
| 992 | 992 | } | 
| 993 | 993 | } | 
| 994 | -		if (!$Connection->checkColumnName('stats_callsign','filter_name')) { | |
| 994 | +		if (!$Connection->checkColumnName('stats_callsign', 'filter_name')) { | |
| 995 | 995 | // Add forsource to airlines | 
| 996 | 996 | $query = "ALTER TABLE stats_callsign ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 997 | 997 |  			try { | 
| 998 | 998 | $sth = $Connection->db->prepare($query); | 
| 999 | 999 | $sth->execute(); | 
| 1000 | -			} catch(PDOException $e) { | |
| 1000 | +			} catch (PDOException $e) { | |
| 1001 | 1001 | return "error (add filter_name column in stats_callsign) : ".$e->getMessage()."\n"; | 
| 1002 | 1002 | } | 
| 1003 | 1003 | // Add unique key | 
| @@ -1009,17 +1009,17 @@ discard block | ||
| 1009 | 1009 |  			try { | 
| 1010 | 1010 | $sth = $Connection->db->prepare($query); | 
| 1011 | 1011 | $sth->execute(); | 
| 1012 | -			} catch(PDOException $e) { | |
| 1012 | +			} catch (PDOException $e) { | |
| 1013 | 1013 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; | 
| 1014 | 1014 | } | 
| 1015 | 1015 | } | 
| 1016 | -		if (!$Connection->checkColumnName('stats_airline','filter_name')) { | |
| 1016 | +		if (!$Connection->checkColumnName('stats_airline', 'filter_name')) { | |
| 1017 | 1017 | // Add forsource to airlines | 
| 1018 | 1018 | $query = "ALTER TABLE stats_airline ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 1019 | 1019 |  			try { | 
| 1020 | 1020 | $sth = $Connection->db->prepare($query); | 
| 1021 | 1021 | $sth->execute(); | 
| 1022 | -			} catch(PDOException $e) { | |
| 1022 | +			} catch (PDOException $e) { | |
| 1023 | 1023 | return "error (add filter_name column in stats_airline) : ".$e->getMessage()."\n"; | 
| 1024 | 1024 | } | 
| 1025 | 1025 | // Add unique key | 
| @@ -1031,7 +1031,7 @@ discard block | ||
| 1031 | 1031 |  			try { | 
| 1032 | 1032 | $sth = $Connection->db->prepare($query); | 
| 1033 | 1033 | $sth->execute(); | 
| 1034 | -			} catch(PDOException $e) { | |
| 1034 | +			} catch (PDOException $e) { | |
| 1035 | 1035 | return "error (add unique key in stats_callsign) : ".$e->getMessage()."\n"; | 
| 1036 | 1036 | } | 
| 1037 | 1037 | } | 
| @@ -1040,7 +1040,7 @@ discard block | ||
| 1040 | 1040 |  		try { | 
| 1041 | 1041 | $sth = $Connection->db->prepare($query); | 
| 1042 | 1042 | $sth->execute(); | 
| 1043 | -		} catch(PDOException $e) { | |
| 1043 | +		} catch (PDOException $e) { | |
| 1044 | 1044 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1045 | 1045 | } | 
| 1046 | 1046 | return $error; | 
| @@ -1050,13 +1050,13 @@ discard block | ||
| 1050 | 1050 | global $globalDBdriver; | 
| 1051 | 1051 | $Connection = new Connection(); | 
| 1052 | 1052 | $error = ''; | 
| 1053 | -		if (!$Connection->checkColumnName('stats_owner','stats_airline')) { | |
| 1053 | +		if (!$Connection->checkColumnName('stats_owner', 'stats_airline')) { | |
| 1054 | 1054 | // Add forsource to airlines | 
| 1055 | 1055 | $query = "ALTER TABLE stats_owner ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 1056 | 1056 |  			try { | 
| 1057 | 1057 | $sth = $Connection->db->prepare($query); | 
| 1058 | 1058 | $sth->execute(); | 
| 1059 | -			} catch(PDOException $e) { | |
| 1059 | +			} catch (PDOException $e) { | |
| 1060 | 1060 | return "error (add stats_airline & filter_name column in stats_owner) : ".$e->getMessage()."\n"; | 
| 1061 | 1061 | } | 
| 1062 | 1062 | // Add unique key | 
| @@ -1068,17 +1068,17 @@ discard block | ||
| 1068 | 1068 |  			try { | 
| 1069 | 1069 | $sth = $Connection->db->prepare($query); | 
| 1070 | 1070 | $sth->execute(); | 
| 1071 | -			} catch(PDOException $e) { | |
| 1071 | +			} catch (PDOException $e) { | |
| 1072 | 1072 | return "error (add unique key in stats_owner) : ".$e->getMessage()."\n"; | 
| 1073 | 1073 | } | 
| 1074 | 1074 | } | 
| 1075 | -		if (!$Connection->checkColumnName('stats_pilot','stats_airline')) { | |
| 1075 | +		if (!$Connection->checkColumnName('stats_pilot', 'stats_airline')) { | |
| 1076 | 1076 | // Add forsource to airlines | 
| 1077 | 1077 | $query = "ALTER TABLE stats_pilot ADD stats_airline VARCHAR(255) NULL DEFAULT '', ADD filter_name VARCHAR(255) NULL DEFAULT ''"; | 
| 1078 | 1078 |  			try { | 
| 1079 | 1079 | $sth = $Connection->db->prepare($query); | 
| 1080 | 1080 | $sth->execute(); | 
| 1081 | -			} catch(PDOException $e) { | |
| 1081 | +			} catch (PDOException $e) { | |
| 1082 | 1082 | return "error (add stats_airline & filter_name column in stats_pilot) : ".$e->getMessage()."\n"; | 
| 1083 | 1083 | } | 
| 1084 | 1084 | // Add unique key | 
| @@ -1090,7 +1090,7 @@ discard block | ||
| 1090 | 1090 |  			try { | 
| 1091 | 1091 | $sth = $Connection->db->prepare($query); | 
| 1092 | 1092 | $sth->execute(); | 
| 1093 | -			} catch(PDOException $e) { | |
| 1093 | +			} catch (PDOException $e) { | |
| 1094 | 1094 | return "error (add unique key in stats_pilot) : ".$e->getMessage()."\n"; | 
| 1095 | 1095 | } | 
| 1096 | 1096 | } | 
| @@ -1098,7 +1098,7 @@ discard block | ||
| 1098 | 1098 |  		try { | 
| 1099 | 1099 | $sth = $Connection->db->prepare($query); | 
| 1100 | 1100 | $sth->execute(); | 
| 1101 | -		} catch(PDOException $e) { | |
| 1101 | +		} catch (PDOException $e) { | |
| 1102 | 1102 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1103 | 1103 | } | 
| 1104 | 1104 | return $error; | 
| @@ -1108,12 +1108,12 @@ discard block | ||
| 1108 | 1108 | global $globalDBdriver; | 
| 1109 | 1109 | $Connection = new Connection(); | 
| 1110 | 1110 | $error = ''; | 
| 1111 | -		if (!$Connection->checkColumnName('atc','format_source')) { | |
| 1111 | +		if (!$Connection->checkColumnName('atc', 'format_source')) { | |
| 1112 | 1112 | $query = "ALTER TABLE atc ADD format_source VARCHAR(255) DEFAULT NULL, ADD source_name VARCHAR(255) DEFAULT NULL"; | 
| 1113 | 1113 |  			try { | 
| 1114 | 1114 | $sth = $Connection->db->prepare($query); | 
| 1115 | 1115 | $sth->execute(); | 
| 1116 | -			} catch(PDOException $e) { | |
| 1116 | +			} catch (PDOException $e) { | |
| 1117 | 1117 | return "error (add format_source & source_name column in atc) : ".$e->getMessage()."\n"; | 
| 1118 | 1118 | } | 
| 1119 | 1119 | } | 
| @@ -1121,7 +1121,7 @@ discard block | ||
| 1121 | 1121 |  		try { | 
| 1122 | 1122 | $sth = $Connection->db->prepare($query); | 
| 1123 | 1123 | $sth->execute(); | 
| 1124 | -		} catch(PDOException $e) { | |
| 1124 | +		} catch (PDOException $e) { | |
| 1125 | 1125 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1126 | 1126 | } | 
| 1127 | 1127 | return $error; | 
| @@ -1131,13 +1131,13 @@ discard block | ||
| 1131 | 1131 | global $globalDBdriver; | 
| 1132 | 1132 | $Connection = new Connection(); | 
| 1133 | 1133 | $error = ''; | 
| 1134 | -		if (!$Connection->checkColumnName('stats_pilot','format_source')) { | |
| 1134 | +		if (!$Connection->checkColumnName('stats_pilot', 'format_source')) { | |
| 1135 | 1135 | // Add forsource to airlines | 
| 1136 | 1136 | $query = "ALTER TABLE stats_pilot ADD format_source VARCHAR(255) NULL DEFAULT ''"; | 
| 1137 | 1137 |  			try { | 
| 1138 | 1138 | $sth = $Connection->db->prepare($query); | 
| 1139 | 1139 | $sth->execute(); | 
| 1140 | -			} catch(PDOException $e) { | |
| 1140 | +			} catch (PDOException $e) { | |
| 1141 | 1141 | return "error (add format_source column in stats_pilot) : ".$e->getMessage()."\n"; | 
| 1142 | 1142 | } | 
| 1143 | 1143 | // Add unique key | 
| @@ -1149,7 +1149,7 @@ discard block | ||
| 1149 | 1149 |  			try { | 
| 1150 | 1150 | $sth = $Connection->db->prepare($query); | 
| 1151 | 1151 | $sth->execute(); | 
| 1152 | -			} catch(PDOException $e) { | |
| 1152 | +			} catch (PDOException $e) { | |
| 1153 | 1153 | return "error (modify unique key in stats_pilot) : ".$e->getMessage()."\n"; | 
| 1154 | 1154 | } | 
| 1155 | 1155 | } | 
| @@ -1157,7 +1157,7 @@ discard block | ||
| 1157 | 1157 |  		try { | 
| 1158 | 1158 | $sth = $Connection->db->prepare($query); | 
| 1159 | 1159 | $sth->execute(); | 
| 1160 | -		} catch(PDOException $e) { | |
| 1160 | +		} catch (PDOException $e) { | |
| 1161 | 1161 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1162 | 1162 | } | 
| 1163 | 1163 | return $error; | 
| @@ -1167,23 +1167,23 @@ discard block | ||
| 1167 | 1167 | global $globalDBdriver; | 
| 1168 | 1168 | $Connection = new Connection(); | 
| 1169 | 1169 | $error = ''; | 
| 1170 | -		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live','latitude')) { | |
| 1170 | +		if ($globalDBdriver == 'mysql' && !$Connection->indexExists('spotter_live', 'latitude')) { | |
| 1171 | 1171 | // Add unique key | 
| 1172 | 1172 | $query = "alter table spotter_live add index(latitude,longitude)"; | 
| 1173 | 1173 |  			try { | 
| 1174 | 1174 | $sth = $Connection->db->prepare($query); | 
| 1175 | 1175 | $sth->execute(); | 
| 1176 | -			} catch(PDOException $e) { | |
| 1176 | +			} catch (PDOException $e) { | |
| 1177 | 1177 | return "error (add index latitude,longitude on spotter_live) : ".$e->getMessage()."\n"; | 
| 1178 | 1178 | } | 
| 1179 | 1179 | } | 
| 1180 | -		if (!$Connection->checkColumnName('aircraft','mfr')) { | |
| 1180 | +		if (!$Connection->checkColumnName('aircraft', 'mfr')) { | |
| 1181 | 1181 | // Add mfr to aircraft | 
| 1182 | 1182 | $query = "ALTER TABLE aircraft ADD mfr VARCHAR(255) NULL"; | 
| 1183 | 1183 |  			try { | 
| 1184 | 1184 | $sth = $Connection->db->prepare($query); | 
| 1185 | 1185 | $sth->execute(); | 
| 1186 | -			} catch(PDOException $e) { | |
| 1186 | +			} catch (PDOException $e) { | |
| 1187 | 1187 | return "error (add mfr column in aircraft) : ".$e->getMessage()."\n"; | 
| 1188 | 1188 | } | 
| 1189 | 1189 | } | 
| @@ -1199,7 +1199,7 @@ discard block | ||
| 1199 | 1199 |  		try { | 
| 1200 | 1200 | $sth = $Connection->db->prepare($query); | 
| 1201 | 1201 | $sth->execute(); | 
| 1202 | -		} catch(PDOException $e) { | |
| 1202 | +		} catch (PDOException $e) { | |
| 1203 | 1203 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1204 | 1204 | } | 
| 1205 | 1205 | return $error; | 
| @@ -1209,13 +1209,13 @@ discard block | ||
| 1209 | 1209 | global $globalDBdriver; | 
| 1210 | 1210 | $Connection = new Connection(); | 
| 1211 | 1211 | $error = ''; | 
| 1212 | -		if ($Connection->checkColumnName('aircraft','mfr')) { | |
| 1212 | +		if ($Connection->checkColumnName('aircraft', 'mfr')) { | |
| 1213 | 1213 | // drop mfr to aircraft | 
| 1214 | 1214 | $query = "ALTER TABLE aircraft DROP COLUMN mfr"; | 
| 1215 | 1215 |  			try { | 
| 1216 | 1216 | $sth = $Connection->db->prepare($query); | 
| 1217 | 1217 | $sth->execute(); | 
| 1218 | -			} catch(PDOException $e) { | |
| 1218 | +			} catch (PDOException $e) { | |
| 1219 | 1219 | return "error (drop mfr column in aircraft) : ".$e->getMessage()."\n"; | 
| 1220 | 1220 | } | 
| 1221 | 1221 | } | 
| @@ -1231,7 +1231,7 @@ discard block | ||
| 1231 | 1231 |  		try { | 
| 1232 | 1232 | $sth = $Connection->db->prepare($query); | 
| 1233 | 1233 | $sth->execute(); | 
| 1234 | -		} catch(PDOException $e) { | |
| 1234 | +		} catch (PDOException $e) { | |
| 1235 | 1235 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1236 | 1236 | } | 
| 1237 | 1237 | return $error; | 
| @@ -1241,33 +1241,33 @@ discard block | ||
| 1241 | 1241 | global $globalDBdriver; | 
| 1242 | 1242 | $Connection = new Connection(); | 
| 1243 | 1243 | $error = ''; | 
| 1244 | -		if (!$Connection->indexExists('notam','ref_idx')) { | |
| 1244 | +		if (!$Connection->indexExists('notam', 'ref_idx')) { | |
| 1245 | 1245 | // Add index key | 
| 1246 | 1246 | $query = "create index ref_idx on notam (ref)"; | 
| 1247 | 1247 |  			try { | 
| 1248 | 1248 | $sth = $Connection->db->prepare($query); | 
| 1249 | 1249 | $sth->execute(); | 
| 1250 | -			} catch(PDOException $e) { | |
| 1250 | +			} catch (PDOException $e) { | |
| 1251 | 1251 | return "error (add index ref on notam) : ".$e->getMessage()."\n"; | 
| 1252 | 1252 | } | 
| 1253 | 1253 | } | 
| 1254 | -		if (!$Connection->indexExists('accidents','registration_idx')) { | |
| 1254 | +		if (!$Connection->indexExists('accidents', 'registration_idx')) { | |
| 1255 | 1255 | // Add index key | 
| 1256 | 1256 | $query = "create index registration_idx on accidents (registration)"; | 
| 1257 | 1257 |  			try { | 
| 1258 | 1258 | $sth = $Connection->db->prepare($query); | 
| 1259 | 1259 | $sth->execute(); | 
| 1260 | -			} catch(PDOException $e) { | |
| 1260 | +			} catch (PDOException $e) { | |
| 1261 | 1261 | return "error (add index registration on accidents) : ".$e->getMessage()."\n"; | 
| 1262 | 1262 | } | 
| 1263 | 1263 | } | 
| 1264 | -		if (!$Connection->indexExists('accidents','rdts')) { | |
| 1264 | +		if (!$Connection->indexExists('accidents', 'rdts')) { | |
| 1265 | 1265 | // Add index key | 
| 1266 | 1266 | $query = "create index rdts on accidents (registration,date,type,source)"; | 
| 1267 | 1267 |  			try { | 
| 1268 | 1268 | $sth = $Connection->db->prepare($query); | 
| 1269 | 1269 | $sth->execute(); | 
| 1270 | -			} catch(PDOException $e) { | |
| 1270 | +			} catch (PDOException $e) { | |
| 1271 | 1271 | return "error (add index registration, date, type & source on accidents) : ".$e->getMessage()."\n"; | 
| 1272 | 1272 | } | 
| 1273 | 1273 | } | 
| @@ -1276,7 +1276,7 @@ discard block | ||
| 1276 | 1276 |  		try { | 
| 1277 | 1277 | $sth = $Connection->db->prepare($query); | 
| 1278 | 1278 | $sth->execute(); | 
| 1279 | -		} catch(PDOException $e) { | |
| 1279 | +		} catch (PDOException $e) { | |
| 1280 | 1280 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1281 | 1281 | } | 
| 1282 | 1282 | return $error; | 
| @@ -1286,23 +1286,23 @@ discard block | ||
| 1286 | 1286 | global $globalDBdriver; | 
| 1287 | 1287 | $Connection = new Connection(); | 
| 1288 | 1288 | $error = ''; | 
| 1289 | -		if (!$Connection->checkColumnName('accidents','airline_name')) { | |
| 1289 | +		if (!$Connection->checkColumnName('accidents', 'airline_name')) { | |
| 1290 | 1290 | // Add airline_name to accidents | 
| 1291 | 1291 | $query = "ALTER TABLE accidents ADD airline_name VARCHAR(255) NULL"; | 
| 1292 | 1292 |  			try { | 
| 1293 | 1293 | $sth = $Connection->db->prepare($query); | 
| 1294 | 1294 | $sth->execute(); | 
| 1295 | -			} catch(PDOException $e) { | |
| 1295 | +			} catch (PDOException $e) { | |
| 1296 | 1296 | return "error (add airline_name column in accidents) : ".$e->getMessage()."\n"; | 
| 1297 | 1297 | } | 
| 1298 | 1298 | } | 
| 1299 | -		if (!$Connection->checkColumnName('accidents','airline_icao')) { | |
| 1299 | +		if (!$Connection->checkColumnName('accidents', 'airline_icao')) { | |
| 1300 | 1300 | // Add airline_icao to accidents | 
| 1301 | 1301 | $query = "ALTER TABLE accidents ADD airline_icao VARCHAR(10) NULL"; | 
| 1302 | 1302 |  			try { | 
| 1303 | 1303 | $sth = $Connection->db->prepare($query); | 
| 1304 | 1304 | $sth->execute(); | 
| 1305 | -			} catch(PDOException $e) { | |
| 1305 | +			} catch (PDOException $e) { | |
| 1306 | 1306 | return "error (add airline_icao column in accidents) : ".$e->getMessage()."\n"; | 
| 1307 | 1307 | } | 
| 1308 | 1308 | } | 
| @@ -1310,7 +1310,7 @@ discard block | ||
| 1310 | 1310 |  		try { | 
| 1311 | 1311 | $sth = $Connection->db->prepare($query); | 
| 1312 | 1312 | $sth->execute(); | 
| 1313 | -		} catch(PDOException $e) { | |
| 1313 | +		} catch (PDOException $e) { | |
| 1314 | 1314 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1315 | 1315 | } | 
| 1316 | 1316 | return $error; | 
| @@ -1320,13 +1320,13 @@ discard block | ||
| 1320 | 1320 | global $globalDBdriver, $globalVATSIM, $globalIVAO; | 
| 1321 | 1321 | $Connection = new Connection(); | 
| 1322 | 1322 | $error = ''; | 
| 1323 | -		if (!$Connection->checkColumnName('airlines','alliance')) { | |
| 1323 | +		if (!$Connection->checkColumnName('airlines', 'alliance')) { | |
| 1324 | 1324 | // Add alliance to airlines | 
| 1325 | 1325 | $query = "ALTER TABLE airlines ADD alliance VARCHAR(255) NULL"; | 
| 1326 | 1326 |  			try { | 
| 1327 | 1327 | $sth = $Connection->db->prepare($query); | 
| 1328 | 1328 | $sth->execute(); | 
| 1329 | -			} catch(PDOException $e) { | |
| 1329 | +			} catch (PDOException $e) { | |
| 1330 | 1330 | return "error (add alliance column in airlines) : ".$e->getMessage()."\n"; | 
| 1331 | 1331 | } | 
| 1332 | 1332 | } | 
| @@ -1353,7 +1353,7 @@ discard block | ||
| 1353 | 1353 |  		try { | 
| 1354 | 1354 | $sth = $Connection->db->prepare($query); | 
| 1355 | 1355 | $sth->execute(); | 
| 1356 | -		} catch(PDOException $e) { | |
| 1356 | +		} catch (PDOException $e) { | |
| 1357 | 1357 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1358 | 1358 | } | 
| 1359 | 1359 | return $error; | 
| @@ -1363,13 +1363,13 @@ discard block | ||
| 1363 | 1363 | global $globalDBdriver, $globalVATSIM, $globalIVAO; | 
| 1364 | 1364 | $Connection = new Connection(); | 
| 1365 | 1365 | $error = ''; | 
| 1366 | -		if (!$Connection->checkColumnName('airlines','ban_eu')) { | |
| 1366 | +		if (!$Connection->checkColumnName('airlines', 'ban_eu')) { | |
| 1367 | 1367 | // Add ban_eu to airlines | 
| 1368 | 1368 | $query = "ALTER TABLE airlines ADD ban_eu INTEGER NOT NULL DEFAULT '0'"; | 
| 1369 | 1369 |  			try { | 
| 1370 | 1370 | $sth = $Connection->db->prepare($query); | 
| 1371 | 1371 | $sth->execute(); | 
| 1372 | -			} catch(PDOException $e) { | |
| 1372 | +			} catch (PDOException $e) { | |
| 1373 | 1373 | return "error (add ban_eu column in airlines) : ".$e->getMessage()."\n"; | 
| 1374 | 1374 | } | 
| 1375 | 1375 | } | 
| @@ -1377,7 +1377,7 @@ discard block | ||
| 1377 | 1377 |  		try { | 
| 1378 | 1378 | $sth = $Connection->db->prepare($query); | 
| 1379 | 1379 | $sth->execute(); | 
| 1380 | -		} catch(PDOException $e) { | |
| 1380 | +		} catch (PDOException $e) { | |
| 1381 | 1381 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1382 | 1382 | } | 
| 1383 | 1383 | return $error; | 
| @@ -1388,19 +1388,19 @@ discard block | ||
| 1388 | 1388 | $Connection = new Connection(); | 
| 1389 | 1389 | $error = ''; | 
| 1390 | 1390 |  		if ($globalDBdriver == 'mysql') { | 
| 1391 | -			if ($Connection->getColumnType('spotter_output','date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output','last_seen') != 'TIMESTAMP') { | |
| 1391 | +			if ($Connection->getColumnType('spotter_output', 'date') == 'TIMESTAMP' && $Connection->getColumnType('spotter_output', 'last_seen') != 'TIMESTAMP') { | |
| 1392 | 1392 | $query = "ALTER TABLE spotter_output CHANGE date date TIMESTAMP NULL DEFAULT NULL"; | 
| 1393 | 1393 |  				try { | 
| 1394 | 1394 | $sth = $Connection->db->prepare($query); | 
| 1395 | 1395 | $sth->execute(); | 
| 1396 | -				} catch(PDOException $e) { | |
| 1396 | +				} catch (PDOException $e) { | |
| 1397 | 1397 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; | 
| 1398 | 1398 | } | 
| 1399 | 1399 | $query = "ALTER TABLE spotter_output MODIFY COLUMN last_seen timestamp not null default current_timestamp()"; | 
| 1400 | 1400 |  				try { | 
| 1401 | 1401 | $sth = $Connection->db->prepare($query); | 
| 1402 | 1402 | $sth->execute(); | 
| 1403 | -				} catch(PDOException $e) { | |
| 1403 | +				} catch (PDOException $e) { | |
| 1404 | 1404 | return "error (convert spotter_output last_seen to timestamp) : ".$e->getMessage()."\n"; | 
| 1405 | 1405 | } | 
| 1406 | 1406 | |
| @@ -1408,7 +1408,7 @@ discard block | ||
| 1408 | 1408 |  				try { | 
| 1409 | 1409 | $sth = $Connection->db->prepare($query); | 
| 1410 | 1410 | $sth->execute(); | 
| 1411 | -				} catch(PDOException $e) { | |
| 1411 | +				} catch (PDOException $e) { | |
| 1412 | 1412 | return "error (delete default timestamp spotter_output) : ".$e->getMessage()."\n"; | 
| 1413 | 1413 | } | 
| 1414 | 1414 | /*$query = "SELECT date,last_seen FROM spotter_output WHERE last_seen < date ORDER BY date DESC LIMIT 150"; | 
| @@ -1459,7 +1459,7 @@ discard block | ||
| 1459 | 1459 |  				try { | 
| 1460 | 1460 | $sth = $Connection->db->prepare($query); | 
| 1461 | 1461 | $sth->execute(); | 
| 1462 | -				} catch(PDOException $e) { | |
| 1462 | +				} catch (PDOException $e) { | |
| 1463 | 1463 | return "error (fix date) : ".$e->getMessage()."\n"; | 
| 1464 | 1464 | } | 
| 1465 | 1465 | } | 
| @@ -1544,7 +1544,7 @@ discard block | ||
| 1544 | 1544 |  		try { | 
| 1545 | 1545 | $sth = $Connection->db->prepare($query); | 
| 1546 | 1546 | $sth->execute(); | 
| 1547 | -		} catch(PDOException $e) { | |
| 1547 | +		} catch (PDOException $e) { | |
| 1548 | 1548 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1549 | 1549 | } | 
| 1550 | 1550 | return $error; | 
| @@ -1553,13 +1553,13 @@ discard block | ||
| 1553 | 1553 | global $globalDBdriver; | 
| 1554 | 1554 | $Connection = new Connection(); | 
| 1555 | 1555 | $error = ''; | 
| 1556 | -		if (!$Connection->indexExists('accidents','type')) { | |
| 1556 | +		if (!$Connection->indexExists('accidents', 'type')) { | |
| 1557 | 1557 | // Add index key | 
| 1558 | 1558 | $query = "create index type on accidents (type,date)"; | 
| 1559 | 1559 |  			try { | 
| 1560 | 1560 | $sth = $Connection->db->prepare($query); | 
| 1561 | 1561 | $sth->execute(); | 
| 1562 | -			} catch(PDOException $e) { | |
| 1562 | +			} catch (PDOException $e) { | |
| 1563 | 1563 | return "error (add index type on accidents) : ".$e->getMessage()."\n"; | 
| 1564 | 1564 | } | 
| 1565 | 1565 | } | 
| @@ -1567,7 +1567,7 @@ discard block | ||
| 1567 | 1567 |  		try { | 
| 1568 | 1568 | $sth = $Connection->db->prepare($query); | 
| 1569 | 1569 | $sth->execute(); | 
| 1570 | -		} catch(PDOException $e) { | |
| 1570 | +		} catch (PDOException $e) { | |
| 1571 | 1571 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1572 | 1572 | } | 
| 1573 | 1573 | return $error; | 
| @@ -1577,12 +1577,12 @@ discard block | ||
| 1577 | 1577 | global $globalDBdriver; | 
| 1578 | 1578 | $Connection = new Connection(); | 
| 1579 | 1579 | $error = ''; | 
| 1580 | -		if (!$Connection->checkColumnName('aircraft_modes','source_type')) { | |
| 1580 | +		if (!$Connection->checkColumnName('aircraft_modes', 'source_type')) { | |
| 1581 | 1581 | $query = "ALTER TABLE aircraft_modes ADD source_type VARCHAR(255) DEFAULT 'modes'"; | 
| 1582 | 1582 |  			try { | 
| 1583 | 1583 | $sth = $Connection->db->prepare($query); | 
| 1584 | 1584 | $sth->execute(); | 
| 1585 | -			} catch(PDOException $e) { | |
| 1585 | +			} catch (PDOException $e) { | |
| 1586 | 1586 | return "error (add source_type column in aircraft_modes) : ".$e->getMessage()."\n"; | 
| 1587 | 1587 | } | 
| 1588 | 1588 | } | 
| @@ -1648,7 +1648,7 @@ discard block | ||
| 1648 | 1648 |  		try { | 
| 1649 | 1649 | $sth = $Connection->db->prepare($query); | 
| 1650 | 1650 | $sth->execute(); | 
| 1651 | -		} catch(PDOException $e) { | |
| 1651 | +		} catch (PDOException $e) { | |
| 1652 | 1652 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1653 | 1653 | } | 
| 1654 | 1654 | return $error; | 
| @@ -1696,7 +1696,7 @@ discard block | ||
| 1696 | 1696 |  			try { | 
| 1697 | 1697 | $sth = $Connection->db->prepare($query); | 
| 1698 | 1698 | $sth->execute(); | 
| 1699 | -			} catch(PDOException $e) { | |
| 1699 | +			} catch (PDOException $e) { | |
| 1700 | 1700 | return "error (problem when select engine for spotter_engine) : ".$e->getMessage()."\n"; | 
| 1701 | 1701 | } | 
| 1702 | 1702 | $row = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -1705,18 +1705,18 @@ discard block | ||
| 1705 | 1705 |  				try { | 
| 1706 | 1706 | $sth = $Connection->db->prepare($query); | 
| 1707 | 1707 | $sth->execute(); | 
| 1708 | -				} catch(PDOException $e) { | |
| 1708 | +				} catch (PDOException $e) { | |
| 1709 | 1709 | return "error (Change table format from archive to InnoDB for spotter_archive) : ".$e->getMessage()."\n"; | 
| 1710 | 1710 | } | 
| 1711 | 1711 | } | 
| 1712 | 1712 | } | 
| 1713 | -		if (!$Connection->indexExists('spotter_archive','flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive','flightaware_id')) { | |
| 1713 | +		if (!$Connection->indexExists('spotter_archive', 'flightaware_id_date_idx') && !$Connection->indexExists('spotter_archive', 'flightaware_id')) { | |
| 1714 | 1714 | // Add index key | 
| 1715 | 1715 | $query = "create index flightaware_id_date_idx on spotter_archive (flightaware_id,date)"; | 
| 1716 | 1716 |  			try { | 
| 1717 | 1717 | $sth = $Connection->db->prepare($query); | 
| 1718 | 1718 | $sth->execute(); | 
| 1719 | -			} catch(PDOException $e) { | |
| 1719 | +			} catch (PDOException $e) { | |
| 1720 | 1720 | return "error (add index flightaware_id, date on spotter_archive) : ".$e->getMessage()."\n"; | 
| 1721 | 1721 | } | 
| 1722 | 1722 | } | 
| @@ -1724,7 +1724,7 @@ discard block | ||
| 1724 | 1724 |  		try { | 
| 1725 | 1725 | $sth = $Connection->db->prepare($query); | 
| 1726 | 1726 | $sth->execute(); | 
| 1727 | -		} catch(PDOException $e) { | |
| 1727 | +		} catch (PDOException $e) { | |
| 1728 | 1728 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1729 | 1729 | } | 
| 1730 | 1730 | return $error; | 
| @@ -1735,148 +1735,148 @@ discard block | ||
| 1735 | 1735 | $Connection = new Connection(); | 
| 1736 | 1736 | $error = ''; | 
| 1737 | 1737 |  		if ($globalDBdriver == 'mysql') { | 
| 1738 | -			if (!$Connection->checkColumnName('marine_output','type_id')) { | |
| 1738 | +			if (!$Connection->checkColumnName('marine_output', 'type_id')) { | |
| 1739 | 1739 | $query = "ALTER TABLE marine_output ADD COLUMN type_id int(11) DEFAULT NULL"; | 
| 1740 | 1740 |  				try { | 
| 1741 | 1741 | $sth = $Connection->db->prepare($query); | 
| 1742 | 1742 | $sth->execute(); | 
| 1743 | -				} catch(PDOException $e) { | |
| 1743 | +				} catch (PDOException $e) { | |
| 1744 | 1744 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; | 
| 1745 | 1745 | } | 
| 1746 | 1746 | } | 
| 1747 | -			if (!$Connection->checkColumnName('marine_live','type_id')) { | |
| 1747 | +			if (!$Connection->checkColumnName('marine_live', 'type_id')) { | |
| 1748 | 1748 | $query = "ALTER TABLE marine_live ADD COLUMN type_id int(11) DEFAULT NULL"; | 
| 1749 | 1749 |  				try { | 
| 1750 | 1750 | $sth = $Connection->db->prepare($query); | 
| 1751 | 1751 | $sth->execute(); | 
| 1752 | -				} catch(PDOException $e) { | |
| 1752 | +				} catch (PDOException $e) { | |
| 1753 | 1753 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; | 
| 1754 | 1754 | } | 
| 1755 | 1755 | } | 
| 1756 | -			if (!$Connection->checkColumnName('marine_archive','type_id')) { | |
| 1756 | +			if (!$Connection->checkColumnName('marine_archive', 'type_id')) { | |
| 1757 | 1757 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id int(11) DEFAULT NULL"; | 
| 1758 | 1758 |  				try { | 
| 1759 | 1759 | $sth = $Connection->db->prepare($query); | 
| 1760 | 1760 | $sth->execute(); | 
| 1761 | -				} catch(PDOException $e) { | |
| 1761 | +				} catch (PDOException $e) { | |
| 1762 | 1762 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; | 
| 1763 | 1763 | } | 
| 1764 | 1764 | } | 
| 1765 | -			if (!$Connection->checkColumnName('marine_archive_output','type_id')) { | |
| 1765 | +			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { | |
| 1766 | 1766 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id int(11) DEFAULT NULL"; | 
| 1767 | 1767 |  				try { | 
| 1768 | 1768 | $sth = $Connection->db->prepare($query); | 
| 1769 | 1769 | $sth->execute(); | 
| 1770 | -				} catch(PDOException $e) { | |
| 1770 | +				} catch (PDOException $e) { | |
| 1771 | 1771 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; | 
| 1772 | 1772 | } | 
| 1773 | 1773 | } | 
| 1774 | -			if (!$Connection->checkColumnName('marine_output','status_id')) { | |
| 1774 | +			if (!$Connection->checkColumnName('marine_output', 'status_id')) { | |
| 1775 | 1775 | $query = "ALTER TABLE marine_output ADD COLUMN status_id int(11) DEFAULT NULL"; | 
| 1776 | 1776 |  				try { | 
| 1777 | 1777 | $sth = $Connection->db->prepare($query); | 
| 1778 | 1778 | $sth->execute(); | 
| 1779 | -				} catch(PDOException $e) { | |
| 1779 | +				} catch (PDOException $e) { | |
| 1780 | 1780 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; | 
| 1781 | 1781 | } | 
| 1782 | 1782 | } | 
| 1783 | -			if (!$Connection->checkColumnName('marine_live','status_id')) { | |
| 1783 | +			if (!$Connection->checkColumnName('marine_live', 'status_id')) { | |
| 1784 | 1784 | $query = "ALTER TABLE marine_live ADD COLUMN status_id int(11) DEFAULT NULL"; | 
| 1785 | 1785 |  				try { | 
| 1786 | 1786 | $sth = $Connection->db->prepare($query); | 
| 1787 | 1787 | $sth->execute(); | 
| 1788 | -				} catch(PDOException $e) { | |
| 1788 | +				} catch (PDOException $e) { | |
| 1789 | 1789 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; | 
| 1790 | 1790 | } | 
| 1791 | 1791 | } | 
| 1792 | -			if (!$Connection->checkColumnName('marine_archive','status_id')) { | |
| 1792 | +			if (!$Connection->checkColumnName('marine_archive', 'status_id')) { | |
| 1793 | 1793 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id int(11) DEFAULT NULL"; | 
| 1794 | 1794 |  				try { | 
| 1795 | 1795 | $sth = $Connection->db->prepare($query); | 
| 1796 | 1796 | $sth->execute(); | 
| 1797 | -				} catch(PDOException $e) { | |
| 1797 | +				} catch (PDOException $e) { | |
| 1798 | 1798 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; | 
| 1799 | 1799 | } | 
| 1800 | 1800 | } | 
| 1801 | -			if (!$Connection->checkColumnName('marine_archive_output','status_id')) { | |
| 1801 | +			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { | |
| 1802 | 1802 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id int(11) DEFAULT NULL"; | 
| 1803 | 1803 |  				try { | 
| 1804 | 1804 | $sth = $Connection->db->prepare($query); | 
| 1805 | 1805 | $sth->execute(); | 
| 1806 | -				} catch(PDOException $e) { | |
| 1806 | +				} catch (PDOException $e) { | |
| 1807 | 1807 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; | 
| 1808 | 1808 | } | 
| 1809 | 1809 | } | 
| 1810 | 1810 |  		} else { | 
| 1811 | -			if (!$Connection->checkColumnName('marine_output','type_id')) { | |
| 1811 | +			if (!$Connection->checkColumnName('marine_output', 'type_id')) { | |
| 1812 | 1812 | $query = "ALTER TABLE marine_output ADD COLUMN type_id integer DEFAULT NULL"; | 
| 1813 | 1813 |  				try { | 
| 1814 | 1814 | $sth = $Connection->db->prepare($query); | 
| 1815 | 1815 | $sth->execute(); | 
| 1816 | -				} catch(PDOException $e) { | |
| 1816 | +				} catch (PDOException $e) { | |
| 1817 | 1817 | return "error (add column type_id in marine_output) : ".$e->getMessage()."\n"; | 
| 1818 | 1818 | } | 
| 1819 | 1819 | } | 
| 1820 | -			if (!$Connection->checkColumnName('marine_live','type_id')) { | |
| 1820 | +			if (!$Connection->checkColumnName('marine_live', 'type_id')) { | |
| 1821 | 1821 | $query = "ALTER TABLE marine_live ADD COLUMN type_id integer DEFAULT NULL"; | 
| 1822 | 1822 |  				try { | 
| 1823 | 1823 | $sth = $Connection->db->prepare($query); | 
| 1824 | 1824 | $sth->execute(); | 
| 1825 | -				} catch(PDOException $e) { | |
| 1825 | +				} catch (PDOException $e) { | |
| 1826 | 1826 | return "error (add column type_id in marine_live) : ".$e->getMessage()."\n"; | 
| 1827 | 1827 | } | 
| 1828 | 1828 | } | 
| 1829 | -			if (!$Connection->checkColumnName('marine_archive','type_id')) { | |
| 1829 | +			if (!$Connection->checkColumnName('marine_archive', 'type_id')) { | |
| 1830 | 1830 | $query = "ALTER TABLE marine_archive ADD COLUMN type_id integer DEFAULT NULL"; | 
| 1831 | 1831 |  				try { | 
| 1832 | 1832 | $sth = $Connection->db->prepare($query); | 
| 1833 | 1833 | $sth->execute(); | 
| 1834 | -				} catch(PDOException $e) { | |
| 1834 | +				} catch (PDOException $e) { | |
| 1835 | 1835 | return "error (add column type_id in marine_archive) : ".$e->getMessage()."\n"; | 
| 1836 | 1836 | } | 
| 1837 | 1837 | } | 
| 1838 | -			if (!$Connection->checkColumnName('marine_archive_output','type_id')) { | |
| 1838 | +			if (!$Connection->checkColumnName('marine_archive_output', 'type_id')) { | |
| 1839 | 1839 | $query = "ALTER TABLE marine_archive_output ADD COLUMN type_id integer DEFAULT NULL"; | 
| 1840 | 1840 |  				try { | 
| 1841 | 1841 | $sth = $Connection->db->prepare($query); | 
| 1842 | 1842 | $sth->execute(); | 
| 1843 | -				} catch(PDOException $e) { | |
| 1843 | +				} catch (PDOException $e) { | |
| 1844 | 1844 | return "error (add column type_id in marine_archive_output) : ".$e->getMessage()."\n"; | 
| 1845 | 1845 | } | 
| 1846 | 1846 | } | 
| 1847 | -			if (!$Connection->checkColumnName('marine_output','status_id')) { | |
| 1847 | +			if (!$Connection->checkColumnName('marine_output', 'status_id')) { | |
| 1848 | 1848 | $query = "ALTER TABLE marine_output ADD COLUMN status_id integer DEFAULT NULL"; | 
| 1849 | 1849 |  				try { | 
| 1850 | 1850 | $sth = $Connection->db->prepare($query); | 
| 1851 | 1851 | $sth->execute(); | 
| 1852 | -				} catch(PDOException $e) { | |
| 1852 | +				} catch (PDOException $e) { | |
| 1853 | 1853 | return "error (add column status_id in marine_output) : ".$e->getMessage()."\n"; | 
| 1854 | 1854 | } | 
| 1855 | 1855 | } | 
| 1856 | -			if (!$Connection->checkColumnName('marine_live','status_id')) { | |
| 1856 | +			if (!$Connection->checkColumnName('marine_live', 'status_id')) { | |
| 1857 | 1857 | $query = "ALTER TABLE marine_live ADD COLUMN status_id integer DEFAULT NULL"; | 
| 1858 | 1858 |  				try { | 
| 1859 | 1859 | $sth = $Connection->db->prepare($query); | 
| 1860 | 1860 | $sth->execute(); | 
| 1861 | -				} catch(PDOException $e) { | |
| 1861 | +				} catch (PDOException $e) { | |
| 1862 | 1862 | return "error (add column status_id in marine_live) : ".$e->getMessage()."\n"; | 
| 1863 | 1863 | } | 
| 1864 | 1864 | } | 
| 1865 | -			if (!$Connection->checkColumnName('marine_archive','status_id')) { | |
| 1865 | +			if (!$Connection->checkColumnName('marine_archive', 'status_id')) { | |
| 1866 | 1866 | $query = "ALTER TABLE marine_archive ADD COLUMN status_id integer DEFAULT NULL"; | 
| 1867 | 1867 |  				try { | 
| 1868 | 1868 | $sth = $Connection->db->prepare($query); | 
| 1869 | 1869 | $sth->execute(); | 
| 1870 | -				} catch(PDOException $e) { | |
| 1870 | +				} catch (PDOException $e) { | |
| 1871 | 1871 | return "error (add column status_id in marine_archive) : ".$e->getMessage()."\n"; | 
| 1872 | 1872 | } | 
| 1873 | 1873 | } | 
| 1874 | -			if (!$Connection->checkColumnName('marine_archive_output','status_id')) { | |
| 1874 | +			if (!$Connection->checkColumnName('marine_archive_output', 'status_id')) { | |
| 1875 | 1875 | $query = "ALTER TABLE marine_archive_output ADD COLUMN status_id integer DEFAULT NULL"; | 
| 1876 | 1876 |  				try { | 
| 1877 | 1877 | $sth = $Connection->db->prepare($query); | 
| 1878 | 1878 | $sth->execute(); | 
| 1879 | -				} catch(PDOException $e) { | |
| 1879 | +				} catch (PDOException $e) { | |
| 1880 | 1880 | return "error (add column status_id in marine_archive_output) : ".$e->getMessage()."\n"; | 
| 1881 | 1881 | } | 
| 1882 | 1882 | } | 
| @@ -1885,7 +1885,7 @@ discard block | ||
| 1885 | 1885 |  		try { | 
| 1886 | 1886 | $sth = $Connection->db->prepare($query); | 
| 1887 | 1887 | $sth->execute(); | 
| 1888 | -		} catch(PDOException $e) { | |
| 1888 | +		} catch (PDOException $e) { | |
| 1889 | 1889 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1890 | 1890 | } | 
| 1891 | 1891 | return $error; | 
| @@ -1900,14 +1900,14 @@ discard block | ||
| 1900 | 1900 |  			try { | 
| 1901 | 1901 | $sth = $Connection->db->prepare($query); | 
| 1902 | 1902 | $sth->execute(); | 
| 1903 | -			} catch(PDOException $e) { | |
| 1903 | +			} catch (PDOException $e) { | |
| 1904 | 1904 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; | 
| 1905 | 1905 | } | 
| 1906 | 1906 | $query = "ALTER TABLE marine_identity MODIFY COLUMN mmsi varchar(255) DEFAULT NULL"; | 
| 1907 | 1907 |  			try { | 
| 1908 | 1908 | $sth = $Connection->db->prepare($query); | 
| 1909 | 1909 | $sth->execute(); | 
| 1910 | -			} catch(PDOException $e) { | |
| 1910 | +			} catch (PDOException $e) { | |
| 1911 | 1911 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; | 
| 1912 | 1912 | } | 
| 1913 | 1913 |  		} else { | 
| @@ -1915,14 +1915,14 @@ discard block | ||
| 1915 | 1915 |  			try { | 
| 1916 | 1916 | $sth = $Connection->db->prepare($query); | 
| 1917 | 1917 | $sth->execute(); | 
| 1918 | -			} catch(PDOException $e) { | |
| 1918 | +			} catch (PDOException $e) { | |
| 1919 | 1919 | return "error (change pilot_id type to varchar in stats_pilot) : ".$e->getMessage()."\n"; | 
| 1920 | 1920 | } | 
| 1921 | 1921 | $query = "alter table marine_identity alter column mmsi type varchar(255)"; | 
| 1922 | 1922 |  			try { | 
| 1923 | 1923 | $sth = $Connection->db->prepare($query); | 
| 1924 | 1924 | $sth->execute(); | 
| 1925 | -			} catch(PDOException $e) { | |
| 1925 | +			} catch (PDOException $e) { | |
| 1926 | 1926 | return "error (change mmsi type to varchar in marine_identity) : ".$e->getMessage()."\n"; | 
| 1927 | 1927 | } | 
| 1928 | 1928 | } | 
| @@ -1930,7 +1930,7 @@ discard block | ||
| 1930 | 1930 |  		try { | 
| 1931 | 1931 | $sth = $Connection->db->prepare($query); | 
| 1932 | 1932 | $sth->execute(); | 
| 1933 | -		} catch(PDOException $e) { | |
| 1933 | +		} catch (PDOException $e) { | |
| 1934 | 1934 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1935 | 1935 | } | 
| 1936 | 1936 | return $error; | 
| @@ -1940,32 +1940,32 @@ discard block | ||
| 1940 | 1940 | global $globalDBdriver; | 
| 1941 | 1941 | $Connection = new Connection(); | 
| 1942 | 1942 | $error = ''; | 
| 1943 | -		if (!$Connection->checkColumnName('source_location','last_seen')) { | |
| 1943 | +		if (!$Connection->checkColumnName('source_location', 'last_seen')) { | |
| 1944 | 1944 | $query = "ALTER TABLE source_location ADD COLUMN last_seen timestamp NULL DEFAULT NULL"; | 
| 1945 | 1945 |  			try { | 
| 1946 | 1946 | $sth = $Connection->db->prepare($query); | 
| 1947 | 1947 | $sth->execute(); | 
| 1948 | -			} catch(PDOException $e) { | |
| 1948 | +			} catch (PDOException $e) { | |
| 1949 | 1949 | return "error (add column last_seen in source_location) : ".$e->getMessage()."\n"; | 
| 1950 | 1950 | } | 
| 1951 | 1951 | } | 
| 1952 | 1952 |  		if ($globalDBdriver == 'mysql') { | 
| 1953 | -			if (!$Connection->checkColumnName('source_location','location_id')) { | |
| 1953 | +			if (!$Connection->checkColumnName('source_location', 'location_id')) { | |
| 1954 | 1954 | $query = "ALTER TABLE source_location ADD COLUMN location_id int(11) DEFAULT NULL"; | 
| 1955 | 1955 |  				try { | 
| 1956 | 1956 | $sth = $Connection->db->prepare($query); | 
| 1957 | 1957 | $sth->execute(); | 
| 1958 | -				} catch(PDOException $e) { | |
| 1958 | +				} catch (PDOException $e) { | |
| 1959 | 1959 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; | 
| 1960 | 1960 | } | 
| 1961 | 1961 | } | 
| 1962 | 1962 |  		} else { | 
| 1963 | -			if (!$Connection->checkColumnName('source_location','location_id')) { | |
| 1963 | +			if (!$Connection->checkColumnName('source_location', 'location_id')) { | |
| 1964 | 1964 | $query = "ALTER TABLE source_location ADD COLUMN location_id integer DEFAULT NULL"; | 
| 1965 | 1965 |  				try { | 
| 1966 | 1966 | $sth = $Connection->db->prepare($query); | 
| 1967 | 1967 | $sth->execute(); | 
| 1968 | -				} catch(PDOException $e) { | |
| 1968 | +				} catch (PDOException $e) { | |
| 1969 | 1969 | return "error (add column location_id in source_location) : ".$e->getMessage()."\n"; | 
| 1970 | 1970 | } | 
| 1971 | 1971 | } | 
| @@ -1974,7 +1974,7 @@ discard block | ||
| 1974 | 1974 |  		try { | 
| 1975 | 1975 | $sth = $Connection->db->prepare($query); | 
| 1976 | 1976 | $sth->execute(); | 
| 1977 | -		} catch(PDOException $e) { | |
| 1977 | +		} catch (PDOException $e) { | |
| 1978 | 1978 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 1979 | 1979 | } | 
| 1980 | 1980 | return $error; | 
| @@ -1984,12 +1984,12 @@ discard block | ||
| 1984 | 1984 | global $globalDBdriver; | 
| 1985 | 1985 | $Connection = new Connection(); | 
| 1986 | 1986 | $error = ''; | 
| 1987 | -		if (!$Connection->checkColumnName('source_location','description')) { | |
| 1987 | +		if (!$Connection->checkColumnName('source_location', 'description')) { | |
| 1988 | 1988 | $query = "ALTER TABLE source_location ADD COLUMN description text DEFAULT NULL"; | 
| 1989 | 1989 |  			try { | 
| 1990 | 1990 | $sth = $Connection->db->prepare($query); | 
| 1991 | 1991 | $sth->execute(); | 
| 1992 | -			} catch(PDOException $e) { | |
| 1992 | +			} catch (PDOException $e) { | |
| 1993 | 1993 | return "error (add column description in source_location) : ".$e->getMessage()."\n"; | 
| 1994 | 1994 | } | 
| 1995 | 1995 | } | 
| @@ -1997,7 +1997,7 @@ discard block | ||
| 1997 | 1997 |  		try { | 
| 1998 | 1998 | $sth = $Connection->db->prepare($query); | 
| 1999 | 1999 | $sth->execute(); | 
| 2000 | -		} catch(PDOException $e) { | |
| 2000 | +		} catch (PDOException $e) { | |
| 2001 | 2001 | return "error (update schema_version) : ".$e->getMessage()."\n"; | 
| 2002 | 2002 | } | 
| 2003 | 2003 | return $error; | 
| @@ -2020,7 +2020,7 @@ discard block | ||
| 2020 | 2020 |  		    try { | 
| 2021 | 2021 | $sth = $Connection->db->prepare($query); | 
| 2022 | 2022 | $sth->execute(); | 
| 2023 | -		    } catch(PDOException $e) { | |
| 2023 | +		    } catch (PDOException $e) { | |
| 2024 | 2024 | return "error : ".$e->getMessage()."\n"; | 
| 2025 | 2025 | } | 
| 2026 | 2026 | $result = $sth->fetch(PDO::FETCH_ASSOC); | 
| @@ -258,7 +258,9 @@ discard block | ||
| 258 | 258 | // Update table countries | 
| 259 | 259 |      		if ($Connection->tableExists('airspace')) { | 
| 260 | 260 | $error .= update_db::update_countries(); | 
| 261 | - if ($error != '') return $error; | |
| 261 | +		    if ($error != '') { | |
| 262 | + return $error; | |
| 263 | + } | |
| 262 | 264 | } | 
| 263 | 265 | // Update schema_version to 7 | 
| 264 | 266 | $query = "UPDATE `config` SET `value` = '7' WHERE `name` = 'schema_version'"; | 
| @@ -314,7 +316,9 @@ discard block | ||
| 314 | 316 | $error = ''; | 
| 315 | 317 | // Update table aircraft | 
| 316 | 318 |  		$error .= create_db::import_file('../db/source_location.sql'); | 
| 317 | - if ($error != '') return $error; | |
| 319 | +		if ($error != '') { | |
| 320 | + return $error; | |
| 321 | + } | |
| 318 | 322 | // Update schema_version to 6 | 
| 319 | 323 | $query = "UPDATE `config` SET `value` = '8' WHERE `name` = 'schema_version'"; | 
| 320 | 324 |          	try { | 
| @@ -331,7 +335,9 @@ discard block | ||
| 331 | 335 | $error = ''; | 
| 332 | 336 | // Update table aircraft | 
| 333 | 337 |  		$error .= create_db::import_file('../db/notam.sql'); | 
| 334 | - if ($error != '') return $error; | |
| 338 | +		if ($error != '') { | |
| 339 | + return $error; | |
| 340 | + } | |
| 335 | 341 | $query = "DELETE FROM config WHERE name = 'last_update_db'; | 
| 336 | 342 |                          INSERT INTO config (name,value) VALUES ('last_update_db',NOW()); | 
| 337 | 343 | DELETE FROM config WHERE name = 'last_update_notam_db'; | 
| @@ -365,7 +371,9 @@ discard block | ||
| 365 | 371 | $error = ''; | 
| 366 | 372 | // Update table atc | 
| 367 | 373 |  		$error .= create_db::import_file('../db/atc.sql'); | 
| 368 | - if ($error != '') return $error; | |
| 374 | +		if ($error != '') { | |
| 375 | + return $error; | |
| 376 | + } | |
| 369 | 377 | |
| 370 | 378 | $query = "UPDATE `config` SET `value` = '10' WHERE `name` = 'schema_version'"; | 
| 371 | 379 |          	try { | 
| @@ -389,13 +397,21 @@ discard block | ||
| 389 | 397 | $error = ''; | 
| 390 | 398 | // Add tables | 
| 391 | 399 |  		$error .= create_db::import_file('../db/aircraft_owner.sql'); | 
| 392 | - if ($error != '') return $error; | |
| 400 | +		if ($error != '') { | |
| 401 | + return $error; | |
| 402 | + } | |
| 393 | 403 |  		$error .= create_db::import_file('../db/metar.sql'); | 
| 394 | - if ($error != '') return $error; | |
| 404 | +		if ($error != '') { | |
| 405 | + return $error; | |
| 406 | + } | |
| 395 | 407 |  		$error .= create_db::import_file('../db/taf.sql'); | 
| 396 | - if ($error != '') return $error; | |
| 408 | +		if ($error != '') { | |
| 409 | + return $error; | |
| 410 | + } | |
| 397 | 411 |  		$error .= create_db::import_file('../db/airport.sql'); | 
| 398 | - if ($error != '') return $error; | |
| 412 | +		if ($error != '') { | |
| 413 | + return $error; | |
| 414 | + } | |
| 399 | 415 | |
| 400 | 416 | $query = "UPDATE `config` SET `value` = '11' WHERE `name` = 'schema_version'"; | 
| 401 | 417 |          	try { | 
| @@ -469,19 +485,33 @@ discard block | ||
| 469 | 485 | $error = ''; | 
| 470 | 486 | // Add tables | 
| 471 | 487 |  		$error .= create_db::import_file('../db/stats.sql'); | 
| 472 | - if ($error != '') return $error; | |
| 488 | +		if ($error != '') { | |
| 489 | + return $error; | |
| 490 | + } | |
| 473 | 491 |  		$error .= create_db::import_file('../db/stats_aircraft.sql'); | 
| 474 | - if ($error != '') return $error; | |
| 492 | +		if ($error != '') { | |
| 493 | + return $error; | |
| 494 | + } | |
| 475 | 495 |  		$error .= create_db::import_file('../db/stats_airline.sql'); | 
| 476 | - if ($error != '') return $error; | |
| 496 | +		if ($error != '') { | |
| 497 | + return $error; | |
| 498 | + } | |
| 477 | 499 |  		$error .= create_db::import_file('../db/stats_airport.sql'); | 
| 478 | - if ($error != '') return $error; | |
| 500 | +		if ($error != '') { | |
| 501 | + return $error; | |
| 502 | + } | |
| 479 | 503 |  		$error .= create_db::import_file('../db/stats_owner.sql'); | 
| 480 | - if ($error != '') return $error; | |
| 504 | +		if ($error != '') { | |
| 505 | + return $error; | |
| 506 | + } | |
| 481 | 507 |  		$error .= create_db::import_file('../db/stats_pilot.sql'); | 
| 482 | - if ($error != '') return $error; | |
| 508 | +		if ($error != '') { | |
| 509 | + return $error; | |
| 510 | + } | |
| 483 | 511 |  		$error .= create_db::import_file('../db/spotter_archive_output.sql'); | 
| 484 | - if ($error != '') return $error; | |
| 512 | +		if ($error != '') { | |
| 513 | + return $error; | |
| 514 | + } | |
| 485 | 515 | |
| 486 | 516 | $query = "UPDATE `config` SET `value` = '13' WHERE `name` = 'schema_version'"; | 
| 487 | 517 |          	try { | 
| @@ -521,7 +551,9 @@ discard block | ||
| 521 | 551 | // Add tables | 
| 522 | 552 |      		if (!$Connection->tableExists('stats_flight')) { | 
| 523 | 553 |  			$error .= create_db::import_file('../db/stats_flight.sql'); | 
| 524 | - if ($error != '') return $error; | |
| 554 | +			if ($error != '') { | |
| 555 | + return $error; | |
| 556 | + } | |
| 525 | 557 | } | 
| 526 | 558 | $query = "UPDATE `config` SET `value` = '15' WHERE `name` = 'schema_version'"; | 
| 527 | 559 |          	try { | 
| @@ -545,7 +577,9 @@ discard block | ||
| 545 | 577 |      		} catch(PDOException $e) { | 
| 546 | 578 | return "error (update stats) : ".$e->getMessage()."\n"; | 
| 547 | 579 | } | 
| 548 | - if ($error != '') return $error; | |
| 580 | +		if ($error != '') { | |
| 581 | + return $error; | |
| 582 | + } | |
| 549 | 583 | $query = "UPDATE `config` SET `value` = '16' WHERE `name` = 'schema_version'"; | 
| 550 | 584 |          	try { | 
| 551 | 585 | $sth = $Connection->db->prepare($query); | 
| @@ -566,7 +600,9 @@ discard block | ||
| 566 | 600 |      		if (!$Connection->tableExists('stats_callsign')) { | 
| 567 | 601 |  			$error .= create_db::import_file('../db/stats_callsign.sql'); | 
| 568 | 602 | } | 
| 569 | - if ($error != '') return $error; | |
| 603 | +		if ($error != '') { | |
| 604 | + return $error; | |
| 605 | + } | |
| 570 | 606 | $query = "UPDATE `config` SET `value` = '17' WHERE `name` = 'schema_version'"; | 
| 571 | 607 |          	try { | 
| 572 | 608 | $sth = $Connection->db->prepare($query); | 
| @@ -584,7 +620,9 @@ discard block | ||
| 584 | 620 |      		if (!$Connection->tableExists('stats_country')) { | 
| 585 | 621 |  			$error .= create_db::import_file('../db/stats_country.sql'); | 
| 586 | 622 | } | 
| 587 | - if ($error != '') return $error; | |
| 623 | +		if ($error != '') { | |
| 624 | + return $error; | |
| 625 | + } | |
| 588 | 626 | $query = "UPDATE `config` SET `value` = '18' WHERE `name` = 'schema_version'"; | 
| 589 | 627 |          	try { | 
| 590 | 628 | $sth = $Connection->db->prepare($query); | 
| @@ -607,7 +645,9 @@ discard block | ||
| 607 | 645 | return "error (update stats) : ".$e->getMessage()."\n"; | 
| 608 | 646 | } | 
| 609 | 647 | } | 
| 610 | - if ($error != '') return $error; | |
| 648 | +		if ($error != '') { | |
| 649 | + return $error; | |
| 650 | + } | |
| 611 | 651 | $query = "UPDATE `config` SET `value` = '19' WHERE `name` = 'schema_version'"; | 
| 612 | 652 |          	try { | 
| 613 | 653 | $sth = $Connection->db->prepare($query); | 
| @@ -623,7 +663,9 @@ discard block | ||
| 623 | 663 | $error = ''; | 
| 624 | 664 | // Update airport table | 
| 625 | 665 |  		$error .= create_db::import_file('../db/airport.sql'); | 
| 626 | - if ($error != '') return 'Import airport.sql : '.$error; | |
| 666 | +		if ($error != '') { | |
| 667 | + return 'Import airport.sql : '.$error; | |
| 668 | + } | |
| 627 | 669 | // Remove primary key on Spotter_Archive | 
| 628 | 670 | $query = "alter table spotter_archive drop spotter_archive_id"; | 
| 629 | 671 |          	try { | 
| @@ -699,7 +741,9 @@ discard block | ||
| 699 | 741 | return "error (add source_name column) : ".$e->getMessage()."\n"; | 
| 700 | 742 | } | 
| 701 | 743 | } | 
| 702 | - if ($error != '') return $error; | |
| 744 | +		if ($error != '') { | |
| 745 | + return $error; | |
| 746 | + } | |
| 703 | 747 | $query = "UPDATE `config` SET `value` = '20' WHERE `name` = 'schema_version'"; | 
| 704 | 748 |          	try { | 
| 705 | 749 | $sth = $Connection->db->prepare($query); | 
| @@ -717,7 +761,9 @@ discard block | ||
| 717 | 761 | // Update airline table | 
| 718 | 762 |      		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { | 
| 719 | 763 |  			$error .= create_db::import_file('../db/airlines.sql'); | 
| 720 | - if ($error != '') return 'Import airlines.sql : '.$error; | |
| 764 | +			if ($error != '') { | |
| 765 | + return 'Import airlines.sql : '.$error; | |
| 766 | + } | |
| 721 | 767 | } | 
| 722 | 768 |  		if (!$Connection->checkColumnName('aircraft_modes','type_flight')) { | 
| 723 | 769 | // Add column over_country | 
| @@ -729,7 +775,9 @@ discard block | ||
| 729 | 775 | return "error (add over_country) : ".$e->getMessage()."\n"; | 
| 730 | 776 | } | 
| 731 | 777 | } | 
| 732 | - if ($error != '') return $error; | |
| 778 | +		if ($error != '') { | |
| 779 | + return $error; | |
| 780 | + } | |
| 733 | 781 | /* | 
| 734 | 782 |      		if (!$globalIVAO && !$globalVATSIM && !$globalphpVMS) { | 
| 735 | 783 | // Force update ModeS (this will put type_flight data | 
| @@ -759,7 +807,9 @@ discard block | ||
| 759 | 807 |  			} catch(PDOException $e) { | 
| 760 | 808 | return "error (rename type to stats_type on stats*) : ".$e->getMessage()."\n"; | 
| 761 | 809 | } | 
| 762 | - if ($error != '') return $error; | |
| 810 | +			if ($error != '') { | |
| 811 | + return $error; | |
| 812 | + } | |
| 763 | 813 | } | 
| 764 | 814 | $query = "UPDATE `config` SET `value` = '22' WHERE `name` = 'schema_version'"; | 
| 765 | 815 |          	try { | 
| @@ -782,7 +832,9 @@ discard block | ||
| 782 | 832 |  			} else { | 
| 783 | 833 |  				$error .= create_db::import_file('../db/pgsql/stats_source.sql'); | 
| 784 | 834 | } | 
| 785 | - if ($error != '') return $error; | |
| 835 | +			if ($error != '') { | |
| 836 | + return $error; | |
| 837 | + } | |
| 786 | 838 | } | 
| 787 | 839 | $query = "UPDATE config SET value = '23' WHERE name = 'schema_version'"; | 
| 788 | 840 |          	try { | 
| @@ -804,12 +856,16 @@ discard block | ||
| 804 | 856 |  		if ($globalDBdriver == 'mysql') { | 
| 805 | 857 |  			if (!$Connection->tableExists('tle')) { | 
| 806 | 858 |  				$error .= create_db::import_file('../db/tle.sql'); | 
| 807 | - if ($error != '') return $error; | |
| 859 | +				if ($error != '') { | |
| 860 | + return $error; | |
| 861 | + } | |
| 808 | 862 | } | 
| 809 | 863 |  		} else { | 
| 810 | 864 |  			if (!$Connection->tableExists('tle')) { | 
| 811 | 865 |  				$error .= create_db::import_file('../db/pgsql/tle.sql'); | 
| 812 | - if ($error != '') return $error; | |
| 866 | +				if ($error != '') { | |
| 867 | + return $error; | |
| 868 | + } | |
| 813 | 869 | } | 
| 814 | 870 | $query = "create index flightaware_id_idx ON spotter_archive USING btree(flightaware_id)"; | 
| 815 | 871 |  			try { | 
| @@ -849,7 +905,9 @@ discard block | ||
| 849 | 905 |  		} else { | 
| 850 | 906 |  			$error .= create_db::import_file('../db/pgsql/airlines.sql'); | 
| 851 | 907 | } | 
| 852 | - if ($error != '') return 'Import airlines.sql : '.$error; | |
| 908 | +		if ($error != '') { | |
| 909 | + return 'Import airlines.sql : '.$error; | |
| 910 | + } | |
| 853 | 911 |  		if (!$Connection->checkColumnName('airlines','forsource')) { | 
| 854 | 912 | // Add forsource to airlines | 
| 855 | 913 | $query = "ALTER TABLE airlines ADD forsource VARCHAR(255) NULL DEFAULT NULL"; | 
| @@ -1332,20 +1390,28 @@ discard block | ||
| 1332 | 1390 | } | 
| 1333 | 1391 |  		if ($globalDBdriver == 'mysql') { | 
| 1334 | 1392 |  			$error .= create_db::import_file('../db/airlines.sql'); | 
| 1335 | - if ($error != '') return $error; | |
| 1393 | +			if ($error != '') { | |
| 1394 | + return $error; | |
| 1395 | + } | |
| 1336 | 1396 |  		} else { | 
| 1337 | 1397 |  			$error .= create_db::import_file('../db/pgsql/airlines.sql'); | 
| 1338 | - if ($error != '') return $error; | |
| 1398 | +			if ($error != '') { | |
| 1399 | + return $error; | |
| 1400 | + } | |
| 1339 | 1401 | } | 
| 1340 | 1402 |  		if ((isset($globalVATSIM) && $globalVATSIM) || (isset($globalIVAO) && $globalIVAO)) { | 
| 1341 | 1403 | include_once(dirname(__FILE__).'/class.update_db.php'); | 
| 1342 | 1404 |  			if (isset($globalVATSIM) && $globalVATSIM) { | 
| 1343 | 1405 | $error .= update_db::update_vatsim(); | 
| 1344 | - if ($error != '') return $error; | |
| 1406 | +				if ($error != '') { | |
| 1407 | + return $error; | |
| 1408 | + } | |
| 1345 | 1409 | } | 
| 1346 | 1410 |  			if (isset($globalIVAO) && $globalIVAO && file_exists('tmp/ivae_feb2013.zip')) { | 
| 1347 | 1411 | $error .= update_db::update_IVAO(); | 
| 1348 | - if ($error != '') return $error; | |
| 1412 | +				if ($error != '') { | |
| 1413 | + return $error; | |
| 1414 | + } | |
| 1349 | 1415 | } | 
| 1350 | 1416 | } | 
| 1351 | 1417 | |
| @@ -1608,41 +1674,65 @@ discard block | ||
| 1608 | 1674 |  		if ($globalDBdriver == 'mysql') { | 
| 1609 | 1675 |  			if (!$Connection->tableExists('tracker_output')) { | 
| 1610 | 1676 |  				$error .= create_db::import_file('../db/tracker_output.sql'); | 
| 1611 | - if ($error != '') return $error; | |
| 1677 | +				if ($error != '') { | |
| 1678 | + return $error; | |
| 1679 | + } | |
| 1612 | 1680 | } | 
| 1613 | 1681 |  			if (!$Connection->tableExists('tracker_live')) { | 
| 1614 | 1682 |  				$error .= create_db::import_file('../db/tracker_live.sql'); | 
| 1615 | - if ($error != '') return $error; | |
| 1683 | +				if ($error != '') { | |
| 1684 | + return $error; | |
| 1685 | + } | |
| 1616 | 1686 | } | 
| 1617 | 1687 |  			if (!$Connection->tableExists('marine_output')) { | 
| 1618 | 1688 |  				$error .= create_db::import_file('../db/marine_output.sql'); | 
| 1619 | - if ($error != '') return $error; | |
| 1689 | +				if ($error != '') { | |
| 1690 | + return $error; | |
| 1691 | + } | |
| 1620 | 1692 | } | 
| 1621 | 1693 |  			if (!$Connection->tableExists('marine_live')) { | 
| 1622 | 1694 |  				$error .= create_db::import_file('../db/marine_live.sql'); | 
| 1623 | - if ($error != '') return $error; | |
| 1695 | +				if ($error != '') { | |
| 1696 | + return $error; | |
| 1697 | + } | |
| 1624 | 1698 | } | 
| 1625 | 1699 |  			if (!$Connection->tableExists('marine_identity')) { | 
| 1626 | 1700 |  				$error .= create_db::import_file('../db/marine_identity.sql'); | 
| 1627 | - if ($error != '') return $error; | |
| 1701 | +				if ($error != '') { | |
| 1702 | + return $error; | |
| 1703 | + } | |
| 1628 | 1704 | } | 
| 1629 | 1705 |  			if (!$Connection->tableExists('marine_mid')) { | 
| 1630 | 1706 |  				$error .= create_db::import_file('../db/marine_mid.sql'); | 
| 1631 | - if ($error != '') return $error; | |
| 1707 | +				if ($error != '') { | |
| 1708 | + return $error; | |
| 1709 | + } | |
| 1632 | 1710 | } | 
| 1633 | 1711 |  		} else { | 
| 1634 | 1712 |  			$error .= create_db::import_file('../db/pgsql/tracker_output.sql'); | 
| 1635 | - if ($error != '') return $error; | |
| 1713 | +			if ($error != '') { | |
| 1714 | + return $error; | |
| 1715 | + } | |
| 1636 | 1716 |  			$error .= create_db::import_file('../db/pgsql/tracker_live.sql'); | 
| 1637 | - if ($error != '') return $error; | |
| 1717 | +			if ($error != '') { | |
| 1718 | + return $error; | |
| 1719 | + } | |
| 1638 | 1720 |  			$error .= create_db::import_file('../db/pgsql/marine_output.sql'); | 
| 1639 | - if ($error != '') return $error; | |
| 1721 | +			if ($error != '') { | |
| 1722 | + return $error; | |
| 1723 | + } | |
| 1640 | 1724 |  			$error .= create_db::import_file('../db/pgsql/marine_live.sql'); | 
| 1641 | - if ($error != '') return $error; | |
| 1725 | +			if ($error != '') { | |
| 1726 | + return $error; | |
| 1727 | + } | |
| 1642 | 1728 |  			$error .= create_db::import_file('../db/pgsql/marine_identity.sql'); | 
| 1643 | - if ($error != '') return $error; | |
| 1729 | +			if ($error != '') { | |
| 1730 | + return $error; | |
| 1731 | + } | |
| 1644 | 1732 |  			$error .= create_db::import_file('../db/pgsql/marine_mid.sql'); | 
| 1645 | - if ($error != '') return $error; | |
| 1733 | +			if ($error != '') { | |
| 1734 | + return $error; | |
| 1735 | + } | |
| 1646 | 1736 | } | 
| 1647 | 1737 | $query = "UPDATE config SET value = '37' WHERE name = 'schema_version'"; | 
| 1648 | 1738 |  		try { | 
| @@ -1661,35 +1751,55 @@ discard block | ||
| 1661 | 1751 |  		if ($globalDBdriver == 'mysql') { | 
| 1662 | 1752 |  			if (!$Connection->tableExists('marine_image')) { | 
| 1663 | 1753 |  				$error .= create_db::import_file('../db/marine_image.sql'); | 
| 1664 | - if ($error != '') return $error; | |
| 1754 | +				if ($error != '') { | |
| 1755 | + return $error; | |
| 1756 | + } | |
| 1665 | 1757 | } | 
| 1666 | 1758 |  			if (!$Connection->tableExists('marine_archive')) { | 
| 1667 | 1759 |  				$error .= create_db::import_file('../db/marine_archive.sql'); | 
| 1668 | - if ($error != '') return $error; | |
| 1760 | +				if ($error != '') { | |
| 1761 | + return $error; | |
| 1762 | + } | |
| 1669 | 1763 | } | 
| 1670 | 1764 |  			if (!$Connection->tableExists('marine_archive_output')) { | 
| 1671 | 1765 |  				$error .= create_db::import_file('../db/marine_archive_output.sql'); | 
| 1672 | - if ($error != '') return $error; | |
| 1766 | +				if ($error != '') { | |
| 1767 | + return $error; | |
| 1768 | + } | |
| 1673 | 1769 | } | 
| 1674 | 1770 |  			if (!$Connection->tableExists('tracker_archive')) { | 
| 1675 | 1771 |  				$error .= create_db::import_file('../db/tracker_archive.sql'); | 
| 1676 | - if ($error != '') return $error; | |
| 1772 | +				if ($error != '') { | |
| 1773 | + return $error; | |
| 1774 | + } | |
| 1677 | 1775 | } | 
| 1678 | 1776 |  			if (!$Connection->tableExists('marine_archive_output')) { | 
| 1679 | 1777 |  				$error .= create_db::import_file('../db/tracker_archive_output.sql'); | 
| 1680 | - if ($error != '') return $error; | |
| 1778 | +				if ($error != '') { | |
| 1779 | + return $error; | |
| 1780 | + } | |
| 1681 | 1781 | } | 
| 1682 | 1782 |  		} else { | 
| 1683 | 1783 |  			$error .= create_db::import_file('../db/pgsql/marine_image.sql'); | 
| 1684 | - if ($error != '') return $error; | |
| 1784 | +			if ($error != '') { | |
| 1785 | + return $error; | |
| 1786 | + } | |
| 1685 | 1787 |  			$error .= create_db::import_file('../db/pgsql/marine_archive.sql'); | 
| 1686 | - if ($error != '') return $error; | |
| 1788 | +			if ($error != '') { | |
| 1789 | + return $error; | |
| 1790 | + } | |
| 1687 | 1791 |  			$error .= create_db::import_file('../db/pgsql/marine_archive_output.sql'); | 
| 1688 | - if ($error != '') return $error; | |
| 1792 | +			if ($error != '') { | |
| 1793 | + return $error; | |
| 1794 | + } | |
| 1689 | 1795 |  			$error .= create_db::import_file('../db/pgsql/tracker_archive.sql'); | 
| 1690 | - if ($error != '') return $error; | |
| 1796 | +			if ($error != '') { | |
| 1797 | + return $error; | |
| 1798 | + } | |
| 1691 | 1799 |  			$error .= create_db::import_file('../db/pgsql/tracker_archive_output.sql'); | 
| 1692 | - if ($error != '') return $error; | |
| 1800 | +			if ($error != '') { | |
| 1801 | + return $error; | |
| 1802 | + } | |
| 1693 | 1803 | } | 
| 1694 | 1804 |  		if ($globalDBdriver == 'mysql') { | 
| 1695 | 1805 | $query = "SELECT ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '".$globalDBname."' AND TABLE_NAME = 'spotter_archive'"; | 
| @@ -2012,8 +2122,11 @@ discard block | ||
| 2012 | 2122 |      	    if ($Connection->tableExists('aircraft')) { | 
| 2013 | 2123 |      		if (!$Connection->tableExists('config')) { | 
| 2014 | 2124 | $version = '1'; | 
| 2015 | - if ($update) return self::update_from_1(); | |
| 2016 | - else return $version; | |
| 2125 | +    		    if ($update) { | |
| 2126 | + return self::update_from_1(); | |
| 2127 | +    		    } else { | |
| 2128 | + return $version; | |
| 2129 | + } | |
| 2017 | 2130 |  		} else { | 
| 2018 | 2131 | $Connection = new Connection(); | 
| 2019 | 2132 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; | 
| @@ -2027,170 +2140,295 @@ discard block | ||
| 2027 | 2140 |      		    if ($update) { | 
| 2028 | 2141 |      			if ($result['value'] == '2') { | 
| 2029 | 2142 | $error = self::update_from_2(); | 
| 2030 | - if ($error != '') return $error; | |
| 2031 | - else return self::check_version(true); | |
| 2143 | +    			    if ($error != '') { | |
| 2144 | + return $error; | |
| 2145 | +    			    } else { | |
| 2146 | + return self::check_version(true); | |
| 2147 | + } | |
| 2032 | 2148 |      			} elseif ($result['value'] == '3') { | 
| 2033 | 2149 | $error = self::update_from_3(); | 
| 2034 | - if ($error != '') return $error; | |
| 2035 | - else return self::check_version(true); | |
| 2150 | +    			    if ($error != '') { | |
| 2151 | + return $error; | |
| 2152 | +    			    } else { | |
| 2153 | + return self::check_version(true); | |
| 2154 | + } | |
| 2036 | 2155 |      			} elseif ($result['value'] == '4') { | 
| 2037 | 2156 | $error = self::update_from_4(); | 
| 2038 | - if ($error != '') return $error; | |
| 2039 | - else return self::check_version(true); | |
| 2157 | +    			    if ($error != '') { | |
| 2158 | + return $error; | |
| 2159 | +    			    } else { | |
| 2160 | + return self::check_version(true); | |
| 2161 | + } | |
| 2040 | 2162 |      			} elseif ($result['value'] == '5') { | 
| 2041 | 2163 | $error = self::update_from_5(); | 
| 2042 | - if ($error != '') return $error; | |
| 2043 | - else return self::check_version(true); | |
| 2164 | +    			    if ($error != '') { | |
| 2165 | + return $error; | |
| 2166 | +    			    } else { | |
| 2167 | + return self::check_version(true); | |
| 2168 | + } | |
| 2044 | 2169 |      			} elseif ($result['value'] == '6') { | 
| 2045 | 2170 | $error = self::update_from_6(); | 
| 2046 | - if ($error != '') return $error; | |
| 2047 | - else return self::check_version(true); | |
| 2171 | +    			    if ($error != '') { | |
| 2172 | + return $error; | |
| 2173 | +    			    } else { | |
| 2174 | + return self::check_version(true); | |
| 2175 | + } | |
| 2048 | 2176 |      			} elseif ($result['value'] == '7') { | 
| 2049 | 2177 | $error = self::update_from_7(); | 
| 2050 | - if ($error != '') return $error; | |
| 2051 | - else return self::check_version(true); | |
| 2178 | +    			    if ($error != '') { | |
| 2179 | + return $error; | |
| 2180 | +    			    } else { | |
| 2181 | + return self::check_version(true); | |
| 2182 | + } | |
| 2052 | 2183 |      			} elseif ($result['value'] == '8') { | 
| 2053 | 2184 | $error = self::update_from_8(); | 
| 2054 | - if ($error != '') return $error; | |
| 2055 | - else return self::check_version(true); | |
| 2185 | +    			    if ($error != '') { | |
| 2186 | + return $error; | |
| 2187 | +    			    } else { | |
| 2188 | + return self::check_version(true); | |
| 2189 | + } | |
| 2056 | 2190 |      			} elseif ($result['value'] == '9') { | 
| 2057 | 2191 | $error = self::update_from_9(); | 
| 2058 | - if ($error != '') return $error; | |
| 2059 | - else return self::check_version(true); | |
| 2192 | +    			    if ($error != '') { | |
| 2193 | + return $error; | |
| 2194 | +    			    } else { | |
| 2195 | + return self::check_version(true); | |
| 2196 | + } | |
| 2060 | 2197 |      			} elseif ($result['value'] == '10') { | 
| 2061 | 2198 | $error = self::update_from_10(); | 
| 2062 | - if ($error != '') return $error; | |
| 2063 | - else return self::check_version(true); | |
| 2199 | +    			    if ($error != '') { | |
| 2200 | + return $error; | |
| 2201 | +    			    } else { | |
| 2202 | + return self::check_version(true); | |
| 2203 | + } | |
| 2064 | 2204 |      			} elseif ($result['value'] == '11') { | 
| 2065 | 2205 | $error = self::update_from_11(); | 
| 2066 | - if ($error != '') return $error; | |
| 2067 | - else return self::check_version(true); | |
| 2206 | +    			    if ($error != '') { | |
| 2207 | + return $error; | |
| 2208 | +    			    } else { | |
| 2209 | + return self::check_version(true); | |
| 2210 | + } | |
| 2068 | 2211 |      			} elseif ($result['value'] == '12') { | 
| 2069 | 2212 | $error = self::update_from_12(); | 
| 2070 | - if ($error != '') return $error; | |
| 2071 | - else return self::check_version(true); | |
| 2213 | +    			    if ($error != '') { | |
| 2214 | + return $error; | |
| 2215 | +    			    } else { | |
| 2216 | + return self::check_version(true); | |
| 2217 | + } | |
| 2072 | 2218 |      			} elseif ($result['value'] == '13') { | 
| 2073 | 2219 | $error = self::update_from_13(); | 
| 2074 | - if ($error != '') return $error; | |
| 2075 | - else return self::check_version(true); | |
| 2220 | +    			    if ($error != '') { | |
| 2221 | + return $error; | |
| 2222 | +    			    } else { | |
| 2223 | + return self::check_version(true); | |
| 2224 | + } | |
| 2076 | 2225 |      			} elseif ($result['value'] == '14') { | 
| 2077 | 2226 | $error = self::update_from_14(); | 
| 2078 | - if ($error != '') return $error; | |
| 2079 | - else return self::check_version(true); | |
| 2227 | +    			    if ($error != '') { | |
| 2228 | + return $error; | |
| 2229 | +    			    } else { | |
| 2230 | + return self::check_version(true); | |
| 2231 | + } | |
| 2080 | 2232 |      			} elseif ($result['value'] == '15') { | 
| 2081 | 2233 | $error = self::update_from_15(); | 
| 2082 | - if ($error != '') return $error; | |
| 2083 | - else return self::check_version(true); | |
| 2234 | +    			    if ($error != '') { | |
| 2235 | + return $error; | |
| 2236 | +    			    } else { | |
| 2237 | + return self::check_version(true); | |
| 2238 | + } | |
| 2084 | 2239 |      			} elseif ($result['value'] == '16') { | 
| 2085 | 2240 | $error = self::update_from_16(); | 
| 2086 | - if ($error != '') return $error; | |
| 2087 | - else return self::check_version(true); | |
| 2241 | +    			    if ($error != '') { | |
| 2242 | + return $error; | |
| 2243 | +    			    } else { | |
| 2244 | + return self::check_version(true); | |
| 2245 | + } | |
| 2088 | 2246 |      			} elseif ($result['value'] == '17') { | 
| 2089 | 2247 | $error = self::update_from_17(); | 
| 2090 | - if ($error != '') return $error; | |
| 2091 | - else return self::check_version(true); | |
| 2248 | +    			    if ($error != '') { | |
| 2249 | + return $error; | |
| 2250 | +    			    } else { | |
| 2251 | + return self::check_version(true); | |
| 2252 | + } | |
| 2092 | 2253 |      			} elseif ($result['value'] == '18') { | 
| 2093 | 2254 | $error = self::update_from_18(); | 
| 2094 | - if ($error != '') return $error; | |
| 2095 | - else return self::check_version(true); | |
| 2255 | +    			    if ($error != '') { | |
| 2256 | + return $error; | |
| 2257 | +    			    } else { | |
| 2258 | + return self::check_version(true); | |
| 2259 | + } | |
| 2096 | 2260 |      			} elseif ($result['value'] == '19') { | 
| 2097 | 2261 | $error = self::update_from_19(); | 
| 2098 | - if ($error != '') return $error; | |
| 2099 | - else return self::check_version(true); | |
| 2262 | +    			    if ($error != '') { | |
| 2263 | + return $error; | |
| 2264 | +    			    } else { | |
| 2265 | + return self::check_version(true); | |
| 2266 | + } | |
| 2100 | 2267 |      			} elseif ($result['value'] == '20') { | 
| 2101 | 2268 | $error = self::update_from_20(); | 
| 2102 | - if ($error != '') return $error; | |
| 2103 | - else return self::check_version(true); | |
| 2269 | +    			    if ($error != '') { | |
| 2270 | + return $error; | |
| 2271 | +    			    } else { | |
| 2272 | + return self::check_version(true); | |
| 2273 | + } | |
| 2104 | 2274 |      			} elseif ($result['value'] == '21') { | 
| 2105 | 2275 | $error = self::update_from_21(); | 
| 2106 | - if ($error != '') return $error; | |
| 2107 | - else return self::check_version(true); | |
| 2276 | +    			    if ($error != '') { | |
| 2277 | + return $error; | |
| 2278 | +    			    } else { | |
| 2279 | + return self::check_version(true); | |
| 2280 | + } | |
| 2108 | 2281 |      			} elseif ($result['value'] == '22') { | 
| 2109 | 2282 | $error = self::update_from_22(); | 
| 2110 | - if ($error != '') return $error; | |
| 2111 | - else return self::check_version(true); | |
| 2283 | +    			    if ($error != '') { | |
| 2284 | + return $error; | |
| 2285 | +    			    } else { | |
| 2286 | + return self::check_version(true); | |
| 2287 | + } | |
| 2112 | 2288 |      			} elseif ($result['value'] == '23') { | 
| 2113 | 2289 | $error = self::update_from_23(); | 
| 2114 | - if ($error != '') return $error; | |
| 2115 | - else return self::check_version(true); | |
| 2290 | +    			    if ($error != '') { | |
| 2291 | + return $error; | |
| 2292 | +    			    } else { | |
| 2293 | + return self::check_version(true); | |
| 2294 | + } | |
| 2116 | 2295 |      			} elseif ($result['value'] == '24') { | 
| 2117 | 2296 | $error = self::update_from_24(); | 
| 2118 | - if ($error != '') return $error; | |
| 2119 | - else return self::check_version(true); | |
| 2297 | +    			    if ($error != '') { | |
| 2298 | + return $error; | |
| 2299 | +    			    } else { | |
| 2300 | + return self::check_version(true); | |
| 2301 | + } | |
| 2120 | 2302 |      			} elseif ($result['value'] == '25') { | 
| 2121 | 2303 | $error = self::update_from_25(); | 
| 2122 | - if ($error != '') return $error; | |
| 2123 | - else return self::check_version(true); | |
| 2304 | +    			    if ($error != '') { | |
| 2305 | + return $error; | |
| 2306 | +    			    } else { | |
| 2307 | + return self::check_version(true); | |
| 2308 | + } | |
| 2124 | 2309 |      			} elseif ($result['value'] == '26') { | 
| 2125 | 2310 | $error = self::update_from_26(); | 
| 2126 | - if ($error != '') return $error; | |
| 2127 | - else return self::check_version(true); | |
| 2311 | +    			    if ($error != '') { | |
| 2312 | + return $error; | |
| 2313 | +    			    } else { | |
| 2314 | + return self::check_version(true); | |
| 2315 | + } | |
| 2128 | 2316 |      			} elseif ($result['value'] == '27') { | 
| 2129 | 2317 | $error = self::update_from_27(); | 
| 2130 | - if ($error != '') return $error; | |
| 2131 | - else return self::check_version(true); | |
| 2318 | +    			    if ($error != '') { | |
| 2319 | + return $error; | |
| 2320 | +    			    } else { | |
| 2321 | + return self::check_version(true); | |
| 2322 | + } | |
| 2132 | 2323 |      			} elseif ($result['value'] == '28') { | 
| 2133 | 2324 | $error = self::update_from_28(); | 
| 2134 | - if ($error != '') return $error; | |
| 2135 | - else return self::check_version(true); | |
| 2325 | +    			    if ($error != '') { | |
| 2326 | + return $error; | |
| 2327 | +    			    } else { | |
| 2328 | + return self::check_version(true); | |
| 2329 | + } | |
| 2136 | 2330 |      			} elseif ($result['value'] == '29') { | 
| 2137 | 2331 | $error = self::update_from_29(); | 
| 2138 | - if ($error != '') return $error; | |
| 2139 | - else return self::check_version(true); | |
| 2332 | +    			    if ($error != '') { | |
| 2333 | + return $error; | |
| 2334 | +    			    } else { | |
| 2335 | + return self::check_version(true); | |
| 2336 | + } | |
| 2140 | 2337 |      			} elseif ($result['value'] == '30') { | 
| 2141 | 2338 | $error = self::update_from_30(); | 
| 2142 | - if ($error != '') return $error; | |
| 2143 | - else return self::check_version(true); | |
| 2339 | +    			    if ($error != '') { | |
| 2340 | + return $error; | |
| 2341 | +    			    } else { | |
| 2342 | + return self::check_version(true); | |
| 2343 | + } | |
| 2144 | 2344 |      			} elseif ($result['value'] == '31') { | 
| 2145 | 2345 | $error = self::update_from_31(); | 
| 2146 | - if ($error != '') return $error; | |
| 2147 | - else return self::check_version(true); | |
| 2346 | +    			    if ($error != '') { | |
| 2347 | + return $error; | |
| 2348 | +    			    } else { | |
| 2349 | + return self::check_version(true); | |
| 2350 | + } | |
| 2148 | 2351 |      			} elseif ($result['value'] == '32') { | 
| 2149 | 2352 | $error = self::update_from_32(); | 
| 2150 | - if ($error != '') return $error; | |
| 2151 | - else return self::check_version(true); | |
| 2353 | +    			    if ($error != '') { | |
| 2354 | + return $error; | |
| 2355 | +    			    } else { | |
| 2356 | + return self::check_version(true); | |
| 2357 | + } | |
| 2152 | 2358 |      			} elseif ($result['value'] == '33') { | 
| 2153 | 2359 | $error = self::update_from_33(); | 
| 2154 | - if ($error != '') return $error; | |
| 2155 | - else return self::check_version(true); | |
| 2360 | +    			    if ($error != '') { | |
| 2361 | + return $error; | |
| 2362 | +    			    } else { | |
| 2363 | + return self::check_version(true); | |
| 2364 | + } | |
| 2156 | 2365 |      			} elseif ($result['value'] == '34') { | 
| 2157 | 2366 | $error = self::update_from_34(); | 
| 2158 | - if ($error != '') return $error; | |
| 2159 | - else return self::check_version(true); | |
| 2367 | +    			    if ($error != '') { | |
| 2368 | + return $error; | |
| 2369 | +    			    } else { | |
| 2370 | + return self::check_version(true); | |
| 2371 | + } | |
| 2160 | 2372 |      			} elseif ($result['value'] == '35') { | 
| 2161 | 2373 | $error = self::update_from_35(); | 
| 2162 | - if ($error != '') return $error; | |
| 2163 | - else return self::check_version(true); | |
| 2374 | +    			    if ($error != '') { | |
| 2375 | + return $error; | |
| 2376 | +    			    } else { | |
| 2377 | + return self::check_version(true); | |
| 2378 | + } | |
| 2164 | 2379 |      			} elseif ($result['value'] == '36') { | 
| 2165 | 2380 | $error = self::update_from_36(); | 
| 2166 | - if ($error != '') return $error; | |
| 2167 | - else return self::check_version(true); | |
| 2381 | +    			    if ($error != '') { | |
| 2382 | + return $error; | |
| 2383 | +    			    } else { | |
| 2384 | + return self::check_version(true); | |
| 2385 | + } | |
| 2168 | 2386 |      			} elseif ($result['value'] == '37') { | 
| 2169 | 2387 | $error = self::update_from_37(); | 
| 2170 | - if ($error != '') return $error; | |
| 2171 | - else return self::check_version(true); | |
| 2388 | +    			    if ($error != '') { | |
| 2389 | + return $error; | |
| 2390 | +    			    } else { | |
| 2391 | + return self::check_version(true); | |
| 2392 | + } | |
| 2172 | 2393 |      			} elseif ($result['value'] == '38') { | 
| 2173 | 2394 | $error = self::update_from_38(); | 
| 2174 | - if ($error != '') return $error; | |
| 2175 | - else return self::check_version(true); | |
| 2395 | +    			    if ($error != '') { | |
| 2396 | + return $error; | |
| 2397 | +    			    } else { | |
| 2398 | + return self::check_version(true); | |
| 2399 | + } | |
| 2176 | 2400 |      			} elseif ($result['value'] == '39') { | 
| 2177 | 2401 | $error = self::update_from_39(); | 
| 2178 | - if ($error != '') return $error; | |
| 2179 | - else return self::check_version(true); | |
| 2402 | +    			    if ($error != '') { | |
| 2403 | + return $error; | |
| 2404 | +    			    } else { | |
| 2405 | + return self::check_version(true); | |
| 2406 | + } | |
| 2180 | 2407 |      			} elseif ($result['value'] == '40') { | 
| 2181 | 2408 | $error = self::update_from_40(); | 
| 2182 | - if ($error != '') return $error; | |
| 2183 | - else return self::check_version(true); | |
| 2409 | +    			    if ($error != '') { | |
| 2410 | + return $error; | |
| 2411 | +    			    } else { | |
| 2412 | + return self::check_version(true); | |
| 2413 | + } | |
| 2184 | 2414 |      			} elseif ($result['value'] == '41') { | 
| 2185 | 2415 | $error = self::update_from_41(); | 
| 2186 | - if ($error != '') return $error; | |
| 2187 | - else return self::check_version(true); | |
| 2188 | - } else return ''; | |
| 2416 | +    			    if ($error != '') { | |
| 2417 | + return $error; | |
| 2418 | +    			    } else { | |
| 2419 | + return self::check_version(true); | |
| 2420 | + } | |
| 2421 | +    			} else { | |
| 2422 | + return ''; | |
| 2423 | + } | |
| 2424 | +    		    } else { | |
| 2425 | + return $result['value']; | |
| 2189 | 2426 | } | 
| 2190 | - else return $result['value']; | |
| 2191 | 2427 | } | 
| 2192 | 2428 | |
| 2193 | - } else return $version; | |
| 2429 | +	    } else { | |
| 2430 | + return $version; | |
| 2431 | + } | |
| 2194 | 2432 | } | 
| 2195 | 2433 | |
| 2196 | 2434 | } | 
| @@ -2,10 +2,10 @@ discard block | ||
| 2 | 2 | require_once(dirname(__FILE__).'/settings.php'); | 
| 3 | 3 | require_once(dirname(__FILE__).'/class.Common.php'); | 
| 4 | 4 |  class aprs { | 
| 5 | - private $socket; | |
| 6 | - private $connected = false; | |
| 5 | + private $socket; | |
| 6 | + private $connected = false; | |
| 7 | 7 | |
| 8 | -    protected $symbols = array('!' => 'Police', | |
| 8 | +	protected $symbols = array('!' => 'Police', | |
| 9 | 9 | '#' => 'DIGI', | 
| 10 | 10 | '$' => 'Phone', | 
| 11 | 11 | '%' => 'DX Cluster', | 
| @@ -89,13 +89,13 @@ discard block | ||
| 89 | 89 | 'y' => 'Yagi At QTH'); | 
| 90 | 90 | |
| 91 | 91 | |
| 92 | -    private function urshift($n, $s) { | |
| 92 | +	private function urshift($n, $s) { | |
| 93 | 93 | return ($n >= 0) ? ($n >> $s) : | 
| 94 | - (($n & 0x7fffffff) >> $s) | | |
| 94 | + (($n & 0x7fffffff) >> $s) | | |
| 95 | 95 | (0x40000000 >> ($s - 1)); | 
| 96 | - } | |
| 96 | + } | |
| 97 | 97 | |
| 98 | -    public function parse($input) { | |
| 98 | +	public function parse($input) { | |
| 99 | 99 | global $globalDebug; | 
| 100 | 100 | $debug = false; | 
| 101 | 101 | $result = array(); | 
| @@ -107,8 +107,8 @@ discard block | ||
| 107 | 107 | |
| 108 | 108 | /* Check that end was found and body has at least one byte. */ | 
| 109 | 109 |  	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { | 
| 110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; | |
| 111 | - return false; | |
| 110 | + if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; | |
| 111 | + return false; | |
| 112 | 112 | } | 
| 113 | 113 | |
| 114 | 114 | if ($debug) echo 'input : '.$input."\n"; | 
| @@ -122,34 +122,34 @@ discard block | ||
| 122 | 122 | /* Parse source, target and path. */ | 
| 123 | 123 | //FLRDF0A52>APRS,qAS,LSTB | 
| 124 | 124 |  	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { | 
| 125 | - $ident = $matches[1]; | |
| 126 | - $all_elements = $matches[2]; | |
| 127 | -	    if ($ident == 'AIRCRAFT') { | |
| 125 | + $ident = $matches[1]; | |
| 126 | + $all_elements = $matches[2]; | |
| 127 | +		if ($ident == 'AIRCRAFT') { | |
| 128 | 128 | $result['format_source'] = 'famaprs'; | 
| 129 | 129 | $result['source_type'] = 'modes'; | 
| 130 | -	    } elseif ($ident == 'MARINE') { | |
| 130 | +		} elseif ($ident == 'MARINE') { | |
| 131 | 131 | $result['format_source'] = 'famaprs'; | 
| 132 | 132 | $result['source_type'] = 'ais'; | 
| 133 | -	    } else { | |
| 133 | +		} else { | |
| 134 | 134 | if ($debug) echo 'ident : '.$ident."\n"; | 
| 135 | 135 | $result['ident'] = $ident; | 
| 136 | - } | |
| 136 | + } | |
| 137 | 137 |  	} else { | 
| 138 | - if ($debug) 'No ident'."\n"; | |
| 139 | - return false; | |
| 138 | + if ($debug) 'No ident'."\n"; | |
| 139 | + return false; | |
| 140 | 140 | } | 
| 141 | 141 |  	$elements = explode(',',$all_elements); | 
| 142 | 142 | $source = end($elements); | 
| 143 | 143 | $result['source'] = $source; | 
| 144 | 144 |  	foreach ($elements as $element) { | 
| 145 | -	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { | |
| 146 | - //echo "ok"; | |
| 147 | - //if ($element == 'TCPIP*') return false; | |
| 148 | -	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { | |
| 145 | +		if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { | |
| 146 | + //echo "ok"; | |
| 147 | + //if ($element == 'TCPIP*') return false; | |
| 148 | +		} elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { | |
| 149 | 149 | if ($debug) echo 'element : '.$element."\n"; | 
| 150 | 150 | return false; | 
| 151 | - } | |
| 152 | - /* | |
| 151 | + } | |
| 152 | + /* | |
| 153 | 153 |  	    } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { | 
| 154 | 154 | //echo "ok"; | 
| 155 | 155 |  	    } else { | 
| @@ -176,49 +176,49 @@ discard block | ||
| 176 | 176 | $body_parse = substr($body,1); | 
| 177 | 177 | //echo 'Body : '.$body."\n"; | 
| 178 | 178 |  	if (preg_match('/^;(.){9}\*/',$body,$matches)) { | 
| 179 | - $body_parse = substr($body_parse,10); | |
| 180 | - $find = true; | |
| 181 | - //echo $body_parse."\n"; | |
| 179 | + $body_parse = substr($body_parse,10); | |
| 180 | + $find = true; | |
| 181 | + //echo $body_parse."\n"; | |
| 182 | 182 | } | 
| 183 | 183 |  	if (preg_match('/^`(.*)\//',$body,$matches)) { | 
| 184 | - $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 185 | - $find = true; | |
| 186 | - //echo $body_parse."\n"; | |
| 184 | + $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 185 | + $find = true; | |
| 186 | + //echo $body_parse."\n"; | |
| 187 | 187 | } | 
| 188 | 188 |  	if (preg_match("/^'(.*)\//",$body,$matches)) { | 
| 189 | - $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 190 | - $find = true; | |
| 191 | - //echo $body_parse."\n"; | |
| 189 | + $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 190 | + $find = true; | |
| 191 | + //echo $body_parse."\n"; | |
| 192 | 192 | } | 
| 193 | 193 |  	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { | 
| 194 | - $find = true; | |
| 195 | - //print_r($matches); | |
| 196 | - $timestamp = $matches[0]; | |
| 197 | -	    if ($matches[4] == 'h') { | |
| 194 | + $find = true; | |
| 195 | + //print_r($matches); | |
| 196 | + $timestamp = $matches[0]; | |
| 197 | +		if ($matches[4] == 'h') { | |
| 198 | 198 |  		$timestamp = strtotime(date('Ymd').' '.$matches[1].':'.$matches[2].':'.$matches[3]); | 
| 199 | 199 | //echo 'timestamp : '.$timestamp.' - now : '.time()."\n"; | 
| 200 | 200 | /* | 
| 201 | 201 | if (time() + 3900 < $timestamp) $timestamp -= 86400; | 
| 202 | 202 | elseif (time() - 82500 > $timestamp) $timestamp += 86400; | 
| 203 | 203 | */ | 
| 204 | -	    } elseif ($matches[4] == 'z' || $matches[4] == '/') { | |
| 204 | +		} elseif ($matches[4] == 'z' || $matches[4] == '/') { | |
| 205 | 205 | // This work or not ? | 
| 206 | 206 |  		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); | 
| 207 | - } | |
| 208 | - $body_parse = substr($body_parse,7); | |
| 209 | - $result['timestamp'] = $timestamp; | |
| 210 | -	    //echo date('Ymd H:i:s',$timestamp); | |
| 207 | + } | |
| 208 | + $body_parse = substr($body_parse,7); | |
| 209 | + $result['timestamp'] = $timestamp; | |
| 210 | +		//echo date('Ymd H:i:s',$timestamp); | |
| 211 | 211 | } | 
| 212 | 212 |  	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { | 
| 213 | - $find = true; | |
| 214 | -	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); | |
| 215 | - $body_parse = substr($body_parse,8); | |
| 216 | - $result['timestamp'] = $timestamp; | |
| 217 | -	    //echo date('Ymd H:i:s',$timestamp); | |
| 213 | + $find = true; | |
| 214 | +		$timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); | |
| 215 | + $body_parse = substr($body_parse,8); | |
| 216 | + $result['timestamp'] = $timestamp; | |
| 217 | +		//echo date('Ymd H:i:s',$timestamp); | |
| 218 | 218 | } | 
| 219 | 219 |  	//if (strlen($body_parse) > 19) { | 
| 220 | -	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { | |
| 221 | - $find = true; | |
| 220 | +		if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { | |
| 221 | + $find = true; | |
| 222 | 222 | // 4658.70N/00707.78Ez | 
| 223 | 223 | //print_r(str_split($body_parse)); | 
| 224 | 224 | |
| @@ -235,7 +235,7 @@ discard block | ||
| 235 | 235 | $lon = intval($lon_deg); | 
| 236 | 236 | if ($lat > 89 || $lon > 179) return false; | 
| 237 | 237 | |
| 238 | - /* | |
| 238 | + /* | |
| 239 | 239 |  	    $tmp_5b = str_replace('.','',$lat_min); | 
| 240 | 240 |  	    if (preg_match('/^([0-9]{0,4})( {0,4})$/',$tmp_5b,$matches)) { | 
| 241 | 241 | print_r($matches); | 
| @@ -249,9 +249,9 @@ discard block | ||
| 249 | 249 | $result['longitude'] = $longitude; | 
| 250 | 250 | $body_parse = substr($body_parse,18); | 
| 251 | 251 | $body_parse_len = strlen($body_parse); | 
| 252 | - } | |
| 253 | - $body_parse_len = strlen($body_parse); | |
| 254 | -	    if ($body_parse_len > 0) { | |
| 252 | + } | |
| 253 | + $body_parse_len = strlen($body_parse); | |
| 254 | +		if ($body_parse_len > 0) { | |
| 255 | 255 | /* | 
| 256 | 256 |  		if (!isset($result['timestamp']) && !isset($result['latitude'])) { | 
| 257 | 257 | $body_split = str_split($body); | 
| @@ -281,95 +281,95 @@ discard block | ||
| 281 | 281 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; | 
| 282 | 282 |  			if ($symbol_code != '_') { | 
| 283 | 283 | } | 
| 284 | - //$body_parse = substr($body_parse,1); | |
| 285 | - //$body_parse = trim($body_parse); | |
| 286 | - //$body_parse_len = strlen($body_parse); | |
| 287 | -		    if ($body_parse_len >= 7) { | |
| 284 | + //$body_parse = substr($body_parse,1); | |
| 285 | + //$body_parse = trim($body_parse); | |
| 286 | + //$body_parse_len = strlen($body_parse); | |
| 287 | +			if ($body_parse_len >= 7) { | |
| 288 | 288 | |
| 289 | -		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { | |
| 290 | - $course = substr($body_parse,0,3); | |
| 291 | - $tmp_s = intval($course); | |
| 292 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); | |
| 293 | - $speed = substr($body_parse,4,3); | |
| 294 | -		    	    if ($speed != '...') { | |
| 295 | - //$result['speed'] = round($speed*1.852); | |
| 296 | - $result['speed'] = intval($speed); | |
| 297 | - } | |
| 298 | - $body_parse = substr($body_parse,7); | |
| 299 | - } | |
| 300 | - // Check PHGR, PHG, RNG | |
| 301 | - } | |
| 302 | - /* | |
| 289 | +				if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { | |
| 290 | + $course = substr($body_parse,0,3); | |
| 291 | + $tmp_s = intval($course); | |
| 292 | + if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); | |
| 293 | + $speed = substr($body_parse,4,3); | |
| 294 | +					if ($speed != '...') { | |
| 295 | + //$result['speed'] = round($speed*1.852); | |
| 296 | + $result['speed'] = intval($speed); | |
| 297 | + } | |
| 298 | + $body_parse = substr($body_parse,7); | |
| 299 | + } | |
| 300 | + // Check PHGR, PHG, RNG | |
| 301 | + } | |
| 302 | + /* | |
| 303 | 303 |  		    else if ($body_parse_len > 0) { | 
| 304 | 304 | $rest = $body_parse; | 
| 305 | 305 | } | 
| 306 | 306 | */ | 
| 307 | -		    if (strlen($body_parse) > 0) { | |
| 308 | -		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { | |
| 309 | - $altitude = intval($matches[1]); | |
| 310 | - //$result['altitude'] = round($altitude*0.3048); | |
| 311 | - $result['altitude'] = $altitude; | |
| 312 | - //$body_parse = trim(substr($body_parse,strlen($matches[0]))); | |
| 313 | -		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); | |
| 314 | - } | |
| 315 | - } | |
| 307 | +			if (strlen($body_parse) > 0) { | |
| 308 | +				if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { | |
| 309 | + $altitude = intval($matches[1]); | |
| 310 | + //$result['altitude'] = round($altitude*0.3048); | |
| 311 | + $result['altitude'] = $altitude; | |
| 312 | + //$body_parse = trim(substr($body_parse,strlen($matches[0]))); | |
| 313 | +					$body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); | |
| 314 | + } | |
| 315 | + } | |
| 316 | 316 | |
| 317 | - // Telemetry | |
| 318 | - /* | |
| 317 | + // Telemetry | |
| 318 | + /* | |
| 319 | 319 |  		    if (preg_match('/^([0-9]+),(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,(-?)([0-9]{1,6}|[0-9]+\\.[0-9]+|\\.[0-9]+)?,([01]{0,8})/',$body_parse,$matches)) { | 
| 320 | 320 | // Nothing yet... | 
| 321 | 321 | } | 
| 322 | 322 | */ | 
| 323 | - // DAO | |
| 323 | + // DAO | |
| 324 | 324 | |
| 325 | -		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { | |
| 325 | +			if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { | |
| 326 | 326 | |
| 327 | - $dao = $matches[1]; | |
| 328 | -			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { | |
| 327 | + $dao = $matches[1]; | |
| 328 | +				if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { | |
| 329 | 329 | $dao_split = str_split($dao); | 
| 330 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; | |
| 331 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; | |
| 330 | + $lat_off = (($dao_split[1])-48.0)*0.001/60.0; | |
| 331 | + $lon_off = (($dao_split[2])-48.0)*0.001/60.0; | |
| 332 | 332 | |
| 333 | 333 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; | 
| 334 | 334 | else $result['latitude'] += $lat_off; | 
| 335 | 335 | if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; | 
| 336 | 336 | else $result['longitude'] += $lon_off; | 
| 337 | - } | |
| 337 | + } | |
| 338 | 338 | |
| 339 | - $body_parse = substr($body_parse,6); | |
| 340 | - } | |
| 339 | + $body_parse = substr($body_parse,6); | |
| 340 | + } | |
| 341 | 341 | |
| 342 | -		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 342 | +			if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 343 | 343 |  			$result['ident'] = str_replace('_',' ',$matches[1]); | 
| 344 | - } | |
| 345 | -		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { | |
| 344 | + } | |
| 345 | +			if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { | |
| 346 | 346 | $result['squawk'] = $matches[1]; | 
| 347 | - } | |
| 348 | -		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { | |
| 347 | + } | |
| 348 | +			if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { | |
| 349 | 349 | $result['aircraft_icao'] = $matches[1]; | 
| 350 | - } | |
| 351 | -		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { | |
| 350 | + } | |
| 351 | +			if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { | |
| 352 | 352 | $result['verticalrate'] = $matches[1]; | 
| 353 | - } | |
| 354 | -		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { | |
| 353 | + } | |
| 354 | +			if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { | |
| 355 | 355 | $result['typeid'] = $matches[1]; | 
| 356 | - } | |
| 357 | -		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { | |
| 356 | + } | |
| 357 | +			if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { | |
| 358 | 358 | $result['statusid'] = $matches[1]; | 
| 359 | - } | |
| 360 | -		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { | |
| 359 | + } | |
| 360 | +			if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { | |
| 361 | 361 | $result['imo'] = $matches[1]; | 
| 362 | - } | |
| 363 | -		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { | |
| 362 | + } | |
| 363 | +			if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { | |
| 364 | 364 | $result['arrival_date'] = $matches[1]; | 
| 365 | - } | |
| 366 | -		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 365 | + } | |
| 366 | +			if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 367 | 367 |  			$result['arrival_code'] = str_replace('_',' ',$matches[1]); | 
| 368 | - } | |
| 369 | - // OGN comment | |
| 368 | + } | |
| 369 | + // OGN comment | |
| 370 | 370 | // echo "Before OGN : ".$body_parse."\n"; | 
| 371 | -		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { | |
| 372 | -		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { | |
| 371 | +			//if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { | |
| 372 | +			if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { | |
| 373 | 373 | $id = $matches[1]; | 
| 374 | 374 | //$mode = substr($id,0,2); | 
| 375 | 375 | $address = substr($id,2); | 
| @@ -399,53 +399,53 @@ discard block | ||
| 399 | 399 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; | 
| 400 | 400 | $result['stealth'] = $stealth; | 
| 401 | 401 | $result['address'] = $address; | 
| 402 | - } | |
| 402 | + } | |
| 403 | 403 | |
| 404 | - //Comment | |
| 405 | - $result['comment'] = trim($body_parse); | |
| 404 | + //Comment | |
| 405 | + $result['comment'] = trim($body_parse); | |
| 406 | 406 |  		} else { | 
| 407 | - // parse weather | |
| 408 | - //$body_parse = substr($body_parse,1); | |
| 409 | - //$body_parse_len = strlen($body_parse); | |
| 407 | + // parse weather | |
| 408 | + //$body_parse = substr($body_parse,1); | |
| 409 | + //$body_parse_len = strlen($body_parse); | |
| 410 | 410 | |
| 411 | -		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 412 | - $result['wind_dir'] = intval($matches[1]); | |
| 413 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); | |
| 414 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); | |
| 415 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); | |
| 416 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 417 | -		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 411 | +			if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 412 | + $result['wind_dir'] = intval($matches[1]); | |
| 413 | + $result['wind_speed'] = round(intval($matches[2])*1.60934,1); | |
| 414 | + $result['wind_gust'] = round(intval($matches[3])*1.60934,1); | |
| 415 | + $result['temp'] = round(5/9*((intval($matches[4]))-32),1); | |
| 416 | + $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 417 | +			} elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 418 | 418 | $result['wind_dir'] = intval($matches[1]); | 
| 419 | 419 | $result['wind_speed'] = round($matches[2]*1.60934,1); | 
| 420 | 420 | $result['wind_gust'] = round($matches[3]*1.60934,1); | 
| 421 | 421 | $result['temp'] = round(5/9*(($matches[4])-32),1); | 
| 422 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 423 | -		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 422 | + $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 423 | +			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 424 | 424 | $result['wind_dir'] = intval($matches[1]); | 
| 425 | 425 | $result['wind_speed'] = round($matches[2]*1.60934,1); | 
| 426 | 426 | $result['wind_gust'] = round($matches[3]*1.60934,1); | 
| 427 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 428 | -		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { | |
| 427 | + $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 428 | +			} elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { | |
| 429 | 429 | $result['wind_dir'] = intval($matches[1]); | 
| 430 | 430 | $result['wind_speed'] = round($matches[2]*1.60934,1); | 
| 431 | 431 | $result['wind_gust'] = round($matches[3]*1.60934,1); | 
| 432 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 433 | - } | |
| 434 | -		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { | |
| 432 | + $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 433 | + } | |
| 434 | +			if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { | |
| 435 | 435 | $result['temp'] = round(5/9*(($matches[1])-32),1); | 
| 436 | - } | |
| 436 | + } | |
| 437 | 437 | } | 
| 438 | 438 | } else $result['comment'] = trim($body_parse); | 
| 439 | 439 | |
| 440 | - } | |
| 440 | + } | |
| 441 | 441 | //} | 
| 442 | 442 | if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); | 
| 443 | 443 | if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); | 
| 444 | 444 | if ($debug) print_r($result); | 
| 445 | 445 | return $result; | 
| 446 | - } | |
| 446 | + } | |
| 447 | 447 | |
| 448 | -    public function connect() { | |
| 448 | +	public function connect() { | |
| 449 | 449 | global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; | 
| 450 | 450 | $aprs_connect = 0; | 
| 451 | 451 | $aprs_keep = 120; | 
| @@ -469,24 +469,24 @@ discard block | ||
| 469 | 469 | socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); | 
| 470 | 470 |  		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { | 
| 471 | 471 |  			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { | 
| 472 | - echo 'APRS user verified !'."\n"; | |
| 473 | - $this->connected = true; | |
| 474 | - return true; | |
| 475 | - break; | |
| 472 | + echo 'APRS user verified !'."\n"; | |
| 473 | + $this->connected = true; | |
| 474 | + return true; | |
| 475 | + break; | |
| 476 | 476 | } | 
| 477 | 477 |  			if (time()-$authstart > 5) { | 
| 478 | - echo 'APRS timeout'."\n"; | |
| 479 | - break; | |
| 478 | + echo 'APRS timeout'."\n"; | |
| 479 | + break; | |
| 480 | 480 | } | 
| 481 | 481 | } | 
| 482 | 482 | } | 
| 483 | - } | |
| 483 | + } | |
| 484 | 484 | |
| 485 | -    public function disconnect() { | |
| 485 | +	public function disconnect() { | |
| 486 | 486 | socket_close($this->socket); | 
| 487 | - } | |
| 487 | + } | |
| 488 | 488 | |
| 489 | -    public function send($data) { | |
| 489 | +	public function send($data) { | |
| 490 | 490 | global $globalDebug; | 
| 491 | 491 | if ($this->connected === false) $this->connect(); | 
| 492 | 492 | $send = socket_send( $this->socket , $data , strlen($data),0); | 
| @@ -495,7 +495,7 @@ discard block | ||
| 495 | 495 | socket_close($this->socket); | 
| 496 | 496 | $this->connect(); | 
| 497 | 497 | } | 
| 498 | - } | |
| 498 | + } | |
| 499 | 499 | } | 
| 500 | 500 | |
| 501 | 501 |  class APRSSpotter extends APRS { | 
| @@ -90,8 +90,7 @@ discard block | ||
| 90 | 90 | |
| 91 | 91 | |
| 92 | 92 |      private function urshift($n, $s) { | 
| 93 | - return ($n >= 0) ? ($n >> $s) : | |
| 94 | - (($n & 0x7fffffff) >> $s) | | |
| 93 | + return ($n >= 0) ? ($n >> $s) : (($n&0x7fffffff) >> $s)| | |
| 95 | 94 | (0x40000000 >> ($s - 1)); | 
| 96 | 95 | } | 
| 97 | 96 | |
| @@ -103,7 +102,7 @@ discard block | ||
| 103 | 102 | //$split_input = str_split($input); | 
| 104 | 103 | |
| 105 | 104 | /* Find the end of header checking for NULL bytes while doing it. */ | 
| 106 | - $splitpos = strpos($input,':'); | |
| 105 | + $splitpos = strpos($input, ':'); | |
| 107 | 106 | |
| 108 | 107 | /* Check that end was found and body has at least one byte. */ | 
| 109 | 108 |  	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { | 
| @@ -113,15 +112,15 @@ discard block | ||
| 113 | 112 | |
| 114 | 113 | if ($debug) echo 'input : '.$input."\n"; | 
| 115 | 114 | /* Save header and body. */ | 
| 116 | - $body = substr($input,$splitpos+1,$input_len); | |
| 115 | + $body = substr($input, $splitpos + 1, $input_len); | |
| 117 | 116 | $body_len = strlen($body); | 
| 118 | - $header = substr($input,0,$splitpos); | |
| 117 | + $header = substr($input, 0, $splitpos); | |
| 119 | 118 | //$header_len = strlen($header); | 
| 120 | 119 | if ($debug) echo 'header : '.$header."\n"; | 
| 121 | 120 | |
| 122 | 121 | /* Parse source, target and path. */ | 
| 123 | 122 | //FLRDF0A52>APRS,qAS,LSTB | 
| 124 | -	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { | |
| 123 | +	if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/', $header, $matches)) { | |
| 125 | 124 | $ident = $matches[1]; | 
| 126 | 125 | $all_elements = $matches[2]; | 
| 127 | 126 |  	    if ($ident == 'AIRCRAFT') { | 
| @@ -138,14 +137,14 @@ discard block | ||
| 138 | 137 | if ($debug) 'No ident'."\n"; | 
| 139 | 138 | return false; | 
| 140 | 139 | } | 
| 141 | -	$elements = explode(',',$all_elements); | |
| 140 | +	$elements = explode(',', $all_elements); | |
| 142 | 141 | $source = end($elements); | 
| 143 | 142 | $result['source'] = $source; | 
| 144 | 143 |  	foreach ($elements as $element) { | 
| 145 | -	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { | |
| 144 | +	    if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/', $element)) { | |
| 146 | 145 | //echo "ok"; | 
| 147 | 146 | //if ($element == 'TCPIP*') return false; | 
| 148 | -	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { | |
| 147 | +	    } elseif (!preg_match('/^([0-9A-F]{32})$/', $element)) { | |
| 149 | 148 | if ($debug) echo 'element : '.$element."\n"; | 
| 150 | 149 | return false; | 
| 151 | 150 | } | 
| @@ -158,14 +157,14 @@ discard block | ||
| 158 | 157 | */ | 
| 159 | 158 | } | 
| 160 | 159 | |
| 161 | - $type = substr($body,0,1); | |
| 160 | + $type = substr($body, 0, 1); | |
| 162 | 161 | if ($debug) echo 'type : '.$type."\n"; | 
| 163 | 162 |  	if ($type == ';') { | 
| 164 | 163 |  		if (isset($result['source_type']) && $result['source_type'] == 'modes') { | 
| 165 | - $result['address'] = trim(substr($body,1,9)); | |
| 164 | + $result['address'] = trim(substr($body, 1, 9)); | |
| 166 | 165 |  		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { | 
| 167 | - $result['mmsi'] = trim(substr($body,1,9)); | |
| 168 | - } else $result['ident'] = trim(substr($body,1,9)); | |
| 166 | + $result['mmsi'] = trim(substr($body, 1, 9)); | |
| 167 | + } else $result['ident'] = trim(substr($body, 1, 9)); | |
| 169 | 168 |  	} elseif ($type == ',') { | 
| 170 | 169 | // Invalid data or test data | 
| 171 | 170 | return false; | 
| @@ -173,24 +172,24 @@ discard block | ||
| 173 | 172 | |
| 174 | 173 | // Check for Timestamp | 
| 175 | 174 | $find = false; | 
| 176 | - $body_parse = substr($body,1); | |
| 175 | + $body_parse = substr($body, 1); | |
| 177 | 176 | //echo 'Body : '.$body."\n"; | 
| 178 | -	if (preg_match('/^;(.){9}\*/',$body,$matches)) { | |
| 179 | - $body_parse = substr($body_parse,10); | |
| 177 | +	if (preg_match('/^;(.){9}\*/', $body, $matches)) { | |
| 178 | + $body_parse = substr($body_parse, 10); | |
| 180 | 179 | $find = true; | 
| 181 | 180 | //echo $body_parse."\n"; | 
| 182 | 181 | } | 
| 183 | -	if (preg_match('/^`(.*)\//',$body,$matches)) { | |
| 184 | - $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 182 | +	if (preg_match('/^`(.*)\//', $body, $matches)) { | |
| 183 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); | |
| 185 | 184 | $find = true; | 
| 186 | 185 | //echo $body_parse."\n"; | 
| 187 | 186 | } | 
| 188 | -	if (preg_match("/^'(.*)\//",$body,$matches)) { | |
| 189 | - $body_parse = substr($body_parse,strlen($matches[1])-1); | |
| 187 | +	if (preg_match("/^'(.*)\//", $body, $matches)) { | |
| 188 | + $body_parse = substr($body_parse, strlen($matches[1]) - 1); | |
| 190 | 189 | $find = true; | 
| 191 | 190 | //echo $body_parse."\n"; | 
| 192 | 191 | } | 
| 193 | -	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/',$body_parse,$matches)) { | |
| 192 | +	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([zh\\/])/', $body_parse, $matches)) { | |
| 194 | 193 | $find = true; | 
| 195 | 194 | //print_r($matches); | 
| 196 | 195 | $timestamp = $matches[0]; | 
| @@ -205,19 +204,19 @@ discard block | ||
| 205 | 204 | // This work or not ? | 
| 206 | 205 |  		$timestamp = strtotime(date('Ym').$matches[1].' '.$matches[2].':'.$matches[3]); | 
| 207 | 206 | } | 
| 208 | - $body_parse = substr($body_parse,7); | |
| 207 | + $body_parse = substr($body_parse, 7); | |
| 209 | 208 | $result['timestamp'] = $timestamp; | 
| 210 | 209 |  	    //echo date('Ymd H:i:s',$timestamp); | 
| 211 | 210 | } | 
| 212 | -	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/',$body_parse,$matches)) { | |
| 211 | +	if (preg_match('/^([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})/', $body_parse, $matches)) { | |
| 213 | 212 | $find = true; | 
| 214 | 213 |  	    $timestamp = strtotime(date('Y').$matches[1].$matches[2].' '.$matches[3].':'.$matches[4]); | 
| 215 | - $body_parse = substr($body_parse,8); | |
| 214 | + $body_parse = substr($body_parse, 8); | |
| 216 | 215 | $result['timestamp'] = $timestamp; | 
| 217 | 216 |  	    //echo date('Ymd H:i:s',$timestamp); | 
| 218 | 217 | } | 
| 219 | 218 |  	//if (strlen($body_parse) > 19) { | 
| 220 | -	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/',$body_parse,$matches)) { | |
| 219 | +	    if (preg_match('/^([0-9]{2})([0-7 ][0-9 ]\\.[0-9 ]{2})([NnSs])(.)([0-9]{3})([0-7 ][0-9 ]\\.[0-9 ]{2})([EeWw])(.)/', $body_parse, $matches)) { | |
| 221 | 220 | $find = true; | 
| 222 | 221 | // 4658.70N/00707.78Ez | 
| 223 | 222 | //print_r(str_split($body_parse)); | 
| @@ -243,11 +242,11 @@ discard block | ||
| 243 | 242 | */ | 
| 244 | 243 | $latitude = $lat + floatval($lat_min)/60; | 
| 245 | 244 | $longitude = $lon + floatval($lon_min)/60; | 
| 246 | - if ($sind == 'S') $latitude = 0-$latitude; | |
| 247 | - if ($wind == 'W') $longitude = 0-$longitude; | |
| 245 | + if ($sind == 'S') $latitude = 0 - $latitude; | |
| 246 | + if ($wind == 'W') $longitude = 0 - $longitude; | |
| 248 | 247 | $result['latitude'] = $latitude; | 
| 249 | 248 | $result['longitude'] = $longitude; | 
| 250 | - $body_parse = substr($body_parse,18); | |
| 249 | + $body_parse = substr($body_parse, 18); | |
| 251 | 250 | $body_parse_len = strlen($body_parse); | 
| 252 | 251 | } | 
| 253 | 252 | $body_parse_len = strlen($body_parse); | 
| @@ -275,7 +274,7 @@ discard block | ||
| 275 | 274 | //echo $body_parse; | 
| 276 | 275 |  			//if ($type != ';' && $type != '>') { | 
| 277 | 276 |  			if ($type != '') { | 
| 278 | - $body_parse = substr($body_parse,1); | |
| 277 | + $body_parse = substr($body_parse, 1); | |
| 279 | 278 | $body_parse_len = strlen($body_parse); | 
| 280 | 279 | $result['symbol_code'] = $symbol_code; | 
| 281 | 280 | if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; | 
| @@ -286,16 +285,16 @@ discard block | ||
| 286 | 285 | //$body_parse_len = strlen($body_parse); | 
| 287 | 286 |  		    if ($body_parse_len >= 7) { | 
| 288 | 287 | |
| 289 | -		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { | |
| 290 | - $course = substr($body_parse,0,3); | |
| 288 | +		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/', $body_parse)) { | |
| 289 | + $course = substr($body_parse, 0, 3); | |
| 291 | 290 | $tmp_s = intval($course); | 
| 292 | 291 | if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); | 
| 293 | - $speed = substr($body_parse,4,3); | |
| 292 | + $speed = substr($body_parse, 4, 3); | |
| 294 | 293 |  		    	    if ($speed != '...') { | 
| 295 | 294 | //$result['speed'] = round($speed*1.852); | 
| 296 | 295 | $result['speed'] = intval($speed); | 
| 297 | 296 | } | 
| 298 | - $body_parse = substr($body_parse,7); | |
| 297 | + $body_parse = substr($body_parse, 7); | |
| 299 | 298 | } | 
| 300 | 299 | // Check PHGR, PHG, RNG | 
| 301 | 300 | } | 
| @@ -305,12 +304,12 @@ discard block | ||
| 305 | 304 | } | 
| 306 | 305 | */ | 
| 307 | 306 |  		    if (strlen($body_parse) > 0) { | 
| 308 | -		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/',$body_parse,$matches)) { | |
| 307 | +		        if (preg_match('/\\/A=(-[0-9]{5}|[0-9]{6})/', $body_parse, $matches)) { | |
| 309 | 308 | $altitude = intval($matches[1]); | 
| 310 | 309 | //$result['altitude'] = round($altitude*0.3048); | 
| 311 | 310 | $result['altitude'] = $altitude; | 
| 312 | 311 | //$body_parse = trim(substr($body_parse,strlen($matches[0]))); | 
| 313 | -		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/','',$body_parse)); | |
| 312 | +		            $body_parse = trim(preg_replace('/\\/A=(-[0-9]{5}|[0-9]{6})/', '', $body_parse)); | |
| 314 | 313 | } | 
| 315 | 314 | } | 
| 316 | 315 | |
| @@ -322,13 +321,13 @@ discard block | ||
| 322 | 321 | */ | 
| 323 | 322 | // DAO | 
| 324 | 323 | |
| 325 | -		    if (preg_match('/^!([0-9A-Z]{3})/',$body_parse,$matches)) { | |
| 324 | +		    if (preg_match('/^!([0-9A-Z]{3})/', $body_parse, $matches)) { | |
| 326 | 325 | |
| 327 | 326 | $dao = $matches[1]; | 
| 328 | -			    if (preg_match('/^([A-Z])([0-9]{2})/',$dao)) { | |
| 327 | +			    if (preg_match('/^([A-Z])([0-9]{2})/', $dao)) { | |
| 329 | 328 | $dao_split = str_split($dao); | 
| 330 | - $lat_off = (($dao_split[1])-48.0)*0.001/60.0; | |
| 331 | - $lon_off = (($dao_split[2])-48.0)*0.001/60.0; | |
| 329 | + $lat_off = (($dao_split[1]) - 48.0)*0.001/60.0; | |
| 330 | + $lon_off = (($dao_split[2]) - 48.0)*0.001/60.0; | |
| 332 | 331 | |
| 333 | 332 | if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; | 
| 334 | 333 | else $result['latitude'] += $lat_off; | 
| @@ -336,50 +335,50 @@ discard block | ||
| 336 | 335 | else $result['longitude'] += $lon_off; | 
| 337 | 336 | } | 
| 338 | 337 | |
| 339 | - $body_parse = substr($body_parse,6); | |
| 338 | + $body_parse = substr($body_parse, 6); | |
| 340 | 339 | } | 
| 341 | 340 | |
| 342 | -		    if (preg_match('/CS=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 343 | -			$result['ident'] = str_replace('_',' ',$matches[1]); | |
| 341 | +		    if (preg_match('/CS=([0-9A-Z_]*)/', $body_parse, $matches)) { | |
| 342 | +			$result['ident'] = str_replace('_', ' ', $matches[1]); | |
| 344 | 343 | } | 
| 345 | -		    if (preg_match('/SQ=([0-9]{4})/',$body_parse,$matches)) { | |
| 344 | +		    if (preg_match('/SQ=([0-9]{4})/', $body_parse, $matches)) { | |
| 346 | 345 | $result['squawk'] = $matches[1]; | 
| 347 | 346 | } | 
| 348 | -		    if (preg_match('/AI=([0-9A-Z]{4})/',$body_parse,$matches)) { | |
| 347 | +		    if (preg_match('/AI=([0-9A-Z]{4})/', $body_parse, $matches)) { | |
| 349 | 348 | $result['aircraft_icao'] = $matches[1]; | 
| 350 | 349 | } | 
| 351 | -		    if (preg_match('/VR=([0-9]*)/',$body_parse,$matches)) { | |
| 350 | +		    if (preg_match('/VR=([0-9]*)/', $body_parse, $matches)) { | |
| 352 | 351 | $result['verticalrate'] = $matches[1]; | 
| 353 | 352 | } | 
| 354 | -		    if (preg_match('/TI=([0-9]*)/',$body_parse,$matches)) { | |
| 353 | +		    if (preg_match('/TI=([0-9]*)/', $body_parse, $matches)) { | |
| 355 | 354 | $result['typeid'] = $matches[1]; | 
| 356 | 355 | } | 
| 357 | -		    if (preg_match('/SI=([0-9]*)/',$body_parse,$matches)) { | |
| 356 | +		    if (preg_match('/SI=([0-9]*)/', $body_parse, $matches)) { | |
| 358 | 357 | $result['statusid'] = $matches[1]; | 
| 359 | 358 | } | 
| 360 | -		    if (preg_match('/IMO=([0-9]{7})/',$body_parse,$matches)) { | |
| 359 | +		    if (preg_match('/IMO=([0-9]{7})/', $body_parse, $matches)) { | |
| 361 | 360 | $result['imo'] = $matches[1]; | 
| 362 | 361 | } | 
| 363 | -		    if (preg_match('/AD=([0-9]*)/',$body_parse,$matches)) { | |
| 362 | +		    if (preg_match('/AD=([0-9]*)/', $body_parse, $matches)) { | |
| 364 | 363 | $result['arrival_date'] = $matches[1]; | 
| 365 | 364 | } | 
| 366 | -		    if (preg_match('/AC=([0-9A-Z_]*)/',$body_parse,$matches)) { | |
| 367 | -			$result['arrival_code'] = str_replace('_',' ',$matches[1]); | |
| 365 | +		    if (preg_match('/AC=([0-9A-Z_]*)/', $body_parse, $matches)) { | |
| 366 | +			$result['arrival_code'] = str_replace('_', ' ', $matches[1]); | |
| 368 | 367 | } | 
| 369 | 368 | // OGN comment | 
| 370 | 369 | // echo "Before OGN : ".$body_parse."\n"; | 
| 371 | 370 |  		    //if (preg_match('/^id([0-9A-F]{8}) ([+-])([0-9]{3,4})fpm ([+-])([0-9.]{3,4})rot (.*)$/',$body_parse,$matches)) { | 
| 372 | -		    if (preg_match('/^id([0-9A-F]{8})/',$body_parse,$matches)) { | |
| 371 | +		    if (preg_match('/^id([0-9A-F]{8})/', $body_parse, $matches)) { | |
| 373 | 372 | $id = $matches[1]; | 
| 374 | 373 | //$mode = substr($id,0,2); | 
| 375 | - $address = substr($id,2); | |
| 374 | + $address = substr($id, 2); | |
| 376 | 375 | //print_r($matches); | 
| 377 | - $addressType = (intval(substr($id,0,2),16))&3; | |
| 376 | + $addressType = (intval(substr($id, 0, 2), 16))&3; | |
| 378 | 377 | if ($addressType == 0) $result['addresstype'] = "RANDOM"; | 
| 379 | 378 | elseif ($addressType == 1) $result['addresstype'] = "ICAO"; | 
| 380 | 379 | elseif ($addressType == 2) $result['addresstype'] = "FLARM"; | 
| 381 | 380 | elseif ($addressType == 3) $result['addresstype'] = "OGN"; | 
| 382 | - $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); | |
| 381 | + $aircraftType = $this->urshift(((intval(substr($id, 0, 2), 16))&0b1111100), 2); | |
| 383 | 382 | $result['aircrafttype_code'] = $aircraftType; | 
| 384 | 383 | if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; | 
| 385 | 384 | elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; | 
| @@ -396,7 +395,7 @@ discard block | ||
| 396 | 395 | elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; | 
| 397 | 396 | elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; | 
| 398 | 397 | elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; | 
| 399 | - $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; | |
| 398 | + $stealth = (intval(substr($id, 0, 2), 16)&0b10000000) != 0; | |
| 400 | 399 | $result['stealth'] = $stealth; | 
| 401 | 400 | $result['address'] = $address; | 
| 402 | 401 | } | 
| @@ -408,73 +407,73 @@ discard block | ||
| 408 | 407 | //$body_parse = substr($body_parse,1); | 
| 409 | 408 | //$body_parse_len = strlen($body_parse); | 
| 410 | 409 | |
| 411 | -		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 410 | +		    if (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { | |
| 412 | 411 | $result['wind_dir'] = intval($matches[1]); | 
| 413 | - $result['wind_speed'] = round(intval($matches[2])*1.60934,1); | |
| 414 | - $result['wind_gust'] = round(intval($matches[3])*1.60934,1); | |
| 415 | - $result['temp'] = round(5/9*((intval($matches[4]))-32),1); | |
| 416 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 417 | -		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 412 | + $result['wind_speed'] = round(intval($matches[2])*1.60934, 1); | |
| 413 | + $result['wind_gust'] = round(intval($matches[3])*1.60934, 1); | |
| 414 | + $result['temp'] = round(5/9*((intval($matches[4])) - 32), 1); | |
| 415 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); | |
| 416 | +		    } elseif (preg_match('/^_{0,1}c([0-9 \\.\\-]{3})s([0-9 \\.]{3})g([0-9 \\.]+)t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { | |
| 418 | 417 | $result['wind_dir'] = intval($matches[1]); | 
| 419 | - $result['wind_speed'] = round($matches[2]*1.60934,1); | |
| 420 | - $result['wind_gust'] = round($matches[3]*1.60934,1); | |
| 421 | - $result['temp'] = round(5/9*(($matches[4])-32),1); | |
| 422 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 423 | -		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/',$body_parse,$matches)) { | |
| 418 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); | |
| 419 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); | |
| 420 | + $result['temp'] = round(5/9*(($matches[4]) - 32), 1); | |
| 421 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); | |
| 422 | +		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})t(-{0,1}[0-9 \\.]+)/', $body_parse, $matches)) { | |
| 424 | 423 | $result['wind_dir'] = intval($matches[1]); | 
| 425 | - $result['wind_speed'] = round($matches[2]*1.60934,1); | |
| 426 | - $result['wind_gust'] = round($matches[3]*1.60934,1); | |
| 427 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 428 | -		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/',$body_parse,$matches)) { | |
| 424 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); | |
| 425 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); | |
| 426 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); | |
| 427 | +		    } elseif (preg_match('/^_{0,1}([0-9 \\.\\-]{3})\\/([0-9 \\.]{3})g([0-9 \\.]+)/', $body_parse, $matches)) { | |
| 429 | 428 | $result['wind_dir'] = intval($matches[1]); | 
| 430 | - $result['wind_speed'] = round($matches[2]*1.60934,1); | |
| 431 | - $result['wind_gust'] = round($matches[3]*1.60934,1); | |
| 432 | - $body_parse = substr($body_parse,strlen($matches[0])+1); | |
| 429 | + $result['wind_speed'] = round($matches[2]*1.60934, 1); | |
| 430 | + $result['wind_gust'] = round($matches[3]*1.60934, 1); | |
| 431 | + $body_parse = substr($body_parse, strlen($matches[0]) + 1); | |
| 433 | 432 | } | 
| 434 | -		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/',$body_parse,$matches)) { | |
| 435 | - $result['temp'] = round(5/9*(($matches[1])-32),1); | |
| 433 | +		    if (!isset($result['temp']) && strlen($body_parse) > 0 && preg_match('/^g([0-9]+)t(-?[0-9 \\.]{1,3})/', $body_parse, $matches)) { | |
| 434 | + $result['temp'] = round(5/9*(($matches[1]) - 32), 1); | |
| 436 | 435 | } | 
| 437 | 436 | } | 
| 438 | 437 | } else $result['comment'] = trim($body_parse); | 
| 439 | 438 | |
| 440 | 439 | } | 
| 441 | 440 | //} | 
| 442 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); | |
| 443 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); | |
| 441 | + if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'], 4); | |
| 442 | + if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'], 4); | |
| 444 | 443 | if ($debug) print_r($result); | 
| 445 | 444 | return $result; | 
| 446 | 445 | } | 
| 447 | 446 | |
| 448 | 447 |      public function connect() { | 
| 449 | - global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass,$globalName, $globalServerAPRShost, $globalServerAPRSport; | |
| 448 | + global $globalAPRSversion, $globalServerAPRSssid, $globalServerAPRSpass, $globalName, $globalServerAPRShost, $globalServerAPRSport; | |
| 450 | 449 | $aprs_connect = 0; | 
| 451 | 450 | $aprs_keep = 120; | 
| 452 | 451 | $aprs_last_tx = time(); | 
| 453 | 452 | if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | 
| 454 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 453 | +	else $aprs_version = 'FlightAirMap '.str_replace(' ', '_', $globalName); | |
| 455 | 454 | if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; | 
| 456 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 455 | +	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ', '_', $globalName)), 0, 8); | |
| 457 | 456 | if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; | 
| 458 | 457 | else $aprs_pass = '-1'; | 
| 459 | 458 | |
| 460 | - $aprs_filter = ''; | |
| 459 | + $aprs_filter = ''; | |
| 461 | 460 |  	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | 
| 462 | 461 | $Common = new Common(); | 
| 463 | - $s = $Common->create_socket($globalServerAPRShost,$globalServerAPRSport,$errno,$errstr); | |
| 462 | + $s = $Common->create_socket($globalServerAPRShost, $globalServerAPRSport, $errno, $errstr); | |
| 464 | 463 |  	if ($s !== false) { | 
| 465 | 464 | echo 'Connected to APRS server! '."\n"; | 
| 466 | 465 | $authstart = time(); | 
| 467 | 466 | $this->socket = $s; | 
| 468 | - $send = socket_send( $this->socket , $aprs_login , strlen($aprs_login) , 0 ); | |
| 469 | - socket_set_option($this->socket,SOL_SOCKET,SO_KEEPALIVE,1); | |
| 470 | -		while ($msgin = socket_read($this->socket, 1000,PHP_NORMAL_READ)) { | |
| 467 | + $send = socket_send($this->socket, $aprs_login, strlen($aprs_login), 0); | |
| 468 | + socket_set_option($this->socket, SOL_SOCKET, SO_KEEPALIVE, 1); | |
| 469 | +		while ($msgin = socket_read($this->socket, 1000, PHP_NORMAL_READ)) { | |
| 471 | 470 |  			if (strpos($msgin, "$aprs_ssid verified") !== FALSE) { | 
| 472 | 471 | echo 'APRS user verified !'."\n"; | 
| 473 | 472 | $this->connected = true; | 
| 474 | 473 | return true; | 
| 475 | 474 | break; | 
| 476 | 475 | } | 
| 477 | -			if (time()-$authstart > 5) { | |
| 476 | +			if (time() - $authstart > 5) { | |
| 478 | 477 | echo 'APRS timeout'."\n"; | 
| 479 | 478 | break; | 
| 480 | 479 | } | 
| @@ -489,7 +488,7 @@ discard block | ||
| 489 | 488 |      public function send($data) { | 
| 490 | 489 | global $globalDebug; | 
| 491 | 490 | if ($this->connected === false) $this->connect(); | 
| 492 | - $send = socket_send( $this->socket , $data , strlen($data),0); | |
| 491 | + $send = socket_send($this->socket, $data, strlen($data), 0); | |
| 493 | 492 |  	if ($send === FALSE) { | 
| 494 | 493 | if ($globalDebug) echo 'Reconnect...'; | 
| 495 | 494 | socket_close($this->socket); | 
| @@ -499,14 +498,14 @@ discard block | ||
| 499 | 498 | } | 
| 500 | 499 | |
| 501 | 500 |  class APRSSpotter extends APRS { | 
| 502 | -	public function addLiveSpotterData($id,$ident,$aircraft_icao,$departure_airport,$arrival_airport,$latitude,$longitude,$waypoints,$altitude,$altitude_real,$heading,$speed,$datetime,$departure_airport_time,$arrival_airport_time,$squawk,$route_stop,$hex,$putinarchive,$registration,$pilot_id,$pilot_name, $verticalrate, $noarchive, $ground,$format_source,$source_name,$over_country) { | |
| 501 | +	public function addLiveSpotterData($id, $ident, $aircraft_icao, $departure_airport, $arrival_airport, $latitude, $longitude, $waypoints, $altitude, $altitude_real, $heading, $speed, $datetime, $departure_airport_time, $arrival_airport_time, $squawk, $route_stop, $hex, $putinarchive, $registration, $pilot_id, $pilot_name, $verticalrate, $noarchive, $ground, $format_source, $source_name, $over_country) { | |
| 503 | 502 | $Common = new Common(); | 
| 504 | 503 |  		if ($latitude != '' && $longitude != '') { | 
| 505 | - $latitude = $Common->convertDM($latitude,'latitude'); | |
| 506 | - $longitude = $Common->convertDM($longitude,'longitude'); | |
| 507 | -			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; | |
| 508 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); | |
| 509 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); | |
| 504 | + $latitude = $Common->convertDM($latitude, 'latitude'); | |
| 505 | + $longitude = $Common->convertDM($longitude, 'longitude'); | |
| 506 | +			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; | |
| 507 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); | |
| 508 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); | |
| 510 | 509 | $w = $w1.$w2; | 
| 511 | 510 | //$w = '00'; | 
| 512 | 511 | $custom = ''; | 
| @@ -527,25 +526,25 @@ discard block | ||
| 527 | 526 | $custom .= 'AI='.$aircraft_icao; | 
| 528 | 527 | } | 
| 529 | 528 | if ($custom != '') $custom = ' '.$custom; | 
| 530 | -			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | |
| 529 | +			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His', strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude_real, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | |
| 531 | 530 | } | 
| 532 | 531 | } | 
| 533 | 532 | } | 
| 534 | 533 |  class APRSMarine extends APRS { | 
| 535 | -	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed,$datetime, $putinarchive,$mmsi,$type,$typeid,$imo,$callsign,$arrival_code,$arrival_date,$status,$statusid,$noarchive,$format_source,$source_name,$over_country) { | |
| 534 | +	public function addLiveMarineData($id, $ident, $latitude, $longitude, $heading, $speed, $datetime, $putinarchive, $mmsi, $type, $typeid, $imo, $callsign, $arrival_code, $arrival_date, $status, $statusid, $noarchive, $format_source, $source_name, $over_country) { | |
| 536 | 535 | $Common = new Common(); | 
| 537 | 536 |  		if ($latitude != '' && $longitude != '') { | 
| 538 | - $latitude = $Common->convertDM($latitude,'latitude'); | |
| 539 | - $longitude = $Common->convertDM($longitude,'longitude'); | |
| 540 | -			$coordinate = sprintf("%02d",$latitude['deg']).str_pad(number_format($latitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d",$longitude['deg']).str_pad(number_format($longitude['min'],2,'.',''),5,'0',STR_PAD_LEFT).$longitude['NSEW']; | |
| 541 | - $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'],2,'.',''))*1000)); | |
| 542 | - $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'],2,'.',''))*1000)); | |
| 537 | + $latitude = $Common->convertDM($latitude, 'latitude'); | |
| 538 | + $longitude = $Common->convertDM($longitude, 'longitude'); | |
| 539 | +			$coordinate = sprintf("%02d", $latitude['deg']).str_pad(number_format($latitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$latitude['NSEW'].'/'.sprintf("%03d", $longitude['deg']).str_pad(number_format($longitude['min'], 2, '.', ''), 5, '0', STR_PAD_LEFT).$longitude['NSEW']; | |
| 540 | + $w1 = abs(ceil(($latitude['min'] - number_format($latitude['min'], 2, '.', ''))*1000)); | |
| 541 | + $w2 = abs(ceil(($longitude['min'] - number_format($longitude['min'], 2, '.', ''))*1000)); | |
| 543 | 542 | $w = $w1.$w2; | 
| 544 | 543 | //$w = '00'; | 
| 545 | 544 | $custom = ''; | 
| 546 | 545 |  			if ($ident != '') { | 
| 547 | 546 | if ($custom != '') $custom .= '/'; | 
| 548 | -				$custom .= 'CS='.str_replace(' ','_',$ident); | |
| 547 | +				$custom .= 'CS='.str_replace(' ', '_', $ident); | |
| 549 | 548 | } | 
| 550 | 549 |  			if ($typeid != '') { | 
| 551 | 550 | if ($custom != '') $custom .= '/'; | 
| @@ -565,11 +564,11 @@ discard block | ||
| 565 | 564 | } | 
| 566 | 565 |  			if ($arrival_code != '') { | 
| 567 | 566 | if ($custom != '') $custom .= '/'; | 
| 568 | -				$custom .= 'AC='.str_replace(' ','_',$arrival_code); | |
| 567 | +				$custom .= 'AC='.str_replace(' ', '_', $arrival_code); | |
| 569 | 568 | } | 
| 570 | 569 | if ($custom != '') $custom = ' '.$custom; | 
| 571 | 570 | $altitude = 0; | 
| 572 | -			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | |
| 571 | +			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His', strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading, 3, '0', STR_PAD_LEFT).'/'.str_pad($speed, 3, '0', STR_PAD_LEFT).'/A='.str_pad($altitude, 6, '0', STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | |
| 573 | 572 | } | 
| 574 | 573 | } | 
| 575 | 574 | } | 
| @@ -107,17 +107,23 @@ discard block | ||
| 107 | 107 | |
| 108 | 108 | /* Check that end was found and body has at least one byte. */ | 
| 109 | 109 |  	if ($splitpos == 0 || $splitpos + 1 == $input_len || $splitpos === FALSE) { | 
| 110 | - if ($globalDebug) echo '!!! APRS invalid : '.$input."\n"; | |
| 110 | +	    if ($globalDebug) { | |
| 111 | + echo '!!! APRS invalid : '.$input."\n"; | |
| 112 | + } | |
| 111 | 113 | return false; | 
| 112 | 114 | } | 
| 113 | 115 | |
| 114 | - if ($debug) echo 'input : '.$input."\n"; | |
| 116 | +	if ($debug) { | |
| 117 | + echo 'input : '.$input."\n"; | |
| 118 | + } | |
| 115 | 119 | /* Save header and body. */ | 
| 116 | 120 | $body = substr($input,$splitpos+1,$input_len); | 
| 117 | 121 | $body_len = strlen($body); | 
| 118 | 122 | $header = substr($input,0,$splitpos); | 
| 119 | 123 | //$header_len = strlen($header); | 
| 120 | - if ($debug) echo 'header : '.$header."\n"; | |
| 124 | +	if ($debug) { | |
| 125 | + echo 'header : '.$header."\n"; | |
| 126 | + } | |
| 121 | 127 | |
| 122 | 128 | /* Parse source, target and path. */ | 
| 123 | 129 | //FLRDF0A52>APRS,qAS,LSTB | 
| @@ -131,11 +137,15 @@ discard block | ||
| 131 | 137 | $result['format_source'] = 'famaprs'; | 
| 132 | 138 | $result['source_type'] = 'ais'; | 
| 133 | 139 |  	    } else { | 
| 134 | - if ($debug) echo 'ident : '.$ident."\n"; | |
| 140 | +		if ($debug) { | |
| 141 | + echo 'ident : '.$ident."\n"; | |
| 142 | + } | |
| 135 | 143 | $result['ident'] = $ident; | 
| 136 | 144 | } | 
| 137 | 145 |  	} else { | 
| 138 | - if ($debug) 'No ident'."\n"; | |
| 146 | +	    if ($debug) { | |
| 147 | + 'No ident'."\n"; | |
| 148 | + } | |
| 139 | 149 | return false; | 
| 140 | 150 | } | 
| 141 | 151 |  	$elements = explode(',',$all_elements); | 
| @@ -146,7 +156,9 @@ discard block | ||
| 146 | 156 | //echo "ok"; | 
| 147 | 157 | //if ($element == 'TCPIP*') return false; | 
| 148 | 158 |  	    } elseif (!preg_match('/^([0-9A-F]{32})$/',$element)) { | 
| 149 | - if ($debug) echo 'element : '.$element."\n"; | |
| 159 | +		if ($debug) { | |
| 160 | + echo 'element : '.$element."\n"; | |
| 161 | + } | |
| 150 | 162 | return false; | 
| 151 | 163 | } | 
| 152 | 164 | /* | 
| @@ -159,13 +171,17 @@ discard block | ||
| 159 | 171 | } | 
| 160 | 172 | |
| 161 | 173 | $type = substr($body,0,1); | 
| 162 | - if ($debug) echo 'type : '.$type."\n"; | |
| 174 | +	if ($debug) { | |
| 175 | + echo 'type : '.$type."\n"; | |
| 176 | + } | |
| 163 | 177 |  	if ($type == ';') { | 
| 164 | 178 |  		if (isset($result['source_type']) && $result['source_type'] == 'modes') { | 
| 165 | 179 | $result['address'] = trim(substr($body,1,9)); | 
| 166 | 180 |  		} elseif (isset($result['source_type']) && $result['source_type'] == 'ais') { | 
| 167 | 181 | $result['mmsi'] = trim(substr($body,1,9)); | 
| 168 | - } else $result['ident'] = trim(substr($body,1,9)); | |
| 182 | +		} else { | |
| 183 | + $result['ident'] = trim(substr($body,1,9)); | |
| 184 | + } | |
| 169 | 185 |  	} elseif ($type == ',') { | 
| 170 | 186 | // Invalid data or test data | 
| 171 | 187 | return false; | 
| @@ -233,7 +249,9 @@ discard block | ||
| 233 | 249 | //$symbol_table = $matches[4]; | 
| 234 | 250 | $lat = intval($lat_deg); | 
| 235 | 251 | $lon = intval($lon_deg); | 
| 236 | - if ($lat > 89 || $lon > 179) return false; | |
| 252 | +		if ($lat > 89 || $lon > 179) { | |
| 253 | + return false; | |
| 254 | + } | |
| 237 | 255 | |
| 238 | 256 | /* | 
| 239 | 257 |  	    $tmp_5b = str_replace('.','',$lat_min); | 
| @@ -243,8 +261,12 @@ discard block | ||
| 243 | 261 | */ | 
| 244 | 262 | $latitude = $lat + floatval($lat_min)/60; | 
| 245 | 263 | $longitude = $lon + floatval($lon_min)/60; | 
| 246 | - if ($sind == 'S') $latitude = 0-$latitude; | |
| 247 | - if ($wind == 'W') $longitude = 0-$longitude; | |
| 264 | +		if ($sind == 'S') { | |
| 265 | + $latitude = 0-$latitude; | |
| 266 | + } | |
| 267 | +		if ($wind == 'W') { | |
| 268 | + $longitude = 0-$longitude; | |
| 269 | + } | |
| 248 | 270 | $result['latitude'] = $latitude; | 
| 249 | 271 | $result['longitude'] = $longitude; | 
| 250 | 272 | $body_parse = substr($body_parse,18); | 
| @@ -278,7 +300,9 @@ discard block | ||
| 278 | 300 | $body_parse = substr($body_parse,1); | 
| 279 | 301 | $body_parse_len = strlen($body_parse); | 
| 280 | 302 | $result['symbol_code'] = $symbol_code; | 
| 281 | - if (isset($this->symbols[$symbol_code])) $result['symbol'] = $this->symbols[$symbol_code]; | |
| 303 | +			if (isset($this->symbols[$symbol_code])) { | |
| 304 | + $result['symbol'] = $this->symbols[$symbol_code]; | |
| 305 | + } | |
| 282 | 306 |  			if ($symbol_code != '_') { | 
| 283 | 307 | } | 
| 284 | 308 | //$body_parse = substr($body_parse,1); | 
| @@ -289,7 +313,9 @@ discard block | ||
| 289 | 313 |  		        if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { | 
| 290 | 314 | $course = substr($body_parse,0,3); | 
| 291 | 315 | $tmp_s = intval($course); | 
| 292 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['heading'] = intval($course); | |
| 316 | +		    	    if ($tmp_s >= 1 && $tmp_s <= 360) { | |
| 317 | + $result['heading'] = intval($course); | |
| 318 | + } | |
| 293 | 319 | $speed = substr($body_parse,4,3); | 
| 294 | 320 |  		    	    if ($speed != '...') { | 
| 295 | 321 | //$result['speed'] = round($speed*1.852); | 
| @@ -330,10 +356,16 @@ discard block | ||
| 330 | 356 | $lat_off = (($dao_split[1])-48.0)*0.001/60.0; | 
| 331 | 357 | $lon_off = (($dao_split[2])-48.0)*0.001/60.0; | 
| 332 | 358 | |
| 333 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; | |
| 334 | - else $result['latitude'] += $lat_off; | |
| 335 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; | |
| 336 | - else $result['longitude'] += $lon_off; | |
| 359 | +				if ($result['latitude'] < 0) { | |
| 360 | + $result['latitude'] -= $lat_off; | |
| 361 | +				} else { | |
| 362 | + $result['latitude'] += $lat_off; | |
| 363 | + } | |
| 364 | +				if ($result['longitude'] < 0) { | |
| 365 | + $result['longitude'] -= $lon_off; | |
| 366 | +				} else { | |
| 367 | + $result['longitude'] += $lon_off; | |
| 368 | + } | |
| 337 | 369 | } | 
| 338 | 370 | |
| 339 | 371 | $body_parse = substr($body_parse,6); | 
| @@ -375,27 +407,48 @@ discard block | ||
| 375 | 407 | $address = substr($id,2); | 
| 376 | 408 | //print_r($matches); | 
| 377 | 409 | $addressType = (intval(substr($id,0,2),16))&3; | 
| 378 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; | |
| 379 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; | |
| 380 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; | |
| 381 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; | |
| 410 | +			if ($addressType == 0) { | |
| 411 | + $result['addresstype'] = "RANDOM"; | |
| 412 | +			} elseif ($addressType == 1) { | |
| 413 | + $result['addresstype'] = "ICAO"; | |
| 414 | +			} elseif ($addressType == 2) { | |
| 415 | + $result['addresstype'] = "FLARM"; | |
| 416 | +			} elseif ($addressType == 3) { | |
| 417 | + $result['addresstype'] = "OGN"; | |
| 418 | + } | |
| 382 | 419 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); | 
| 383 | 420 | $result['aircrafttype_code'] = $aircraftType; | 
| 384 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; | |
| 385 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; | |
| 386 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; | |
| 387 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; | |
| 388 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; | |
| 389 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; | |
| 390 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; | |
| 391 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; | |
| 392 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; | |
| 393 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; | |
| 394 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; | |
| 395 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; | |
| 396 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; | |
| 397 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; | |
| 398 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; | |
| 421 | +			if ($aircraftType == 0) { | |
| 422 | + $result['aircrafttype'] = "UNKNOWN"; | |
| 423 | +			} elseif ($aircraftType == 1) { | |
| 424 | + $result['aircrafttype'] = "GLIDER"; | |
| 425 | +			} elseif ($aircraftType == 2) { | |
| 426 | + $result['aircrafttype'] = "TOW_PLANE"; | |
| 427 | +			} elseif ($aircraftType == 3) { | |
| 428 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; | |
| 429 | +			} elseif ($aircraftType == 4) { | |
| 430 | + $result['aircrafttype'] = "PARACHUTE"; | |
| 431 | +			} elseif ($aircraftType == 5) { | |
| 432 | + $result['aircrafttype'] = "DROP_PLANE"; | |
| 433 | +			} elseif ($aircraftType == 6) { | |
| 434 | + $result['aircrafttype'] = "HANG_GLIDER"; | |
| 435 | +			} elseif ($aircraftType == 7) { | |
| 436 | + $result['aircrafttype'] = "PARA_GLIDER"; | |
| 437 | +			} elseif ($aircraftType == 8) { | |
| 438 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; | |
| 439 | +			} elseif ($aircraftType == 9) { | |
| 440 | + $result['aircrafttype'] = "JET_AIRCRAFT"; | |
| 441 | +			} elseif ($aircraftType == 10) { | |
| 442 | + $result['aircrafttype'] = "UFO"; | |
| 443 | +			} elseif ($aircraftType == 11) { | |
| 444 | + $result['aircrafttype'] = "BALLOON"; | |
| 445 | +			} elseif ($aircraftType == 12) { | |
| 446 | + $result['aircrafttype'] = "AIRSHIP"; | |
| 447 | +			} elseif ($aircraftType == 13) { | |
| 448 | + $result['aircrafttype'] = "UAV"; | |
| 449 | +			} elseif ($aircraftType == 15) { | |
| 450 | + $result['aircrafttype'] = "STATIC_OBJECT"; | |
| 451 | + } | |
| 399 | 452 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; | 
| 400 | 453 | $result['stealth'] = $stealth; | 
| 401 | 454 | $result['address'] = $address; | 
| @@ -435,13 +488,21 @@ discard block | ||
| 435 | 488 | $result['temp'] = round(5/9*(($matches[1])-32),1); | 
| 436 | 489 | } | 
| 437 | 490 | } | 
| 438 | - } else $result['comment'] = trim($body_parse); | |
| 491 | +		} else { | |
| 492 | + $result['comment'] = trim($body_parse); | |
| 493 | + } | |
| 439 | 494 | |
| 440 | 495 | } | 
| 441 | 496 | //} | 
| 442 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); | |
| 443 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); | |
| 444 | - if ($debug) print_r($result); | |
| 497 | +	if (isset($result['latitude'])) { | |
| 498 | + $result['latitude'] = round($result['latitude'],4); | |
| 499 | + } | |
| 500 | +	if (isset($result['longitude'])) { | |
| 501 | + $result['longitude'] = round($result['longitude'],4); | |
| 502 | + } | |
| 503 | +	if ($debug) { | |
| 504 | + print_r($result); | |
| 505 | + } | |
| 445 | 506 | return $result; | 
| 446 | 507 | } | 
| 447 | 508 | |
| @@ -450,12 +511,21 @@ discard block | ||
| 450 | 511 | $aprs_connect = 0; | 
| 451 | 512 | $aprs_keep = 120; | 
| 452 | 513 | $aprs_last_tx = time(); | 
| 453 | - if (isset($globalAPRSversion)) $aprs_version = $globalAPRSversion; | |
| 454 | -	else $aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 455 | - if (isset($globalServerAPRSssid)) $aprs_ssid = $globalServerAPRSssid; | |
| 456 | -	else $aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 457 | - if (isset($globalServerAPRSpass)) $aprs_pass = $globalServerAPRSpass; | |
| 458 | - else $aprs_pass = '-1'; | |
| 514 | +	if (isset($globalAPRSversion)) { | |
| 515 | + $aprs_version = $globalAPRSversion; | |
| 516 | +	} else { | |
| 517 | +		$aprs_version = 'FlightAirMap '.str_replace(' ','_',$globalName); | |
| 518 | + } | |
| 519 | +	if (isset($globalServerAPRSssid)) { | |
| 520 | + $aprs_ssid = $globalServerAPRSssid; | |
| 521 | +	} else { | |
| 522 | +		$aprs_ssid = substr('FAM'.strtoupper(str_replace(' ','_',$globalName)),0,8); | |
| 523 | + } | |
| 524 | +	if (isset($globalServerAPRSpass)) { | |
| 525 | + $aprs_pass = $globalServerAPRSpass; | |
| 526 | +	} else { | |
| 527 | + $aprs_pass = '-1'; | |
| 528 | + } | |
| 459 | 529 | |
| 460 | 530 | $aprs_filter = ''; | 
| 461 | 531 |  	$aprs_login = "user {$aprs_ssid} pass {$aprs_pass} vers {$aprs_version}\n"; | 
| @@ -488,10 +558,14 @@ discard block | ||
| 488 | 558 | |
| 489 | 559 |      public function send($data) { | 
| 490 | 560 | global $globalDebug; | 
| 491 | - if ($this->connected === false) $this->connect(); | |
| 561 | +	if ($this->connected === false) { | |
| 562 | + $this->connect(); | |
| 563 | + } | |
| 492 | 564 | $send = socket_send( $this->socket , $data , strlen($data),0); | 
| 493 | 565 |  	if ($send === FALSE) { | 
| 494 | - if ($globalDebug) echo 'Reconnect...'; | |
| 566 | +		if ($globalDebug) { | |
| 567 | + echo 'Reconnect...'; | |
| 568 | + } | |
| 495 | 569 | socket_close($this->socket); | 
| 496 | 570 | $this->connect(); | 
| 497 | 571 | } | 
| @@ -511,22 +585,32 @@ discard block | ||
| 511 | 585 | //$w = '00'; | 
| 512 | 586 | $custom = ''; | 
| 513 | 587 |  			if ($ident != '') { | 
| 514 | - if ($custom != '') $custom .= '/'; | |
| 588 | +				if ($custom != '') { | |
| 589 | + $custom .= '/'; | |
| 590 | + } | |
| 515 | 591 | $custom .= 'CS='.$ident; | 
| 516 | 592 | } | 
| 517 | 593 |  			if ($squawk != '') { | 
| 518 | - if ($custom != '') $custom .= '/'; | |
| 594 | +				if ($custom != '') { | |
| 595 | + $custom .= '/'; | |
| 596 | + } | |
| 519 | 597 | $custom .= 'SQ='.$squawk; | 
| 520 | 598 | } | 
| 521 | 599 |  			if ($verticalrate != '') { | 
| 522 | - if ($custom != '') $custom .= '/'; | |
| 600 | +				if ($custom != '') { | |
| 601 | + $custom .= '/'; | |
| 602 | + } | |
| 523 | 603 | $custom .= 'VR='.$verticalrate; | 
| 524 | 604 | } | 
| 525 | 605 |  			if ($aircraft_icao != '' && $aircraft_icao != 'NA') { | 
| 526 | - if ($custom != '') $custom .= '/'; | |
| 606 | +				if ($custom != '') { | |
| 607 | + $custom .= '/'; | |
| 608 | + } | |
| 527 | 609 | $custom .= 'AI='.$aircraft_icao; | 
| 528 | 610 | } | 
| 529 | - if ($custom != '') $custom = ' '.$custom; | |
| 611 | +			if ($custom != '') { | |
| 612 | + $custom = ' '.$custom; | |
| 613 | + } | |
| 530 | 614 |  			$this->send('AIRCRAFT>APRS,TCPIP*:;'.$hex.'   *'.date('His',strtotime($datetime)).'h'.$coordinate.'^'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude_real,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | 
| 531 | 615 | } | 
| 532 | 616 | } | 
| @@ -544,30 +628,44 @@ discard block | ||
| 544 | 628 | //$w = '00'; | 
| 545 | 629 | $custom = ''; | 
| 546 | 630 |  			if ($ident != '') { | 
| 547 | - if ($custom != '') $custom .= '/'; | |
| 631 | +				if ($custom != '') { | |
| 632 | + $custom .= '/'; | |
| 633 | + } | |
| 548 | 634 |  				$custom .= 'CS='.str_replace(' ','_',$ident); | 
| 549 | 635 | } | 
| 550 | 636 |  			if ($typeid != '') { | 
| 551 | - if ($custom != '') $custom .= '/'; | |
| 637 | +				if ($custom != '') { | |
| 638 | + $custom .= '/'; | |
| 639 | + } | |
| 552 | 640 | $custom .= 'TI='.$typeid; | 
| 553 | 641 | } | 
| 554 | 642 |  			if ($statusid != '') { | 
| 555 | - if ($custom != '') $custom .= '/'; | |
| 643 | +				if ($custom != '') { | |
| 644 | + $custom .= '/'; | |
| 645 | + } | |
| 556 | 646 | $custom .= 'SI='.$statusid; | 
| 557 | 647 | } | 
| 558 | 648 |  			if ($imo != '') { | 
| 559 | - if ($custom != '') $custom .= '/'; | |
| 649 | +				if ($custom != '') { | |
| 650 | + $custom .= '/'; | |
| 651 | + } | |
| 560 | 652 | $custom .= 'IMO='.$imo; | 
| 561 | 653 | } | 
| 562 | 654 |  			if ($arrival_date != '') { | 
| 563 | - if ($custom != '') $custom .= '/'; | |
| 655 | +				if ($custom != '') { | |
| 656 | + $custom .= '/'; | |
| 657 | + } | |
| 564 | 658 | $custom .= 'AD='.strtotime($arrival_date); | 
| 565 | 659 | } | 
| 566 | 660 |  			if ($arrival_code != '') { | 
| 567 | - if ($custom != '') $custom .= '/'; | |
| 661 | +				if ($custom != '') { | |
| 662 | + $custom .= '/'; | |
| 663 | + } | |
| 568 | 664 |  				$custom .= 'AC='.str_replace(' ','_',$arrival_code); | 
| 569 | 665 | } | 
| 570 | - if ($custom != '') $custom = ' '.$custom; | |
| 666 | +			if ($custom != '') { | |
| 667 | + $custom = ' '.$custom; | |
| 668 | + } | |
| 571 | 669 | $altitude = 0; | 
| 572 | 670 |  			$this->send('MARINE>APRS,TCPIP*:;'.$mmsi.'*'.date('His',strtotime($datetime)).'h'.$coordinate.'s'.str_pad($heading,3,'0',STR_PAD_LEFT).'/'.str_pad($speed,3,'0',STR_PAD_LEFT).'/A='.str_pad($altitude,6,'0',STR_PAD_LEFT).' !W'.$w.'!'.$custom."\n"); | 
| 573 | 671 | } | 
| @@ -15,7 +15,7 @@ discard block | ||
| 15 | 15 |  		try { | 
| 16 | 16 | $sth = $this->db->prepare($query); | 
| 17 | 17 | $sth->execute($query_values); | 
| 18 | -		} catch(PDOException $e) { | |
| 18 | +		} catch (PDOException $e) { | |
| 19 | 19 | return "error : ".$e->getMessage(); | 
| 20 | 20 | } | 
| 21 | 21 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -28,7 +28,7 @@ discard block | ||
| 28 | 28 |  		try { | 
| 29 | 29 | $sth = $this->db->prepare($query); | 
| 30 | 30 | $sth->execute($query_values); | 
| 31 | -		} catch(PDOException $e) { | |
| 31 | +		} catch (PDOException $e) { | |
| 32 | 32 | return "error : ".$e->getMessage(); | 
| 33 | 33 | } | 
| 34 | 34 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -41,7 +41,7 @@ discard block | ||
| 41 | 41 |  		try { | 
| 42 | 42 | $sth = $this->db->prepare($query); | 
| 43 | 43 | $sth->execute($query_values); | 
| 44 | -		} catch(PDOException $e) { | |
| 44 | +		} catch (PDOException $e) { | |
| 45 | 45 | return "error : ".$e->getMessage(); | 
| 46 | 46 | } | 
| 47 | 47 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 |  		try { | 
| 55 | 55 | $sth = $this->db->prepare($query); | 
| 56 | 56 | $sth->execute($query_values); | 
| 57 | -		} catch(PDOException $e) { | |
| 57 | +		} catch (PDOException $e) { | |
| 58 | 58 | return "error : ".$e->getMessage(); | 
| 59 | 59 | } | 
| 60 | 60 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -67,7 +67,7 @@ discard block | ||
| 67 | 67 |  		try { | 
| 68 | 68 | $sth = $this->db->prepare($query); | 
| 69 | 69 | $sth->execute($query_values); | 
| 70 | -		} catch(PDOException $e) { | |
| 70 | +		} catch (PDOException $e) { | |
| 71 | 71 | return "error : ".$e->getMessage(); | 
| 72 | 72 | } | 
| 73 | 73 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| @@ -80,57 +80,57 @@ discard block | ||
| 80 | 80 |  		try { | 
| 81 | 81 | $sth = $this->db->prepare($query); | 
| 82 | 82 | $sth->execute($query_values); | 
| 83 | -		} catch(PDOException $e) { | |
| 83 | +		} catch (PDOException $e) { | |
| 84 | 84 | return "error : ".$e->getMessage(); | 
| 85 | 85 | } | 
| 86 | 86 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); | 
| 87 | 87 | return $all; | 
| 88 | 88 | } | 
| 89 | 89 | |
| 90 | -	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { | |
| 90 | +	public function addLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { | |
| 91 | 91 |  		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); | 
| 92 | 92 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; | 
| 93 | -		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); | |
| 93 | +		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); | |
| 94 | 94 |  		try { | 
| 95 | 95 | $sth = $this->db->prepare($query); | 
| 96 | 96 | $sth->execute($query_values); | 
| 97 | -		} catch(PDOException $e) { | |
| 97 | +		} catch (PDOException $e) { | |
| 98 | 98 | echo "error : ".$e->getMessage(); | 
| 99 | 99 | } | 
| 100 | 100 | } | 
| 101 | 101 | |
| 102 | -	public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { | |
| 102 | +	public function updateLocation($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id = 0, $last_seen = '', $description = '') { | |
| 103 | 103 |  		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); | 
| 104 | 104 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; | 
| 105 | -		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); | |
| 105 | +		$query_values = array(':name' => $name, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':source_id' => $source_id, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); | |
| 106 | 106 |  		try { | 
| 107 | 107 | $sth = $this->db->prepare($query); | 
| 108 | 108 | $sth->execute($query_values); | 
| 109 | -		} catch(PDOException $e) { | |
| 109 | +		} catch (PDOException $e) { | |
| 110 | 110 | return "error : ".$e->getMessage(); | 
| 111 | 111 | } | 
| 112 | 112 | } | 
| 113 | 113 | |
| 114 | -	public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { | |
| 114 | +	public function updateLocationDescByName($name, $source, $source_id = 0, $description = '') { | |
| 115 | 115 |  		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); | 
| 116 | 116 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; | 
| 117 | -		$query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); | |
| 117 | +		$query_values = array(':name' => $name, ':source' => $source, ':source_id' => $source_id, ':description' => $description); | |
| 118 | 118 |  		try { | 
| 119 | 119 | $sth = $this->db->prepare($query); | 
| 120 | 120 | $sth->execute($query_values); | 
| 121 | -		} catch(PDOException $e) { | |
| 121 | +		} catch (PDOException $e) { | |
| 122 | 122 | return "error : ".$e->getMessage(); | 
| 123 | 123 | } | 
| 124 | 124 | } | 
| 125 | 125 | |
| 126 | -	public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { | |
| 126 | +	public function updateLocationByLocationID($name, $latitude, $longitude, $altitude, $city, $country, $source, $logo = 'antenna.png', $type = '', $source_id = 0, $location_id, $last_seen = '', $description = '') { | |
| 127 | 127 |  		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); | 
| 128 | 128 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; | 
| 129 | -		$query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); | |
| 129 | +		$query_values = array(':source_id' => $source_id, ':latitude' => $latitude, ':longitude' => $longitude, ':altitude' => $altitude, ':city' => $city, ':country' => $country, ':logo' => $logo, ':source' => $source, ':type' => $type, ':last_seen' => $last_seen, ':location_id' => $location_id, ':description' => $description); | |
| 130 | 130 |  		try { | 
| 131 | 131 | $sth = $this->db->prepare($query); | 
| 132 | 132 | $sth->execute($query_values); | 
| 133 | -		} catch(PDOException $e) { | |
| 133 | +		} catch (PDOException $e) { | |
| 134 | 134 | echo "error : ".$e->getMessage(); | 
| 135 | 135 | } | 
| 136 | 136 | } | 
| @@ -141,7 +141,7 @@ discard block | ||
| 141 | 141 |  		try { | 
| 142 | 142 | $sth = $this->db->prepare($query); | 
| 143 | 143 | $sth->execute($query_values); | 
| 144 | -		} catch(PDOException $e) { | |
| 144 | +		} catch (PDOException $e) { | |
| 145 | 145 | return "error : ".$e->getMessage(); | 
| 146 | 146 | } | 
| 147 | 147 | } | 
| @@ -152,7 +152,7 @@ discard block | ||
| 152 | 152 |  		try { | 
| 153 | 153 | $sth = $this->db->prepare($query); | 
| 154 | 154 | $sth->execute($query_values); | 
| 155 | -		} catch(PDOException $e) { | |
| 155 | +		} catch (PDOException $e) { | |
| 156 | 156 | return "error : ".$e->getMessage(); | 
| 157 | 157 | } | 
| 158 | 158 | } | 
| @@ -162,7 +162,7 @@ discard block | ||
| 162 | 162 |  		try { | 
| 163 | 163 | $sth = $this->db->prepare($query); | 
| 164 | 164 | $sth->execute(); | 
| 165 | -		} catch(PDOException $e) { | |
| 165 | +		} catch (PDOException $e) { | |
| 166 | 166 | return "error : ".$e->getMessage(); | 
| 167 | 167 | } | 
| 168 | 168 | } | 
| @@ -177,7 +177,7 @@ discard block | ||
| 177 | 177 |  		try { | 
| 178 | 178 | $sth = $this->db->prepare($query); | 
| 179 | 179 |  			$sth->execute(array(':type' => $type)); | 
| 180 | -		} catch(PDOException $e) { | |
| 180 | +		} catch (PDOException $e) { | |
| 181 | 181 | return "error"; | 
| 182 | 182 | } | 
| 183 | 183 | return "success"; | 
| @@ -88,7 +88,9 @@ discard block | ||
| 88 | 88 | } | 
| 89 | 89 | |
| 90 | 90 |  	public function addLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '', $description = '') { | 
| 91 | -		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); | |
| 91 | +		if ($last_seen == '') { | |
| 92 | +			$last_seen = date('Y-m-d H:i:s'); | |
| 93 | + } | |
| 92 | 94 | $query = "INSERT INTO source_location (name,latitude,longitude,altitude,country,city,logo,source,type,source_id,last_seen,location_id,description) VALUES (:name,:latitude,:longitude,:altitude,:country,:city,:logo,:source,:type,:source_id,:last_seen,:location_id,:description)"; | 
| 93 | 95 |  		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); | 
| 94 | 96 |  		try { | 
| @@ -100,7 +102,9 @@ discard block | ||
| 100 | 102 | } | 
| 101 | 103 | |
| 102 | 104 |  	public function updateLocation($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0,$location_id = 0,$last_seen = '',$description = '') { | 
| 103 | -		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); | |
| 105 | +		if ($last_seen == '') { | |
| 106 | +			$last_seen = date('Y-m-d H:i:s'); | |
| 107 | + } | |
| 104 | 108 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, source_id = :source_id, last_seen = :last_seen,location_id = :location_id, description = :description WHERE name = :name AND source = :source"; | 
| 105 | 109 |  		$query_values = array(':name' => $name,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':source_id' => $source_id,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); | 
| 106 | 110 |  		try { | 
| @@ -112,7 +116,9 @@ discard block | ||
| 112 | 116 | } | 
| 113 | 117 | |
| 114 | 118 |  	public function updateLocationDescByName($name,$source,$source_id = 0,$description = '') { | 
| 115 | -		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); | |
| 119 | +		if ($last_seen == '') { | |
| 120 | +			$last_seen = date('Y-m-d H:i:s'); | |
| 121 | + } | |
| 116 | 122 | $query = "UPDATE source_location SET description = :description WHERE source_id = :source_id AND name = :name AND source = :source"; | 
| 117 | 123 |  		$query_values = array(':name' => $name,':source' => $source,':source_id' => $source_id,':description' => $description); | 
| 118 | 124 |  		try { | 
| @@ -124,7 +130,9 @@ discard block | ||
| 124 | 130 | } | 
| 125 | 131 | |
| 126 | 132 |  	public function updateLocationByLocationID($name,$latitude,$longitude,$altitude,$city,$country,$source,$logo = 'antenna.png',$type = '',$source_id = 0, $location_id,$last_seen = '',$description = '') { | 
| 127 | -		if ($last_seen == '') $last_seen = date('Y-m-d H:i:s'); | |
| 133 | +		if ($last_seen == '') { | |
| 134 | +			$last_seen = date('Y-m-d H:i:s'); | |
| 135 | + } | |
| 128 | 136 | $query = "UPDATE source_location SET latitude = :latitude,longitude = :longitude,altitude = :altitude,country = :country,city = :city,logo = :logo,type = :type, last_seen = :last_seen, description = :description WHERE location_id = :location_id AND source = :source AND source_id = :source_id"; | 
| 129 | 137 |  		$query_values = array(':source_id' => $source_id,':latitude' => $latitude, ':longitude' => $longitude,':altitude' => $altitude,':city' => $city,':country' => $country,':logo' => $logo,':source' => $source,':type' => $type,':last_seen' => $last_seen,':location_id' => $location_id,':description' => $description); | 
| 130 | 138 |  		try { |