Completed
Push — master ( 76be65...99c8e1 )
by Yannick
42:08 queued 16:49
created
require/class.Connection.php 1 patch
Braces   +83 added lines, -32 removed lines patch added patch discarded remove patch
@@ -73,8 +73,11 @@  discard block
 block discarded – undo
73 73
 				$globalDBSname = $globalDBname;
74 74
 				$globalDBSuser = $globalDBuser;
75 75
 				$globalDBSpass = $globalDBpass;
76
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
77
-				else $globalDBSport = $globalDBport;
76
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
77
+					$globalDBSport = 3306;
78
+				} else {
79
+					$globalDBSport = $globalDBport;
80
+				}
78 81
 			} else {
79 82
 				$DBname = 'default';
80 83
 				$globalDBSdriver = $globalDBdriver;
@@ -82,8 +85,11 @@  discard block
 block discarded – undo
82 85
 				$globalDBSname = $globalDBname;
83 86
 				$globalDBSuser = $user;
84 87
 				$globalDBSpass = $pass;
85
-				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') $globalDBSport = 3306;
86
-				else $globalDBSport = $globalDBport;
88
+				if (!isset($globalDBport) || $globalDBport === NULL || $globalDBport == '') {
89
+					$globalDBSport = 3306;
90
+				} else {
91
+					$globalDBSport = $globalDBport;
92
+				}
87 93
 			}
88 94
 		} else {
89 95
 			$globalDBSdriver = $globalDB[$DBname]['driver'];
@@ -91,11 +97,16 @@  discard block
 block discarded – undo
91 97
 			$globalDBSname = $globalDB[$DBname]['name'];
92 98
 			$globalDBSuser = $globalDB[$DBname]['user'];
93 99
 			$globalDBSpass = $globalDB[$DBname]['pass'];
94
-			if (isset($globalDB[$DBname]['port'])) $globalDBSport = $globalDB[$DBname]['port'];
95
-			else $globalDBSport = 3306;
100
+			if (isset($globalDB[$DBname]['port'])) {
101
+				$globalDBSport = $globalDB[$DBname]['port'];
102
+			} else {
103
+				$globalDBSport = 3306;
104
+			}
96 105
 		}
97 106
 		// Set number of try to connect to DB
98
-		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) $globalDBretry = 5;
107
+		if (!isset($globalDBretry) || $globalDBretry == '' || $globalDBretry === NULL) {
108
+			$globalDBretry = 5;
109
+		}
99 110
 		$i = 0;
100 111
 		while (true) {
101 112
 			try {
@@ -104,10 +115,16 @@  discard block
 block discarded – undo
104 115
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
105 116
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
106 117
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
107
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
108
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
109
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
110
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
118
+					if (!isset($globalDBTimeOut)) {
119
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500);
120
+					} else {
121
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
122
+					}
123
+					if (!isset($globalDBPersistent)) {
124
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
125
+					} else {
126
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
127
+					}
111 128
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
112 129
 					$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
113 130
 					// Workaround against "ONLY_FULL_GROUP_BY" mode
@@ -121,24 +138,36 @@  discard block
 block discarded – undo
121 138
 					//$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'");
122 139
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
123 140
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER);
124
-					if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
125
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
126
-					if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
127
-					else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
141
+					if (!isset($globalDBTimeOut)) {
142
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200);
143
+					} else {
144
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut);
145
+					}
146
+					if (!isset($globalDBPersistent)) {
147
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true);
148
+					} else {
149
+						$this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent);
150
+					}
128 151
 					$this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
129 152
 					$this->dbs[$DBname]->exec('SET timezone="UTC"');
130 153
 				}
131 154
 				break;
132 155
 			} catch(PDOException $e) {
133 156
 				$i++;
134
-				if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
157
+				if (isset($globalDebug) && $globalDebug) {
158
+					echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n";
159
+				}
135 160
 				//exit;
136
-				if ($i > $globalDBretry) return false;
161
+				if ($i > $globalDBretry) {
162
+					return false;
163
+				}
137 164
 				//return false;
138 165
 			}
139 166
 			sleep(2);
140 167
 		}
141
-		if ($DBname === 'default') $this->db = $this->dbs['default'];
168
+		if ($DBname === 'default') {
169
+			$this->db = $this->dbs['default'];
170
+		}
142 171
 		return true;
143 172
 	}
144 173
 
@@ -150,7 +179,9 @@  discard block
 block discarded – undo
150 179
 		} else {
151 180
 			$query = "SELECT * FROM pg_catalog.pg_tables WHERE tablename = '".$table."'";
152 181
 		}
153
-		if ($this->db == NULL) return false;
182
+		if ($this->db == NULL) {
183
+			return false;
184
+		}
154 185
 		try {
155 186
 			//$Connection = new Connection();
156 187
 			$results = $this->db->query($query);
@@ -159,22 +190,31 @@  discard block
 block discarded – undo
159 190
 		}
160 191
 		if($results->rowCount()>0) {
161 192
 		    return true; 
193
+		} else {
194
+			return false;
162 195
 		}
163
-		else return false;
164 196
 	}
165 197
 
166 198
 	public function connectionExists()
167 199
 	{
168 200
 		global $globalDBdriver, $globalDBCheckConnection, $globalNoDB;
169
-		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) return true;
170
-		if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
201
+		if (isset($globalDBCheckConnection) && $globalDBCheckConnection === FALSE) {
202
+			return true;
203
+		}
204
+		if (isset($globalNoDB) && $globalNoDB === TRUE) {
205
+			return true;
206
+		}
171 207
 		$query = "SELECT 1 + 1";
172
-		if ($this->db === null) return false;
208
+		if ($this->db === null) {
209
+			return false;
210
+		}
173 211
 		try {
174 212
 			$sum = @$this->db->query($query);
175 213
 			if ($sum instanceof \PDOStatement) {
176 214
 				$sum = $sum->fetchColumn(0);
177
-			} else $sum = 0;
215
+			} else {
216
+				$sum = 0;
217
+			}
178 218
 			if (intval($sum) !== 2) {
179 219
 			     return false;
180 220
 			}
@@ -209,8 +249,9 @@  discard block
 block discarded – undo
209 249
 		$nb = $results->fetchAll(PDO::FETCH_ASSOC);
210 250
 		if($nb[0]['nb'] > 0) {
211 251
 			return true; 
252
+		} else {
253
+			return false;
212 254
 		}
213
-		else return false;
214 255
 	}
215 256
 
216 257
 	/*
@@ -260,9 +301,12 @@  discard block
 block discarded – undo
260 301
 			}
261 302
 			$result = $sth->fetch(PDO::FETCH_ASSOC);
262 303
 			$sth->closeCursor();
263
-			if ($result['nb'] > 0) return true;
264
-			else return false;
265
-/*		} else {
304
+			if ($result['nb'] > 0) {
305
+				return true;
306
+			} else {
307
+				return false;
308
+			}
309
+			/*		} else {
266 310
 			$query = "SELECT * FROM ".$table." LIMIT 0";
267 311
 			try {
268 312
 				$results = $this->db->query($query);
@@ -301,7 +345,9 @@  discard block
 block discarded – undo
301 345
 				$sth->closeCursor();
302 346
 				return $result['value'];
303 347
 			}
304
-		} else return $version;
348
+		} else {
349
+			return $version;
350
+		}
305 351
 	}
306 352
 	
307 353
 	/*
@@ -310,9 +356,14 @@  discard block
 block discarded – undo
310 356
 	*/
311 357
 	public function latest() {
312 358
 	    global $globalNoDB;
313
-	    if (isset($globalNoDB) && $globalNoDB === TRUE) return true;
314
-	    if ($this->check_schema_version() == $this->latest_schema) return true;
315
-	    else return false;
359
+	    if (isset($globalNoDB) && $globalNoDB === TRUE) {
360
+	    	return true;
361
+	    }
362
+	    if ($this->check_schema_version() == $this->latest_schema) {
363
+	    	return true;
364
+	    } else {
365
+	    	return false;
366
+	    }
316 367
 	}
317 368
 
318 369
 }
Please login to merge, or discard this patch.
install/index.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 				</tr>
323 323
 				<!--
324 324
 		<?php
325
-		    if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
326
-			    require_once(dirname(__FILE__).'/../require/class.Connection.php');
327
-			    $Connection = new Connection();
325
+			if (isset($globalDBuser) && isset($globalDBpass) && $globalDBuser != '' && $globalDBpass != '') {
326
+				require_once(dirname(__FILE__).'/../require/class.Connection.php');
327
+				$Connection = new Connection();
328 328
 		?>
329 329
 			-->
330 330
 		<?php
331 331
 			if ($Connection->db != NULL) {
332
-			    if ($Connection->tableExists('source_location')) {
332
+				if ($Connection->tableExists('source_location')) {
333 333
 				require_once(dirname(__FILE__).'/../require/class.Source.php');
334 334
 				$Source = new Source();
335 335
 				//$alllocations = $Source->getAllLocationInfo();
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 		
350 350
 		<?php
351 351
 				}
352
-			    }
352
+				}
353
+			}
353 354
 			}
354
-		    }
355 355
 		?>
356 356
 
357 357
 				<tr>
@@ -461,12 +461,12 @@  discard block
 block discarded – undo
461 461
 ?>
462 462
 							<tr>
463 463
 								<?php
464
-								    if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
464
+									if (filter_var($source['host'],FILTER_VALIDATE_URL)) {
465 465
 								?>
466 466
 								<td><input type="text" name="host[]" id="host" value="<?php print $source['host']; ?>" /></td>
467 467
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php if (isset($source['port'])) print $source['port']; ?>" /></td>
468 468
 								<?php
469
-								    } else {
469
+									} else {
470 470
 									$hostport = explode(':',$source['host']);
471 471
 									if (isset($hostport[1])) {
472 472
 										$host = $hostport[0];
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
 								<td><input type="text" name="host[]" id="host" value="<?php print $host; ?>" /></td>
480 480
 								<td><input type="text" name="port[]" class="col-xs-2" id="port" value="<?php print $port; ?>" /></td>
481 481
 								<?php
482
-								    }
482
+									}
483 483
 								?>
484 484
 								<td>
485 485
 									<select name="format[]" id="format">
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 			<br />
894 894
 			<p>
895 895
 			<?php 
896
-			    if (extension_loaded('gd') && function_exists('gd_info')) {
896
+				if (extension_loaded('gd') && function_exists('gd_info')) {
897 897
 			?>
898 898
 				<label for="aircrafticoncolor">Color of aircraft icon on map</label>
899 899
 				<input type="color" name="aircrafticoncolor" id="aircrafticoncolor" value="#<?php if (isset($globalAircraftIconColor)) echo $globalAircraftIconColor; else echo '1a3151'; ?>" />
@@ -903,11 +903,11 @@  discard block
 block discarded – undo
903 903
 				<b>The directory cache is not writable, aircraft icon will not be cached</b>
904 904
 			<?php
905 905
 				}
906
-			    } else {
906
+				} else {
907 907
 			?>
908 908
 				<b>PHP GD is not installed, you can't change color of aircraft icon on map</b>
909 909
 			<?php
910
-			    }
910
+				}
911 911
 			?>
912 912
 			</p>
913 913
 			<br />
@@ -931,7 +931,7 @@  discard block
 block discarded – undo
931 931
 	</p>
932 932
 <?php
933 933
 	require('../footer.php');
934
-        exit;
934
+		exit;
935 935
 }
936 936
 // '	
937 937
 $settings = array();
@@ -1022,8 +1022,8 @@  discard block
 block discarded – undo
1022 1022
 	
1023 1023
 	$sources = array();
1024 1024
 	foreach ($source_name as $keys => $name) {
1025
-	    if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1026
-	    else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1025
+		if (isset($source_id[$keys])) $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'id' => $source_id[$keys],'source' => $source_ref[$keys]);
1026
+		else $sources[] = array('name' => $name,'latitude' => $source_latitude[$keys],'longitude' => $source_longitude[$keys],'altitude' => $source_altitude[$keys],'city' => $source_city[$keys],'country' => $source_country[$keys],'source' => $source_ref[$keys]);
1027 1027
 	}
1028 1028
 	if (count($sources) > 0) $_SESSION['sources'] = $sources;
1029 1029
 
@@ -1408,14 +1408,14 @@  discard block
 block discarded – undo
1408 1408
 
1409 1409
 	// Set some defaults values...
1410 1410
 	if (!isset($globalAircraftImageSources)) {
1411
-	    $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1412
-	    $settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1411
+		$globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters');
1412
+		$settings = array_merge($settings,array('globalAircraftImageSources' => $globalAircraftImageSources));
1413 1413
 	}
1414 1414
 
1415 1415
 	if (!isset($globalSchedulesSources)) {
1416
-	    $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1417
-    	    $settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1418
-    	}
1416
+		$globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware');
1417
+			$settings = array_merge($settings,array('globalSchedulesSources' => $globalSchedulesSources));
1418
+		}
1419 1419
 
1420 1420
 	$settings = array_merge($settings,array('globalInstalled' => 'TRUE'));
1421 1421
 
@@ -1462,21 +1462,21 @@  discard block
 block discarded – undo
1462 1462
 	$popi = false;
1463 1463
 	$popw = false;
1464 1464
 	foreach ($_SESSION['done'] as $done) {
1465
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1466
-	    if ($done == 'Create database') $pop = true;
1467
-	    if ($_SESSION['install'] == 'database_create') $pop = true;
1468
-	    if ($_SESSION['install'] == 'database_import') $popi = true;
1469
-	    if ($_SESSION['install'] == 'waypoints') $popw = true;
1465
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1466
+		if ($done == 'Create database') $pop = true;
1467
+		if ($_SESSION['install'] == 'database_create') $pop = true;
1468
+		if ($_SESSION['install'] == 'database_import') $popi = true;
1469
+		if ($_SESSION['install'] == 'waypoints') $popw = true;
1470 1470
 	}
1471 1471
 	if ($pop) {
1472
-	    sleep(5);
1473
-	    print '<li>Create database....<img src="../images/loading.gif" /></li>';
1472
+		sleep(5);
1473
+		print '<li>Create database....<img src="../images/loading.gif" /></li>';
1474 1474
 	} else if ($popi) {
1475
-	    sleep(5);
1476
-	    print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1475
+		sleep(5);
1476
+		print '<li>Create and import tables....<img src="../images/loading.gif" /></li>';
1477 1477
 	} else if ($popw) {
1478
-	    sleep(5);
1479
-	    print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1478
+		sleep(5);
1479
+		print '<li>Populate waypoints database....<img src="../images/loading.gif" /></li>';
1480 1480
 	} else print '<li>Update schema if needed....<img src="../images/loading.gif" /></li>';
1481 1481
 	print '</div></ul>';
1482 1482
 	print '<div id="error"></div>';
@@ -1539,7 +1539,7 @@  discard block
 block discarded – undo
1539 1539
 	unset($_COOKIE['install']);
1540 1540
 	print '<div class="info column"><ul>';
1541 1541
 	foreach ($_SESSION['done'] as $done) {
1542
-	    print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1542
+		print '<li>'.$done.'....<strong>SUCCESS</strong></li>';
1543 1543
 	}
1544 1544
 	print '<li>Reloading page to check all is now ok....<strong>SUCCESS</strong></li>';
1545 1545
 	print '</ul></div>';
Please login to merge, or discard this patch.