Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Failed Conditions
Pull Request — master (#812)
by Dan
04:25
created
lib/Default/AbstractSmrLocation.class.php 1 patch
Braces   +10 added lines, -16 removed lines patch added patch discarded remove patch
@@ -98,8 +98,7 @@  discard block
 block discarded – undo
98 98
 			$this->name = $db->getField('location_name');
99 99
 			$this->processor = $db->getField('location_processor');
100 100
 			$this->image = $db->getField('location_image');
101
-		}
102
-		else {
101
+		} else {
103 102
 			throw new Exception('Cannot find location: ' . $locationTypeID);
104 103
 		}
105 104
 	}
@@ -158,8 +157,7 @@  discard block
 block discarded – undo
158 157
 		if ($bool === true) {
159 158
 			$this->db->query('INSERT IGNORE INTO location_is_fed (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
160 159
 			$this->fed = true;
161
-		}
162
-		else if ($bool === false) {
160
+		} else if ($bool === false) {
163 161
 			$this->db->query('DELETE FROM location_is_fed WHERE ' . $this->SQL . ' LIMIT 1');
164 162
 			$this->fed = false;
165 163
 		}
@@ -180,8 +178,7 @@  discard block
 block discarded – undo
180 178
 		if ($bool === true) {
181 179
 			$this->db->query('INSERT INTO location_is_bank (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
182 180
 			$this->bank = true;
183
-		}
184
-		else if ($bool === false) {
181
+		} else if ($bool === false) {
185 182
 			$this->db->query('DELETE FROM location_is_bank WHERE ' . $this->SQL . ' LIMIT 1');
186 183
 			$this->bank = false;
187 184
 		}
@@ -202,8 +199,7 @@  discard block
 block discarded – undo
202 199
 		if ($bool === true) {
203 200
 			$this->db->query('INSERT IGNORE INTO location_is_bar (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
204 201
 			$this->bar = true;
205
-		}
206
-		else if ($bool === false) {
202
+		} else if ($bool === false) {
207 203
 			$this->db->query('DELETE FROM location_is_bar WHERE ' . $this->SQL . ' LIMIT 1');
208 204
 			$this->bar = false;
209 205
 		}
@@ -224,8 +220,7 @@  discard block
 block discarded – undo
224 220
 		if ($bool === true) {
225 221
 			$this->db->query('INSERT IGNORE INTO location_is_hq (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
226 222
 			$this->HQ = true;
227
-		}
228
-		else if ($bool === false) {
223
+		} else if ($bool === false) {
229 224
 			$this->db->query('DELETE FROM location_is_hq WHERE ' . $this->SQL . ' LIMIT 1');
230 225
 			$this->HQ = false;
231 226
 		}
@@ -246,8 +241,7 @@  discard block
 block discarded – undo
246 241
 		if ($bool === true) {
247 242
 			$this->db->query('INSERT INTO location_is_ug (location_type_id) values (' . $this->db->escapeNumber($this->getTypeID()) . ')');
248 243
 			$this->UG = true;
249
-		}
250
-		else if ($bool === false) {
244
+		} else if ($bool === false) {
251 245
 			$this->db->query('DELETE FROM location_is_ug WHERE ' . $this->SQL . ' LIMIT 1');
252 246
 			$this->UG = false;
253 247
 		}
@@ -335,8 +329,9 @@  discard block
 block discarded – undo
335 329
 		if (!isset($this->weaponsSold)) {
336 330
 			$this->weaponsSold = array();
337 331
 			$this->db->query('SELECT * FROM location_sells_weapons JOIN weapon_type USING (weapon_type_id) WHERE ' . $this->SQL);
338
-			while ($this->db->nextRecord())
339
-				$this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db);
332
+			while ($this->db->nextRecord()) {
333
+							$this->weaponsSold[$this->db->getInt('weapon_type_id')] = SmrWeapon::getWeapon($this->db->getInt('weapon_type_id'), false, $this->db);
334
+			}
340 335
 		}
341 336
 		return $this->weaponsSold;
342 337
 	}
@@ -375,8 +370,7 @@  discard block
 block discarded – undo
375 370
 			if ($this->getTypeID() == LOCATION_TYPE_FEDERAL_HQ) {
376 371
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_BEACON);
377 372
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_TYPE_FEDERAL_MINT);
378
-			}
379
-			else {
373
+			} else {
380 374
 				$raceID = $this->getRaceID();
381 375
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_BEACONS + $raceID);
382 376
 				$linkedLocations[] = SmrLocation::getLocation(LOCATION_GROUP_RACIAL_SHIPS + $raceID);
Please login to merge, or discard this patch.
lib/Default/MySqlDatabase.class.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -227,8 +227,7 @@
 block discarded – undo
227 227
 				}
228 228
 			}
229 229
 			$string = substr($string, 0, -1);
230
-		}
231
-		else {
230
+		} else {
232 231
 			$string = $this->escape(implode($implodeString, $array), $autoQuotes, $quotes);
233 232
 		}
234 233
 		return $string;
Please login to merge, or discard this patch.
lib/Default/AbstractSmrShip.class.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	public function setWeaponLocations(array $orderArray) {
302 302
 		$weapons = $this->weapons;
303 303
 		foreach ($orderArray as $newOrder => $oldOrder) {
304
-			$this->weapons[$newOrder] =& $weapons[$oldOrder];
304
+			$this->weapons[$newOrder] = & $weapons[$oldOrder];
305 305
 		}
306 306
 		$this->hasChangedWeapons = true;
307 307
 	}
@@ -901,14 +901,14 @@  discard block
 block discarded – undo
901 901
 		}
902 902
 		$results['DeadBeforeShot'] = false;
903 903
 		foreach ($this->weapons as $orderID => $weapon) {
904
-			$results['Weapons'][$orderID] =& $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
904
+			$results['Weapons'][$orderID] = & $weapon->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
905 905
 			if ($results['Weapons'][$orderID]['Hit']) {
906 906
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
907 907
 			}
908 908
 		}
909 909
 		if ($this->hasCDs()) {
910 910
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
911
-			$results['Drones'] =& $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
911
+			$results['Drones'] = & $thisCDs->shootPlayer($thisPlayer, $targetPlayers[array_rand($targetPlayers)]);
912 912
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
913 913
 		}
914 914
 		$thisPlayer->increaseExperience(IRound($results['TotalDamage'] * self::EXP_PER_DAMAGE_PLAYER));
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
 		}
927 927
 		$results['DeadBeforeShot'] = false;
928 928
 		foreach ($this->weapons as $orderID => $weapon) {
929
-			$results['Weapons'][$orderID] =& $weapon->shootForces($thisPlayer, $forces);
929
+			$results['Weapons'][$orderID] = & $weapon->shootForces($thisPlayer, $forces);
930 930
 			if ($results['Weapons'][$orderID]['Hit']) {
931 931
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
932 932
 				$thisPlayer->increaseHOF($results['Weapons'][$orderID]['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC);
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 		}
941 941
 		if ($this->hasCDs()) {
942 942
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
943
-			$results['Drones'] =& $thisCDs->shootForces($thisPlayer, $forces);
943
+			$results['Drones'] = & $thisCDs->shootForces($thisPlayer, $forces);
944 944
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
945 945
 			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['NumMines'], array('Combat', 'Forces', 'Mines', 'Killed'), HOF_PUBLIC);
946 946
 			$thisPlayer->increaseHOF($results['Drones']['ActualDamage']['Mines'], array('Combat', 'Forces', 'Mines', 'Damage Done'), HOF_PUBLIC);
@@ -965,14 +965,14 @@  discard block
 block discarded – undo
965 965
 		}
966 966
 		$results['DeadBeforeShot'] = false;
967 967
 		foreach ($this->weapons as $orderID => $weapon) {
968
-			$results['Weapons'][$orderID] =& $weapon->shootPort($thisPlayer, $port);
968
+			$results['Weapons'][$orderID] = & $weapon->shootPort($thisPlayer, $port);
969 969
 			if ($results['Weapons'][$orderID]['Hit']) {
970 970
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
971 971
 			}
972 972
 		}
973 973
 		if ($this->hasCDs()) {
974 974
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
975
-			$results['Drones'] =& $thisCDs->shootPort($thisPlayer, $port);
975
+			$results['Drones'] = & $thisCDs->shootPort($thisPlayer, $port);
976 976
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
977 977
 		}
978 978
 		$thisPlayer->increaseExperience(IRound($results['TotalDamage'] * self::EXP_PER_DAMAGE_PORT));
@@ -1003,14 +1003,14 @@  discard block
 block discarded – undo
1003 1003
 		}
1004 1004
 		$results['DeadBeforeShot'] = false;
1005 1005
 		foreach ($this->weapons as $orderID => $weapon) {
1006
-			$results['Weapons'][$orderID] =& $weapon->shootPlanet($thisPlayer, $planet, $delayed);
1006
+			$results['Weapons'][$orderID] = & $weapon->shootPlanet($thisPlayer, $planet, $delayed);
1007 1007
 			if ($results['Weapons'][$orderID]['Hit']) {
1008 1008
 				$results['TotalDamage'] += $results['Weapons'][$orderID]['ActualDamage']['TotalDamage'];
1009 1009
 			}
1010 1010
 		}
1011 1011
 		if ($this->hasCDs()) {
1012 1012
 			$thisCDs = new SmrCombatDrones($this->getGameID(), $this->getCDs());
1013
-			$results['Drones'] =& $thisCDs->shootPlanet($thisPlayer, $planet, $delayed);
1013
+			$results['Drones'] = & $thisCDs->shootPlanet($thisPlayer, $planet, $delayed);
1014 1014
 			$results['TotalDamage'] += $results['Drones']['ActualDamage']['TotalDamage'];
1015 1015
 		}
1016 1016
 		$thisPlayer->increaseExperience(IRound($results['TotalDamage'] * self::EXP_PER_DAMAGE_PLANET));
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -273,8 +273,7 @@  discard block
 block discarded – undo
273 273
 		if ($replacement < 0) {
274 274
 			// Shift everything up by one and put the selected weapon at the bottom
275 275
 			array_push($this->weapons, array_shift($this->weapons));
276
-		}
277
-		else {
276
+		} else {
278 277
 			// Swap the selected weapon with the one above it
279 278
 			$temp = $this->weapons[$replacement];
280 279
 			$this->weapons[$replacement] = $this->weapons[$orderID];
@@ -288,8 +287,7 @@  discard block
 block discarded – undo
288 287
 		if ($replacement >= count($this->weapons)) {
289 288
 			// Shift everything down by one and put the selected weapon at the top
290 289
 			array_unshift($this->weapons, array_pop($this->weapons));
291
-		}
292
-		else {
290
+		} else {
293 291
 			// Swap the selected weapon with the one below it
294 292
 			$temp = $this->weapons[$replacement];
295 293
 			$this->weapons[$replacement] = $this->weapons[$orderID];
@@ -348,8 +346,7 @@  discard block
 block discarded – undo
348 346
 			$this->setArmour(150, true);
349 347
 			$this->setCargoHolds(40);
350 348
 			$this->setShipTypeID(SHIP_TYPE_NEWBIE_MERCHANT_VESSEL);
351
-		}
352
-		else {
349
+		} else {
353 350
 			$this->setShields(50, true);
354 351
 			$this->setArmour(50, true);
355 352
 			$this->setCargoHolds(5);
Please login to merge, or discard this patch.
lib/Default/SmrWeapon.class.php 1 patch
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -193,22 +193,28 @@
 block discarded – undo
193 193
 	}
194 194
 	
195 195
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
196
-		if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
196
+		if (!$this->canShootForces()) {
197
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
197 198
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
199
+		}
198 200
 		$damage =& $this->getModifiedDamage();
199 201
 		return $damage;
200 202
 	}
201 203
 	
202 204
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
203
-		if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
205
+		if (!$this->canShootPorts()) {
206
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
204 207
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
208
+		}
205 209
 		$damage =& $this->getModifiedDamage();
206 210
 		return $damage;
207 211
 	}
208 212
 	
209 213
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
210
-		if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
214
+		if (!$this->canShootPlanets()) {
215
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
211 216
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
217
+		}
212 218
 		$damage =& $this->getModifiedDamage();
213 219
 		
214 220
 		$planetMod = self::PLANET_DAMAGE_MOD;
Please login to merge, or discard this patch.
lib/Default/SmrForce.class.php 1 patch
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -279,8 +279,7 @@  discard block
 block discarded – undo
279 279
 		// Changed (26/10/05) - scout drones count * 2
280 280
 		if ($this->getCDs() == 0 && $this->getMines() == 0 && $this->getSDs() > 0) {
281 281
 			$time = self::TIME_PER_SCOUT_ONLY * $this->getSDs();
282
-		}
283
-		else {
282
+		} else {
284 283
 			$time = ($this->getCDs() * self::TIME_PERCENT_PER_COMBAT + $this->getSDs() * self::TIME_PERCENT_PER_SCOUT + $this->getMines() * self::TIME_PERCENT_PER_MINE) * $this->getMaxGalaxyExpireTime();
285 284
 		}
286 285
 		$this->setExpire(TIME + $time);
@@ -307,11 +306,9 @@  discard block
 block discarded – undo
307 306
 		}
308 307
 		if ($mines < 10) {
309 308
 			$turns = 1;
310
-		}
311
-		else if ($mines < 25) {
309
+		} else if ($mines < 25) {
312 310
 			$turns = 2;
313
-		}
314
-		else {
311
+		} else {
315 312
 			$turns = 3;
316 313
 		}
317 314
 		if ($ship->isFederal() || $ship->hasDCS()) {
@@ -366,12 +363,10 @@  discard block
 block discarded – undo
366 363
 			if (!$this->exists()) {
367 364
 				$this->db->query('DELETE FROM sector_has_forces WHERE ' . $this->SQL);
368 365
 				$this->isNew = true;
369
-			}
370
-			else if ($this->hasChanged) {
366
+			} else if ($this->hasChanged) {
371 367
 				$this->db->query('UPDATE sector_has_forces SET combat_drones = ' . $this->db->escapeNumber($this->combatDrones) . ', scout_drones = ' . $this->db->escapeNumber($this->scoutDrones) . ', mines = ' . $this->db->escapeNumber($this->mines) . ', expire_time = ' . $this->db->escapeNumber($this->expire) . ' WHERE ' . $this->SQL);
372 368
 			}
373
-		}
374
-		else if ($this->exists()) {
369
+		} else if ($this->exists()) {
375 370
 			$this->db->query('INSERT INTO sector_has_forces (game_id, sector_id, owner_id, combat_drones, scout_drones, mines, expire_time)
376 371
 								VALUES('.$this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($this->ownerID) . ', ' . $this->db->escapeNumber($this->combatDrones) . ', ' . $this->db->escapeNumber($this->scoutDrones) . ', ' . $this->db->escapeNumber($this->mines) . ', ' . $this->db->escapeNumber($this->expire) . ')');
377 372
 			$this->isNew = false;
Please login to merge, or discard this patch.
lib/Default/AbstractSmrCombatWeapon.class.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 	protected $maxDamage;
13 13
 	protected $shieldDamage;
14 14
 	protected $armourDamage;
15
-	protected $empDamage=0;
15
+	protected $empDamage = 0;
16 16
 	protected $accuracy;
17 17
 	protected $damageRollover;
18 18
 	protected $raidWeapon;
@@ -85,68 +85,68 @@  discard block
 block discarded – undo
85 85
 	abstract public function &getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer);
86 86
 	
87 87
 	protected function &doPlayerDamageToForce(array &$return, AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
88
-		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstForces($weaponPlayer,$forces);
89
-		$return['ActualDamage'] =& $forces->doWeaponDamage($return['WeaponDamage']);
90
-		if($return['ActualDamage']['KillingShot']) {
91
-			$return['KillResults'] =& $forces->killForcesByPlayer($weaponPlayer);
88
+		$return['WeaponDamage'] = & $this->getModifiedDamageAgainstForces($weaponPlayer, $forces);
89
+		$return['ActualDamage'] = & $forces->doWeaponDamage($return['WeaponDamage']);
90
+		if ($return['ActualDamage']['KillingShot']) {
91
+			$return['KillResults'] = & $forces->killForcesByPlayer($weaponPlayer);
92 92
 		}
93 93
 		return $return;
94 94
 	}
95 95
 	
96 96
 	protected function &doPlayerDamageToPlayer(array &$return, AbstractSmrPlayer $weaponPlayer, AbstractSmrPlayer $targetPlayer) {
97
-		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlayer($weaponPlayer,$targetPlayer);
98
-		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
97
+		$return['WeaponDamage'] = & $this->getModifiedDamageAgainstPlayer($weaponPlayer, $targetPlayer);
98
+		$return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
99 99
 
100
-		if($return['ActualDamage']['KillingShot']) {
101
-			$return['KillResults'] =& $targetPlayer->killPlayerByPlayer($weaponPlayer);
100
+		if ($return['ActualDamage']['KillingShot']) {
101
+			$return['KillResults'] = & $targetPlayer->killPlayerByPlayer($weaponPlayer);
102 102
 		}
103 103
 		return $return;
104 104
 	}
105 105
 	
106 106
 	protected function &doPlayerDamageToPort(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
107
-		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPort($weaponPlayer,$port);
108
-		$return['ActualDamage'] =& $port->doWeaponDamage($return['WeaponDamage']);
109
-		if($return['ActualDamage']['KillingShot']) {
110
-			$return['KillResults'] =& $port->killPortByPlayer($weaponPlayer);
107
+		$return['WeaponDamage'] = & $this->getModifiedDamageAgainstPort($weaponPlayer, $port);
108
+		$return['ActualDamage'] = & $port->doWeaponDamage($return['WeaponDamage']);
109
+		if ($return['ActualDamage']['KillingShot']) {
110
+			$return['KillResults'] = & $port->killPortByPlayer($weaponPlayer);
111 111
 		}
112 112
 		return $return;
113 113
 	}
114 114
 	
115 115
 	protected function &doPlayerDamageToPlanet(array &$return, AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet, $delayed) {
116
-		$return['WeaponDamage'] =& $this->getModifiedDamageAgainstPlanet($weaponPlayer,$planet);
117
-		$return['ActualDamage'] =& $planet->doWeaponDamage($return['WeaponDamage'],$delayed);
118
-		if($return['ActualDamage']['KillingShot']) {
119
-			$return['KillResults'] =& $planet->killPlanetByPlayer($weaponPlayer);
116
+		$return['WeaponDamage'] = & $this->getModifiedDamageAgainstPlanet($weaponPlayer, $planet);
117
+		$return['ActualDamage'] = & $planet->doWeaponDamage($return['WeaponDamage'], $delayed);
118
+		if ($return['ActualDamage']['KillingShot']) {
119
+			$return['KillResults'] = & $planet->killPlanetByPlayer($weaponPlayer);
120 120
 		}
121 121
 		return $return;
122 122
 	}
123 123
 	
124 124
 	protected function &doPortDamageToPlayer(array &$return, SmrPort $port, AbstractSmrPlayer $targetPlayer) {
125
-		$return['WeaponDamage'] =& $this->getModifiedPortDamageAgainstPlayer($port,$targetPlayer);
126
-		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
125
+		$return['WeaponDamage'] = & $this->getModifiedPortDamageAgainstPlayer($port, $targetPlayer);
126
+		$return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
127 127
 
128
-		if($return['ActualDamage']['KillingShot']) {
129
-			$return['KillResults'] =& $targetPlayer->killPlayerByPort($port);
128
+		if ($return['ActualDamage']['KillingShot']) {
129
+			$return['KillResults'] = & $targetPlayer->killPlayerByPort($port);
130 130
 		}
131 131
 		return $return;
132 132
 	}
133 133
 	
134 134
 	protected function &doPlanetDamageToPlayer(array &$return, SmrPlanet $planet, AbstractSmrPlayer $targetPlayer) {
135
-		$return['WeaponDamage'] =& $this->getModifiedPlanetDamageAgainstPlayer($planet,$targetPlayer);
136
-		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
135
+		$return['WeaponDamage'] = & $this->getModifiedPlanetDamageAgainstPlayer($planet, $targetPlayer);
136
+		$return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
137 137
 
138
-		if($return['ActualDamage']['KillingShot']) {
139
-			$return['KillResults'] =& $targetPlayer->killPlayerByPlanet($planet);
138
+		if ($return['ActualDamage']['KillingShot']) {
139
+			$return['KillResults'] = & $targetPlayer->killPlayerByPlanet($planet);
140 140
 		}
141 141
 		return $return;
142 142
 	}
143 143
 	
144 144
 	protected function &doForceDamageToPlayer(array &$return, SmrForce $forces, AbstractSmrPlayer $targetPlayer) {
145
-		$return['WeaponDamage'] =& $this->getModifiedForceDamageAgainstPlayer($forces,$targetPlayer);
146
-		$return['ActualDamage'] =& $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
145
+		$return['WeaponDamage'] = & $this->getModifiedForceDamageAgainstPlayer($forces, $targetPlayer);
146
+		$return['ActualDamage'] = & $targetPlayer->getShip()->doWeaponDamage($return['WeaponDamage']);
147 147
 
148
-		if($return['ActualDamage']['KillingShot']) {
149
-			$return['KillResults'] =& $targetPlayer->killPlayerByForces($forces);
148
+		if ($return['ActualDamage']['KillingShot']) {
149
+			$return['KillResults'] = & $targetPlayer->killPlayerByForces($forces);
150 150
 		}
151 151
 		return $return;
152 152
 	}
Please login to merge, or discard this patch.
lib/Default/SmrPlanet.class.php 1 patch
Braces   +20 added lines, -36 removed lines patch added patch discarded remove patch
@@ -151,26 +151,19 @@  discard block
 block discarded – undo
151 151
 		$level = $this->getLevel();
152 152
 		if ($level < 9) {
153 153
 			return .0404;
154
-		}
155
-		elseif ($level < 19) {
154
+		} elseif ($level < 19) {
156 155
 			return .0609;
157
-		}
158
-		elseif ($level < 29) {
156
+		} elseif ($level < 29) {
159 157
 			return .1236;
160
-		}
161
-		elseif ($level < 39) {
158
+		} elseif ($level < 39) {
162 159
 			return .050625;
163
-		}
164
-		elseif ($level < 49) {
160
+		} elseif ($level < 49) {
165 161
 			return .0404;
166
-		}
167
-		elseif ($level < 59) {
162
+		} elseif ($level < 59) {
168 163
 			return .030225;
169
-		}
170
-		elseif ($level < 69) {
164
+		} elseif ($level < 69) {
171 165
 			return .0201;
172
-		}
173
-		else {
166
+		} else {
174 167
 			return .018081;
175 168
 		}
176 169
 	}
@@ -383,8 +376,7 @@  discard block
 block discarded – undo
383 376
 		}
384 377
 		if ($delayed === false) {
385 378
 			$this->setShields($this->getShields() - $number);
386
-		}
387
-		else {
379
+		} else {
388 380
 			$this->delayedShieldsDelta -= $number;
389 381
 		}
390 382
 	}
@@ -395,8 +387,7 @@  discard block
 block discarded – undo
395 387
 		}
396 388
 		if ($delayed === false) {
397 389
 			$this->setShields($this->getShields() + $number);
398
-		}
399
-		else {
390
+		} else {
400 391
 			$this->delayedShieldsDelta += $number;
401 392
 		}
402 393
 	}
@@ -428,8 +419,7 @@  discard block
 block discarded – undo
428 419
 		}
429 420
 		if ($delayed === false) {
430 421
 			$this->setArmour($this->getArmour() - $number);
431
-		}
432
-		else {
422
+		} else {
433 423
 			$this->delayedArmourDelta -= $number;
434 424
 		}
435 425
 	}
@@ -440,8 +430,7 @@  discard block
 block discarded – undo
440 430
 		}
441 431
 		if ($delayed === false) {
442 432
 			$this->setArmour($this->getArmour() + $number);
443
-		}
444
-		else {
433
+		} else {
445 434
 			$this->delayedArmourDelta += $number;
446 435
 		}
447 436
 	}
@@ -473,8 +462,7 @@  discard block
 block discarded – undo
473 462
 		}
474 463
 		if ($delayed === false) {
475 464
 			$this->setCDs($this->getCDs() - $number);
476
-		}
477
-		else {
465
+		} else {
478 466
 			$this->delayedCDsDelta -= $number;
479 467
 		}
480 468
 	}
@@ -485,8 +473,7 @@  discard block
 block discarded – undo
485 473
 		}
486 474
 		if ($delayed === false) {
487 475
 			$this->setCDs($this->getCDs() + $number);
488
-		}
489
-		else {
476
+		} else {
490 477
 			$this->delayedCDsDelta += $number;
491 478
 		}
492 479
 	}
@@ -580,8 +567,9 @@  discard block
 block discarded – undo
580 567
 			// get supplies from db
581 568
 			$this->db->query('SELECT good_id, amount FROM planet_has_cargo WHERE ' . $this->SQL);
582 569
 			// adding cargo and amount to array
583
-			while ($this->db->nextRecord())
584
-				$this->stockpile[$this->db->getInt('good_id')] = $this->db->getInt('amount');
570
+			while ($this->db->nextRecord()) {
571
+							$this->stockpile[$this->db->getInt('good_id')] = $this->db->getInt('amount');
572
+			}
585 573
 		}
586 574
 		if ($goodID === false) {
587 575
 			return $this->stockpile;
@@ -596,8 +584,7 @@  discard block
 block discarded – undo
596 584
 		if ($goodID === false) {
597 585
 			$stockpile = $this->getStockpile($goodID);
598 586
 			return count($stockpile) > 0 && max($stockpile) > 0;
599
-		}
600
-		else {
587
+		} else {
601 588
 			return $this->getStockpile($goodID) > 0;
602 589
 		}
603 590
 	}
@@ -831,8 +818,7 @@  discard block
 block discarded – undo
831 818
 				if ($amount != 0) {
832 819
 					$this->db->query('REPLACE INTO planet_has_cargo (game_id, sector_id, good_id, amount) ' .
833 820
 										 'VALUES(' . $this->db->escapeNumber($this->getGameID()) . ', ' . $this->db->escapeNumber($this->getSectorID()) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($amount) . ')');
834
-				}
835
-				else {
821
+				} else {
836 822
 					$this->db->query('DELETE FROM planet_has_cargo WHERE ' . $this->SQL . '
837 823
 										AND good_id = ' . $this->db->escapeNumber($id));
838 824
 				}
@@ -861,8 +847,7 @@  discard block
 block discarded – undo
861 847
 				if ($this->hasBuilding($id)) {
862 848
 					$this->db->query('REPLACE INTO planet_has_building (game_id, sector_id, construction_id, amount) ' .
863 849
 										'VALUES(' . $this->db->escapeNumber($this->gameID) . ', ' . $this->db->escapeNumber($this->sectorID) . ', ' . $this->db->escapeNumber($id) . ', ' . $this->db->escapeNumber($this->getBuilding($id)) . ')');
864
-				}
865
-				else {
850
+				} else {
866 851
 					$this->db->query('DELETE FROM planet_has_building WHERE ' . $this->SQL . '
867 852
 										AND construction_id = ' . $this->db->escapeNumber($id));
868 853
 				}
@@ -1236,8 +1221,7 @@  discard block
 block discarded – undo
1236 1221
 					}
1237 1222
 				}
1238 1223
 
1239
-			}
1240
-			else { // hit drones behind shields - we should only use this reduced damage branch if we cannot hit shields.
1224
+			} else { // hit drones behind shields - we should only use this reduced damage branch if we cannot hit shields.
1241 1225
 				$cdDamage = $this->doCDDamage(IFloor(min($damage['MaxDamage'], $damage['Armour']) * DRONES_BEHIND_SHIELDS_DAMAGE_PERCENT), $delayed);
1242 1226
 			}
1243 1227
 		}
Please login to merge, or discard this patch.
lib/Default/SmrCombatDrones.class.php 1 patch
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@  discard block
 block discarded – undo
13 13
 			$this->maxDamage = 2;
14 14
 			$this->shieldDamage = 2;
15 15
 			$this->armourDamage = 2;
16
-		}
17
-		else {
16
+		} else {
18 17
 			$this->maxDamage = 1;
19 18
 			$this->shieldDamage = 1;
20 19
 			$this->armourDamage = 1;
@@ -129,8 +128,10 @@  discard block
 block discarded – undo
129 128
 	}
130 129
 	
131 130
 	public function &getModifiedDamageAgainstForces(AbstractSmrPlayer $weaponPlayer, SmrForce $forces) {
132
-		if (!$this->canShootForces()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
131
+		if (!$this->canShootForces()) {
132
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
133 133
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
134
+		}
134 135
 		$damage =& $this->getModifiedDamage();
135 136
 		$damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstForces($weaponPlayer, $forces) / 100);
136 137
 		$damage['Kamikaze'] = 0;
@@ -151,8 +152,10 @@  discard block
 block discarded – undo
151 152
 	}
152 153
 	
153 154
 	public function &getModifiedDamageAgainstPort(AbstractSmrPlayer $weaponPlayer, SmrPort $port) {
154
-		if (!$this->canShootPorts()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
155
+		if (!$this->canShootPorts()) {
156
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
155 157
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
158
+		}
156 159
 		$damage =& $this->getModifiedDamage();
157 160
 		$damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPort($weaponPlayer, $port) / 100);
158 161
 		$damage['MaxDamage'] = ICeil($damage['Launched'] * $damage['MaxDamage']);
@@ -163,8 +166,10 @@  discard block
 block discarded – undo
163 166
 	}
164 167
 	
165 168
 	public function &getModifiedDamageAgainstPlanet(AbstractSmrPlayer $weaponPlayer, SmrPlanet $planet) {
166
-		if (!$this->canShootPlanets()) // If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
169
+		if (!$this->canShootPlanets()) {
170
+			// If we can't shoot forces then just return a damageless array and don't waste resources calculated any damage mods.
167 171
 			return array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
172
+		}
168 173
 		$damage =& $this->getModifiedDamage();
169 174
 		$damage['Launched'] = ICeil($this->getNumberOfCDs() * $this->getModifiedAccuracyAgainstPlanet($weaponPlayer, $planet) / 100);
170 175
 		$planetMod = self::PLANET_DAMAGE_MOD;
Please login to merge, or discard this patch.
lib/Default/AbstractSmrAccount.class.php 2 patches
Spacing   +282 added lines, -282 removed lines patch added patch discarded remove patch
@@ -10,23 +10,23 @@  discard block
 block discarded – undo
10 10
 	protected const USER_RANKINGS_SCORE = array(
11 11
 		// [Stat, a, b]
12 12
 		// Used as: pow(Stat * a, USER_RANKINGS_EACH_STAT_POW) * b
13
-		array(array('Trade','Experience','Total'),.1,0.5),
14
-		array(array('Trade','Money','Profit'),0.00005,0.5),
15
-		array(array('Killing','Kills'),1000,1)
13
+		array(array('Trade', 'Experience', 'Total'), .1, 0.5),
14
+		array(array('Trade', 'Money', 'Profit'), 0.00005, 0.5),
15
+		array(array('Killing', 'Kills'), 1000, 1)
16 16
 		);
17 17
 
18 18
 	protected static $CACHE_ACCOUNTS = array();
19 19
 	protected const DEFAULT_HOTKEYS = array(
20
-		'MoveUp' => array('w','up'),
21
-		'ScanUp' => array('shift+w','shift+up'),
22
-		'MoveLeft' => array('a','left'),
23
-		'ScanLeft' => array('shift+a','shift+left'),
24
-		'MoveRight' => array('d','right'),
25
-		'ScanRight' => array('shift+d','shift+right'),
26
-		'MoveDown' => array('s','down'),
27
-		'ScanDown' => array('shift+s','shift+down'),
28
-		'MoveWarp' => array('e','0'),
29
-		'ScanWarp' => array('shift+e','shift+0'),
20
+		'MoveUp' => array('w', 'up'),
21
+		'ScanUp' => array('shift+w', 'shift+up'),
22
+		'MoveLeft' => array('a', 'left'),
23
+		'ScanLeft' => array('shift+a', 'shift+left'),
24
+		'MoveRight' => array('d', 'right'),
25
+		'ScanRight' => array('shift+d', 'shift+right'),
26
+		'MoveDown' => array('s', 'down'),
27
+		'ScanDown' => array('shift+s', 'shift+down'),
28
+		'MoveWarp' => array('e', '0'),
29
+		'ScanWarp' => array('shift+e', 'shift+0'),
30 30
 		'ScanCurrent' => array('shift+1'),
31 31
 		'CurrentSector' => array('1'),
32 32
 		'LocalMap' => array('2'),
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	protected $oldAccountIDs = array();
68 68
 	protected $maxRankAchieved;
69 69
 	protected $referrerID;
70
-	protected $credits;       // SMR credits
70
+	protected $credits; // SMR credits
71 71
 	protected $rewardCredits; // SMR reward credits
72 72
 	protected $dateShort;
73 73
 	protected $timeShort;
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 		return self::DEFAULT_HOTKEYS;
89 89
 	}
90 90
 
91
-	public static function getAccount($accountID,$forceUpdate = false) {
92
-		if($forceUpdate || !isset(self::$CACHE_ACCOUNTS[$accountID])) {
91
+	public static function getAccount($accountID, $forceUpdate = false) {
92
+		if ($forceUpdate || !isset(self::$CACHE_ACCOUNTS[$accountID])) {
93 93
 			self::$CACHE_ACCOUNTS[$accountID] = new SmrAccount($accountID);
94 94
 		}
95 95
 		return self::$CACHE_ACCOUNTS[$accountID];
@@ -98,18 +98,18 @@  discard block
 block discarded – undo
98 98
 	public static function getAccountByName($login, $forceUpdate = false) {
99 99
 		if (empty($login)) { return null; }
100 100
 		$db = new SmrMySqlDatabase();
101
-		$db->query('SELECT account_id FROM account WHERE login = '.$db->escapeString($login).' LIMIT 1');
102
-		if($db->nextRecord()) {
101
+		$db->query('SELECT account_id FROM account WHERE login = ' . $db->escapeString($login) . ' LIMIT 1');
102
+		if ($db->nextRecord()) {
103 103
 			return self::getAccount($db->getInt('account_id'), $forceUpdate);
104 104
 		}
105 105
 		$return = null;
106 106
 		return $return;
107 107
 	}
108 108
 
109
-	public static function getAccountByEmail($email, $forceUpdate=false) {
109
+	public static function getAccountByEmail($email, $forceUpdate = false) {
110 110
 		if (empty($email)) { return null; }
111 111
 		$db = new SmrMySqlDatabase();
112
-		$db->query('SELECT account_id FROM account WHERE email = '.$db->escapeString($email).' LIMIT 1');
112
+		$db->query('SELECT account_id FROM account WHERE email = ' . $db->escapeString($email) . ' LIMIT 1');
113 113
 		if ($db->nextRecord()) {
114 114
 			return self::getAccount($db->getInt('account_id'), $forceUpdate);
115 115
 		} else {
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 		}
118 118
 	}
119 119
 
120
-	public static function getAccountByDiscordId($id, $forceUpdate=false) {
120
+	public static function getAccountByDiscordId($id, $forceUpdate = false) {
121 121
 		if (empty($id)) { return null; }
122 122
 		$db = new SmrMySqlDatabase();
123
-		$db->query('SELECT account_id FROM account where discord_id = '.$db->escapeString($id).' LIMIT 1');
123
+		$db->query('SELECT account_id FROM account where discord_id = ' . $db->escapeString($id) . ' LIMIT 1');
124 124
 		if ($db->nextRecord()) {
125 125
 			return self::getAccount($db->getInt('account_id'), $forceUpdate);
126 126
 		} else {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	public static function getAccountByIrcNick($nick, $forceUpdate = false) {
132 132
 		if (empty($nick)) { return null; }
133 133
 		$db = new SmrMySqlDatabase();
134
-		$db->query('SELECT account_id FROM account WHERE irc_nick = '.$db->escapeString($nick).' LIMIT 1');
134
+		$db->query('SELECT account_id FROM account WHERE irc_nick = ' . $db->escapeString($nick) . ' LIMIT 1');
135 135
 		if ($db->nextRecord()) {
136 136
 			return self::getAccount($db->getInt('account_id'), $forceUpdate);
137 137
 		} else {
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 		}
140 140
 	}
141 141
 
142
-	public static function getAccountBySocialLogin(SocialLogin $social, $forceUpdate=false) {
142
+	public static function getAccountBySocialLogin(SocialLogin $social, $forceUpdate = false) {
143 143
 		if (!$social->isValid()) { return null; }
144 144
 		$db = new SmrMySqlDatabase();
145 145
 		$db->query('SELECT account_id FROM account JOIN account_auth USING(account_id)
146
-		            WHERE login_type = '.$db->escapeString($social->getLoginType()).'
147
-		              AND auth_key = '.$db->escapeString($social->getUserID()).' LIMIT 1');
146
+		            WHERE login_type = '.$db->escapeString($social->getLoginType()) . '
147
+		              AND auth_key = '.$db->escapeString($social->getUserID()) . ' LIMIT 1');
148 148
 		if ($db->nextRecord()) {
149 149
 			return self::getAccount($db->getInt('account_id'), $forceUpdate);
150 150
 		} else {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	}
154 154
 
155 155
 	public static function createAccount($login, $password, $email, $timez, $referral) {
156
-		if($referral!=0) {
156
+		if ($referral != 0) {
157 157
 			// Will throw if referral account doesn't exist
158 158
 			SmrAccount::getAccount($referral);
159 159
 		}
@@ -161,60 +161,60 @@  discard block
 block discarded – undo
161 161
 		$passwordHash = password_hash($password, PASSWORD_DEFAULT);
162 162
 		$db->query('INSERT INTO account (login, password, email, validation_code, last_login, offset,referral_id,hof_name) VALUES(' .
163 163
 			$db->escapeString($login) . ', ' . $db->escapeString($passwordHash) . ', ' . $db->escapeString($email) . ', ' .
164
-			$db->escapeString(random_string(10)) . ',' . $db->escapeNumber(TIME) . ',' . $db->escapeNumber($timez) . ',' . $db->escapeNumber($referral).','.$db->escapeString($login).')');
164
+			$db->escapeString(random_string(10)) . ',' . $db->escapeNumber(TIME) . ',' . $db->escapeNumber($timez) . ',' . $db->escapeNumber($referral) . ',' . $db->escapeString($login) . ')');
165 165
 		return self::getAccountByName($login);
166 166
 	}
167 167
 
168 168
 	public static function getUserScoreCaseStatement($db) {
169 169
 		$userRankingTypes = array();
170 170
 		$case = 'FLOOR(SUM(CASE type ';
171
-		foreach(self::USER_RANKINGS_SCORE as $userRankingScore) {
172
-			$userRankingType = $db->escapeArray($userRankingScore[0],false,false,':',false);
171
+		foreach (self::USER_RANKINGS_SCORE as $userRankingScore) {
172
+			$userRankingType = $db->escapeArray($userRankingScore[0], false, false, ':', false);
173 173
 			$userRankingTypes[] = $userRankingType;
174
-			$case.= ' WHEN '.$db->escapeString($userRankingType).' THEN POW(amount*'.$userRankingScore[1].','.SmrAccount::USER_RANKINGS_EACH_STAT_POW.')*'.$userRankingScore[2];
174
+			$case .= ' WHEN ' . $db->escapeString($userRankingType) . ' THEN POW(amount*' . $userRankingScore[1] . ',' . SmrAccount::USER_RANKINGS_EACH_STAT_POW . ')*' . $userRankingScore[2];
175 175
 		}
176 176
 		$case .= ' END))';
177
-		return array('CASE'=>$case,'IN'=>$db->escapeArray($userRankingTypes));
177
+		return array('CASE'=>$case, 'IN'=>$db->escapeArray($userRankingTypes));
178 178
 	}
179 179
 
180 180
 	protected function __construct($accountID) {
181 181
 		$this->db = new SmrMySqlDatabase();
182 182
 		$this->SQL = 'account_id = ' . $this->db->escapeNumber($accountID);
183
-		$this->db->query('SELECT * FROM account WHERE '.$this->SQL.' LIMIT 1');
183
+		$this->db->query('SELECT * FROM account WHERE ' . $this->SQL . ' LIMIT 1');
184 184
 
185 185
 		if ($this->db->nextRecord()) {
186 186
 			$row = $this->db->getRow();
187
-			$this->account_id		= $row['account_id'];
187
+			$this->account_id = $row['account_id'];
188 188
 
189 189
 			$this->login			= $row['login'];
190
-			$this->passwordHash		= $row['password'];
190
+			$this->passwordHash = $row['password'];
191 191
 			$this->email			= $row['email'];
192
-			$this->validated		= $this->db->getBoolean('validated');
192
+			$this->validated = $this->db->getBoolean('validated');
193 193
 
194
-			$this->last_login		= $row['last_login'];
195
-			$this->validation_code 	= $row['validation_code'];
196
-			$this->veteranForced	= $this->db->getBoolean('veteran');
197
-			$this->logging			= $this->db->getBoolean('logging');
194
+			$this->last_login = $row['last_login'];
195
+			$this->validation_code = $row['validation_code'];
196
+			$this->veteranForced = $this->db->getBoolean('veteran');
197
+			$this->logging = $this->db->getBoolean('logging');
198 198
 			$this->offset			= $row['offset'];
199 199
 			$this->images			= $row['images'];
200
-			$this->fontSize			= $row['fontsize'];
200
+			$this->fontSize = $row['fontsize'];
201 201
 
202
-			$this->passwordReset	= $row['password_reset'];
203
-			$this->useAJAX			= $this->db->getBoolean('use_ajax');
204
-			$this->mailBanned		= (int)$row['mail_banned'];
202
+			$this->passwordReset = $row['password_reset'];
203
+			$this->useAJAX = $this->db->getBoolean('use_ajax');
204
+			$this->mailBanned = (int)$row['mail_banned'];
205 205
 			
206
-			$this->friendlyColour 	= $row['friendly_colour'];
207
-			$this->neutralColour 	= $row['neutral_colour'];
208
-			$this->enemyColour 		= $row['enemy_colour'];
206
+			$this->friendlyColour = $row['friendly_colour'];
207
+			$this->neutralColour = $row['neutral_colour'];
208
+			$this->enemyColour = $row['enemy_colour'];
209 209
 
210
-			$this->cssLink			= $row['css_link'];
211
-			$this->defaultCSSEnabled	= $this->db->getBoolean('default_css_enabled');
212
-			$this->centerGalaxyMapOnPlayer	= $this->db->getBoolean('center_galaxy_map_on_player');
210
+			$this->cssLink = $row['css_link'];
211
+			$this->defaultCSSEnabled = $this->db->getBoolean('default_css_enabled');
212
+			$this->centerGalaxyMapOnPlayer = $this->db->getBoolean('center_galaxy_map_on_player');
213 213
 
214 214
 			$this->messageNotifications = $this->db->getObject('message_notifications');
215 215
 			$this->hotkeys = $this->db->getObject('hotkeys');
216
-			foreach(self::DEFAULT_HOTKEYS as $hotkey => $binding) {
217
-				if(!isset($this->hotkeys[$hotkey])) {
216
+			foreach (self::DEFAULT_HOTKEYS as $hotkey => $binding) {
217
+				if (!isset($this->hotkeys[$hotkey])) {
218 218
 					$this->hotkeys[$hotkey] = $binding;
219 219
 				}
220 220
 			}
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 				$this->oldAccountIDs[$databaseName] = $row[$oldColumn];
224 224
 			}
225 225
 
226
-			$this->referrerID		= $row['referral_id'];
227
-			$this->maxRankAchieved	= $row['max_rank_achieved'];
226
+			$this->referrerID = $row['referral_id'];
227
+			$this->maxRankAchieved = $row['max_rank_achieved'];
228 228
 
229 229
 			$this->hofName			= $row['hof_name'];
230 230
 			$this->discordId		= $row['discord_id'];
@@ -234,20 +234,20 @@  discard block
 block discarded – undo
234 234
 			$this->timeShort		= $row['time_short'];
235 235
 
236 236
 			$this->template			= $row['template'];
237
-			$this->colourScheme		= $row['colour_scheme'];
237
+			$this->colourScheme = $row['colour_scheme'];
238 238
 
239
-			if(empty($this->hofName)) {
240
-				$this->hofName=$this->login;
239
+			if (empty($this->hofName)) {
240
+				$this->hofName = $this->login;
241 241
 			}
242 242
 		}
243 243
 		else {
244
-			throw new AccountNotFoundException('Account ID '.$accountID.' does not exist!');
244
+			throw new AccountNotFoundException('Account ID ' . $accountID . ' does not exist!');
245 245
 		}
246 246
 	}
247 247
 
248 248
 	public function isDisabled() {
249 249
 		$this->db->query('SELECT * FROM account_is_closed JOIN closing_reason USING(reason_id) ' .
250
-			'WHERE '.$this->SQL.' LIMIT 1');
250
+			'WHERE ' . $this->SQL . ' LIMIT 1');
251 251
 		if ($this->db->nextRecord()) {
252 252
 			// get the expire time
253 253
 			$expireTime = $this->db->getInt('expires');
@@ -269,64 +269,64 @@  discard block
 block discarded – undo
269 269
 	}
270 270
 
271 271
 	public function update() {
272
-		$this->db->query('UPDATE account SET email = '.$this->db->escapeString($this->email).
273
-			', validation_code = '.$this->db->escapeString($this->validation_code).
274
-			', validated = '.$this->db->escapeBoolean($this->validated).
275
-			', password = '.$this->db->escapeString($this->passwordHash).
276
-			', images = '.$this->db->escapeString($this->images).
277
-			', password_reset = '.$this->db->escapeString($this->passwordReset).
278
-			', use_ajax='.$this->db->escapeBoolean($this->useAJAX).
279
-			', mail_banned='.$this->db->escapeNumber($this->mailBanned).
280
-			', max_rank_achieved='.$this->db->escapeNumber($this->maxRankAchieved).
281
-			', default_css_enabled='.$this->db->escapeBoolean($this->defaultCSSEnabled).
282
-			', center_galaxy_map_on_player='.$this->db->escapeBoolean($this->centerGalaxyMapOnPlayer).
283
-			', message_notifications='.$this->db->escapeObject($this->messageNotifications).
284
-			', hotkeys='.$this->db->escapeObject($this->hotkeys).
285
-			', last_login = '.$this->db->escapeNumber($this->last_login).
286
-			', logging = '.$this->db->escapeBoolean($this->logging).
287
-			', time_short = ' . $this->db->escapeString($this->timeShort).
288
-			', date_short = ' . $this->db->escapeString($this->dateShort).
289
-			', discord_id = ' . $this->db->escapeString($this->discordId, true, true).
290
-			', irc_nick = ' . $this->db->escapeString($this->ircNick, true, true).
291
-			', hof_name = ' . $this->db->escapeString($this->hofName).
292
-			', colour_scheme = ' . $this->db->escapeString($this->colourScheme).
293
-			', fontsize = ' . $this->db->escapeNumber($this->fontSize).
294
-			', css_link = ' . $this->db->escapeString($this->cssLink,true,true).
295
-			', friendly_colour = ' . $this->db->escapeString($this->friendlyColour, true, true).
296
-			', neutral_colour = ' . $this->db->escapeString($this->neutralColour, true, true).
297
-			', enemy_colour = ' . $this->db->escapeString($this->enemyColour, true, true).
298
-			' WHERE '.$this->SQL.' LIMIT 1');
272
+		$this->db->query('UPDATE account SET email = ' . $this->db->escapeString($this->email) .
273
+			', validation_code = ' . $this->db->escapeString($this->validation_code) .
274
+			', validated = ' . $this->db->escapeBoolean($this->validated) .
275
+			', password = ' . $this->db->escapeString($this->passwordHash) .
276
+			', images = ' . $this->db->escapeString($this->images) .
277
+			', password_reset = ' . $this->db->escapeString($this->passwordReset) .
278
+			', use_ajax=' . $this->db->escapeBoolean($this->useAJAX) .
279
+			', mail_banned=' . $this->db->escapeNumber($this->mailBanned) .
280
+			', max_rank_achieved=' . $this->db->escapeNumber($this->maxRankAchieved) .
281
+			', default_css_enabled=' . $this->db->escapeBoolean($this->defaultCSSEnabled) .
282
+			', center_galaxy_map_on_player=' . $this->db->escapeBoolean($this->centerGalaxyMapOnPlayer) .
283
+			', message_notifications=' . $this->db->escapeObject($this->messageNotifications) .
284
+			', hotkeys=' . $this->db->escapeObject($this->hotkeys) .
285
+			', last_login = ' . $this->db->escapeNumber($this->last_login) .
286
+			', logging = ' . $this->db->escapeBoolean($this->logging) .
287
+			', time_short = ' . $this->db->escapeString($this->timeShort) .
288
+			', date_short = ' . $this->db->escapeString($this->dateShort) .
289
+			', discord_id = ' . $this->db->escapeString($this->discordId, true, true) .
290
+			', irc_nick = ' . $this->db->escapeString($this->ircNick, true, true) .
291
+			', hof_name = ' . $this->db->escapeString($this->hofName) .
292
+			', colour_scheme = ' . $this->db->escapeString($this->colourScheme) .
293
+			', fontsize = ' . $this->db->escapeNumber($this->fontSize) .
294
+			', css_link = ' . $this->db->escapeString($this->cssLink, true, true) .
295
+			', friendly_colour = ' . $this->db->escapeString($this->friendlyColour, true, true) .
296
+			', neutral_colour = ' . $this->db->escapeString($this->neutralColour, true, true) .
297
+			', enemy_colour = ' . $this->db->escapeString($this->enemyColour, true, true) .
298
+			' WHERE ' . $this->SQL . ' LIMIT 1');
299 299
 		$this->hasChanged = false;
300 300
 	}
301 301
 
302 302
 	public function updateIP() {
303 303
 		$curr_ip = getIpAddress();
304
-		$this->log(LOG_TYPE_LOGIN, 'logged in from '.$curr_ip);
304
+		$this->log(LOG_TYPE_LOGIN, 'logged in from ' . $curr_ip);
305 305
 
306 306
 		// more than 50 elements in it?
307 307
 
308
-		$this->db->query('SELECT time,ip FROM account_has_ip WHERE '.$this->SQL.' ORDER BY time ASC');
308
+		$this->db->query('SELECT time,ip FROM account_has_ip WHERE ' . $this->SQL . ' ORDER BY time ASC');
309 309
 		if ($this->db->getNumRows() > 50 && $this->db->nextRecord()) {
310 310
 			$delete_time = $this->db->getInt('time');
311 311
 			$delete_ip = $this->db->getField('ip');
312 312
 
313 313
 			$this->db->query('DELETE FROM account_has_ip
314
-				WHERE '.$this->SQL.' AND
315
-				time = '.$this->db->escapeNumber($delete_time).' AND
314
+				WHERE '.$this->SQL . ' AND
315
+				time = '.$this->db->escapeNumber($delete_time) . ' AND
316 316
 				ip = '.$this->db->escapeString($delete_ip));
317 317
 		}
318
-		list($fi,$se,$th,$fo) = preg_split('/[.\s,]/', $curr_ip, 4);
318
+		list($fi, $se, $th, $fo) = preg_split('/[.\s,]/', $curr_ip, 4);
319 319
 		if ($curr_ip != 'unknown' && $curr_ip != 'unknown...' && $curr_ip != 'unknown, unknown') {
320
-			$curr_ip = $fi.'.'.$se.'.'.$th.'.'.$fo;
320
+			$curr_ip = $fi . '.' . $se . '.' . $th . '.' . $fo;
321 321
 			$host = gethostbyaddr($curr_ip);
322 322
 		} else $host = 'unknown';
323 323
 
324 324
 		// save...first make sure there isn't one for these keys (someone could double click and get error)
325
-		$this->db->query('REPLACE INTO account_has_ip (account_id, time, ip, host) VALUES ('.$this->db->escapeNumber($this->account_id).', '.$this->db->escapeNumber(TIME).', '.$this->db->escapeString($curr_ip).', '.$this->db->escapeString($host).')');
325
+		$this->db->query('REPLACE INTO account_has_ip (account_id, time, ip, host) VALUES (' . $this->db->escapeNumber($this->account_id) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeString($curr_ip) . ', ' . $this->db->escapeString($host) . ')');
326 326
 	}
327 327
 
328 328
 	public function updateLastLogin() {
329
-		if($this->last_login == TIME) {
329
+		if ($this->last_login == TIME) {
330 330
 			return;
331 331
 		}
332 332
 		$this->last_login = TIME;
@@ -339,10 +339,10 @@  discard block
 block discarded – undo
339 339
 	}
340 340
 
341 341
 	public function setLoggingEnabled($bool) {
342
-		if($this->logging==$bool) {
342
+		if ($this->logging == $bool) {
343 343
 			return;
344 344
 		}
345
-		$this->logging=$bool;
345
+		$this->logging = $bool;
346 346
 		$this->hasChanged = true;
347 347
 		$this->update();
348 348
 	}
@@ -362,26 +362,26 @@  discard block
 block discarded – undo
362 362
 	}
363 363
 
364 364
 	public function isNPC() {
365
-		if(!isset($this->npc)) {
366
-			$this->db->query('SELECT login FROM npc_logins WHERE login = '.$this->db->escapeString($this->getLogin()).' LIMIT 1;');
365
+		if (!isset($this->npc)) {
366
+			$this->db->query('SELECT login FROM npc_logins WHERE login = ' . $this->db->escapeString($this->getLogin()) . ' LIMIT 1;');
367 367
 			$this->npc = $this->db->nextRecord();
368 368
 		}
369 369
 		return $this->npc;
370 370
 	}
371 371
 
372 372
 	protected function getHOFData() {
373
-		if(!isset($this->HOF)) {
373
+		if (!isset($this->HOF)) {
374 374
 			//Get Player HOF
375 375
 			$this->db->query('SELECT type,sum(amount) as amount FROM player_hof WHERE ' . $this->SQL . ' AND game_id IN (SELECT game_id FROM game WHERE ignore_stats = \'FALSE\') GROUP BY type');
376 376
 			$this->HOF = array();
377
-			while($this->db->nextRecord()) {
378
-				$hof =& $this->HOF;
379
-				$typeList = explode(':',$this->db->getField('type'));
380
-				foreach($typeList as $type) {
381
-					if(!isset($hof[$type])) {
377
+			while ($this->db->nextRecord()) {
378
+				$hof = & $this->HOF;
379
+				$typeList = explode(':', $this->db->getField('type'));
380
+				foreach ($typeList as $type) {
381
+					if (!isset($hof[$type])) {
382 382
 						$hof[$type] = array();
383 383
 					}
384
-					$hof =& $hof[$type];
384
+					$hof = & $hof[$type];
385 385
 				}
386 386
 				$hof = $this->db->getFloat('amount');
387 387
 			}
@@ -390,12 +390,12 @@  discard block
 block discarded – undo
390 390
 
391 391
 	public function getHOF(array $typeList = null) {
392 392
 		$this->getHOFData();
393
-		if($typeList==null) {
393
+		if ($typeList == null) {
394 394
 			return $this->HOF;
395 395
 		}
396
-		$hof=$this->HOF;
397
-		foreach($typeList as $type) {
398
-			if(!isset($hof[$type])) {
396
+		$hof = $this->HOF;
397
+		foreach ($typeList as $type) {
398
+			if (!isset($hof[$type])) {
399 399
 				return 0;
400 400
 			}
401 401
 			$hof = $hof[$type];
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 
406 406
 	public function getRankName() {
407 407
 		$rankings = Globals::getUserRanking();
408
-		if(isset($rankings[$this->getRank()])) {
408
+		if (isset($rankings[$this->getRank()])) {
409 409
 			return $rankings[$this->getRank()];
410 410
 		} else {
411 411
 			return end($rankings);
@@ -413,56 +413,56 @@  discard block
 block discarded – undo
413 413
 	}
414 414
 
415 415
 	public function getScore() {
416
-		if(!isset($this->score)) {
417
-			$score=0;
418
-			foreach($this->getIndividualScores() as $each) {
419
-				$score+=$each['Score'];
416
+		if (!isset($this->score)) {
417
+			$score = 0;
418
+			foreach ($this->getIndividualScores() as $each) {
419
+				$score += $each['Score'];
420 420
 			}
421
-			$this->score=round($score);
421
+			$this->score = round($score);
422 422
 		}
423 423
 		return $this->score;
424 424
 	}
425 425
 
426 426
 	public function getIndividualScores(SmrPlayer $player = null) {
427
-		$gameID=0;
428
-		if($player!=null) {
427
+		$gameID = 0;
428
+		if ($player != null) {
429 429
 			$gameID = $player->getGameID();
430 430
 		}
431
-		if(!isset($this->individualScores[$gameID])) {
431
+		if (!isset($this->individualScores[$gameID])) {
432 432
 			$this->individualScores[$gameID] = array();
433
-			foreach(self::USER_RANKINGS_SCORE as $statScore) {
434
-				if($player==null) {
433
+			foreach (self::USER_RANKINGS_SCORE as $statScore) {
434
+				if ($player == null) {
435 435
 					$stat = $this->getHOF($statScore[0]);
436 436
 				} else {
437 437
 					$stat = $player->getHOF($statScore[0]);
438 438
 				}
439
-				$this->individualScores[$gameID][]=array('Stat'=>$statScore[0],'Score'=>pow($stat*$statScore[1],self::USER_RANKINGS_EACH_STAT_POW)*$statScore[2]);
439
+				$this->individualScores[$gameID][] = array('Stat'=>$statScore[0], 'Score'=>pow($stat * $statScore[1], self::USER_RANKINGS_EACH_STAT_POW) * $statScore[2]);
440 440
 			}
441 441
 		}
442 442
 		return $this->individualScores[$gameID];
443 443
 	}
444 444
 
445 445
 	public function getRank() : int {
446
-		$rank = ICeil(pow($this->getScore(),self::USER_RANKINGS_TOTAL_SCORE_POW)/self::USER_RANKINGS_RANK_BOUNDARY);
447
-		if($rank<1) {
448
-			$rank=1;
446
+		$rank = ICeil(pow($this->getScore(), self::USER_RANKINGS_TOTAL_SCORE_POW) / self::USER_RANKINGS_RANK_BOUNDARY);
447
+		if ($rank < 1) {
448
+			$rank = 1;
449 449
 		}
450
-		if($rank > $this->maxRankAchieved) {
450
+		if ($rank > $this->maxRankAchieved) {
451 451
 			$this->updateMaxRankAchieved($rank);
452 452
 		}
453 453
 		return $rank;
454 454
 	}
455 455
 
456 456
 	protected function updateMaxRankAchieved($rank) {
457
-		if($rank <= $this->maxRankAchieved) {
457
+		if ($rank <= $this->maxRankAchieved) {
458 458
 			throw new Exception('Trying to set max rank achieved to a lower value: ' . $rank);
459 459
 		}
460 460
 		$delta = $rank - $this->maxRankAchieved;
461
-		if($this->hasReferrer()) {
461
+		if ($this->hasReferrer()) {
462 462
 			$this->getReferrer()->increaseSmrRewardCredits($delta * CREDITS_PER_DOLLAR);
463 463
 		}
464
-		$this->maxRankAchieved+=$delta;
465
-		$this->hasChanged=true;
464
+		$this->maxRankAchieved += $delta;
465
+		$this->hasChanged = true;
466 466
 		$this->update();
467 467
 	}
468 468
 
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	}
472 472
 
473 473
 	public function hasReferrer() {
474
-		return $this->referrerID>0;
474
+		return $this->referrerID > 0;
475 475
 	}
476 476
 
477 477
 	public function getReferrer() {
@@ -482,15 +482,15 @@  discard block
 block discarded – undo
482 482
 		if ($this->isLoggingEnabled()) {
483 483
 			$this->db->query('INSERT INTO account_has_logs ' .
484 484
 				'(account_id, microtime, log_type_id, message, sector_id) ' .
485
-				'VALUES('.$this->db->escapeNumber($this->account_id).', '. $this->db->escapeMicrotime(MICRO_TIME) . ', '.$this->db->escapeNumber($log_type_id).', ' . $this->db->escapeString($msg) . ', '.$this->db->escapeNumber($sector_id).')');
485
+				'VALUES(' . $this->db->escapeNumber($this->account_id) . ', ' . $this->db->escapeMicrotime(MICRO_TIME) . ', ' . $this->db->escapeNumber($log_type_id) . ', ' . $this->db->escapeString($msg) . ', ' . $this->db->escapeNumber($sector_id) . ')');
486 486
 		}
487 487
 	}
488 488
 
489 489
 	protected function getSmrCreditsData() {
490
-		if(!isset($this->credits)||!isset($this->rewardCredits)) {
490
+		if (!isset($this->credits) || !isset($this->rewardCredits)) {
491 491
 			$this->credits = 0;
492 492
 			$this->rewardCredits = 0;
493
-			$this->db->query('SELECT * FROM account_has_credits WHERE '.$this->SQL.' LIMIT 1');
493
+			$this->db->query('SELECT * FROM account_has_credits WHERE ' . $this->SQL . ' LIMIT 1');
494 494
 			if ($this->db->nextRecord()) {
495 495
 				$this->credits = $this->db->getInt('credits_left');
496 496
 				$this->rewardCredits = $this->db->getInt('reward_credits');
@@ -503,30 +503,30 @@  discard block
 block discarded – undo
503 503
 	}
504 504
 
505 505
 	public function decreaseTotalSmrCredits($totalCredits) {
506
-		if($totalCredits==0) {
506
+		if ($totalCredits == 0) {
507 507
 			return;
508 508
 		}
509
-		if($totalCredits<0) {
509
+		if ($totalCredits < 0) {
510 510
 			throw new Exception('You cannot use negative total credits');
511 511
 		}
512
-		if($totalCredits>$this->getTotalSmrCredits()) {
512
+		if ($totalCredits > $this->getTotalSmrCredits()) {
513 513
 			throw new Exception('You do not have that many credits in total to use');
514 514
 		}
515 515
 
516
-		$rewardCredits=$this->rewardCredits;
517
-		$credits=$this->credits;
518
-		$rewardCredits-=$totalCredits;
519
-		if($rewardCredits<0) {
520
-			$credits+=$rewardCredits;
521
-			$rewardCredits=0;
516
+		$rewardCredits = $this->rewardCredits;
517
+		$credits = $this->credits;
518
+		$rewardCredits -= $totalCredits;
519
+		if ($rewardCredits < 0) {
520
+			$credits += $rewardCredits;
521
+			$rewardCredits = 0;
522 522
 		}
523
-		if($this->credits==0 && $this->rewardCredits==0) {
524
-			$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).','.$this->db->escapeNumber($rewardCredits).')');
523
+		if ($this->credits == 0 && $this->rewardCredits == 0) {
524
+			$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left, reward_credits) VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($credits) . ',' . $this->db->escapeNumber($rewardCredits) . ')');
525 525
 		} else {
526
-			$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).', reward_credits='.$this->db->escapeNumber($rewardCredits).' WHERE '.$this->SQL.' LIMIT 1');
526
+			$this->db->query('UPDATE account_has_credits SET credits_left=' . $this->db->escapeNumber($credits) . ', reward_credits=' . $this->db->escapeNumber($rewardCredits) . ' WHERE ' . $this->SQL . ' LIMIT 1');
527 527
 		}
528
-		$this->credits=$credits;
529
-		$this->rewardCredits=$rewardCredits;
528
+		$this->credits = $credits;
529
+		$this->rewardCredits = $rewardCredits;
530 530
 	}
531 531
 
532 532
 	public function getSmrCredits() {
@@ -540,60 +540,60 @@  discard block
 block discarded – undo
540 540
 	}
541 541
 
542 542
 	public function setSmrCredits($credits) {
543
-		if($this->getSmrCredits()==$credits) {
543
+		if ($this->getSmrCredits() == $credits) {
544 544
 			return;
545 545
 		}
546
-		if($this->credits==0 && $this->rewardCredits==0) {
547
-			$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
546
+		if ($this->credits == 0 && $this->rewardCredits == 0) {
547
+			$this->db->query('REPLACE INTO account_has_credits (account_id, credits_left) VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($credits) . ')');
548 548
 		} else {
549
-			$this->db->query('UPDATE account_has_credits SET credits_left='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
549
+			$this->db->query('UPDATE account_has_credits SET credits_left=' . $this->db->escapeNumber($credits) . ' WHERE ' . $this->SQL . ' LIMIT 1');
550 550
 		}
551
-		$this->credits=$credits;
551
+		$this->credits = $credits;
552 552
 	}
553 553
 
554 554
 	public function increaseSmrCredits($credits) {
555
-		if($credits==0) {
555
+		if ($credits == 0) {
556 556
 			return;
557 557
 		}
558
-		if($credits<0) {
558
+		if ($credits < 0) {
559 559
 			throw new Exception('You cannot gain negative credits');
560 560
 		}
561
-		$this->setSmrCredits($this->getSmrCredits()+$credits);
561
+		$this->setSmrCredits($this->getSmrCredits() + $credits);
562 562
 	}
563 563
 
564 564
 	public function decreaseSmrCredits($credits) {
565
-		if($credits==0) {
565
+		if ($credits == 0) {
566 566
 			return;
567 567
 		}
568
-		if($credits<0) {
568
+		if ($credits < 0) {
569 569
 			throw new Exception('You cannot use negative credits');
570 570
 		}
571
-		if($credits>$this->getSmrCredits()) {
571
+		if ($credits > $this->getSmrCredits()) {
572 572
 			throw new Exception('You cannot use more credits than you have');
573 573
 		}
574
-		$this->setSmrCredits($this->getSmrCredits()-$credits);
574
+		$this->setSmrCredits($this->getSmrCredits() - $credits);
575 575
 	}
576 576
 
577 577
 	public function setSmrRewardCredits($credits) {
578
-		if($this->getSmrRewardCredits()==$credits) {
578
+		if ($this->getSmrRewardCredits() == $credits) {
579 579
 			return;
580 580
 		}
581
-		if($this->credits==0 && $this->rewardCredits==0) {
582
-			$this->db->query('REPLACE INTO account_has_credits (account_id, reward_credits) VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($credits).')');
581
+		if ($this->credits == 0 && $this->rewardCredits == 0) {
582
+			$this->db->query('REPLACE INTO account_has_credits (account_id, reward_credits) VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($credits) . ')');
583 583
 		} else {
584
-			$this->db->query('UPDATE account_has_credits SET reward_credits='.$this->db->escapeNumber($credits).' WHERE '.$this->SQL.' LIMIT 1');
584
+			$this->db->query('UPDATE account_has_credits SET reward_credits=' . $this->db->escapeNumber($credits) . ' WHERE ' . $this->SQL . ' LIMIT 1');
585 585
 		}
586
-		$this->rewardCredits=$credits;
586
+		$this->rewardCredits = $credits;
587 587
 	}
588 588
 
589 589
 	public function increaseSmrRewardCredits($credits) {
590
-		if($credits==0) {
590
+		if ($credits == 0) {
591 591
 			return;
592 592
 		}
593
-		if($credits<0) {
593
+		if ($credits < 0) {
594 594
 			throw new Exception('You cannot gain negative reward credits');
595 595
 		}
596
-		$this->setSmrRewardCredits($this->getSmrRewardCredits()+$credits);
596
+		$this->setSmrRewardCredits($this->getSmrRewardCredits() + $credits);
597 597
 	}
598 598
 
599 599
 	public function sendMessageToBox($boxTypeID, $message) {
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 		self::doMessageSendingToBox($this->getAccountID(), $boxTypeID, $message);
602 602
 	}
603 603
 
604
-	public static function doMessageSendingToBox($senderID, $boxTypeID, $message, $gameID=0) {
604
+	public static function doMessageSendingToBox($senderID, $boxTypeID, $message, $gameID = 0) {
605 605
 		$db = new SmrMySqlDatabase();
606 606
 		// send him the message
607 607
 		$db->query('INSERT INTO message_boxes
@@ -624,14 +624,14 @@  discard block
 block discarded – undo
624 624
 	}
625 625
 
626 626
 	public function getOldAccountID($dbName) {
627
-		return isset($this->oldAccountIDs[$dbName])?$this->oldAccountIDs[$dbName]:0;
627
+		return isset($this->oldAccountIDs[$dbName]) ? $this->oldAccountIDs[$dbName] : 0;
628 628
 	}
629 629
 
630
-	public function hasOldAccountID($dbName=false) {
631
-		if($dbName===false) {
632
-			return count($this->getOldAccountIDs())!=0;
630
+	public function hasOldAccountID($dbName = false) {
631
+		if ($dbName === false) {
632
+			return count($this->getOldAccountIDs()) != 0;
633 633
 		}
634
-		return $this->getOldAccountID($dbName)!=0;
634
+		return $this->getOldAccountID($dbName) != 0;
635 635
 	}
636 636
 
637 637
 	public function getLogin() {
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 	}
644 644
 
645 645
 	public function setEmail($email) {
646
-		if($this->email==$email) {
646
+		if ($this->email == $email) {
647 647
 			return;
648 648
 		}
649 649
 		$this->email = $email;
@@ -660,14 +660,14 @@  discard block
 block discarded – undo
660 660
 
661 661
 		// check if the host got a MX or at least an A entry
662 662
 		if (!checkdnsrr($host, 'MX') && !checkdnsrr($host, 'A')) {
663
-			create_error('This is not a valid email address! The domain '.$host.' does not exist.');
663
+			create_error('This is not a valid email address! The domain ' . $host . ' does not exist.');
664 664
 		}
665 665
 
666 666
 		if (strstr($email, ' ')) {
667 667
 			create_error('The email is invalid! It cannot contain any spaces.');
668 668
 		}
669 669
 
670
-		$this->db->query('SELECT 1 FROM account WHERE email = '.$this->db->escapeString($email).' and account_id != ' . $this->db->escapeNumber($this->getAccountID()) . ' LIMIT 1');
670
+		$this->db->query('SELECT 1 FROM account WHERE email = ' . $this->db->escapeString($email) . ' and account_id != ' . $this->db->escapeNumber($this->getAccountID()) . ' LIMIT 1');
671 671
 		if ($this->db->getNumRows() > 0) {
672 672
 			create_error('This email address is already registered.');
673 673
 		}
@@ -678,12 +678,12 @@  discard block
 block discarded – undo
678 678
 
679 679
 		// remember when we sent validation code
680 680
 		$this->db->query('REPLACE INTO notification (notification_type, account_id, time)
681
-				VALUES(\'validation_code\', '.$this->db->escapeNumber($this->getAccountID()).', ' . $this->db->escapeNumber(TIME) . ')');
681
+				VALUES(\'validation_code\', '.$this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber(TIME) . ')');
682 682
 
683 683
 		$emailMessage =
684
-			'You changed your email address registered with SMR and need to revalidate now!'.EOL.EOL.
685
-			'   Your new validation code is: '.$this->getValidationCode().EOL.EOL.
686
-			'The Space Merchant Realms server is on the web at '.URL;
684
+			'You changed your email address registered with SMR and need to revalidate now!' . EOL . EOL .
685
+			'   Your new validation code is: ' . $this->getValidationCode() . EOL . EOL .
686
+			'The Space Merchant Realms server is on the web at ' . URL;
687 687
 
688 688
 		$mail = setupMailer();
689 689
 		$mail->Subject = 'Your validation code!';
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 	}
710 710
 
711 711
 	public function setFontSize($size) {
712
-		if($this->fontSize==$size) {
712
+		if ($this->fontSize == $size) {
713 713
 			return;
714 714
 		}
715 715
 		$this->fontSize = $size;
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 
725 725
 	// sets the extra CSS file linked in preferences
726 726
 	public function setCssLink($link) {
727
-		if($this->cssLink==$link) {
727
+		if ($this->cssLink == $link) {
728 728
 			return;
729 729
 		}
730 730
 		$this->cssLink = $link;
@@ -737,13 +737,13 @@  discard block
 block discarded – undo
737 737
 	}
738 738
 
739 739
 	public function setTemplate($template) {
740
-		if($this->template==$template) {
740
+		if ($this->template == $template) {
741 741
 			return;
742 742
 		}
743
-		if(!in_array($template,array_keys(Globals::getAvailableTemplates()))) {
744
-			throw new Exception('Template not allowed: '.$template);
743
+		if (!in_array($template, array_keys(Globals::getAvailableTemplates()))) {
744
+			throw new Exception('Template not allowed: ' . $template);
745 745
 		}
746
-		$this->db->query('UPDATE account SET template = ' . $this->db->escapeString($template) . ' WHERE '.$this->SQL.' LIMIT 1');
746
+		$this->db->query('UPDATE account SET template = ' . $this->db->escapeString($template) . ' WHERE ' . $this->SQL . ' LIMIT 1');
747 747
 		$this->template = $template;
748 748
 		$colourSchemes = Globals::getAvailableColourSchemes($template);
749 749
 		$this->setColourScheme($colourSchemes[0]);
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
 	}
755 755
 
756 756
 	public function setColourScheme($colourScheme) {
757
-		if($this->colourScheme==$colourScheme) {
757
+		if ($this->colourScheme == $colourScheme) {
758 758
 			return;
759 759
 		}
760
-		if(!in_array($colourScheme,array_keys(Globals::getAvailableColourSchemes($this->getTemplate())))) {
761
-			throw new Exception('Colour scheme not allowed: '.$colourScheme);
760
+		if (!in_array($colourScheme, array_keys(Globals::getAvailableColourSchemes($this->getTemplate())))) {
761
+			throw new Exception('Colour scheme not allowed: ' . $colourScheme);
762 762
 		}
763 763
 		$this->colourScheme = $colourScheme;
764 764
 		$this->hasChanged = true;
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 	 * The Hall Of Fame name is not html-escaped in the database, so to display
780 780
 	 * it correctly we must escape html entities.
781 781
 	 */
782
-	public function getHofDisplayName($linked=false) {
782
+	public function getHofDisplayName($linked = false) {
783 783
 		$hofDisplayName = htmlspecialchars($this->getHofName());
784 784
 		if ($linked) {
785 785
 			return '<a href="' . $this->getPersonalHofHREF() . '">' . $hofDisplayName . '</a>';
@@ -793,7 +793,7 @@  discard block
 block discarded – undo
793 793
 	}
794 794
 
795 795
 	public function setHofName($name) {
796
-		if($this->hofName==$name) {
796
+		if ($this->hofName == $name) {
797 797
 			return;
798 798
 		}
799 799
 		$this->hofName = $name;
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 	}
807 807
 
808 808
 	public function setIrcNick($nick) {
809
-		if($this->ircNick==$nick) {
809
+		if ($this->ircNick == $nick) {
810 810
 			return;
811 811
 		}
812 812
 		$this->ircNick = $nick;
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 	}
829 829
 
830 830
 	public function getReferralLink() {
831
-		return URL . '/login_create.php?ref='.$this->getAccountID();
831
+		return URL . '/login_create.php?ref=' . $this->getAccountID();
832 832
 	}
833 833
 
834 834
 	public function getShortDateFormat() {
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 	}
837 837
 
838 838
 	public function setShortDateFormat($format) {
839
-		if($this->dateShort==$format) {
839
+		if ($this->dateShort == $format) {
840 840
 			return;
841 841
 		}
842 842
 		$this->dateShort = $format;
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
 	}
850 850
 
851 851
 	public function setShortTimeFormat($format) {
852
-		if($this->timeShort==$format) {
852
+		if ($this->timeShort == $format) {
853 853
 			return;
854 854
 		}
855 855
 		$this->timeShort = $format;
@@ -862,16 +862,16 @@  discard block
 block discarded – undo
862 862
 	}
863 863
 
864 864
 	protected function setValidationCode($code) {
865
-		if($this->validation_code == $code) {
865
+		if ($this->validation_code == $code) {
866 866
 			return;
867 867
 		}
868
-		$this->validation_code=$code;
869
-		$this->hasChanged=true;
868
+		$this->validation_code = $code;
869
+		$this->hasChanged = true;
870 870
 		$this->update();
871 871
 	}
872 872
 
873 873
 	public function setValidated($bool) {
874
-		if($this->validated == $bool) {
874
+		if ($this->validated == $bool) {
875 875
 			return;
876 876
 		}
877 877
 		$this->validated = $bool;
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	}
885 885
 
886 886
 	public function isLoggedIn() {
887
-		$this->db->query('SELECT 1 FROM active_session WHERE account_id = '.$this->db->escapeNumber($this->getAccountID()).' LIMIT 1');
887
+		$this->db->query('SELECT 1 FROM active_session WHERE account_id = ' . $this->db->escapeNumber($this->getAccountID()) . ' LIMIT 1');
888 888
 		return $this->db->nextRecord();
889 889
 	}
890 890
 
@@ -925,15 +925,15 @@  discard block
 block discarded – undo
925 925
 		$this->update();
926 926
 	}
927 927
 
928
-	public function addAuthMethod($loginType,$authKey) {
929
-		$this->db->query('SELECT account_id FROM account_auth WHERE login_type='.$this->db->escapeString($loginType).' AND auth_key = '.$this->db->escapeString($authKey).';');
930
-		if($this->db->nextRecord()) {
931
-			if($this->db->getInt('account_id')!=$this->getAccountID()) {
928
+	public function addAuthMethod($loginType, $authKey) {
929
+		$this->db->query('SELECT account_id FROM account_auth WHERE login_type=' . $this->db->escapeString($loginType) . ' AND auth_key = ' . $this->db->escapeString($authKey) . ';');
930
+		if ($this->db->nextRecord()) {
931
+			if ($this->db->getInt('account_id') != $this->getAccountID()) {
932 932
 				throw new Exception('Another account already uses this form of auth.');
933 933
 			}
934 934
 			return true;
935 935
 		}
936
-		$this->db->query('INSERT INTO account_auth values ('.$this->db->escapeNumber($this->getAccountID()).','.$this->db->escapeString($loginType).','.$this->db->escapeString($authKey).');');
936
+		$this->db->query('INSERT INTO account_auth values (' . $this->db->escapeNumber($this->getAccountID()) . ',' . $this->db->escapeString($loginType) . ',' . $this->db->escapeString($authKey) . ');');
937 937
 		return true;
938 938
 	}
939 939
 
@@ -946,11 +946,11 @@  discard block
 block discarded – undo
946 946
 	}
947 947
 
948 948
 	protected function setPasswordReset($passwordReset) {
949
-		if($this->passwordReset == $passwordReset) {
949
+		if ($this->passwordReset == $passwordReset) {
950 950
 			return;
951 951
 		}
952
-		$this->passwordReset=$passwordReset;
953
-		$this->hasChanged=true;
952
+		$this->passwordReset = $passwordReset;
953
+		$this->hasChanged = true;
954 954
 		$this->update();
955 955
 	}
956 956
 
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 	}
960 960
 
961 961
 	public function setDisplayShipImages($yesNo) {
962
-		if($this->images == $yesNo) {
962
+		if ($this->images == $yesNo) {
963 963
 			return;
964 964
 		}
965 965
 		$this->images = $yesNo;
@@ -972,11 +972,11 @@  discard block
 block discarded – undo
972 972
 	}
973 973
 
974 974
 	public function setUseAJAX($bool) {
975
-		if($this->useAJAX == $bool) {
975
+		if ($this->useAJAX == $bool) {
976 976
 			return;
977 977
 		}
978
-		$this->useAJAX=$bool;
979
-		$this->hasChanged=true;
978
+		$this->useAJAX = $bool;
979
+		$this->hasChanged = true;
980 980
 		$this->update();
981 981
 	}
982 982
 
@@ -985,17 +985,17 @@  discard block
 block discarded – undo
985 985
 	}
986 986
 
987 987
 	public function setDefaultCSSEnabled($bool) {
988
-		if($this->defaultCSSEnabled == $bool) {
988
+		if ($this->defaultCSSEnabled == $bool) {
989 989
 			return;
990 990
 		}
991
-		$this->defaultCSSEnabled=$bool;
992
-		$this->hasChanged=true;
991
+		$this->defaultCSSEnabled = $bool;
992
+		$this->hasChanged = true;
993 993
 		$this->update();
994 994
 	}
995 995
 
996 996
 	public function getHotkeys($hotkeyType = false) {
997
-		if($hotkeyType!==false) {
998
-			if(isset($this->hotkeys[$hotkeyType])) {
997
+		if ($hotkeyType !== false) {
998
+			if (isset($this->hotkeys[$hotkeyType])) {
999 999
 				return $this->hotkeys[$hotkeyType];
1000 1000
 			}
1001 1001
 			else {
@@ -1005,47 +1005,47 @@  discard block
 block discarded – undo
1005 1005
 		return $this->hotkeys;
1006 1006
 	}
1007 1007
 
1008
-	public function setHotkey($hotkeyType,$binding) {
1009
-		if($this->getHotkeys($hotkeyType) == $binding) {
1008
+	public function setHotkey($hotkeyType, $binding) {
1009
+		if ($this->getHotkeys($hotkeyType) == $binding) {
1010 1010
 			return;
1011 1011
 		}
1012 1012
 		$this->hotkeys[$hotkeyType] = $binding;
1013
-		$this->hasChanged=true;
1013
+		$this->hasChanged = true;
1014 1014
 		$this->update();
1015 1015
 	}
1016 1016
 
1017 1017
 	public function isReceivingMessageNotifications($messageTypeID) {
1018
-		return isset($this->messageNotifications[$messageTypeID])?$this->messageNotifications[$messageTypeID]>0:false;
1018
+		return isset($this->messageNotifications[$messageTypeID]) ? $this->messageNotifications[$messageTypeID] > 0 : false;
1019 1019
 	}
1020 1020
 
1021 1021
 	public function getMessageNotifications($messageTypeID) {
1022
-		return isset($this->messageNotifications[$messageTypeID])?$this->messageNotifications[$messageTypeID]:0;
1022
+		return isset($this->messageNotifications[$messageTypeID]) ? $this->messageNotifications[$messageTypeID] : 0;
1023 1023
 	}
1024 1024
 
1025
-	public function setMessageNotifications($messageTypeID,$num) {
1026
-		if($this->getMessageNotifications($messageTypeID) == $num) {
1025
+	public function setMessageNotifications($messageTypeID, $num) {
1026
+		if ($this->getMessageNotifications($messageTypeID) == $num) {
1027 1027
 			return;
1028 1028
 		}
1029
-		$this->messageNotifications[$messageTypeID]=$num;
1030
-		$this->hasChanged=true;
1029
+		$this->messageNotifications[$messageTypeID] = $num;
1030
+		$this->hasChanged = true;
1031 1031
 		$this->update();
1032 1032
 	}
1033 1033
 
1034
-	public function increaseMessageNotifications($messageTypeID,$num) {
1035
-		if($num==0) {
1034
+	public function increaseMessageNotifications($messageTypeID, $num) {
1035
+		if ($num == 0) {
1036 1036
 			return;
1037 1037
 		}
1038
-		if($num<0) {
1038
+		if ($num < 0) {
1039 1039
 			throw new Exception('You cannot increase by a negative amount');
1040 1040
 		}
1041 1041
 		$this->setMessageNotifications($messageTypeID, $this->getMessageNotifications($messageTypeID) + $num);
1042 1042
 	}
1043 1043
 
1044
-	public function decreaseMessageNotifications($messageTypeID,$num) {
1045
-		if($num==0) {
1044
+	public function decreaseMessageNotifications($messageTypeID, $num) {
1045
+		if ($num == 0) {
1046 1046
 			return;
1047 1047
 		}
1048
-		if($num<0) {
1048
+		if ($num < 0) {
1049 1049
 			throw new Exception('You cannot decrease by a negative amount');
1050 1050
 		}
1051 1051
 		$this->setMessageNotifications($messageTypeID, $this->getMessageNotifications($messageTypeID) - $num);
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
 	}
1057 1057
 
1058 1058
 	public function setCenterGalaxyMapOnPlayer($bool) {
1059
-		if($this->centerGalaxyMapOnPlayer == $bool) {
1059
+		if ($this->centerGalaxyMapOnPlayer == $bool) {
1060 1060
 			return;
1061 1061
 		}
1062
-		$this->centerGalaxyMapOnPlayer=$bool;
1063
-		$this->hasChanged=true;
1062
+		$this->centerGalaxyMapOnPlayer = $bool;
1063
+		$this->hasChanged = true;
1064 1064
 		$this->update();
1065 1065
 	}
1066 1066
 
@@ -1069,27 +1069,27 @@  discard block
 block discarded – undo
1069 1069
 	}
1070 1070
 
1071 1071
 	public function isMailBanned() {
1072
-		return $this->mailBanned>TIME;
1072
+		return $this->mailBanned > TIME;
1073 1073
 	}
1074 1074
 
1075 1075
 	public function setMailBanned($time) {
1076
-		if($this->mailBanned == $time) {
1076
+		if ($this->mailBanned == $time) {
1077 1077
 			return;
1078 1078
 		}
1079
-		$this->mailBanned=$time;
1080
-		$this->hasChanged=true;
1079
+		$this->mailBanned = $time;
1080
+		$this->hasChanged = true;
1081 1081
 	}
1082 1082
 
1083 1083
 	public function increaseMailBanned($increaseTime) {
1084
-		$time = max(TIME,$this->getMailBanned());
1085
-		$this->setMailBanned($time+$increaseTime);
1084
+		$time = max(TIME, $this->getMailBanned());
1085
+		$this->setMailBanned($time + $increaseTime);
1086 1086
 	}
1087 1087
 	
1088 1088
 	public function getPermissions() {
1089
-		if(!isset($this->permissions)) {
1089
+		if (!isset($this->permissions)) {
1090 1090
 			$this->permissions = array();
1091 1091
 			$this->db->query('SELECT permission_id FROM account_has_permission WHERE ' . $this->SQL);
1092
-			while($this->db->nextRecord()) {
1092
+			while ($this->db->nextRecord()) {
1093 1093
 				$this->permissions[$this->db->getInt('permission_id')] = true;
1094 1094
 			}
1095 1095
 		}
@@ -1098,28 +1098,28 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
 	public function hasPermission($permissionID = false) {
1100 1100
 		$permissions = $this->getPermissions();
1101
-		if($permissionID === false) {
1101
+		if ($permissionID === false) {
1102 1102
 			return count($permissions) > 0;
1103 1103
 		}
1104 1104
 		return isset($permissions[$permissionID]) ? $permissions[$permissionID] : false;
1105 1105
 	}
1106 1106
 
1107 1107
 	public function getPoints() {
1108
-		if(!isset($this->points)) {
1109
-			$this->points=0;
1108
+		if (!isset($this->points)) {
1109
+			$this->points = 0;
1110 1110
 			$this->db->lockTable('account_has_points');
1111
-			$this->db->query('SELECT * FROM account_has_points WHERE '.$this->SQL.' LIMIT 1');
1112
-			if($this->db->nextRecord()) {
1113
-				$this->points=$this->db->getInt('points');
1111
+			$this->db->query('SELECT * FROM account_has_points WHERE ' . $this->SQL . ' LIMIT 1');
1112
+			if ($this->db->nextRecord()) {
1113
+				$this->points = $this->db->getInt('points');
1114 1114
 				$lastUpdate = $this->db->getInt('last_update');
1115 1115
 				//we are gonna check for reducing points...
1116
-				if($this->points>0 && $lastUpdate < TIME - (7 * 86400)) {
1117
-					$removePoints=0;
1118
-					while($lastUpdate < TIME - (7 * 86400)) {
1116
+				if ($this->points > 0 && $lastUpdate < TIME - (7 * 86400)) {
1117
+					$removePoints = 0;
1118
+					while ($lastUpdate < TIME - (7 * 86400)) {
1119 1119
 						$removePoints++;
1120 1120
 						$lastUpdate += (7 * 86400);
1121 1121
 					}
1122
-					$this->removePoints($removePoints,$lastUpdate);
1122
+					$this->removePoints($removePoints, $lastUpdate);
1123 1123
 				}
1124 1124
 			}
1125 1125
 			$this->db->unlock();
@@ -1127,33 +1127,33 @@  discard block
 block discarded – undo
1127 1127
 		return $this->points;
1128 1128
 	}
1129 1129
 
1130
-	public function setPoints($numPoints,$lastUpdate=false) {
1131
-		$numPoints = max($numPoints,0);
1132
-		if($this->getPoints()==$numPoints) {
1130
+	public function setPoints($numPoints, $lastUpdate = false) {
1131
+		$numPoints = max($numPoints, 0);
1132
+		if ($this->getPoints() == $numPoints) {
1133 1133
 			return;
1134 1134
 		}
1135
-		if ($this->points==0) {
1136
-			$this->db->query('INSERT INTO account_has_points (account_id, points, last_update) VALUES ('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($numPoints).', '.$this->db->escapeNumber($lastUpdate?$lastUpdate:TIME).')');
1137
-		} else if($numPoints<=0) {
1138
-			$this->db->query('DELETE FROM account_has_points WHERE '.$this->SQL.' LIMIT 1');
1135
+		if ($this->points == 0) {
1136
+			$this->db->query('INSERT INTO account_has_points (account_id, points, last_update) VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($numPoints) . ', ' . $this->db->escapeNumber($lastUpdate ? $lastUpdate : TIME) . ')');
1137
+		} else if ($numPoints <= 0) {
1138
+			$this->db->query('DELETE FROM account_has_points WHERE ' . $this->SQL . ' LIMIT 1');
1139 1139
 		} else {
1140
-			$this->db->query('UPDATE account_has_points SET points = '.$this->db->escapeNumber($numPoints).($lastUpdate ? ', last_update = '.$this->db->escapeNumber(TIME) : '').' WHERE '.$this->SQL.' LIMIT 1');
1140
+			$this->db->query('UPDATE account_has_points SET points = ' . $this->db->escapeNumber($numPoints) . ($lastUpdate ? ', last_update = ' . $this->db->escapeNumber(TIME) : '') . ' WHERE ' . $this->SQL . ' LIMIT 1');
1141 1141
 		}
1142
-		$this->points=$numPoints;
1142
+		$this->points = $numPoints;
1143 1143
 	}
1144 1144
 
1145
-	public function removePoints($numPoints,$lastUpdate=false) {
1146
-		if($numPoints>0) {
1147
-			$this->setPoints($this->getPoints()-$numPoints,$lastUpdate);
1145
+	public function removePoints($numPoints, $lastUpdate = false) {
1146
+		if ($numPoints > 0) {
1147
+			$this->setPoints($this->getPoints() - $numPoints, $lastUpdate);
1148 1148
 		}
1149 1149
 	}
1150 1150
 
1151
-	public function addPoints($numPoints,SmrAccount $admin,$reasonID,$suspicion) {
1151
+	public function addPoints($numPoints, SmrAccount $admin, $reasonID, $suspicion) {
1152 1152
 		//do we have points
1153
-		$this->setPoints($this->getPoints() + $numPoints,TIME);
1153
+		$this->setPoints($this->getPoints() + $numPoints, TIME);
1154 1154
 		$totalPoints = $this->getPoints();
1155 1155
 		if ($totalPoints < 10) {
1156
-			return false;//leave scripts its only a warning
1156
+			return false; //leave scripts its only a warning
1157 1157
 		} elseif ($totalPoints < 20) {
1158 1158
 			$days = 2;
1159 1159
 		} elseif ($totalPoints < 30) {
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
 		} elseif ($totalPoints < 50) {
1162 1162
 			$days = 7;
1163 1163
 		} elseif ($totalPoints < 75) {
1164
-			$days = 15 ;
1164
+			$days = 15;
1165 1165
 		} elseif ($totalPoints < 100) {
1166 1166
 			$days = 30;
1167 1167
 		} elseif ($totalPoints < 125) {
@@ -1176,13 +1176,13 @@  discard block
 block discarded – undo
1176 1176
 			$days = 0; //Forever/indefinite
1177 1177
 		}
1178 1178
 
1179
-		if($days==0) {
1179
+		if ($days == 0) {
1180 1180
 			$expireTime = 0;
1181 1181
 		}
1182 1182
 		else {
1183 1183
 			$expireTime = TIME + $days * 86400;
1184 1184
 		}
1185
-		$this->banAccount($expireTime,$admin,$reasonID,$suspicion);
1185
+		$this->banAccount($expireTime, $admin, $reasonID, $suspicion);
1186 1186
 
1187 1187
 		return $days;
1188 1188
 	}
@@ -1209,12 +1209,12 @@  discard block
 block discarded – undo
1209 1209
 		$this->hasChanged = true;
1210 1210
 	}
1211 1211
 
1212
-	public function banAccount($expireTime,SmrAccount $admin,$reasonID,$suspicion,$removeExceptions = false) {
1212
+	public function banAccount($expireTime, SmrAccount $admin, $reasonID, $suspicion, $removeExceptions = false) {
1213 1213
 		$this->db->query('REPLACE INTO account_is_closed
1214 1214
 					(account_id, reason_id, suspicion, expires)
1215
-					VALUES('.$this->db->escapeNumber($this->getAccountID()).', '.$this->db->escapeNumber($reasonID).', '.$this->db->escapeString($suspicion).', '.$this->db->escapeNumber($expireTime).')');
1215
+					VALUES('.$this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber($reasonID) . ', ' . $this->db->escapeString($suspicion) . ', ' . $this->db->escapeNumber($expireTime) . ')');
1216 1216
 		$this->db->lockTable('active_session');
1217
-		$this->db->query('DELETE FROM active_session WHERE '.$this->SQL.' LIMIT 1');
1217
+		$this->db->query('DELETE FROM active_session WHERE ' . $this->SQL . ' LIMIT 1');
1218 1218
 		$this->db->unlock();
1219 1219
 
1220 1220
 		$this->db->query('INSERT INTO account_has_closing_history
@@ -1234,14 +1234,14 @@  discard block
 block discarded – undo
1234 1234
 			$player->update();
1235 1235
 		}
1236 1236
 		$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account closed by ' . $admin->getLogin() . '.');
1237
-		if($removeExceptions!==false) {
1237
+		if ($removeExceptions !== false) {
1238 1238
 			$this->db->query('DELETE FROM account_exceptions WHERE ' . $this->SQL);
1239 1239
 		}
1240 1240
 	}
1241 1241
 
1242
-	public function unbanAccount(SmrAccount $admin = null,$currException=false) {
1242
+	public function unbanAccount(SmrAccount $admin = null, $currException = false) {
1243 1243
 		$adminID = 0;
1244
-		if($admin!==null) {
1244
+		if ($admin !== null) {
1245 1245
 			$adminID = $admin->getAccountID();
1246 1246
 		}
1247 1247
 		$this->db->query('DELETE FROM account_is_closed WHERE ' . $this->SQL . ' LIMIT 1');
@@ -1249,12 +1249,12 @@  discard block
 block discarded – undo
1249 1249
 						(account_id, time, admin_id, action)
1250 1250
 						VALUES(' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeNumber(TIME) . ', ' . $this->db->escapeNumber($adminID) . ', ' . $this->db->escapeString('Opened') . ')');
1251 1251
 		$this->db->query('UPDATE player SET last_turn_update = GREATEST(' . $this->db->escapeNumber(TIME) . ', last_turn_update) WHERE ' . $this->SQL);
1252
-		if($admin!==null) {
1252
+		if ($admin !== null) {
1253 1253
 			$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account reopened by ' . $admin->getLogin() . '.');
1254 1254
 		} else {
1255 1255
 			$this->log(LOG_TYPE_ACCOUNT_CHANGES, 'Account automatically reopened.');
1256 1256
 		}
1257
-		if($currException!==false) {
1257
+		if ($currException !== false) {
1258 1258
 			$this->db->query('REPLACE INTO account_exceptions (account_id, reason)
1259 1259
 							VALUES (' . $this->db->escapeNumber($this->getAccountID()) . ', ' . $this->db->escapeString($currException) . ')');
1260 1260
 		}
@@ -1262,14 +1262,14 @@  discard block
 block discarded – undo
1262 1262
 
1263 1263
 	public function getToggleAJAXHREF() {
1264 1264
 		global $var;
1265
-		return SmrSession::getNewHREF(create_container('skeleton.php','toggle_processing.php',array('toggle'=>'AJAX','referrer'=>$var['body'])));
1265
+		return SmrSession::getNewHREF(create_container('skeleton.php', 'toggle_processing.php', array('toggle'=>'AJAX', 'referrer'=>$var['body'])));
1266 1266
 	}
1267 1267
 
1268 1268
 	public function getUserRankingHREF() {
1269
-		return SmrSession::getNewHREF(create_container('skeleton.php','rankings_view.php'));
1269
+		return SmrSession::getNewHREF(create_container('skeleton.php', 'rankings_view.php'));
1270 1270
 	}
1271 1271
 
1272 1272
 	public function getPersonalHofHREF() {
1273
-		return SmrSession::getNewHREF(create_container('skeleton.php','hall_of_fame_player_detail.php',array('account_id' => $this->getAccountID())));
1273
+		return SmrSession::getNewHREF(create_container('skeleton.php', 'hall_of_fame_player_detail.php', array('account_id' => $this->getAccountID())));
1274 1274
 	}
1275 1275
 }
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -239,8 +239,7 @@  discard block
 block discarded – undo
239 239
 			if(empty($this->hofName)) {
240 240
 				$this->hofName=$this->login;
241 241
 			}
242
-		}
243
-		else {
242
+		} else {
244 243
 			throw new AccountNotFoundException('Account ID '.$accountID.' does not exist!');
245 244
 		}
246 245
 	}
@@ -262,8 +261,7 @@  discard block
 block discarded – undo
262 261
 				'Reason' => $this->db->getField('reason'),
263 262
 				'ReasonID' => $this->db->getInt('reason_id')
264 263
 			);
265
-		}
266
-		else {
264
+		} else {
267 265
 			return false;
268 266
 		}
269 267
 	}
@@ -319,7 +317,9 @@  discard block
 block discarded – undo
319 317
 		if ($curr_ip != 'unknown' && $curr_ip != 'unknown...' && $curr_ip != 'unknown, unknown') {
320 318
 			$curr_ip = $fi.'.'.$se.'.'.$th.'.'.$fo;
321 319
 			$host = gethostbyaddr($curr_ip);
322
-		} else $host = 'unknown';
320
+		} else {
321
+			$host = 'unknown';
322
+		}
323 323
 
324 324
 		// save...first make sure there isn't one for these keys (someone could double click and get error)
325 325
 		$this->db->query('REPLACE INTO account_has_ip (account_id, time, ip, host) VALUES ('.$this->db->escapeNumber($this->account_id).', '.$this->db->escapeNumber(TIME).', '.$this->db->escapeString($curr_ip).', '.$this->db->escapeString($host).')');
@@ -997,8 +997,7 @@  discard block
 block discarded – undo
997 997
 		if($hotkeyType!==false) {
998 998
 			if(isset($this->hotkeys[$hotkeyType])) {
999 999
 				return $this->hotkeys[$hotkeyType];
1000
-			}
1001
-			else {
1000
+			} else {
1002 1001
 				return array();
1003 1002
 			}
1004 1003
 		}
@@ -1178,8 +1177,7 @@  discard block
 block discarded – undo
1178 1177
 
1179 1178
 		if($days==0) {
1180 1179
 			$expireTime = 0;
1181
-		}
1182
-		else {
1180
+		} else {
1183 1181
 			$expireTime = TIME + $days * 86400;
1184 1182
 		}
1185 1183
 		$this->banAccount($expireTime,$admin,$reasonID,$suspicion);
Please login to merge, or discard this patch.