Completed
Push — master ( 04cc20...60bf6d )
by Yannick
08:30
created
airport-statistics-time.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -23,7 +23,9 @@
 block discarded – undo
23 23
 	print '<option></option>';
24 24
 	$Stats = new Stats();
25 25
 	$airport_names = $Stats->getAllAirportNames();
26
-	if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
26
+	if (empty($airport_names)) {
27
+		$airport_names = $Spotter->getAllAirportNames();
28
+	}
27 29
 	ksort($airport_names);
28 30
 	foreach($airport_names as $airport_name)
29 31
 	{
Please login to merge, or discard this patch.
aircraft.php 1 patch
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 	print '<h1>'._("Aircrafts 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
 block discarded – undo
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
 block discarded – undo
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'] == '') {
Please login to merge, or discard this patch.
require/class.Accident.php 1 patch
Braces   +75 added lines, -27 removed lines patch added patch discarded remove patch
@@ -96,8 +96,11 @@  discard block
 block discarded – undo
96 96
 			$data = array();
97 97
 			if ($row['registration'] != '') {
98 98
 				$image_array = $Image->getSpotterImage($row['registration']);
99
-				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']));
100
-				else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
99
+				if (count($image_array) > 0) {
100
+					$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']));
101
+				} else {
102
+					$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
103
+				}
101 104
 				$aircraft_type = $Spotter->getAllAircraftTypeByRegistration($row['registration']);
102 105
 				$aircraft_info = $Spotter->getAllAircraftInfo($aircraft_type);
103 106
 				if (!empty($aircraft_info)) {
@@ -113,17 +116,30 @@  discard block
 block discarded – undo
113 116
 					$data['aircraft_base'] = $owner_data['base'];
114 117
 					$data['aircraft_date_first_reg'] = $owner_data['date_first_reg'];
115 118
 				}
116
-			} else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
117
-			if ($row['registration'] == '') $row['registration'] = 'NA';
118
-			if ($row['ident'] == '') $row['ident'] = 'NA';
119
+			} else {
120
+				$data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => ''));
121
+			}
122
+			if ($row['registration'] == '') {
123
+				$row['registration'] = 'NA';
124
+			}
125
+			if ($row['ident'] == '') {
126
+				$row['ident'] = 'NA';
127
+			}
119 128
 			$identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,3));
120 129
 			if (isset($identicao[0])) {
121 130
 				if (substr($row['ident'],0,2) == 'AF') {
122
-					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident'];
123
-					else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
124
-				} else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
131
+					if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) {
132
+						$icao = $row['ident'];
133
+					} else {
134
+						$icao = 'AFR'.ltrim(substr($row['ident'],2),'0');
135
+					}
136
+				} else {
137
+					$icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0');
138
+				}
125 139
 				$data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name']));
126
-			} else $icao = $row['ident'];
140
+			} else {
141
+				$icao = $row['ident'];
142
+			}
127 143
 			$icao = $Translation->checkTranslation($icao,false);
128 144
 			//$data = array_merge($data,array('registration' => $row['registration'], 'date' => $row['date'], 'ident' => $icao,'url' => $row['url']));
129 145
 			if ($row['airline_name'] != '' && !isset($data['airline_name'])) {
@@ -138,10 +154,14 @@  discard block
 block discarded – undo
138 154
 				//else echo 'No data...'."\n";
139 155
 			}
140 156
 			$data = array_merge($row,$data);
141
-			if ($data['ident'] == null) $data['ident'] = $icao;
157
+			if ($data['ident'] == null) {
158
+				$data['ident'] = $icao;
159
+			}
142 160
 			if ($data['title'] == null) {
143 161
 				$data['message'] = $row['type'].' of '.$row['registration'].' at '.$row['place'].','.$row['country'];
144
-			} else $data['message'] = strtolower($data['title']);
162
+			} else {
163
+				$data['message'] = strtolower($data['title']);
164
+			}
145 165
 			$ids = $Spotter->getAllIDByRegistration($data['registration']);
146 166
 			$date = $data['date'];
147 167
 			if (isset($ids[$date])) {
@@ -158,8 +178,9 @@  discard block
 block discarded – undo
158 178
 		if (isset($result)) {
159 179
 			$result[0]['query_number_rows'] = $i;
160 180
 			return $result;
181
+		} else {
182
+			return array();
161 183
 		}
162
-		else return array();
163 184
 	}
164 185
 	
165 186
 	/*
@@ -198,7 +219,9 @@  discard block
 block discarded – undo
198 219
 	*/
199 220
 	public function import($file) {
200 221
 		global $globalTransaction, $globalDebug;
201
-		if ($globalDebug) echo 'Import '.$file."\n";
222
+		if ($globalDebug) {
223
+			echo 'Import '.$file."\n";
224
+		}
202 225
 		$result = array();
203 226
 		if (file_exists($file)) {
204 227
 			if (($handle = fopen($file,'r')) !== FALSE) {
@@ -209,8 +232,11 @@  discard block
 block discarded – undo
209 232
 				}
210 233
 				fclose($handle);
211 234
 			}
212
-			if (!empty($result)) $this->add($result,true);
213
-			elseif ($globalDebug) echo 'Nothing to import';
235
+			if (!empty($result)) {
236
+				$this->add($result,true);
237
+			} elseif ($globalDebug) {
238
+				echo 'Nothing to import';
239
+			}
214 240
 		}
215 241
 	}
216 242
 
@@ -246,14 +272,23 @@  discard block
 block discarded – undo
246 272
 					}
247 273
 				}
248 274
 				fclose($handle);
249
-			} elseif ($globalDebug) echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
250
-		} elseif ($globalDebug) echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
275
+			} elseif ($globalDebug) {
276
+				echo "Can't open ".dirname(__FILE__).'/../install/tmp/cr-all.md5';
277
+			}
278
+		} elseif ($globalDebug) {
279
+			echo 'Download cr-all.md5 failed. '.dirname(__FILE__).'/../install/tmp/cr-all.md5 not here.';
280
+		}
251 281
 		$result = $Common->arr_diff($all_md5_new,$all_md5);
252
-		if (empty($result) && $globalDebug) echo 'Nothing to update';
282
+		if (empty($result) && $globalDebug) {
283
+			echo 'Nothing to update';
284
+		}
253 285
 		foreach ($result as $file => $md5) {
254 286
 			$Common->download('http://data.flightairmap.fr/data/cr/'.$file,dirname(__FILE__).'/../install/tmp/'.$file);
255
-			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) $this->import(dirname(__FILE__).'/../install/tmp/'.$file);
256
-			elseif ($globalDebug) echo 'Download '.$file.' failed';
287
+			if (file_exists(dirname(__FILE__).'/../install/tmp/'.$file)) {
288
+				$this->import(dirname(__FILE__).'/../install/tmp/'.$file);
289
+			} elseif ($globalDebug) {
290
+				echo 'Download '.$file.' failed';
291
+			}
257 292
 		}
258 293
 	}
259 294
 
@@ -270,13 +305,17 @@  discard block
 block discarded – undo
270 305
 		$Image = new Image();
271 306
 		$Spotter = new Spotter();
272 307
 
273
-		if (empty($crash)) return false;
308
+		if (empty($crash)) {
309
+			return false;
310
+		}
274 311
 		if (!$new) {
275 312
 			$query_delete = 'DELETE FROM accidents WHERE source = :source';
276 313
 			$sthd = $Connection->db->prepare($query_delete);
277 314
 			$sthd->execute(array(':source' => $crash[0]['source']));
278 315
 		}
279
-		if ($globalTransaction) $Connection->db->beginTransaction();
316
+		if ($globalTransaction) {
317
+			$Connection->db->beginTransaction();
318
+		}
280 319
 		$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);
281 320
 		$query_check = 'SELECT COUNT(*) as nb FROM accidents WHERE registration = :registration AND date = :date AND type = :type AND source = :source';
282 321
 		$sth_check = $Connection->db->prepare($query_check);
@@ -291,7 +330,9 @@  discard block
 block discarded – undo
291 330
 					return $value === "" ? NULL : $value;
292 331
 				}, $cr);
293 332
 				if ($cr['date'] != '' && $cr['registration'] != null && $cr['registration'] != '' && $cr['registration'] != '?' && $cr['registration'] != '-' && strtolower($cr['registration']) != 'unknown' && $cr['date'] < time() && !preg_match('/\s/',$cr['registration'])) {
294
-					if (strpos($cr['registration'],'-') === FALSE) $cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
333
+					if (strpos($cr['registration'],'-') === FALSE) {
334
+						$cr['registration'] = $Spotter->convertAircraftRegistration($cr['registration']);
335
+					}
295 336
 					$query_check_values = array(':registration' => $cr['registration'],':date' => date('Y-m-d',$cr['date']),':type' => $cr['type'],':source' => $cr['source']);
296 337
 					$sth_check->execute($query_check_values);
297 338
 					$result_check = $sth_check->fetch(PDO::FETCH_ASSOC);
@@ -313,9 +354,13 @@  discard block
 block discarded – undo
313 354
 					$Connection->db->beginTransaction();
314 355
 				}
315 356
 			}
316
-			if ($globalTransaction) $Connection->db->commit();
357
+			if ($globalTransaction) {
358
+				$Connection->db->commit();
359
+			}
317 360
 		} catch(PDOException $e) {
318
-			if ($globalTransaction) $Connection->db->rollBack();
361
+			if ($globalTransaction) {
362
+				$Connection->db->rollBack();
363
+			}
319 364
 			echo $e->getMessage();
320 365
 		}
321 366
 		$sth_check->closeCursor();
@@ -354,8 +399,11 @@  discard block
 block discarded – undo
354 399
 			return "error : ".$e->getMessage();
355 400
 		}
356 401
 		$row = $sth->fetch(PDO::FETCH_ASSOC);
357
-		if ($row['nb'] > 0) return false;
358
-		else return true;
402
+		if ($row['nb'] > 0) {
403
+			return false;
404
+		} else {
405
+			return true;
406
+		}
359 407
 	}
360 408
 
361 409
 	public static function insert_last_accidents_update() {
Please login to merge, or discard this patch.
accident-latest.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,8 +58,12 @@
 block discarded – undo
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.'">&laquo;'._("Previous Page").'</a>';
62
-	if ($spotter_array[0]['query_number_rows'] == $absolute_difference) print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'">'._("Next Page").'&raquo;</a>';
61
+	if ($limit_previous_1 >= 0) {
62
+		print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'">&laquo;'._("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").'&raquo;</a>';
66
+	}
63 67
 	print '</div>';
64 68
 }
65 69
 print '</div>';
Please login to merge, or discard this patch.
statistics-airline-country.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -4,7 +4,9 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
statistics-airline.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
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'); 
Please login to merge, or discard this patch.
pilot.php 1 patch
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,7 +31,9 @@  discard block
 block discarded – undo
31 31
 			}
32 32
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
33 33
 		}
34
-		if ($firstLetter != "'") $previous = $firstLetter;
34
+		if ($firstLetter != "'") {
35
+			$previous = $firstLetter;
36
+		}
35 37
 	}
36 38
 	print '</div>';
37 39
 	$previous = null;
@@ -46,10 +48,15 @@  discard block
 block discarded – undo
46 48
 				}
47 49
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
48 50
 			}
49
-			if ($firstLetter != "'") $previous = $firstLetter;
51
+			if ($firstLetter != "'") {
52
+				$previous = $firstLetter;
53
+			}
50 54
 			print '<div class="alphabet-item">';
51
-			if (isset($value['pilot_id']) && $value['pilot_id'] != '') print '<a href="'.$globalURL.'/pilot/'.$value['pilot_id'].'">'.$value['pilot_name'].' ('.$value['pilot_id'].')';
52
-			else print '<a href="'.$globalURL.'/pilot/'.$value['pilot_name'].'">'.$value['pilot_name'];
55
+			if (isset($value['pilot_id']) && $value['pilot_id'] != '') {
56
+				print '<a href="'.$globalURL.'/pilot/'.$value['pilot_id'].'">'.$value['pilot_name'].' ('.$value['pilot_id'].')';
57
+			} else {
58
+				print '<a href="'.$globalURL.'/pilot/'.$value['pilot_name'].'">'.$value['pilot_name'];
59
+			}
53 60
 			print '</a>';
54 61
 			print '</div>';
55 62
 		}
Please login to merge, or discard this patch.
owner.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -33,7 +33,9 @@  discard block
 block discarded – undo
33 33
 			}
34 34
 			print '<a href="#'.$firstLetter.'">'.$firstLetter.'</a>';
35 35
 		}
36
-		if ($firstLetter != "'" && $firstLetter != '"') $previous = $firstLetter;
36
+		if ($firstLetter != "'" && $firstLetter != '"') {
37
+			$previous = $firstLetter;
38
+		}
37 39
 	}
38 40
 	print '</div>';
39 41
 	$previous = null;
@@ -48,7 +50,9 @@  discard block
 block discarded – undo
48 50
 				}
49 51
 				print '<a name="'.$firstLetter.'"></a><h4 class="alphabet-header">'.$firstLetter.'</h4><div class="alphabet">';
50 52
 			}
51
-			if ($firstLetter != "'" && $firstLetter != '"') $previous = $firstLetter;
53
+			if ($firstLetter != "'" && $firstLetter != '"') {
54
+				$previous = $firstLetter;
55
+			}
52 56
 			print '<div class="alphabet-item">';
53 57
 			print '<a href="'.$globalURL.'/owner/'.$value['owner_name'].'">';
54 58
 			print $value['owner_name'];
Please login to merge, or discard this patch.
require/class.Connection.php 1 patch
Braces   +77 added lines, -30 removed lines patch added patch discarded remove patch
@@ -64,8 +64,11 @@  discard block
 block discarded – undo
64 64
 				$globalDBSname = $globalDBname;
65 65
 				$globalDBSuser = $globalDBuser;
66 66
 				$globalDBSpass = $globalDBpass;
67
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
68
-				else $globalDBSport = $globalDBport;
67
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
68
+					$globalDBSport = 3306;
69
+				} else {
70
+					$globalDBSport = $globalDBport;
71
+				}
69 72
 			} else {
70 73
 				$DBname = 'default';
71 74
 				$globalDBSdriver = $globalDBdriver;
@@ -73,8 +76,11 @@  discard block
 block discarded – undo
73 76
 				$globalDBSname = $globalDBname;
74 77
 				$globalDBSuser = $user;
75 78
 				$globalDBSpass = $pass;
76
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
77
-				else $globalDBSport = $globalDBport;
79
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
80
+					$globalDBSport = 3306;
81
+				} else {
82
+					$globalDBSport = $globalDBport;
83
+				}
78 84
 			}
79 85
 		} else {
80 86
 			$globalDBSdriver = $globalDB[$DBname]['driver'];
@@ -82,11 +88,16 @@  discard block
 block discarded – undo
82 88
 			$globalDBSname = $globalDB[$DBname]['name'];
83 89
 			$globalDBSuser = $globalDB[$DBname]['user'];
84 90
 			$globalDBSpass = $globalDB[$DBname]['pass'];
85
-			if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port'];
86
-			else $globalDBSport = 3306;
91
+			if (isset($globalDB[$DBname]['port'])) {
92
+				$globalDBSport = $globalDB[$DBname]['port'];
93
+			} else {
94
+				$globalDBSport = 3306;
95
+			}
87 96
 		}
88 97
 		// Set number of try to connect to DB
89
-		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5;
98
+		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) {
99
+			$globalDBretry = 5;
100
+		}
90 101
 		$i = 0;
91 102
 		while (true) {
92 103
 			try {
@@ -95,10 +106,16 @@  discard block
 block discarded – undo
95 106
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
96 107
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
97 108
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
98
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
99
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
100
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
101
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
109
+					if (!isset($globalDBTimeOut)) {
110
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
111
+					} else {
112
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
113
+					}
114
+					if (!isset($globalDBPersistent)) {
115
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
116
+					} else {
117
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
118
+					}
102 119
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
103 120
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
104 121
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -112,23 +129,35 @@  discard block
 block discarded – undo
112 129
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
113 130
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
114 131
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
115
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
116
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
117
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
118
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
132
+					if (!isset($globalDBTimeOut)) {
133
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
134
+					} else {
135
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
136
+					}
137
+					if (!isset($globalDBPersistent)) {
138
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
139
+					} else {
140
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
141
+					}
119 142
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
120 143
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
121 144
 				}
122 145
 				break;
123 146
 			} catch(PDOException $e) {
124 147
 				$i++;
125
-				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
148
+				if (isset($globalDebug) && $globalDebug) {
149
+					echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
150
+				}
126 151
 				//exit;
127
-				if ($i > $globalDBretry) return false;
152
+				if ($i > $globalDBretry) {
153
+					return false;
154
+				}
128 155
 				//return false;
129 156
 			}
130 157
 		}
131
-		if ($DBname === 'default') $this->db = $this->dbs['default'];
158
+		if ($DBname === 'default') {
159
+			$this->db = $this->dbs['default'];
160
+		}
132 161
 		return true;
133 162
 	}
134 163
 
@@ -140,7 +169,9 @@  discard block
 block discarded – undo
140 169
 		} else {
141 170
 			$query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'";
142 171
 		}
143
-		if ($this->db == NULL) return false;
172
+		if ($this->db == NULL) {
173
+			return false;
174
+		}
144 175
 		try {
145 176
 			//$Connection = new Connection();
146 177
 			$results = $this->db->query($query);
@@ -149,21 +180,28 @@  discard block
 block discarded – undo
149 180
 		}
150 181
 		if($results->rowCount()>0) {
151 182
 		    return true; 
183
+		} else {
184
+			return false;
152 185
 		}
153
-		else return false;
154 186
 	}
155 187
 
156 188
 	public function connectionExists()
157 189
 	{
158 190
 		global $globalDBdriver, $globalDBCheckConnection;
159
-		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true;
191
+		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) {
192
+			return true;
193
+		}
160 194
 		$query = "SELECT 1 + 1";
161
-		if ($this->db === null) return false;
195
+		if ($this->db === null) {
196
+			return false;
197
+		}
162 198
 		try {
163 199
 			$sum = @$this->db->query($query);
164 200
 			if ($sum instanceof \PDOStatement) {
165 201
 				$sum = $sum->fetchColumn(0);
166
-			} else $sum = 0;
202
+			} else {
203
+				$sum = 0;
204
+			}
167 205
 			if (intval($sum) !== 2) {
168 206
 			     return false;
169 207
 			}
@@ -198,8 +236,9 @@  discard block
 block discarded – undo
198 236
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
199 237
 		if($nb[0]['nb'] > 0) {
200 238
 			return true; 
239
+		} else {
240
+			return false;
201 241
 		}
202
-		else return false;
203 242
 	}
204 243
 
205 244
 	/*
@@ -243,9 +282,12 @@  discard block
 block discarded – undo
243 282
 			}
244 283
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
245 284
 			$sth->closeCursor();
246
-			if ($result['nb'] > 0) return true;
247
-			else return false;
248
-/*		} else {
285
+			if ($result['nb'] > 0) {
286
+				return true;
287
+			} else {
288
+				return false;
289
+			}
290
+			/*		} else {
249 291
 			$query = "SELECT * FROM ".$table." LIMIT 0";
250 292
 			try {
251 293
 				$results = $this->db->query($query);
@@ -284,7 +326,9 @@  discard block
 block discarded – undo
284 326
 				$sth->closeCursor();
285 327
 				return $result['value'];
286 328
 			}
287
-		} else return $version;
329
+		} else {
330
+			return $version;
331
+		}
288 332
 	}
289 333
 	
290 334
 	/*
@@ -292,8 +336,11 @@  discard block
 block discarded – undo
292 336
 	* @return Boolean if latest version or not
293 337
 	*/
294 338
 	public function latest() {
295
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
296
-	    else return false;
339
+	    if ($this->check_schema_version() == $this->latest_schema) {
340
+	    	return true;
341
+	    } else {
342
+	    	return false;
343
+	    }
297 344
 	}
298 345
 
299 346
 }
Please login to merge, or discard this patch.