|
@@ -29,20 +29,20 @@ discard block |
|
|
block discarded – undo |
|
29
|
29
|
* @param String $date get data for a date |
|
30
|
30
|
* @return Array Return Accidents data in array |
|
31
|
31
|
*/ |
|
32
|
|
- public function getAccidentData($limit = '',$type = '',$date = '') { |
|
|
32
|
+ public function getAccidentData($limit = '', $type = '', $date = '') { |
|
33
|
33
|
global $globalURL, $globalDBdriver; |
|
34
|
34
|
$Image = new Image($this->db); |
|
35
|
35
|
$Spotter = new Spotter($this->db); |
|
36
|
36
|
$Translation = new Translation($this->db); |
|
37
|
|
- $date = filter_var($date,FILTER_SANITIZE_STRING); |
|
|
37
|
+ $date = filter_var($date, FILTER_SANITIZE_STRING); |
|
38
|
38
|
date_default_timezone_set('UTC'); |
|
39
|
39
|
$result = array(); |
|
40
|
40
|
$limit_query = ''; |
|
41
|
41
|
if ($limit != "") |
|
42
|
42
|
{ |
|
43
|
43
|
$limit_array = explode(",", $limit); |
|
44
|
|
- $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
45
|
|
- $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
|
44
|
+ $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
|
45
|
+ $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
46
|
46
|
if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
|
47
|
47
|
{ |
|
48
|
48
|
$limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
|
@@ -51,7 +51,7 @@ discard block |
|
|
block discarded – undo |
|
51
|
51
|
|
|
52
|
52
|
if ($type != '') { |
|
53
|
53
|
if ($date != '') { |
|
54
|
|
- if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
|
54
|
+ if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
55
|
55
|
$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; |
|
56
|
56
|
//$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; |
|
57
|
57
|
} else { |
|
@@ -63,7 +63,7 @@ discard block |
|
|
block discarded – undo |
|
63
|
63
|
//$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; |
|
64
|
64
|
} |
|
65
|
65
|
} |
|
66
|
|
- $query_values = array(':type' => $type,':date' => $date); |
|
|
66
|
+ $query_values = array(':type' => $type, ':date' => $date); |
|
67
|
67
|
} else { |
|
68
|
68
|
$query = "SELECT * FROM accidents WHERE accidents_id IN (SELECT max(accidents_id) FROM accidents WHERE type = :type 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 GROUP BY registration) ORDER BY accidents.date DESC".$limit_query; |
|
@@ -71,7 +71,7 @@ discard block |
|
|
block discarded – undo |
|
71
|
71
|
} |
|
72
|
72
|
} else { |
|
73
|
73
|
if ($date != '') { |
|
74
|
|
- if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/",$date)) { |
|
|
74
|
+ if (preg_match("/^[0-9]{4}-[0-9]{2}-[0-9]{2}$/", $date)) { |
|
75
|
75
|
$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; |
|
76
|
76
|
//$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; |
|
77
|
77
|
} else { |
|
@@ -90,7 +90,7 @@ discard block |
|
|
block discarded – undo |
|
90
|
90
|
try { |
|
91
|
91
|
$sth = $this->db->prepare($query); |
|
92
|
92
|
$sth->execute($query_values); |
|
93
|
|
- } catch(PDOException $e) { |
|
|
93
|
+ } catch (PDOException $e) { |
|
94
|
94
|
echo "error : ".$e->getMessage(); |
|
95
|
95
|
} |
|
96
|
96
|
$i = 0; |
|
@@ -100,8 +100,8 @@ discard block |
|
|
block discarded – undo |
|
100
|
100
|
$data = array(); |
|
101
|
101
|
if ($row['registration'] != '') { |
|
102
|
102
|
$image_array = $Image->getSpotterImage($row['registration']); |
|
103
|
|
- 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'])); |
|
104
|
|
- else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
|
103
|
+ 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'])); |
|
|
104
|
+ else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
105
|
105
|
$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']); |
|
106
|
106
|
$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type); |
|
107
|
107
|
if (!empty($aircraft_info)) { |
|
@@ -109,7 +109,7 @@ discard block |
|
|
block discarded – undo |
|
109
|
109
|
$data['aircraft_name'] = $aircraft_info[0]['type']; |
|
110
|
110
|
$data['aircraft_manufacturer'] = $aircraft_info[0]['manufacturer']; |
|
111
|
111
|
} else { |
|
112
|
|
- $data = array_merge($data,array('aircraft_type' => 'NA')); |
|
|
112
|
+ $data = array_merge($data, array('aircraft_type' => 'NA')); |
|
113
|
113
|
} |
|
114
|
114
|
$owner_data = $Spotter->getAircraftOwnerByRegistration($row['registration']); |
|
115
|
115
|
if (!empty($owner_data)) { |
|
@@ -117,18 +117,18 @@ discard block |
|
|
block discarded – undo |
|
117
|
117
|
$data['aircraft_base'] = $owner_data['base']; |
|
118
|
118
|
$data['aircraft_date_first_reg'] = $owner_data['date_first_reg']; |
|
119
|
119
|
} |
|
120
|
|
- } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
|
120
|
+ } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
121
|
121
|
if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
122
|
122
|
if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
123
|
|
- $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3)); |
|
|
123
|
+ $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 3)); |
|
124
|
124
|
if (isset($identicao[0])) { |
|
125
|
|
- if (substr($row['ident'],0,2) == 'AF') { |
|
126
|
|
- if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
127
|
|
- else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
128
|
|
- } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
129
|
|
- $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
|
125
|
+ if (substr($row['ident'], 0, 2) == 'AF') { |
|
|
126
|
+ if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
|
127
|
+ else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
|
128
|
+ } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
|
129
|
+ $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
130
|
130
|
} else $icao = $row['ident']; |
|
131
|
|
- $icao = $Translation->checkTranslation($icao,false); |
|
|
131
|
+ $icao = $Translation->checkTranslation($icao, false); |
|
132
|
132
|
//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url'])); |
|
133
|
133
|
if ($row['airline_name'] != '' && !isset($data['airline_name'])) { |
|
134
|
134
|
//echo 'Check airline info... for '.$row['airline_name'].' '; |
|
@@ -137,11 +137,11 @@ discard block |
|
|
block discarded – undo |
|
137
|
137
|
if (!empty($airline_info)) { |
|
138
|
138
|
//echo 'data found !'."\n"; |
|
139
|
139
|
//print_r($airline_info); |
|
140
|
|
- $data = array_merge($data,$airline_info); |
|
|
140
|
+ $data = array_merge($data, $airline_info); |
|
141
|
141
|
} |
|
142
|
142
|
//else echo 'No data...'."\n"; |
|
143
|
143
|
} |
|
144
|
|
- $data = array_merge($row,$data); |
|
|
144
|
+ $data = array_merge($row, $data); |
|
145
|
145
|
if ($data['ident'] == null) $data['ident'] = $icao; |
|
146
|
146
|
if ($data['title'] == null) { |
|
147
|
147
|
$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country']; |
|
@@ -175,7 +175,7 @@ discard block |
|
|
block discarded – undo |
|
175
|
175
|
try { |
|
176
|
176
|
$sth = $this->db->prepare($query); |
|
177
|
177
|
$sth->execute(); |
|
178
|
|
- } catch(PDOException $e) { |
|
|
178
|
+ } catch (PDOException $e) { |
|
179
|
179
|
echo "Error : ".$e->getMessage(); |
|
180
|
180
|
} |
|
181
|
181
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
@@ -195,7 +195,7 @@ discard block |
|
|
block discarded – undo |
|
195
|
195
|
try { |
|
196
|
196
|
$sth = $this->db->prepare($query); |
|
197
|
197
|
$sth->execute(); |
|
198
|
|
- } catch(PDOException $e) { |
|
|
198
|
+ } catch (PDOException $e) { |
|
199
|
199
|
echo "Error : ".$e->getMessage(); |
|
200
|
200
|
} |
|
201
|
201
|
return $sth->fetchAll(PDO::FETCH_ASSOC); |
|
@@ -210,15 +210,15 @@ discard block |
|
|
block discarded – undo |
|
210
|
210
|
if ($globalDebug) echo 'Import '.$file."\n"; |
|
211
|
211
|
$result = array(); |
|
212
|
212
|
if (file_exists($file)) { |
|
213
|
|
- if (($handle = fopen($file,'r')) !== FALSE) { |
|
214
|
|
- while (($data = fgetcsv($handle,2000,",")) !== FALSE) { |
|
|
213
|
+ if (($handle = fopen($file, 'r')) !== FALSE) { |
|
|
214
|
+ while (($data = fgetcsv($handle, 2000, ",")) !== FALSE) { |
|
215
|
215
|
if (isset($data[1]) && $data[1] != '0000-00-00 00:00:00') { |
|
216
|
|
- $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'); |
|
|
216
|
+ $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'); |
|
217
|
217
|
} |
|
218
|
218
|
} |
|
219
|
219
|
fclose($handle); |
|
220
|
220
|
} |
|
221
|
|
- if (!empty($result)) $this->add($result,true); |
|
|
221
|
+ if (!empty($result)) $this->add($result, true); |
|
222
|
222
|
elseif ($globalDebug) echo 'Nothing to import'; |
|
223
|
223
|
} |
|
224
|
224
|
} |
|
@@ -234,8 +234,8 @@ discard block |
|
|
block discarded – undo |
|
234
|
234
|
$all_md5_new = array(); |
|
235
|
235
|
if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
|
236
|
236
|
if ($this->check_accidents_nb() > 0) { |
|
237
|
|
- if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
238
|
|
- while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
|
237
|
+ if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
|
238
|
+ while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
239
|
239
|
if (isset($data[1])) { |
|
240
|
240
|
$year = $data[0]; |
|
241
|
241
|
$all_md5[$year] = $data[1]; |
|
@@ -245,10 +245,10 @@ discard block |
|
|
block discarded – undo |
|
245
|
245
|
} |
|
246
|
246
|
} |
|
247
|
247
|
} |
|
248
|
|
- $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5',dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
|
248
|
+ $Common->download('http://data.flightairmap.fr/data/cr/cr-all.md5', dirname(__FILE__).'/../install/tmp/cr-all.md5'); |
|
249
|
249
|
if (file_exists(dirname(__FILE__).'/../install/tmp/cr-all.md5')) { |
|
250
|
|
- if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5','r')) !== FALSE) { |
|
251
|
|
- while (($data = fgetcsv($handle,2000,"\t")) !== FALSE) { |
|
|
250
|
+ if (($handle = fopen(dirname(__FILE__).'/../install/tmp/cr-all.md5', 'r')) !== FALSE) { |
|
|
251
|
+ while (($data = fgetcsv($handle, 2000, "\t")) !== FALSE) { |
|
252
|
252
|
if (isset($data[1])) { |
|
253
|
253
|
$year = $data[0]; |
|
254
|
254
|
$all_md5_new[$year] = $data[1]; |
|
@@ -257,10 +257,10 @@ discard block |
|
|
block discarded – undo |
|
257
|
257
|
fclose($handle); |
|
258
|
258
|
} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5'; |
|
259
|
259
|
} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.'; |
|
260
|
|
- $result = $Common->arr_diff($all_md5_new,$all_md5); |
|
|
260
|
+ $result = $Common->arr_diff($all_md5_new, $all_md5); |
|
261
|
261
|
if (empty($result) && $globalDebug) echo 'Nothing to update'; |
|
262
|
262
|
foreach ($result as $file => $md5) { |
|
263
|
|
- $Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file); |
|
|
263
|
+ $Common->download('http://data.flightairmap.fr/data/cr/'.$file, dirname(__FILE__).'/../install/tmp/'.$file); |
|
264
|
264
|
if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file); |
|
265
|
265
|
elseif ($globalDebug) echo 'Download '.$file.' failed'; |
|
266
|
266
|
} |
|
@@ -270,7 +270,7 @@ discard block |
|
|
block discarded – undo |
|
270
|
270
|
* Add data to DB |
|
271
|
271
|
* @param Array $crash An array with accidents/incidents data |
|
272
|
272
|
*/ |
|
273
|
|
- public function add($crash,$new = false) { |
|
|
273
|
+ public function add($crash, $new = false) { |
|
274
|
274
|
global $globalTransaction, $globalDebug; |
|
275
|
275
|
require_once('class.Connection.php'); |
|
276
|
276
|
require_once('class.Image.php'); |
|
@@ -286,7 +286,7 @@ discard block |
|
|
block discarded – undo |
|
286
|
286
|
$sthd->execute(array(':source' => $crash[0]['source'])); |
|
287
|
287
|
} |
|
288
|
288
|
if ($globalTransaction) $Connection->db->beginTransaction(); |
|
289
|
|
- $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); |
|
|
289
|
+ $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); |
|
290
|
290
|
$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source'; |
|
291
|
291
|
$sth_check = $Connection->db->prepare($query_check); |
|
292
|
292
|
$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)'; |
|
@@ -299,31 +299,31 @@ discard block |
|
|
block discarded – undo |
|
299
|
299
|
$cr = array_map(function($value) { |
|
300
|
300
|
return $value === "" ? NULL : $value; |
|
301
|
301
|
}, $cr); |
|
302
|
|
- if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) { |
|
303
|
|
- if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
304
|
|
- $query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']); |
|
|
302
|
+ if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/', $cr['registration'])) { |
|
|
303
|
+ if (strpos($cr['registration'], '-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']); |
|
|
304
|
+ $query_check_values = array(':registration' => $cr['registration'], ':date' => date('Y-m-d', $cr['date']), ':type' => $cr['type'], ':source' => $cr['source']); |
|
305
|
305
|
$sth_check->execute($query_check_values); |
|
306
|
306
|
$result_check = $sth_check->fetch(PDO::FETCH_ASSOC); |
|
307
|
307
|
if ($result_check['nb'] == 0) { |
|
308
|
|
- $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']); |
|
|
308
|
+ $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']); |
|
309
|
309
|
$sth->execute($query_values); |
|
310
|
|
- if ($cr['date'] > time()-(30*86400)) { |
|
|
310
|
+ if ($cr['date'] > time() - (30*86400)) { |
|
311
|
311
|
if (empty($Image->getSpotterImage($cr['registration']))) { |
|
312
|
312
|
//if ($globalDebug) echo 'Get image...'."\n"; |
|
313
|
313
|
$Image->addSpotterImage($cr['registration']); |
|
314
|
314
|
} |
|
315
|
315
|
// elseif ($globalDebug) echo 'Image already in DB'."\n"; |
|
316
|
316
|
} |
|
317
|
|
- $Spotter->setHighlightFlightByRegistration($cr['registration'],$cr['title'],date('Y-m-d',$cr['date'])); |
|
|
317
|
+ $Spotter->setHighlightFlightByRegistration($cr['registration'], $cr['title'], date('Y-m-d', $cr['date'])); |
|
318
|
318
|
} |
|
319
|
319
|
} |
|
320
|
|
- if ($globalTransaction && $j % 1000 == 0) { |
|
|
320
|
+ if ($globalTransaction && $j%1000 == 0) { |
|
321
|
321
|
$Connection->db->commit(); |
|
322
|
322
|
$Connection->db->beginTransaction(); |
|
323
|
323
|
} |
|
324
|
324
|
} |
|
325
|
325
|
if ($globalTransaction) $Connection->db->commit(); |
|
326
|
|
- } catch(PDOException $e) { |
|
|
326
|
+ } catch (PDOException $e) { |
|
327
|
327
|
if ($globalTransaction) $Connection->db->rollBack(); |
|
328
|
328
|
echo $e->getMessage(); |
|
329
|
329
|
} |
|
@@ -341,7 +341,7 @@ discard block |
|
|
block discarded – undo |
|
341
|
341
|
$Connection = new Connection(); |
|
342
|
342
|
$sth = $Connection->db->prepare($query); |
|
343
|
343
|
$sth->execute(); |
|
344
|
|
- } catch(PDOException $e) { |
|
|
344
|
+ } catch (PDOException $e) { |
|
345
|
345
|
return "error : ".$e->getMessage(); |
|
346
|
346
|
} |
|
347
|
347
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
@@ -359,7 +359,7 @@ discard block |
|
|
block discarded – undo |
|
359
|
359
|
$Connection = new Connection(); |
|
360
|
360
|
$sth = $Connection->db->prepare($query); |
|
361
|
361
|
$sth->execute(); |
|
362
|
|
- } catch(PDOException $e) { |
|
|
362
|
+ } catch (PDOException $e) { |
|
363
|
363
|
return "error : ".$e->getMessage(); |
|
364
|
364
|
} |
|
365
|
365
|
$row = $sth->fetch(PDO::FETCH_ASSOC); |
|
@@ -374,7 +374,7 @@ discard block |
|
|
block discarded – undo |
|
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
|
} |