@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') $aircraft_types = $Spotter->getAllAircraftTypes(); |
| 20 | 20 | $previous = null; |
| 21 | 21 | print '<div class="alphabet-legend">'; |
| 22 | - foreach($aircraft_types as $value) { |
|
| 22 | + foreach ($aircraft_types as $value) { |
|
| 23 | 23 | //$firstLetter = substr($value['aircraft_name'], 0, 1); |
| 24 | 24 | $firstLetter = substr($value['aircraft_manufacturer'], 0, 1); |
| 25 | - if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
|
| 25 | + if ($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
|
| 26 | 26 | { |
| 27 | 27 | if ($previous !== null) print ' | '; |
| 28 | 28 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
@@ -31,12 +31,12 @@ discard block |
||
| 31 | 31 | } |
| 32 | 32 | print '</div>'; |
| 33 | 33 | $previous = null; |
| 34 | - foreach($aircraft_types as $value) { |
|
| 34 | + foreach ($aircraft_types as $value) { |
|
| 35 | 35 | //$firstLetter = substr($value['aircraft_name'], 0, 1); |
| 36 | 36 | $firstLetter = substr($value['aircraft_manufacturer'], 0, 1); |
| 37 | 37 | if ($firstLetter != "") |
| 38 | 38 | { |
| 39 | - if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
|
| 39 | + if ($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
|
| 40 | 40 | { |
| 41 | 41 | if ($previous !== null) print '</div>'; |
| 42 | 42 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
@@ -16,7 +16,9 @@ discard block |
||
| 16 | 16 | print '<h1>'._("Aircraft Types").'</h1>'; |
| 17 | 17 | |
| 18 | 18 | $aircraft_types = $Stats->getAllAircraftTypes(); |
| 19 | - if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
| 19 | + if (empty($aircraft_types) || $aircraft_types[0]['aircraft_manufacturer'] == '') { |
|
| 20 | + $aircraft_types = $Spotter->getAllAircraftTypes(); |
|
| 21 | + } |
|
| 20 | 22 | $previous = null; |
| 21 | 23 | print '<div class="alphabet-legend">'; |
| 22 | 24 | foreach($aircraft_types as $value) { |
@@ -24,10 +26,14 @@ discard block |
||
| 24 | 26 | $firstLetter = substr($value['aircraft_manufacturer'], 0, 1); |
| 25 | 27 | if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
| 26 | 28 | { |
| 27 | - if ($previous !== null) print ' | '; |
|
| 29 | + if ($previous !== null) { |
|
| 30 | + print ' | '; |
|
| 31 | + } |
|
| 28 | 32 | print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>'; |
| 29 | 33 | } |
| 30 | - if ($firstLetter != '(' && $firstLetter != ')') $previous = $firstLetter; |
|
| 34 | + if ($firstLetter != '(' && $firstLetter != ')') { |
|
| 35 | + $previous = $firstLetter; |
|
| 36 | + } |
|
| 31 | 37 | } |
| 32 | 38 | print '</div>'; |
| 33 | 39 | $previous = null; |
@@ -38,10 +44,14 @@ discard block |
||
| 38 | 44 | { |
| 39 | 45 | if($previous !== $firstLetter && $firstLetter != '(' && $firstLetter != ')') |
| 40 | 46 | { |
| 41 | - if ($previous !== null) print '</div>'; |
|
| 47 | + if ($previous !== null) { |
|
| 48 | + print '</div>'; |
|
| 49 | + } |
|
| 42 | 50 | print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">'; |
| 43 | 51 | } |
| 44 | - if ($firstLetter != '(' && $firstLetter != ')') $previous = $firstLetter; |
|
| 52 | + if ($firstLetter != '(' && $firstLetter != ')') { |
|
| 53 | + $previous = $firstLetter; |
|
| 54 | + } |
|
| 45 | 55 | print '<div class="alphabet-item">'; |
| 46 | 56 | print '<a href="'.$globalURL.'/aircraft/'.$value['aircraft_icao'].'">'; |
| 47 | 57 | if ($value['aircraft_name'] == '') { |
@@ -23,12 +23,12 @@ |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | - * Get Accidents data from DB |
|
| 27 | - * @param String $limit Limit |
|
| 28 | - * @param String $type Set type accident or incident |
|
| 29 | - * @param String $date get data for a date |
|
| 30 | - * @return Array Return Accidents data in array |
|
| 31 | - */ |
|
| 26 | + * Get Accidents data from DB |
|
| 27 | + * @param String $limit Limit |
|
| 28 | + * @param String $type Set type accident or incident |
|
| 29 | + * @param String $date get data for a date |
|
| 30 | + * @return Array Return Accidents data in array |
|
| 31 | + */ |
|
| 32 | 32 | public function getAccidentData($limit = '',$type = '',$date = '') { |
| 33 | 33 | global $globalURL, $globalDBdriver; |
| 34 | 34 | $Image = new Image($this->db); |
@@ -42,20 +42,20 @@ discard block |
||
| 42 | 42 | * @param String $date get data for a date |
| 43 | 43 | * @return Array Return Accidents data in array |
| 44 | 44 | */ |
| 45 | - public function getAccidentData($limit = '',$type = '',$date = '') { |
|
| 45 | + public function getAccidentData($limit = '', $type = '', $date = '') { |
|
| 46 | 46 | global $globalURL, $globalDBdriver; |
| 47 | 47 | $Image = new Image($this->db); |
| 48 | 48 | $Spotter = new Spotter($this->db); |
| 49 | 49 | $Translation = new Translation($this->db); |
| 50 | - $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
| 50 | + $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
| 51 | 51 | date_default_timezone_set('UTC'); |
| 52 | 52 | $result = array(); |
| 53 | 53 | $limit_query = ''; |
| 54 | 54 | if ($limit != "") |
| 55 | 55 | { |
| 56 | 56 | $limit_array = explode(",", $limit); |
| 57 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
| 58 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
| 57 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
| 58 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
| 59 | 59 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
| 60 | 60 | { |
| 61 | 61 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -64,29 +64,29 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | if ($type != '') { |
| 66 | 66 | if ($date != '') { |
| 67 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 67 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 68 | 68 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 69 | 69 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 70 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 71 | - } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/",$date)) { |
|
| 70 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 71 | + } elseif (preg_match("/^[0-9]{4}-[0-9]{2}$/", $date)) { |
|
| 72 | 72 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND date BETWEEN :dated AND :datef GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 73 | - $query_values = array(':type' => $type,':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 74 | - } elseif (preg_match("/^[0-9]{4}$/",$date)) { |
|
| 73 | + $query_values = array(':type' => $type, ':dated' => $date.'-01', ':datef' => $date.'-31'); |
|
| 74 | + } elseif (preg_match("/^[0-9]{4}$/", $date)) { |
|
| 75 | 75 | if ($globalDBdriver == 'mysql') { |
| 76 | 76 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND YEAR(date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 77 | 77 | } else { |
| 78 | 78 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND EXTRACT(YEAR FROM date) = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 79 | 79 | } |
| 80 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 80 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 81 | 81 | } else { |
| 82 | 82 | $date = $date.'%'; |
| 83 | 83 | if ($globalDBdriver == 'mysql') { |
| 84 | 84 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND DATE_FORMAT(date,'%Y-%m-%d') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 85 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 85 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 86 | 86 | } else { |
| 87 | 87 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 88 | 88 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type AND to_char(date,'YYYY-MM-DD') LIKE :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 89 | - $query_values = array(':type' => $type,':date' => $date); |
|
| 89 | + $query_values = array(':type' => $type, ':date' => $date); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } else { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | 99 | if ($date != '') { |
| 100 | - if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
| 100 | + if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
| 101 | 101 | $query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 102 | 102 | //$query = "SELECT accidents.registration, accidents.ident, accidents.date, accidents.url, accidents.country, accidents.place, accidents.title, accidents.fatalities, accidents.type, accidents.ident, accidents.aircraft_manufacturer, accidents.aircraft_name, accidents.airline_name, accidents.airline_icao, spotter_output.flightaware_id FROM accidents LEFT OUTER JOIN spotter_output ON accidents.registration = spotter_output.registration WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE date = :date GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
| 103 | 103 | } else { |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | try { |
| 117 | 117 | $sth = $this->db->prepare($query); |
| 118 | 118 | $sth->execute($query_values); |
| 119 | - } catch(PDOException $e) { |
|
| 119 | + } catch (PDOException $e) { |
|
| 120 | 120 | echo "error : ".$e->getMessage(); |
| 121 | 121 | } |
| 122 | 122 | $i = 0; |
| 123 | 123 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
| 124 | - if (preg_match('/^[\w\-]+$/',$row['registration'])) { |
|
| 124 | + if (preg_match('/^[\w\-]+$/', $row['registration'])) { |
|
| 125 | 125 | $data = array(); |
| 126 | 126 | if ($row['registration'] != '') { |
| 127 | 127 | $image_array = $Image->getSpotterImage($row['registration']); |
| 128 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 129 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 128 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 129 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 130 | 130 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 131 | 131 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 132 | 132 | if (!empty($aircraft_info)) { |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | $data['aircraft_name'] = $aircraft_info[0]['type']; |
| 135 | 135 | $data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
| 136 | 136 | } else { |
| 137 | - $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
| 137 | + $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
| 138 | 138 | } |
| 139 | 139 | $owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
| 140 | 140 | if (!empty($owner_data)) { |
@@ -142,18 +142,18 @@ discard block |
||
| 142 | 142 | $data['aircraft_base'] = $owner_data['base']; |
| 143 | 143 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 144 | 144 | } |
| 145 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 145 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
| 146 | 146 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
| 147 | 147 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
| 148 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
| 148 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
| 149 | 149 | if (isset($identicao[0])) { |
| 150 | - if (substr($row['ident'],0,2) == 'AF') { |
|
| 151 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 152 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 153 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 154 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
| 150 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
| 151 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 152 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
| 153 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
| 154 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
| 155 | 155 | } else $icao = $row['ident']; |
| 156 | - $icao = $Translation->checkTranslation($icao,false); |
|
| 156 | + $icao = $Translation->checkTranslation($icao, false); |
|
| 157 | 157 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 158 | 158 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
| 159 | 159 | //echo 'Check airline info... for '.$row['airline_name'].' '; |
@@ -162,16 +162,16 @@ discard block |
||
| 162 | 162 | if (!empty($airline_info)) { |
| 163 | 163 | //echo 'data found !'."\n"; |
| 164 | 164 | //print_r($airline_info); |
| 165 | - $data = array_merge($data,$airline_info); |
|
| 165 | + $data = array_merge($data, $airline_info); |
|
| 166 | 166 | } |
| 167 | 167 | //else echo 'No data...'."\n"; |
| 168 | 168 | } |
| 169 | - $data = array_merge($row,$data); |
|
| 169 | + $data = array_merge($row, $data); |
|
| 170 | 170 | if ($data['ident'] == null) $data['ident'] = $icao; |
| 171 | 171 | if ($data['title'] == null) { |
| 172 | 172 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 173 | 173 | } else $data['message'] = strtolower($data['title']); |
| 174 | - $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
|
| 174 | + $ids = $Spotter->getAllIDByRegistration($data['registration'], true); |
|
| 175 | 175 | $date = $data['date']; |
| 176 | 176 | if (isset($ids[$date])) { |
| 177 | 177 | $data['spotted'] = TRUE; |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | try { |
| 204 | 204 | $sth = $this->db->prepare($query); |
| 205 | 205 | $sth->execute(); |
| 206 | - } catch(PDOException $e) { |
|
| 206 | + } catch (PDOException $e) { |
|
| 207 | 207 | echo "Error : ".$e->getMessage(); |
| 208 | 208 | } |
| 209 | 209 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | try { |
| 224 | 224 | $sth = $this->db->prepare($query); |
| 225 | 225 | $sth->execute(); |
| 226 | - } catch(PDOException $e) { |
|
| 226 | + } catch (PDOException $e) { |
|
| 227 | 227 | echo "Error : ".$e->getMessage(); |
| 228 | 228 | } |
| 229 | 229 | return $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | if ($globalDebug) echo 'Import '.$file."\n"; |
| 239 | 239 | $result = array(); |
| 240 | 240 | if (file_exists($file)) { |
| 241 | - if (($handle = fopen($file,'r')) !== FALSE) { |
|
| 242 | - while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
| 241 | + if (($handle = fopen($file, 'r')) !== FALSE) { |
|
| 242 | + while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
| 243 | 243 | if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
| 244 | - $result[] = array('registration' => $data[0],'date' => strtotime($data[1]),'url' => $data[2],'country' => $data[3],'place' => $data[4],'title' => $data[5],'fatalities' => $data[6],'latitude' => $data[7],'longitude' => $data[8],'type' => $data[9],'ident' => $data[10],'aircraft_manufacturer' => $data[11],'aircraft_name' => $data[12],'operator' => $data[13],'source' => 'website_fam'); |
|
| 244 | + $result[] = array('registration' => $data[0], 'date' => strtotime($data[1]), 'url' => $data[2], 'country' => $data[3], 'place' => $data[4], 'title' => $data[5], 'fatalities' => $data[6], 'latitude' => $data[7], 'longitude' => $data[8], 'type' => $data[9], 'ident' => $data[10], 'aircraft_manufacturer' => $data[11], 'aircraft_name' => $data[12], 'operator' => $data[13], 'source' => 'website_fam'); |
|
| 245 | 245 | } |
| 246 | 246 | } |
| 247 | 247 | fclose($handle); |
| 248 | 248 | } |
| 249 | - if (!empty($result)) $this->add($result,true); |
|
| 249 | + if (!empty($result)) $this->add($result, true); |
|
| 250 | 250 | elseif ($globalDebug) echo 'Nothing to import'; |
| 251 | 251 | } |
| 252 | 252 | } |
@@ -262,8 +262,8 @@ discard block |
||
| 262 | 262 | $all_md5_new = array(); |
| 263 | 263 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 264 | 264 | if ($this->check_accidents_nb() > 0) { |
| 265 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 266 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 265 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 266 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 267 | 267 | if (isset($data[1])) { |
| 268 | 268 | $year = $data[0]; |
| 269 | 269 | $all_md5[$year] = $data[1]; |
@@ -273,10 +273,10 @@ discard block |
||
| 273 | 273 | } |
| 274 | 274 | } |
| 275 | 275 | } |
| 276 | - $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 276 | + $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
| 277 | 277 | if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
| 278 | - if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
| 279 | - while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
| 278 | + if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
| 279 | + while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
| 280 | 280 | if (isset($data[1])) { |
| 281 | 281 | $year = $data[0]; |
| 282 | 282 | $all_md5_new[$year] = $data[1]; |
@@ -285,10 +285,10 @@ discard block |
||
| 285 | 285 | fclose($handle); |
| 286 | 286 | } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
| 287 | 287 | } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
| 288 | - $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
| 288 | + $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
| 289 | 289 | if (empty($result) && $globalDebug) echo 'Nothing to update'; |
| 290 | 290 | foreach ($result as $file => $md5) { |
| 291 | - $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 291 | + $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 292 | 292 | if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
| 293 | 293 | elseif ($globalDebug) echo 'Download '.$file.' failed'; |
| 294 | 294 | } |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | * Add data to DB |
| 299 | 299 | * @param Array $crash An array with accidents/incidents data |
| 300 | 300 | */ |
| 301 | - public function add($crash,$new = false) { |
|
| 301 | + public function add($crash, $new = false) { |
|
| 302 | 302 | global $globalTransaction, $globalDebug, $globalAircraftImageFetch; |
| 303 | 303 | require_once('class.Connection.php'); |
| 304 | 304 | require_once('class.Image.php'); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 315 | 315 | } |
| 316 | 316 | if ($globalTransaction) $Connection->db->beginTransaction(); |
| 317 | - $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
|
| 317 | + $initial_array = array('ident' => null, 'type' => 'accident', 'url' => null, 'registration' => null, 'date' => null, 'place' => null, 'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '', 'source' => '', 'aircraft_manufacturer' => null, 'aircraft_name' => null, 'operator' => null); |
|
| 318 | 318 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 319 | 319 | $sth_check = $Connection->db->prepare($query_check); |
| 320 | 320 | $query = 'INSERT INTO accidents (aircraft_manufacturer,aircraft_name,ident,registration,date,url,country,place,title,fatalities,latitude,longitude,type,airline_name,source) VALUES (:aircraft_manufacturer,:aircraft_name,:ident,:registration,:date,:url,:country,:place,:title,:fatalities,:latitude,:longitude,:type,:airline_name,:source)'; |
@@ -327,15 +327,15 @@ discard block |
||
| 327 | 327 | $cr = array_map(function($value) { |
| 328 | 328 | return $value === "" ? NULL : $value; |
| 329 | 329 | }, $cr); |
| 330 | - if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
| 331 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 332 | - $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
| 330 | + if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
| 331 | + if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 332 | + $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
| 333 | 333 | $sth_check->execute($query_check_values); |
| 334 | 334 | $result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC); |
| 335 | 335 | if ($result_check[0]['nb'] == 0) { |
| 336 | - $query_values = array(':registration' => trim($cr['registration']),':date' => date('Y-m-d',$cr['date']),':url' => $cr['url'],':country' => $cr['country'],':place' => $cr['place'],':title' => $cr['title'],':fatalities' => $cr['fatalities'],':latitude' => $cr['latitude'],':longitude' => $cr['longitude'],':type' => $cr['type'],':source' => $cr['source'],':ident' => $cr['ident'],':aircraft_manufacturer' => $cr['aircraft_manufacturer'],':aircraft_name' => $cr['aircraft_name'],':airline_name' => $cr['operator']); |
|
| 336 | + $query_values = array(':registration' => trim($cr['registration']), ':date' => date('Y-m-d', $cr['date']), ':url' => $cr['url'], ':country' => $cr['country'], ':place' => $cr['place'], ':title' => $cr['title'], ':fatalities' => $cr['fatalities'], ':latitude' => $cr['latitude'], ':longitude' => $cr['longitude'], ':type' => $cr['type'], ':source' => $cr['source'], ':ident' => $cr['ident'], ':aircraft_manufacturer' => $cr['aircraft_manufacturer'], ':aircraft_name' => $cr['aircraft_name'], ':airline_name' => $cr['operator']); |
|
| 337 | 337 | $sth->execute($query_values); |
| 338 | - if ($cr['date'] > time()-(30*86400)) { |
|
| 338 | + if ($cr['date'] > time() - (30*86400)) { |
|
| 339 | 339 | if ($globalAircraftImageFetch) { |
| 340 | 340 | $imgchk = $Image->getSpotterImage($cr['registration']); |
| 341 | 341 | if (empty($imgchk)) { |
@@ -346,17 +346,17 @@ discard block |
||
| 346 | 346 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 347 | 347 | } |
| 348 | 348 | if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
| 349 | - $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
| 349 | + $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
| 350 | 350 | } |
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | - if ($globalTransaction && $j % 1000 == 0) { |
|
| 353 | + if ($globalTransaction && $j%1000 == 0) { |
|
| 354 | 354 | $Connection->db->commit(); |
| 355 | 355 | $Connection->db->beginTransaction(); |
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 | if ($globalTransaction) $Connection->db->commit(); |
| 359 | - } catch(PDOException $e) { |
|
| 359 | + } catch (PDOException $e) { |
|
| 360 | 360 | if ($globalTransaction) $Connection->db->rollBack(); |
| 361 | 361 | echo $e->getMessage(); |
| 362 | 362 | } |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | $Connection = new Connection(); |
| 375 | 375 | $sth = $Connection->db->prepare($query); |
| 376 | 376 | $sth->execute(); |
| 377 | - } catch(PDOException $e) { |
|
| 377 | + } catch (PDOException $e) { |
|
| 378 | 378 | return "error : ".$e->getMessage(); |
| 379 | 379 | } |
| 380 | 380 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $Connection = new Connection(); |
| 393 | 393 | $sth = $Connection->db->prepare($query); |
| 394 | 394 | $sth->execute(); |
| 395 | - } catch(PDOException $e) { |
|
| 395 | + } catch (PDOException $e) { |
|
| 396 | 396 | return "error : ".$e->getMessage(); |
| 397 | 397 | } |
| 398 | 398 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | $Connection = new Connection(); |
| 408 | 408 | $sth = $Connection->db->prepare($query); |
| 409 | 409 | $sth->execute(); |
| 410 | - } catch(PDOException $e) { |
|
| 410 | + } catch (PDOException $e) { |
|
| 411 | 411 | return "error : ".$e->getMessage(); |
| 412 | 412 | } |
| 413 | 413 | } |
@@ -20,7 +20,9 @@ discard block |
||
| 20 | 20 | public function __construct($dbc = null) { |
| 21 | 21 | $Connection = new Connection($dbc); |
| 22 | 22 | $this->db = $Connection->db(); |
| 23 | - if ($this->db === null) die('Error: No DB connection. (Accident)'); |
|
| 23 | + if ($this->db === null) { |
|
| 24 | + die('Error: No DB connection. (Accident)'); |
|
| 25 | + } |
|
| 24 | 26 | } |
| 25 | 27 | |
| 26 | 28 | /* |
@@ -125,8 +127,11 @@ discard block |
||
| 125 | 127 | $data = array(); |
| 126 | 128 | if ($row['registration'] != '') { |
| 127 | 129 | $image_array = $Image->getSpotterImage($row['registration']); |
| 128 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 129 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 130 | + if (count($image_array) > 0) { |
|
| 131 | + $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
| 132 | + } else { |
|
| 133 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 134 | + } |
|
| 130 | 135 | $aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
| 131 | 136 | $aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
| 132 | 137 | if (!empty($aircraft_info)) { |
@@ -142,17 +147,30 @@ discard block |
||
| 142 | 147 | $data['aircraft_base'] = $owner_data['base']; |
| 143 | 148 | $data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
| 144 | 149 | } |
| 145 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 146 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 147 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 150 | + } else { |
|
| 151 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 152 | + } |
|
| 153 | + if ($row['registration'] == '') { |
|
| 154 | + $row['registration'] = 'NA'; |
|
| 155 | + } |
|
| 156 | + if ($row['ident'] == '') { |
|
| 157 | + $row['ident'] = 'NA'; |
|
| 158 | + } |
|
| 148 | 159 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
| 149 | 160 | if (isset($identicao[0])) { |
| 150 | 161 | if (substr($row['ident'],0,2) == 'AF') { |
| 151 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 152 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 153 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 162 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 163 | + $icao = $row['ident']; |
|
| 164 | + } else { |
|
| 165 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 166 | + } |
|
| 167 | + } else { |
|
| 168 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 169 | + } |
|
| 154 | 170 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 155 | - } else $icao = $row['ident']; |
|
| 171 | + } else { |
|
| 172 | + $icao = $row['ident']; |
|
| 173 | + } |
|
| 156 | 174 | $icao = $Translation->checkTranslation($icao,false); |
| 157 | 175 | //$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
| 158 | 176 | if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
@@ -167,10 +185,14 @@ discard block |
||
| 167 | 185 | //else echo 'No data...'."\n"; |
| 168 | 186 | } |
| 169 | 187 | $data = array_merge($row,$data); |
| 170 | - if ($data['ident'] == null) $data['ident'] = $icao; |
|
| 188 | + if ($data['ident'] == null) { |
|
| 189 | + $data['ident'] = $icao; |
|
| 190 | + } |
|
| 171 | 191 | if ($data['title'] == null) { |
| 172 | 192 | $data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
| 173 | - } else $data['message'] = strtolower($data['title']); |
|
| 193 | + } else { |
|
| 194 | + $data['message'] = strtolower($data['title']); |
|
| 195 | + } |
|
| 174 | 196 | $ids = $Spotter->getAllIDByRegistration($data['registration'],true); |
| 175 | 197 | $date = $data['date']; |
| 176 | 198 | if (isset($ids[$date])) { |
@@ -189,8 +211,9 @@ discard block |
||
| 189 | 211 | if (isset($result)) { |
| 190 | 212 | $result[0]['query_number_rows'] = $i; |
| 191 | 213 | return $result; |
| 214 | + } else { |
|
| 215 | + return array(); |
|
| 192 | 216 | } |
| 193 | - else return array(); |
|
| 194 | 217 | } |
| 195 | 218 | |
| 196 | 219 | /* |
@@ -235,7 +258,9 @@ discard block |
||
| 235 | 258 | */ |
| 236 | 259 | public function import($file) { |
| 237 | 260 | global $globalTransaction, $globalDebug; |
| 238 | - if ($globalDebug) echo 'Import '.$file."\n"; |
|
| 261 | + if ($globalDebug) { |
|
| 262 | + echo 'Import '.$file."\n"; |
|
| 263 | + } |
|
| 239 | 264 | $result = array(); |
| 240 | 265 | if (file_exists($file)) { |
| 241 | 266 | if (($handle = fopen($file,'r')) !== FALSE) { |
@@ -246,8 +271,11 @@ discard block |
||
| 246 | 271 | } |
| 247 | 272 | fclose($handle); |
| 248 | 273 | } |
| 249 | - if (!empty($result)) $this->add($result,true); |
|
| 250 | - elseif ($globalDebug) echo 'Nothing to import'; |
|
| 274 | + if (!empty($result)) { |
|
| 275 | + $this->add($result,true); |
|
| 276 | + } elseif ($globalDebug) { |
|
| 277 | + echo 'Nothing to import'; |
|
| 278 | + } |
|
| 251 | 279 | } |
| 252 | 280 | } |
| 253 | 281 | |
@@ -283,14 +311,23 @@ discard block |
||
| 283 | 311 | } |
| 284 | 312 | } |
| 285 | 313 | fclose($handle); |
| 286 | - } elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 287 | - } elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 314 | + } elseif ($globalDebug) { |
|
| 315 | + echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
| 316 | + } |
|
| 317 | + } elseif ($globalDebug) { |
|
| 318 | + echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
| 319 | + } |
|
| 288 | 320 | $result = $Common->arr_diff($all_md5_new,$all_md5); |
| 289 | - if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
| 321 | + if (empty($result) && $globalDebug) { |
|
| 322 | + echo 'Nothing to update'; |
|
| 323 | + } |
|
| 290 | 324 | foreach ($result as $file => $md5) { |
| 291 | 325 | $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
| 292 | - if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 293 | - elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
| 326 | + if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) { |
|
| 327 | + $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
| 328 | + } elseif ($globalDebug) { |
|
| 329 | + echo 'Download '.$file.' failed'; |
|
| 330 | + } |
|
| 294 | 331 | } |
| 295 | 332 | } |
| 296 | 333 | |
@@ -307,13 +344,17 @@ discard block |
||
| 307 | 344 | $Image = new Image($this->db); |
| 308 | 345 | $Spotter = new Spotter($this->db); |
| 309 | 346 | |
| 310 | - if (empty($crash)) return false; |
|
| 347 | + if (empty($crash)) { |
|
| 348 | + return false; |
|
| 349 | + } |
|
| 311 | 350 | if ($new === false) { |
| 312 | 351 | $query_delete = 'DELETE FROM accidents WHERE source = :source'; |
| 313 | 352 | $sthd = $Connection->db->prepare($query_delete); |
| 314 | 353 | $sthd->execute(array(':source' => $crash[0]['source'])); |
| 315 | 354 | } |
| 316 | - if ($globalTransaction) $Connection->db->beginTransaction(); |
|
| 355 | + if ($globalTransaction) { |
|
| 356 | + $Connection->db->beginTransaction(); |
|
| 357 | + } |
|
| 317 | 358 | $initial_array = array('ident' => null,'type' => 'accident','url' => null,'registration' => null, 'date' => null, 'place' => null,'country' => null, 'latitude' => null, 'longitude' => null, 'fatalities' => null, 'title' => '','source' => '','aircraft_manufacturer' => null,'aircraft_name' => null,'operator' => null); |
| 318 | 359 | $query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
| 319 | 360 | $sth_check = $Connection->db->prepare($query_check); |
@@ -328,7 +369,9 @@ discard block |
||
| 328 | 369 | return $value === "" ? NULL : $value; |
| 329 | 370 | }, $cr); |
| 330 | 371 | if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
| 331 | - if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 372 | + if (strpos($cr['registration'],'-') === FALSE) { |
|
| 373 | + $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
| 374 | + } |
|
| 332 | 375 | $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
| 333 | 376 | $sth_check->execute($query_check_values); |
| 334 | 377 | $result_check = $sth_check->fetchAll(PDO::FETCH_ASSOC); |
@@ -339,13 +382,19 @@ discard block |
||
| 339 | 382 | if ($globalAircraftImageFetch) { |
| 340 | 383 | $imgchk = $Image->getSpotterImage($cr['registration']); |
| 341 | 384 | if (empty($imgchk)) { |
| 342 | - if ($globalDebug) echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 385 | + if ($globalDebug) { |
|
| 386 | + echo "\t".'Get image for '.$cr['registration'].'...'; |
|
| 387 | + } |
|
| 343 | 388 | $Image->addSpotterImage($cr['registration']); |
| 344 | - if ($globalDebug) echo "\t".'Done'."\n"; |
|
| 389 | + if ($globalDebug) { |
|
| 390 | + echo "\t".'Done'."\n"; |
|
| 391 | + } |
|
| 345 | 392 | } |
| 346 | 393 | // elseif ($globalDebug) echo 'Image already in DB'."\n"; |
| 347 | 394 | } |
| 348 | - if ($cr['title'] == '') $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 395 | + if ($cr['title'] == '') { |
|
| 396 | + $cr['title'] = $cr['registration'].' '.$cr['type']; |
|
| 397 | + } |
|
| 349 | 398 | $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
| 350 | 399 | } |
| 351 | 400 | } |
@@ -355,9 +404,13 @@ discard block |
||
| 355 | 404 | $Connection->db->beginTransaction(); |
| 356 | 405 | } |
| 357 | 406 | } |
| 358 | - if ($globalTransaction) $Connection->db->commit(); |
|
| 407 | + if ($globalTransaction) { |
|
| 408 | + $Connection->db->commit(); |
|
| 409 | + } |
|
| 359 | 410 | } catch(PDOException $e) { |
| 360 | - if ($globalTransaction) $Connection->db->rollBack(); |
|
| 411 | + if ($globalTransaction) { |
|
| 412 | + $Connection->db->rollBack(); |
|
| 413 | + } |
|
| 361 | 414 | echo $e->getMessage(); |
| 362 | 415 | } |
| 363 | 416 | $sth_check->closeCursor(); |
@@ -396,8 +449,11 @@ discard block |
||
| 396 | 449 | return "error : ".$e->getMessage(); |
| 397 | 450 | } |
| 398 | 451 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
| 399 | - if ($row['nb'] > 0) return false; |
|
| 400 | - else return true; |
|
| 452 | + if ($row['nb'] > 0) { |
|
| 453 | + return false; |
|
| 454 | + } else { |
|
| 455 | + return true; |
|
| 456 | + } |
|
| 401 | 457 | } |
| 402 | 458 | |
| 403 | 459 | public static function insert_last_accidents_update() { |
@@ -58,8 +58,12 @@ |
||
| 58 | 58 | if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) { |
| 59 | 59 | include('table-output.php'); |
| 60 | 60 | print '<div class="pagination">'; |
| 61 | - if ($limit_previous_1 >= 0) print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
| 62 | - if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
| 61 | + if ($limit_previous_1 >= 0) { |
|
| 62 | + print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">«'._("Previous Page").'</a>'; |
|
| 63 | + } |
|
| 64 | + if ($spotter_array[0]['query_number_rows'] == $absolute_difference) { |
|
| 65 | + print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'»</a>'; |
|
| 66 | + } |
|
| 63 | 67 | print '</div>'; |
| 64 | 68 | } |
| 65 | 69 | print '</div>'; |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | $page_url = $globalURL.'/accident-latest'; |
| 10 | 10 | |
| 11 | -if(!isset($_GET['limit'])) |
|
| 11 | +if (!isset($_GET['limit'])) |
|
| 12 | 12 | { |
| 13 | 13 | $limit_start = 0; |
| 14 | 14 | $limit_end = 25; |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | print '<div class="table column">'; |
| 35 | 35 | print '<p>'._("The table below shows the latest Accidents.").'</p>'; |
| 36 | -$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference,'accident'); |
|
| 36 | +$spotter_array = $Accident->getAccidentData($limit_start.",".$absolute_difference, 'accident'); |
|
| 37 | 37 | if (!empty($spotter_array) && isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] != 0) { |
| 38 | 38 | include('table-output.php'); |
| 39 | 39 | print '<div class="pagination">'; |
@@ -4,7 +4,9 @@ |
||
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | $Stats = new Stats(); |
| 6 | 6 | $title = _("Statistics").' - '._("Most common Airline by Country"); |
| 7 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 7 | +if (!isset($filter_name)) { |
|
| 8 | + $filter_name = ''; |
|
| 9 | +} |
|
| 8 | 10 | require_once('header.php'); |
| 9 | 11 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 10 | 12 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Most common Airline by Country"); |
| 7 | 7 | if (!isset($filter_name)) $filter_name = ''; |
| 8 | 8 | require_once('header.php'); |
| 9 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 10 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 9 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 10 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 11 | 11 | include('statistics-sub-menu.php'); |
| 12 | 12 | |
| 13 | 13 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -18,11 +18,11 @@ discard block |
||
| 18 | 18 | </div> |
| 19 | 19 | <p>'._("Below are the <strong>Top 10</strong> countries that an airline belongs to.").'</p>'; |
| 20 | 20 | |
| 21 | -$airline_array = $Stats->countAllAirlineCountries(true,$filter_name,$year,$month); |
|
| 21 | +$airline_array = $Stats->countAllAirlineCountries(true, $filter_name, $year, $month); |
|
| 22 | 22 | if (count($airline_array) > 0) { |
| 23 | 23 | print '<div id="chartCountry" class="chart" width="100%"></div><script>'; |
| 24 | 24 | $country_data = ''; |
| 25 | -foreach($airline_array as $airline_item) |
|
| 25 | +foreach ($airline_array as $airline_item) |
|
| 26 | 26 | { |
| 27 | 27 | $country_data .= '[ "'.$airline_item['airline_country_iso3'].'",'.$airline_item['airline_country_count'].'],'; |
| 28 | 28 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | print '</thead>'; |
| 70 | 70 | print '<tbody>'; |
| 71 | 71 | $i = 1; |
| 72 | - foreach($airline_array as $airline_item) |
|
| 72 | + foreach ($airline_array as $airline_item) |
|
| 73 | 73 | { |
| 74 | 74 | print '<tr>'; |
| 75 | 75 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -5,7 +5,9 @@ |
||
| 5 | 5 | $Stats = new Stats(); |
| 6 | 6 | $title = _("Statistics").' - '._("Most common Airline"); |
| 7 | 7 | require_once('header.php'); |
| 8 | -if (!isset($filter_name)) $filter_name = ''; |
|
| 8 | +if (!isset($filter_name)) { |
|
| 9 | + $filter_name = ''; |
|
| 10 | +} |
|
| 9 | 11 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 10 | 12 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
| 11 | 13 | include('statistics-sub-menu.php'); |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | $title = _("Statistics").' - '._("Most common Airline"); |
| 7 | 7 | require_once('header.php'); |
| 8 | 8 | if (!isset($filter_name)) $filter_name = ''; |
| 9 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 10 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 9 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 10 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 11 | 11 | include('statistics-sub-menu.php'); |
| 12 | 12 | |
| 13 | 13 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
@@ -17,10 +17,10 @@ discard block |
||
| 17 | 17 | </div> |
| 18 | 18 | <p>'._("Below are the <strong>Top 10</strong> most common airlines.").'</p>'; |
| 19 | 19 | |
| 20 | -$airline_array = $Stats->countAllAirlines(true,$filter_name,$year,$month); |
|
| 20 | +$airline_array = $Stats->countAllAirlines(true, $filter_name, $year, $month); |
|
| 21 | 21 | print '<div id="chart" class="chart" width="100%"></div><script>'; |
| 22 | 22 | $airline_data = ''; |
| 23 | -foreach($airline_array as $airline_item) |
|
| 23 | +foreach ($airline_array as $airline_item) |
|
| 24 | 24 | { |
| 25 | 25 | $airline_data .= '["'.$airline_item['airline_name'].' ('.$airline_item['airline_icao'].')",'.$airline_item['airline_count'].'],'; |
| 26 | 26 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | print '</thead>'; |
| 48 | 48 | print '<tbody>'; |
| 49 | 49 | $i = 1; |
| 50 | - foreach($airline_array as $airline_item) |
|
| 50 | + foreach ($airline_array as $airline_item) |
|
| 51 | 51 | { |
| 52 | 52 | print '<tr>'; |
| 53 | 53 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | require_once('require/class.Spotter.php'); |
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | if (!isset($_GET['owner'])) { |
| 6 | - header('Location: '.$globalURL.'/owner'); |
|
| 7 | - die(); |
|
| 6 | + header('Location: '.$globalURL.'/owner'); |
|
| 7 | + die(); |
|
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | 10 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
@@ -12,8 +12,12 @@ |
||
| 12 | 12 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 13 | 13 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
| 14 | 14 | $filter = array(); |
| 15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 15 | +if ($year != '') { |
|
| 16 | + $filter = array_merge($filter,array('year' => $year)); |
|
| 17 | +} |
|
| 18 | +if ($month != '') { |
|
| 19 | + $filter = array_merge($filter,array('month' => $month)); |
|
| 20 | +} |
|
| 17 | 21 | if ($sort != '') { |
| 18 | 22 | $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter); |
| 19 | 23 | } else { |
@@ -7,22 +7,22 @@ discard block |
||
| 7 | 7 | die(); |
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 11 | -$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING)); |
|
| 12 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 11 | +$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING)); |
|
| 12 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 14 | 14 | $filter = array(); |
| 15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 15 | +if ($year != '') $filter = array_merge($filter, array('year' => $year)); |
|
| 16 | +if ($month != '') $filter = array_merge($filter, array('month' => $month)); |
|
| 17 | 17 | if ($sort != '') { |
| 18 | - $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter); |
|
| 18 | + $spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter); |
|
| 19 | 19 | } else { |
| 20 | - $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", '',$filter); |
|
| 20 | + $spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", '', $filter); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!empty($spotter_array)) |
| 24 | 24 | { |
| 25 | - $title = sprintf(_("Most Common Aircraft of %s"),$spotter_array[0]['aircraft_owner']); |
|
| 25 | + $title = sprintf(_("Most Common Aircraft of %s"), $spotter_array[0]['aircraft_owner']); |
|
| 26 | 26 | require_once('header.php'); |
| 27 | 27 | print '<div class="info column">'; |
| 28 | 28 | print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>'; |
@@ -33,9 +33,9 @@ discard block |
||
| 33 | 33 | include('owner-sub-menu.php'); |
| 34 | 34 | print '<div class="column">'; |
| 35 | 35 | print '<h2>'._("Most Common Aircraft").'</h2>'; |
| 36 | - print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>'; |
|
| 36 | + print '<p>'.sprintf(_("The statistic below shows the most common aircraft of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>'; |
|
| 37 | 37 | |
| 38 | - $aircraft_array = $Spotter->countAllAircraftTypesByOwner($owner,$filter); |
|
| 38 | + $aircraft_array = $Spotter->countAllAircraftTypesByOwner($owner, $filter); |
|
| 39 | 39 | if (!empty($aircraft_array)) |
| 40 | 40 | { |
| 41 | 41 | print '<div class="table-responsive">'; |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | print '</thead>'; |
| 48 | 48 | print '<tbody>'; |
| 49 | 49 | $i = 1; |
| 50 | - foreach($aircraft_array as $aircraft_item) |
|
| 50 | + foreach ($aircraft_array as $aircraft_item) |
|
| 51 | 51 | { |
| 52 | 52 | print '<tr>'; |
| 53 | 53 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | require_once('require/class.Spotter.php'); |
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | if (!isset($_GET['pilot'])) { |
| 6 | - header('Location: '.$globalURL.'/pilot'); |
|
| 7 | - die(); |
|
| 6 | + header('Location: '.$globalURL.'/pilot'); |
|
| 7 | + die(); |
|
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | 10 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
@@ -12,8 +12,12 @@ |
||
| 12 | 12 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 13 | 13 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
| 14 | 14 | $filter = array(); |
| 15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 15 | +if ($year != '') { |
|
| 16 | + $filter = array_merge($filter,array('year' => $year)); |
|
| 17 | +} |
|
| 18 | +if ($month != '') { |
|
| 19 | + $filter = array_merge($filter,array('month' => $month)); |
|
| 20 | +} |
|
| 17 | 21 | $spotter_array = $Spotter->getSpotterDataByPilot($pilot,"0,1", $sort,$filter); |
| 18 | 22 | |
| 19 | 23 | if (!empty($spotter_array)) |
@@ -7,18 +7,18 @@ discard block |
||
| 7 | 7 | die(); |
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 11 | -$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING); |
|
| 12 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 11 | +$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING); |
|
| 12 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 14 | 14 | $filter = array(); |
| 15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 17 | -$spotter_array = $Spotter->getSpotterDataByPilot($pilot,"0,1", $sort,$filter); |
|
| 15 | +if ($year != '') $filter = array_merge($filter, array('year' => $year)); |
|
| 16 | +if ($month != '') $filter = array_merge($filter, array('month' => $month)); |
|
| 17 | +$spotter_array = $Spotter->getSpotterDataByPilot($pilot, "0,1", $sort, $filter); |
|
| 18 | 18 | |
| 19 | 19 | if (!empty($spotter_array)) |
| 20 | 20 | { |
| 21 | - $title = sprintf(_("Most Common Time of Day of %s"),$spotter_array[0]['pilot_name']); |
|
| 21 | + $title = sprintf(_("Most Common Time of Day of %s"), $spotter_array[0]['pilot_name']); |
|
| 22 | 22 | require_once('header.php'); |
| 23 | 23 | print '<div class="info column">'; |
| 24 | 24 | print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>'; |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | include('pilot-sub-menu.php'); |
| 30 | 30 | print '<div class="column">'; |
| 31 | 31 | print '<h2>'._("Most Common Time of Day").'</h2>'; |
| 32 | - print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights piloted by <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>'; |
|
| 32 | + print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights piloted by <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>'; |
|
| 33 | 33 | |
| 34 | - $hour_array = $Spotter->countAllHoursByPilot($pilot,$filter); |
|
| 34 | + $hour_array = $Spotter->countAllHoursByPilot($pilot, $filter); |
|
| 35 | 35 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
| 36 | 36 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
| 37 | 37 | print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>'; |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | $hour_data = ''; |
| 40 | 40 | $hour_cnt = ''; |
| 41 | 41 | $last = 0; |
| 42 | - foreach($hour_array as $hour_item) |
|
| 42 | + foreach ($hour_array as $hour_item) |
|
| 43 | 43 | { |
| 44 | - while($last != $hour_item['hour_name']) { |
|
| 44 | + while ($last != $hour_item['hour_name']) { |
|
| 45 | 45 | $hour_data .= '"'.$last.':00",'; |
| 46 | 46 | $hour_cnt .= '0,'; |
| 47 | 47 | $last++; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $hour_cnt .= $hour_item['hour_count'].','; |
| 52 | 52 | } |
| 53 | 53 | $hour_data = "['x',".substr($hour_data, 0, -1)."]"; |
| 54 | - $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
| 54 | + $hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
| 55 | 55 | print 'c3.generate({ |
| 56 | 56 | bindto: "#chartHour", |
| 57 | 57 | data: { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | print '</thead>'; |
| 77 | 77 | print '<tbody>'; |
| 78 | 78 | $i = 1; |
| 79 | - foreach($hour_array as $hour_item) |
|
| 79 | + foreach ($hour_array as $hour_item) |
|
| 80 | 80 | { |
| 81 | 81 | print '<tr>'; |
| 82 | 82 | print '<td>'.$hour_item['hour_name'].':00</td>'; |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | require_once('require/class.Spotter.php'); |
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | if (!isset($_GET['pilot'])) { |
| 6 | - header('Location: '.$globalURL.'/pilot'); |
|
| 7 | - die(); |
|
| 6 | + header('Location: '.$globalURL.'/pilot'); |
|
| 7 | + die(); |
|
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | 10 | $pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING); |
@@ -7,18 +7,18 @@ discard block |
||
| 7 | 7 | die(); |
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | -$pilot = filter_input(INPUT_GET,'pilot',FILTER_SANITIZE_STRING); |
|
| 11 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 12 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 10 | +$pilot = filter_input(INPUT_GET, 'pilot', FILTER_SANITIZE_STRING); |
|
| 11 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 12 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 14 | 14 | $filter = array(); |
| 15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 17 | -$spotter_array = $Spotter->getSpotterDataByPilot($pilot,"0,1", $sort,$filter); |
|
| 15 | +if ($year != '') $filter = array_merge($filter, array('year' => $year)); |
|
| 16 | +if ($month != '') $filter = array_merge($filter, array('month' => $month)); |
|
| 17 | +$spotter_array = $Spotter->getSpotterDataByPilot($pilot, "0,1", $sort, $filter); |
|
| 18 | 18 | |
| 19 | 19 | if (!empty($spotter_array)) |
| 20 | 20 | { |
| 21 | - $title = sprintf(_("Most Common Aircraft by Registration of %s"),$spotter_array[0]['pilot_name']); |
|
| 21 | + $title = sprintf(_("Most Common Aircraft by Registration of %s"), $spotter_array[0]['pilot_name']); |
|
| 22 | 22 | require_once('header.php'); |
| 23 | 23 | print '<div class="info column">'; |
| 24 | 24 | print '<h1>'.$spotter_array[0]['pilot_name'].'</h1>'; |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | include('pilot-sub-menu.php'); |
| 30 | 30 | print '<div class="column">'; |
| 31 | 31 | print '<h2>'._("Most Common Aircraft by Registration").'</h2>'; |
| 32 | - print '<p>'.sprintf(_("The statistic below shows the most common aircraft by Registration of flights piloted by <strong>%s</strong>."),$spotter_array[0]['pilot_name']).'</p>'; |
|
| 32 | + print '<p>'.sprintf(_("The statistic below shows the most common aircraft by Registration of flights piloted by <strong>%s</strong>."), $spotter_array[0]['pilot_name']).'</p>'; |
|
| 33 | 33 | |
| 34 | - $aircraft_array = $Spotter->countAllAircraftRegistrationByPilot($pilot,$filter); |
|
| 34 | + $aircraft_array = $Spotter->countAllAircraftRegistrationByPilot($pilot, $filter); |
|
| 35 | 35 | |
| 36 | 36 | if (!empty($aircraft_array)) |
| 37 | 37 | { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | print '</thead>'; |
| 48 | 48 | print '<tbody>'; |
| 49 | 49 | $i = 1; |
| 50 | - foreach($aircraft_array as $aircraft_item) |
|
| 50 | + foreach ($aircraft_array as $aircraft_item) |
|
| 51 | 51 | { |
| 52 | 52 | print '<tr>'; |
| 53 | 53 | print '<td><strong>'.$i.'</strong></td>'; |
@@ -12,8 +12,12 @@ |
||
| 12 | 12 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 13 | 13 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
| 14 | 14 | $filter = array(); |
| 15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 15 | +if ($year != '') { |
|
| 16 | + $filter = array_merge($filter,array('year' => $year)); |
|
| 17 | +} |
|
| 18 | +if ($month != '') { |
|
| 19 | + $filter = array_merge($filter,array('month' => $month)); |
|
| 20 | +} |
|
| 17 | 21 | $spotter_array = $Spotter->getSpotterDataByPilot($pilot,"0,1", $sort,$filter); |
| 18 | 22 | |
| 19 | 23 | if (!empty($spotter_array)) |
@@ -3,8 +3,8 @@ |
||
| 3 | 3 | require_once('require/class.Spotter.php'); |
| 4 | 4 | require_once('require/class.Language.php'); |
| 5 | 5 | if (!isset($_GET['owner'])) { |
| 6 | - header('Location: '.$globalURL.'/owner'); |
|
| 7 | - die(); |
|
| 6 | + header('Location: '.$globalURL.'/owner'); |
|
| 7 | + die(); |
|
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | 10 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
@@ -12,8 +12,12 @@ |
||
| 12 | 12 | $year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
| 13 | 13 | $month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
| 14 | 14 | $filter = array(); |
| 15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 15 | +if ($year != '') { |
|
| 16 | + $filter = array_merge($filter,array('year' => $year)); |
|
| 17 | +} |
|
| 18 | +if ($month != '') { |
|
| 19 | + $filter = array_merge($filter,array('month' => $month)); |
|
| 20 | +} |
|
| 17 | 21 | $spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter); |
| 18 | 22 | |
| 19 | 23 | if (!empty($spotter_array)) |
@@ -7,18 +7,18 @@ discard block |
||
| 7 | 7 | die(); |
| 8 | 8 | } |
| 9 | 9 | $Spotter = new Spotter(); |
| 10 | -$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
|
| 11 | -$owner = urldecode(filter_input(INPUT_GET,'owner',FILTER_SANITIZE_STRING)); |
|
| 12 | -$year = filter_input(INPUT_GET,'year',FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | -$month = filter_input(INPUT_GET,'month',FILTER_SANITIZE_NUMBER_INT); |
|
| 10 | +$sort = filter_input(INPUT_GET, 'sort', FILTER_SANITIZE_STRING); |
|
| 11 | +$owner = urldecode(filter_input(INPUT_GET, 'owner', FILTER_SANITIZE_STRING)); |
|
| 12 | +$year = filter_input(INPUT_GET, 'year', FILTER_SANITIZE_NUMBER_INT); |
|
| 13 | +$month = filter_input(INPUT_GET, 'month', FILTER_SANITIZE_NUMBER_INT); |
|
| 14 | 14 | $filter = array(); |
| 15 | -if ($year != '') $filter = array_merge($filter,array('year' => $year)); |
|
| 16 | -if ($month != '') $filter = array_merge($filter,array('month' => $month)); |
|
| 17 | -$spotter_array = $Spotter->getSpotterDataByOwner($owner,"0,1", $sort,$filter); |
|
| 15 | +if ($year != '') $filter = array_merge($filter, array('year' => $year)); |
|
| 16 | +if ($month != '') $filter = array_merge($filter, array('month' => $month)); |
|
| 17 | +$spotter_array = $Spotter->getSpotterDataByOwner($owner, "0,1", $sort, $filter); |
|
| 18 | 18 | |
| 19 | 19 | if (!empty($spotter_array)) |
| 20 | 20 | { |
| 21 | - $title = sprintf(_("Most Common Time of Day of %s"),$spotter_array[0]['aircraft_owner']); |
|
| 21 | + $title = sprintf(_("Most Common Time of Day of %s"), $spotter_array[0]['aircraft_owner']); |
|
| 22 | 22 | require_once('header.php'); |
| 23 | 23 | print '<div class="info column">'; |
| 24 | 24 | print '<h1>'.$spotter_array[0]['aircraft_owner'].'</h1>'; |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | include('owner-sub-menu.php'); |
| 30 | 30 | print '<div class="column">'; |
| 31 | 31 | print '<h2>'._("Most Common Time of Day").'</h2>'; |
| 32 | - print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights owned by <strong>%s</strong>."),$spotter_array[0]['aircraft_owner']).'</p>'; |
|
| 32 | + print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights owned by <strong>%s</strong>."), $spotter_array[0]['aircraft_owner']).'</p>'; |
|
| 33 | 33 | |
| 34 | - $hour_array = $Spotter->countAllHoursByOwner($owner,$filter); |
|
| 34 | + $hour_array = $Spotter->countAllHoursByOwner($owner, $filter); |
|
| 35 | 35 | print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">'; |
| 36 | 36 | print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>'; |
| 37 | 37 | print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>'; |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | $hour_data = ''; |
| 40 | 40 | $hour_cnt = ''; |
| 41 | 41 | $last = 0; |
| 42 | - foreach($hour_array as $hour_item) |
|
| 42 | + foreach ($hour_array as $hour_item) |
|
| 43 | 43 | { |
| 44 | - while($last != $hour_item['hour_name']) { |
|
| 44 | + while ($last != $hour_item['hour_name']) { |
|
| 45 | 45 | $hour_data .= '"'.$last.':00",'; |
| 46 | 46 | $hour_cnt .= '0,'; |
| 47 | 47 | $last++; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | $hour_cnt .= $hour_item['hour_count'].','; |
| 52 | 52 | } |
| 53 | 53 | $hour_data = "['x',".substr($hour_data, 0, -1)."]"; |
| 54 | - $hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]"; |
|
| 54 | + $hour_cnt = "['flights',".substr($hour_cnt, 0, -1)."]"; |
|
| 55 | 55 | print 'c3.generate({ |
| 56 | 56 | bindto: "#chartHour", |
| 57 | 57 | data: { |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | print '</thead>'; |
| 77 | 77 | print '<tbody>'; |
| 78 | 78 | $i = 1; |
| 79 | - foreach($hour_array as $hour_item) |
|
| 79 | + foreach ($hour_array as $hour_item) |
|
| 80 | 80 | { |
| 81 | 81 | print '<tr>'; |
| 82 | 82 | print '<td>'.$hour_item['hour_name'].':00</td>'; |