@@ -6,6 +6,9 @@ discard block |
||
| 6 | 6 | public $dbs = array(); |
| 7 | 7 | public $latest_schema = 37; |
| 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) return true; |
@@ -133,6 +136,9 @@ discard block |
||
| 133 | 136 | return true; |
| 134 | 137 | } |
| 135 | 138 | |
| 139 | + /** |
|
| 140 | + * @param string $table |
|
| 141 | + */ |
|
| 136 | 142 | public function tableExists($table) |
| 137 | 143 | { |
| 138 | 144 | global $globalDBdriver, $globalDBname; |
@@ -182,6 +188,11 @@ discard block |
||
| 182 | 188 | /* |
| 183 | 189 | * Check if index exist |
| 184 | 190 | */ |
| 191 | + |
|
| 192 | + /** |
|
| 193 | + * @param string $table |
|
| 194 | + * @param string $index |
|
| 195 | + */ |
|
| 185 | 196 | public function indexExists($table,$index) |
| 186 | 197 | { |
| 187 | 198 | global $globalDBdriver, $globalDBname; |
@@ -224,6 +235,10 @@ discard block |
||
| 224 | 235 | return $columns; |
| 225 | 236 | } |
| 226 | 237 | |
| 238 | + /** |
|
| 239 | + * @param string $table |
|
| 240 | + * @param string $column |
|
| 241 | + */ |
|
| 227 | 242 | public function getColumnType($table,$column) { |
| 228 | 243 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 229 | 244 | $tomet = $select->getColumnMeta(0); |
@@ -234,6 +249,11 @@ discard block |
||
| 234 | 249 | * Check if a column name exist in a table |
| 235 | 250 | * @return Boolean column exist or not |
| 236 | 251 | */ |
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @param string $table |
|
| 255 | + * @param string $name |
|
| 256 | + */ |
|
| 237 | 257 | public function checkColumnName($table,$name) |
| 238 | 258 | { |
| 239 | 259 | global $globalDBdriver, $globalDBname; |
@@ -7,32 +7,32 @@ discard block |
||
| 7 | 7 | public $latest_schema = 37; |
| 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) return true; |
|
| 12 | - if ($dbc === null) { |
|
| 10 | + global $globalDBdriver, $globalNoDB; |
|
| 11 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 12 | + if ($dbc === null) { |
|
| 13 | 13 | if ($this->db === null && $dbname === null) { |
| 14 | - if ($user === null && $pass === null) { |
|
| 15 | - $this->createDBConnection(); |
|
| 16 | - } else { |
|
| 17 | - $this->createDBConnection(null,$user,$pass); |
|
| 18 | - } |
|
| 14 | + if ($user === null && $pass === null) { |
|
| 15 | + $this->createDBConnection(); |
|
| 16 | + } else { |
|
| 17 | + $this->createDBConnection(null,$user,$pass); |
|
| 18 | + } |
|
| 19 | 19 | } else { |
| 20 | - $this->createDBConnection($dbname); |
|
| 20 | + $this->createDBConnection($dbname); |
|
| 21 | 21 | } |
| 22 | - } elseif ($dbname === null || $dbname === 'default') { |
|
| 23 | - $this->db = $dbc; |
|
| 24 | - if ($this->connectionExists() === false) { |
|
| 25 | - /* |
|
| 22 | + } elseif ($dbname === null || $dbname === 'default') { |
|
| 23 | + $this->db = $dbc; |
|
| 24 | + if ($this->connectionExists() === false) { |
|
| 25 | + /* |
|
| 26 | 26 | echo 'Restart Connection !!!'."\n"; |
| 27 | 27 | $e = new \Exception; |
| 28 | 28 | var_dump($e->getTraceAsString()); |
| 29 | 29 | */ |
| 30 | - $this->createDBConnection(); |
|
| 30 | + $this->createDBConnection(); |
|
| 31 | 31 | } |
| 32 | - } else { |
|
| 32 | + } else { |
|
| 33 | 33 | //$this->connectionExists(); |
| 34 | 34 | $this->dbs[$dbname] = $dbc; |
| 35 | - } |
|
| 35 | + } |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function db() { |
@@ -48,11 +48,11 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | - * Creates the database connection |
|
| 52 | - * |
|
| 53 | - * @return Boolean of the database connection |
|
| 54 | - * |
|
| 55 | - */ |
|
| 51 | + * Creates the database connection |
|
| 52 | + * |
|
| 53 | + * @return Boolean of the database connection |
|
| 54 | + * |
|
| 55 | + */ |
|
| 56 | 56 | |
| 57 | 57 | public function createDBConnection($DBname = null, $user = null, $pass = null) |
| 58 | 58 | { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | 151 | if($results->rowCount()>0) { |
| 152 | - return true; |
|
| 152 | + return true; |
|
| 153 | 153 | } |
| 154 | 154 | else return false; |
| 155 | 155 | } |
@@ -166,14 +166,14 @@ discard block |
||
| 166 | 166 | $sum = $sum->fetchColumn(0); |
| 167 | 167 | } else $sum = 0; |
| 168 | 168 | if (intval($sum) !== 2) { |
| 169 | - return false; |
|
| 169 | + return false; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | } catch(PDOException $e) { |
| 173 | 173 | if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
| 174 | - throw $e; |
|
| 175 | - } |
|
| 176 | - //echo 'error ! '.$e->getMessage(); |
|
| 174 | + throw $e; |
|
| 175 | + } |
|
| 176 | + //echo 'error ! '.$e->getMessage(); |
|
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | return true; |
@@ -277,8 +277,8 @@ discard block |
||
| 277 | 277 | $version = 0; |
| 278 | 278 | if ($this->tableExists('aircraft')) { |
| 279 | 279 | if (!$this->tableExists('config')) { |
| 280 | - $version = '1'; |
|
| 281 | - return $version; |
|
| 280 | + $version = '1'; |
|
| 281 | + return $version; |
|
| 282 | 282 | } else { |
| 283 | 283 | $query = "SELECT value FROM config WHERE name = 'schema_version' LIMIT 1"; |
| 284 | 284 | try { |
@@ -299,10 +299,10 @@ discard block |
||
| 299 | 299 | * @return Boolean if latest version or not |
| 300 | 300 | */ |
| 301 | 301 | public function latest() { |
| 302 | - global $globalNoDB; |
|
| 303 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 304 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 305 | - else return false; |
|
| 302 | + global $globalNoDB; |
|
| 303 | + if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 304 | + if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 305 | + else return false; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | } |
@@ -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 = 37; |
| 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) return true; |
| 12 | 12 | if ($dbc === null) { |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | if ($user === null && $pass === null) { |
| 15 | 15 | $this->createDBConnection(); |
| 16 | 16 | } else { |
| 17 | - $this->createDBConnection(null,$user,$pass); |
|
| 17 | + $this->createDBConnection(null, $user, $pass); |
|
| 18 | 18 | } |
| 19 | 19 | } else { |
| 20 | 20 | $this->createDBConnection($dbname); |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | while (true) { |
| 93 | 93 | try { |
| 94 | 94 | if ($globalDBSdriver == 'mysql') { |
| 95 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 95 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
| 96 | 96 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 97 | 97 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 98 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 99 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 100 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 101 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 102 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 98 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 99 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
| 100 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 101 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 102 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 103 | 103 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 105 | 105 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -109,19 +109,19 @@ discard block |
||
| 109 | 109 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
| 110 | 110 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
| 111 | 111 | } else { |
| 112 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 112 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
| 113 | 113 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 114 | 114 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 115 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
| 116 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 117 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 118 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 119 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 115 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
| 116 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
| 117 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
| 118 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
| 119 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
| 120 | 120 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 121 | 121 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
| 122 | 122 | } |
| 123 | 123 | break; |
| 124 | - } catch(PDOException $e) { |
|
| 124 | + } catch (PDOException $e) { |
|
| 125 | 125 | $i++; |
| 126 | 126 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
| 127 | 127 | //exit; |
@@ -145,10 +145,10 @@ discard block |
||
| 145 | 145 | try { |
| 146 | 146 | //$Connection = new Connection(); |
| 147 | 147 | $results = $this->db->query($query); |
| 148 | - } catch(PDOException $e) { |
|
| 148 | + } catch (PDOException $e) { |
|
| 149 | 149 | return false; |
| 150 | 150 | } |
| 151 | - if($results->rowCount()>0) { |
|
| 151 | + if ($results->rowCount() > 0) { |
|
| 152 | 152 | return true; |
| 153 | 153 | } |
| 154 | 154 | else return false; |
@@ -169,8 +169,8 @@ discard block |
||
| 169 | 169 | return false; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - } catch(PDOException $e) { |
|
| 173 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 172 | + } catch (PDOException $e) { |
|
| 173 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
| 174 | 174 | throw $e; |
| 175 | 175 | } |
| 176 | 176 | //echo 'error ! '.$e->getMessage(); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | /* |
| 183 | 183 | * Check if index exist |
| 184 | 184 | */ |
| 185 | - public function indexExists($table,$index) |
|
| 185 | + public function indexExists($table, $index) |
|
| 186 | 186 | { |
| 187 | 187 | global $globalDBdriver, $globalDBname; |
| 188 | 188 | if ($globalDBdriver == 'mysql') { |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | try { |
| 194 | 194 | //$Connection = new Connection(); |
| 195 | 195 | $results = $this->db->query($query); |
| 196 | - } catch(PDOException $e) { |
|
| 196 | + } catch (PDOException $e) { |
|
| 197 | 197 | return false; |
| 198 | 198 | } |
| 199 | 199 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
| 200 | - if($nb[0]['nb'] > 0) { |
|
| 200 | + if ($nb[0]['nb'] > 0) { |
|
| 201 | 201 | return true; |
| 202 | 202 | } |
| 203 | 203 | else return false; |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 213 | 213 | try { |
| 214 | 214 | $results = $this->db->query($query); |
| 215 | - } catch(PDOException $e) { |
|
| 215 | + } catch (PDOException $e) { |
|
| 216 | 216 | return "error : ".$e->getMessage()."\n"; |
| 217 | 217 | } |
| 218 | 218 | $columns = array(); |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | return $columns; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | - public function getColumnType($table,$column) { |
|
| 227 | + public function getColumnType($table, $column) { |
|
| 228 | 228 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
| 229 | 229 | $tomet = $select->getColumnMeta(0); |
| 230 | 230 | return $tomet['native_type']; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * Check if a column name exist in a table |
| 235 | 235 | * @return Boolean column exist or not |
| 236 | 236 | */ |
| 237 | - public function checkColumnName($table,$name) |
|
| 237 | + public function checkColumnName($table, $name) |
|
| 238 | 238 | { |
| 239 | 239 | global $globalDBdriver, $globalDBname; |
| 240 | 240 | if ($globalDBdriver == 'mysql') { |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | } |
| 245 | 245 | try { |
| 246 | 246 | $sth = $this->db()->prepare($query); |
| 247 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
| 248 | - } catch(PDOException $e) { |
|
| 247 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
| 248 | + } catch (PDOException $e) { |
|
| 249 | 249 | echo "error : ".$e->getMessage()."\n"; |
| 250 | 250 | } |
| 251 | 251 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | try { |
| 285 | 285 | $sth = $this->db->prepare($query); |
| 286 | 286 | $sth->execute(); |
| 287 | - } catch(PDOException $e) { |
|
| 287 | + } catch (PDOException $e) { |
|
| 288 | 288 | return "error : ".$e->getMessage()."\n"; |
| 289 | 289 | } |
| 290 | 290 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -8,7 +8,9 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
| 10 | 10 | global $globalDBdriver, $globalNoDB; |
| 11 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 11 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
| 12 | + return true; |
|
| 13 | + } |
|
| 12 | 14 | if ($dbc === null) { |
| 13 | 15 | if ($this->db === null && $dbname === null) { |
| 14 | 16 | if ($user === null && $pass === null) { |
@@ -65,8 +67,11 @@ discard block |
||
| 65 | 67 | $globalDBSname = $globalDBname; |
| 66 | 68 | $globalDBSuser = $globalDBuser; |
| 67 | 69 | $globalDBSpass = $globalDBpass; |
| 68 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
| 69 | - else $globalDBSport = $globalDBport; |
|
| 70 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
| 71 | + $globalDBSport = 3306; |
|
| 72 | + } else { |
|
| 73 | + $globalDBSport = $globalDBport; |
|
| 74 | + } |
|
| 70 | 75 | } else { |
| 71 | 76 | $DBname = 'default'; |
| 72 | 77 | $globalDBSdriver = $globalDBdriver; |
@@ -74,8 +79,11 @@ discard block |
||
| 74 | 79 | $globalDBSname = $globalDBname; |
| 75 | 80 | $globalDBSuser = $user; |
| 76 | 81 | $globalDBSpass = $pass; |
| 77 | - if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306; |
|
| 78 | - else $globalDBSport = $globalDBport; |
|
| 82 | + if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') { |
|
| 83 | + $globalDBSport = 3306; |
|
| 84 | + } else { |
|
| 85 | + $globalDBSport = $globalDBport; |
|
| 86 | + } |
|
| 79 | 87 | } |
| 80 | 88 | } else { |
| 81 | 89 | $globalDBSdriver = $globalDB[$DBname]['driver']; |
@@ -83,11 +91,16 @@ discard block |
||
| 83 | 91 | $globalDBSname = $globalDB[$DBname]['name']; |
| 84 | 92 | $globalDBSuser = $globalDB[$DBname]['user']; |
| 85 | 93 | $globalDBSpass = $globalDB[$DBname]['pass']; |
| 86 | - if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port']; |
|
| 87 | - else $globalDBSport = 3306; |
|
| 94 | + if (isset($globalDB[$DBname]['port'])) { |
|
| 95 | + $globalDBSport = $globalDB[$DBname]['port']; |
|
| 96 | + } else { |
|
| 97 | + $globalDBSport = 3306; |
|
| 98 | + } |
|
| 88 | 99 | } |
| 89 | 100 | // Set number of try to connect to DB |
| 90 | - if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5; |
|
| 101 | + if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) { |
|
| 102 | + $globalDBretry = 5; |
|
| 103 | + } |
|
| 91 | 104 | $i = 0; |
| 92 | 105 | while (true) { |
| 93 | 106 | try { |
@@ -96,10 +109,16 @@ discard block |
||
| 96 | 109 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 97 | 110 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 98 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
| 99 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 100 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 101 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 102 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 112 | + if (!isset($globalDBTimeOut)) { |
|
| 113 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
| 114 | + } else { |
|
| 115 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 116 | + } |
|
| 117 | + if (!isset($globalDBPersistent)) { |
|
| 118 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 119 | + } else { |
|
| 120 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 121 | + } |
|
| 103 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 104 | 123 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
| 105 | 124 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -113,23 +132,35 @@ discard block |
||
| 113 | 132 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
| 114 | 133 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
| 115 | 134 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
| 116 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 117 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 118 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 119 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 135 | + if (!isset($globalDBTimeOut)) { |
|
| 136 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
| 137 | + } else { |
|
| 138 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
| 139 | + } |
|
| 140 | + if (!isset($globalDBPersistent)) { |
|
| 141 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
| 142 | + } else { |
|
| 143 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
| 144 | + } |
|
| 120 | 145 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
| 121 | 146 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
| 122 | 147 | } |
| 123 | 148 | break; |
| 124 | 149 | } catch(PDOException $e) { |
| 125 | 150 | $i++; |
| 126 | - if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
| 151 | + if (isset($globalDebug) && $globalDebug) { |
|
| 152 | + echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
|
| 153 | + } |
|
| 127 | 154 | //exit; |
| 128 | - if ($i > $globalDBretry) return false; |
|
| 155 | + if ($i > $globalDBretry) { |
|
| 156 | + return false; |
|
| 157 | + } |
|
| 129 | 158 | //return false; |
| 130 | 159 | } |
| 131 | 160 | } |
| 132 | - if ($DBname === 'default') $this->db = $this->dbs['default']; |
|
| 161 | + if ($DBname === 'default') { |
|
| 162 | + $this->db = $this->dbs['default']; |
|
| 163 | + } |
|
| 133 | 164 | return true; |
| 134 | 165 | } |
| 135 | 166 | |
@@ -141,7 +172,9 @@ discard block |
||
| 141 | 172 | } else { |
| 142 | 173 | $query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'"; |
| 143 | 174 | } |
| 144 | - if ($this->db == NULL) return false; |
|
| 175 | + if ($this->db == NULL) { |
|
| 176 | + return false; |
|
| 177 | + } |
|
| 145 | 178 | try { |
| 146 | 179 | //$Connection = new Connection(); |
| 147 | 180 | $results = $this->db->query($query); |
@@ -150,21 +183,28 @@ discard block |
||
| 150 | 183 | } |
| 151 | 184 | if($results->rowCount()>0) { |
| 152 | 185 | return true; |
| 186 | + } else { |
|
| 187 | + return false; |
|
| 153 | 188 | } |
| 154 | - else return false; |
|
| 155 | 189 | } |
| 156 | 190 | |
| 157 | 191 | public function connectionExists() |
| 158 | 192 | { |
| 159 | 193 | global $globalDBdriver, $globalDBCheckConnection; |
| 160 | - if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true; |
|
| 194 | + if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) { |
|
| 195 | + return true; |
|
| 196 | + } |
|
| 161 | 197 | $query = "SELECT 1 + 1"; |
| 162 | - if ($this->db === null) return false; |
|
| 198 | + if ($this->db === null) { |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 163 | 201 | try { |
| 164 | 202 | $sum = @$this->db->query($query); |
| 165 | 203 | if ($sum instanceof \PDOStatement) { |
| 166 | 204 | $sum = $sum->fetchColumn(0); |
| 167 | - } else $sum = 0; |
|
| 205 | + } else { |
|
| 206 | + $sum = 0; |
|
| 207 | + } |
|
| 168 | 208 | if (intval($sum) !== 2) { |
| 169 | 209 | return false; |
| 170 | 210 | } |
@@ -199,8 +239,9 @@ discard block |
||
| 199 | 239 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
| 200 | 240 | if($nb[0]['nb'] > 0) { |
| 201 | 241 | return true; |
| 242 | + } else { |
|
| 243 | + return false; |
|
| 202 | 244 | } |
| 203 | - else return false; |
|
| 204 | 245 | } |
| 205 | 246 | |
| 206 | 247 | /* |
@@ -250,9 +291,12 @@ discard block |
||
| 250 | 291 | } |
| 251 | 292 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 252 | 293 | $sth->closeCursor(); |
| 253 | - if ($result['nb'] > 0) return true; |
|
| 254 | - else return false; |
|
| 255 | -/* } else { |
|
| 294 | + if ($result['nb'] > 0) { |
|
| 295 | + return true; |
|
| 296 | + } else { |
|
| 297 | + return false; |
|
| 298 | + } |
|
| 299 | + /* } else { |
|
| 256 | 300 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
| 257 | 301 | try { |
| 258 | 302 | $results = $this->db->query($query); |
@@ -291,7 +335,9 @@ discard block |
||
| 291 | 335 | $sth->closeCursor(); |
| 292 | 336 | return $result['value']; |
| 293 | 337 | } |
| 294 | - } else return $version; |
|
| 338 | + } else { |
|
| 339 | + return $version; |
|
| 340 | + } |
|
| 295 | 341 | } |
| 296 | 342 | |
| 297 | 343 | /* |
@@ -300,9 +346,14 @@ discard block |
||
| 300 | 346 | */ |
| 301 | 347 | public function latest() { |
| 302 | 348 | global $globalNoDB; |
| 303 | - if (isset($globalNoDB) && $globalNoDB === TRUE) return true; |
|
| 304 | - if ($this->check_schema_version() == $this->latest_schema) return true; |
|
| 305 | - else return false; |
|
| 349 | + if (isset($globalNoDB) && $globalNoDB === TRUE) { |
|
| 350 | + return true; |
|
| 351 | + } |
|
| 352 | + if ($this->check_schema_version() == $this->latest_schema) { |
|
| 353 | + return true; |
|
| 354 | + } else { |
|
| 355 | + return false; |
|
| 356 | + } |
|
| 306 | 357 | } |
| 307 | 358 | |
| 308 | 359 | } |
@@ -20,13 +20,13 @@ discard block |
||
| 20 | 20 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 21 | 21 | $year_data = ''; |
| 22 | 22 | $year_cnt = ''; |
| 23 | -foreach($date_array as $year_item) |
|
| 23 | +foreach ($date_array as $year_item) |
|
| 24 | 24 | { |
| 25 | 25 | $year_data .= '"'.$year_item['year'].'-'.$year_item['month'].'-01",'; |
| 26 | 26 | $year_cnt .= $year_item['count'].','; |
| 27 | 27 | } |
| 28 | 28 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
| 29 | -$year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
|
| 29 | +$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]"; |
|
| 30 | 30 | print 'c3.generate({ |
| 31 | 31 | bindto: "#chart", |
| 32 | 32 | data: { x: "x", |
@@ -36,13 +36,13 @@ discard block |
||
| 36 | 36 | |
| 37 | 37 | if (!empty($date_array)) |
| 38 | 38 | { |
| 39 | - foreach($date_array as $key => $row) { |
|
| 39 | + foreach ($date_array as $key => $row) { |
|
| 40 | 40 | $years[$key] = $row['year']; |
| 41 | 41 | $months[$key] = $row['month']; |
| 42 | 42 | $counts[$key] = $row['count']; |
| 43 | 43 | } |
| 44 | 44 | // array_multisort($years,SORT_DESC,$months,SORT_DESC,$date_array); |
| 45 | - array_multisort($counts,SORT_DESC,$date_array); |
|
| 45 | + array_multisort($counts, SORT_DESC, $date_array); |
|
| 46 | 46 | print '<div class="table-responsive">'; |
| 47 | 47 | print '<table class="common-date table-striped">'; |
| 48 | 48 | print '<thead>'; |
@@ -52,14 +52,14 @@ discard block |
||
| 52 | 52 | print '</thead>'; |
| 53 | 53 | print '<tbody>'; |
| 54 | 54 | $i = 1; |
| 55 | - foreach($date_array as $date_item) |
|
| 55 | + foreach ($date_array as $date_item) |
|
| 56 | 56 | { |
| 57 | 57 | print '<tr>'; |
| 58 | 58 | print '<td><strong>'.$i.'</strong></td>'; |
| 59 | 59 | print '<td>'; |
| 60 | 60 | if ($date_item['month'] < 10) $month = '0'.$date_item['month']; |
| 61 | 61 | else $month = $date_item['month']; |
| 62 | - print '<a href="'.$globalURL.'/accident/'.$date_item['year'].'-'.$month.'">'.date('F, Y',strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'</a>'; |
|
| 62 | + print '<a href="'.$globalURL.'/accident/'.$date_item['year'].'-'.$month.'">'.date('F, Y', strtotime($date_item['year'].'-'.$date_item['month'].'-01')).'</a>'; |
|
| 63 | 63 | print '</td>'; |
| 64 | 64 | print '<td>'; |
| 65 | 65 | print $date_item['count']; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | 12 | } |
| 13 | 13 | setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
| 14 | 14 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
@@ -6,13 +6,13 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Most common Pilots"); |
| 7 | 7 | |
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | 11 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 12 | 12 | } |
| 13 | -setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
|
| 14 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 15 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | +setcookie('stats_airline_icao', $airline_icao, time() + 60*60*24, '/'); |
|
| 14 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 15 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 16 | 16 | require_once('header.php'); |
| 17 | 17 | include('statistics-sub-menu.php'); |
| 18 | 18 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | </div> |
| 23 | 23 | <p>'._("Below are the <strong>Top 10</strong> most common pilot.").'</p>'; |
| 24 | 24 | |
| 25 | -$pilot_array = $Stats->countAllPilots(true,$airline_icao,$filter_name,$year,$month); |
|
| 25 | +$pilot_array = $Stats->countAllPilots(true, $airline_icao, $filter_name, $year, $month); |
|
| 26 | 26 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 27 | 27 | $pilot_data = ''; |
| 28 | -foreach($pilot_array as $pilot_item) |
|
| 28 | +foreach ($pilot_array as $pilot_item) |
|
| 29 | 29 | { |
| 30 | 30 | $pilot_data .= '["'.$pilot_item['pilot_name'].' ('.$pilot_item['pilot_id'].')",'.$pilot_item['pilot_count'].'],'; |
| 31 | 31 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | print '</thead>'; |
| 51 | 51 | print '<tbody>'; |
| 52 | 52 | $i = 1; |
| 53 | - foreach($pilot_array as $pilot_item) |
|
| 53 | + foreach ($pilot_array as $pilot_item) |
|
| 54 | 54 | { |
| 55 | 55 | print '<tr>'; |
| 56 | 56 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | 12 | } |
| 13 | 13 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 14 | 14 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | $airport_airport_array = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month); |
| 29 | 29 | |
| 30 | 30 | print 'var series = ['; |
| 31 | - $airport_data = ''; |
|
| 31 | + $airport_data = ''; |
|
| 32 | 32 | foreach($airport_airport_array as $airport_item) |
| 33 | 33 | { |
| 34 | 34 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |
@@ -6,12 +6,12 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Most common Arrival Airport"); |
| 7 | 7 | |
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | 11 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 12 | 12 | } |
| 13 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 14 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 14 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 15 | 15 | |
| 16 | 16 | require_once('header.php'); |
| 17 | 17 | include('statistics-sub-menu.php'); |
@@ -25,11 +25,11 @@ discard block |
||
| 25 | 25 | <p>'._("Below are the <strong>Top 10</strong> most common arrival airports.").'</p>'; |
| 26 | 26 | print '<div id="chartAirport" class="chart" width="100%"></div>'; |
| 27 | 27 | print '<script>'; |
| 28 | -$airport_airport_array = $Stats->countAllArrivalAirports(true,$airline_icao,$filter_name,$year,$month); |
|
| 28 | +$airport_airport_array = $Stats->countAllArrivalAirports(true, $airline_icao, $filter_name, $year, $month); |
|
| 29 | 29 | |
| 30 | 30 | print 'var series = ['; |
| 31 | 31 | $airport_data = ''; |
| 32 | -foreach($airport_airport_array as $airport_item) |
|
| 32 | +foreach ($airport_airport_array as $airport_item) |
|
| 33 | 33 | { |
| 34 | 34 | $airport_data .= '[ "'.$airport_item['airport_arrival_icao_count'].'", "'.$airport_item['airport_arrival_icao'].'",'.$airport_item['airport_arrival_latitude'].','.$airport_item['airport_arrival_longitude'].'],'; |
| 35 | 35 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | print '</thead>'; |
| 84 | 84 | print '<tbody>'; |
| 85 | 85 | $i = 1; |
| 86 | -foreach($airport_airport_array as $airport_item) |
|
| 86 | +foreach ($airport_airport_array as $airport_item) |
|
| 87 | 87 | { |
| 88 | 88 | print '<tr>'; |
| 89 | 89 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Busiest Time of the Day"); |
| 7 | 7 | |
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | 11 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 12 | 12 | } |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | </div> |
| 23 | 23 | <p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>'; |
| 24 | 24 | |
| 25 | -$hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name); |
|
| 25 | +$hour_array = $Stats->countAllHours('hour', true, $airline_icao, $filter_name); |
|
| 26 | 26 | print '<div id="chartHour" class="chart" width="100%"></div><script>'; |
| 27 | 27 | $hour_data = ''; |
| 28 | 28 | $hour_cnt = ''; |
| 29 | -foreach($hour_array as $hour_item) |
|
| 29 | +foreach ($hour_array as $hour_item) |
|
| 30 | 30 | { |
| 31 | 31 | $hour_data .= '"'.$hour_item['hour_name'].':00",'; |
| 32 | 32 | $hour_cnt .= $hour_item['hour_count'].','; |
| 33 | 33 | } |
| 34 | 34 | $hour_data = "[".substr($hour_data, 0, -1)."]"; |
| 35 | -$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
| 35 | +$hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
| 36 | 36 | print 'c3.generate({ |
| 37 | 37 | bindto: "#chartHour", |
| 38 | 38 | data: { |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});'; |
| 41 | 41 | print '</script>'; |
| 42 | 42 | |
| 43 | -$hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name); |
|
| 43 | +$hour_array = $Stats->countAllHours('count', true, $airline_icao, $filter_name); |
|
| 44 | 44 | if (!empty($hour_array)) |
| 45 | 45 | { |
| 46 | 46 | print '<div class="table-responsive">'; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | print '</thead>'; |
| 53 | 53 | print '<tbody>'; |
| 54 | 54 | $i = 1; |
| 55 | - foreach($hour_array as $hour_item) |
|
| 55 | + foreach ($hour_array as $hour_item) |
|
| 56 | 56 | { |
| 57 | 57 | print '<tr>'; |
| 58 | 58 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -19,13 +19,13 @@ discard block |
||
| 19 | 19 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 20 | 20 | $year_data = ''; |
| 21 | 21 | $year_cnt = ''; |
| 22 | -foreach($date_array as $year_item) |
|
| 22 | +foreach ($date_array as $year_item) |
|
| 23 | 23 | { |
| 24 | 24 | $year_data .= '"'.$year_item['year'].'-01-01",'; |
| 25 | 25 | $year_cnt .= $year_item['count'].','; |
| 26 | 26 | } |
| 27 | 27 | $year_data = "['x',".substr($year_data, 0, -1)."]"; |
| 28 | -$year_cnt = "['flights',".substr($year_cnt,0,-1)."]"; |
|
| 28 | +$year_cnt = "['flights',".substr($year_cnt, 0, -1)."]"; |
|
| 29 | 29 | print 'c3.generate({ |
| 30 | 30 | bindto: "#chart", |
| 31 | 31 | data: { x: "x", |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | if (!empty($date_array)) |
| 37 | 37 | { |
| 38 | - foreach($date_array as $key => $row) { |
|
| 38 | + foreach ($date_array as $key => $row) { |
|
| 39 | 39 | $years[$key] = $row['year']; |
| 40 | 40 | $counts[$key] = $row['count']; |
| 41 | 41 | } |
| 42 | 42 | //array_multisort($years,SORT_DESC,$date_array); |
| 43 | - array_multisort($counts,SORT_DESC,$date_array); |
|
| 43 | + array_multisort($counts, SORT_DESC, $date_array); |
|
| 44 | 44 | print '<div class="table-responsive">'; |
| 45 | 45 | print '<table class="common-date table-striped">'; |
| 46 | 46 | print '<thead>'; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | print '</thead>'; |
| 51 | 51 | print '<tbody>'; |
| 52 | 52 | $i = 1; |
| 53 | - foreach($date_array as $date_item) |
|
| 53 | + foreach ($date_array as $date_item) |
|
| 54 | 54 | { |
| 55 | 55 | print '<tr>'; |
| 56 | 56 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | 12 | } |
| 13 | 13 | setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
| 14 | 14 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
@@ -6,13 +6,13 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Most common Aircraft Registrations"); |
| 7 | 7 | |
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | 11 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 12 | 12 | } |
| 13 | -setcookie('stats_airline_icao',$airline_icao,time()+60*60*24,'/'); |
|
| 14 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 15 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | +setcookie('stats_airline_icao', $airline_icao, time() + 60*60*24, '/'); |
|
| 14 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 15 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 16 | 16 | |
| 17 | 17 | require_once('header.php'); |
| 18 | 18 | include('statistics-sub-menu.php'); |
@@ -24,10 +24,10 @@ discard block |
||
| 24 | 24 | </div> |
| 25 | 25 | <p>'._("Below are the <strong>Top 10</strong> most common aircraft registrations.").'</p>'; |
| 26 | 26 | |
| 27 | -$registration_array = $Stats->countAllAircraftRegistrations(true,$airline_icao,$filter_name,$year,$month); |
|
| 27 | +$registration_array = $Stats->countAllAircraftRegistrations(true, $airline_icao, $filter_name, $year, $month); |
|
| 28 | 28 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 29 | 29 | $registration_data = ''; |
| 30 | -foreach($registration_array as $registration_item) |
|
| 30 | +foreach ($registration_array as $registration_item) |
|
| 31 | 31 | { |
| 32 | 32 | $registration_data .= '[ "'.$registration_item['registration'].' - '.$registration_item['aircraft_name'].' ('.$registration_item['aircraft_icao'].')",'.$registration_item['aircraft_registration_count'].'],'; |
| 33 | 33 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | print '</thead>'; |
| 55 | 55 | print '<tbody>'; |
| 56 | 56 | $i = 1; |
| 57 | - foreach($registration_array as $registration_item) |
|
| 57 | + foreach ($registration_array as $registration_item) |
|
| 58 | 58 | { |
| 59 | 59 | print '<tr>'; |
| 60 | 60 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | 9 | $airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | - if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 11 | + if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | require_once('header.php'); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 32 | 32 | print 'var series = ['; |
| 33 | - $flightover_data = ''; |
|
| 33 | + $flightover_data = ''; |
|
| 34 | 34 | foreach($flightover_array as $flightover_item) |
| 35 | 35 | { |
| 36 | 36 | $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Most common Country a flight was over"); |
| 7 | 7 | |
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | 11 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 12 | 12 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | </div> |
| 23 | 23 | <p>'._("Below are the <strong>Top 10</strong> most common country a flight was over.").'</p>'; |
| 24 | 24 | |
| 25 | -$flightover_array = $Stats->countAllFlightOverCountries(true,$airline_icao,$filter_name); |
|
| 25 | +$flightover_array = $Stats->countAllFlightOverCountries(true, $airline_icao, $filter_name); |
|
| 26 | 26 | /* |
| 27 | 27 | require_once('require/class.Spotter.php'); |
| 28 | 28 | $Spotter = new Spotter(); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 32 | 32 | print 'var series = ['; |
| 33 | 33 | $flightover_data = ''; |
| 34 | -foreach($flightover_array as $flightover_item) |
|
| 34 | +foreach ($flightover_array as $flightover_item) |
|
| 35 | 35 | { |
| 36 | 36 | $flightover_data .= '[ "'.$flightover_item['flight_country_iso3'].'",'.$flightover_item['flight_count'].'],'; |
| 37 | 37 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | print '</thead>'; |
| 81 | 81 | print '<tbody>'; |
| 82 | 82 | $i = 1; |
| 83 | - foreach($flightover_array as $flightover_item) |
|
| 83 | + foreach ($flightover_array as $flightover_item) |
|
| 84 | 84 | { |
| 85 | 85 | print '<tr>'; |
| 86 | 86 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Busiest Day"); |
| 7 | 7 | |
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | -$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
|
| 9 | +$airline_icao = (string) filter_input(INPUT_GET, 'airline', FILTER_SANITIZE_STRING); |
|
| 10 | 10 | if ($airline_icao == '' && isset($globalFilter)) { |
| 11 | 11 | if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0]; |
| 12 | 12 | } |
@@ -22,20 +22,20 @@ discard block |
||
| 22 | 22 | </div> |
| 23 | 23 | <p>'._("Below is a chart that plots the busiest day during the <strong>last 7 days</strong>.").'</p>'; |
| 24 | 24 | |
| 25 | -$date_array = $Stats->countAllDatesLast7Days($airline_icao,$filter_name); |
|
| 25 | +$date_array = $Stats->countAllDatesLast7Days($airline_icao, $filter_name); |
|
| 26 | 26 | if (count($date_array) == 0) { |
| 27 | 27 | print _("No data available"); |
| 28 | 28 | } else { |
| 29 | 29 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 30 | 30 | $date_data = ''; |
| 31 | 31 | $date_cnt = ''; |
| 32 | -foreach($date_array as $date_item) |
|
| 32 | +foreach ($date_array as $date_item) |
|
| 33 | 33 | { |
| 34 | 34 | $date_data .= '"'.$date_item['date_name'].'",'; |
| 35 | 35 | $date_cnt .= $date_item['date_count'].','; |
| 36 | 36 | } |
| 37 | 37 | $date_data = "['x',".substr($date_data, 0, -1)."]"; |
| 38 | -$date_cnt = "['flights',".substr($date_cnt,0,-1)."]"; |
|
| 38 | +$date_cnt = "['flights',".substr($date_cnt, 0, -1)."]"; |
|
| 39 | 39 | print 'c3.generate({ |
| 40 | 40 | bindto: "#chart", |
| 41 | 41 | data: { x: "x", |
@@ -44,11 +44,11 @@ discard block |
||
| 44 | 44 | print '</script>'; |
| 45 | 45 | } |
| 46 | 46 | if (isset($globalDBArchiveMonths) && $globalDBArchiveMonths > 0) { |
| 47 | - print '<p>'.sprintf(_("Below are the <strong>Top 10</strong> most busiest dates of last %d month(s)."),$globalDBArchiveMonths).'</p>'; |
|
| 47 | + print '<p>'.sprintf(_("Below are the <strong>Top 10</strong> most busiest dates of last %d month(s)."), $globalDBArchiveMonths).'</p>'; |
|
| 48 | 48 | } else { |
| 49 | 49 | print '<p>'._("Below are the <strong>Top 10</strong> most busiest dates.").'</p>'; |
| 50 | 50 | } |
| 51 | -$date_array = $Stats->countAllDates($airline_icao,$filter_name); |
|
| 51 | +$date_array = $Stats->countAllDates($airline_icao, $filter_name); |
|
| 52 | 52 | if (!empty($date_array)) |
| 53 | 53 | { |
| 54 | 54 | print '<div class="table-responsive">'; |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | print '</thead>'; |
| 61 | 61 | print '<tbody>'; |
| 62 | 62 | $i = 1; |
| 63 | - foreach($date_array as $date_item) |
|
| 63 | + foreach ($date_array as $date_item) |
|
| 64 | 64 | { |
| 65 | 65 | print '<tr>'; |
| 66 | 66 | print '<td><strong>'.$i.'</strong></td>'; |