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

Completed
Branch master (287493)
by Dan
06:08
created
tools/testDistancePlotters.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -8,50 +8,50 @@  discard block
 block discarded – undo
8 8
 function testDistances($gameID)
9 9
 {
10 10
 	//Initialise cache for fairness
11
-	$galaxies =& SmrGalaxy::getGameGalaxies($gameID);
11
+	$galaxies = & SmrGalaxy::getGameGalaxies($gameID);
12 12
 	$galaxySectors = array();
13
-	foreach($galaxies as &$galaxy)
13
+	foreach ($galaxies as &$galaxy)
14 14
 	{
15
-		$galaxiesSectors[] =& $galaxy->getSectors();
15
+		$galaxiesSectors[] = & $galaxy->getSectors();
16 16
 	} unset($galaxy);
17
-	foreach($galaxiesSectors as &$galaxySectors)
17
+	foreach ($galaxiesSectors as &$galaxySectors)
18 18
 	{
19
-		foreach($galaxySectors as &$galaxySector)
19
+		foreach ($galaxySectors as &$galaxySector)
20 20
 		{
21
-			if($galaxySector->hasPort())
21
+			if ($galaxySector->hasPort())
22 22
 				$galaxySector->getPort();
23 23
 		} unset($galaxySector);
24 24
 	} unset($galaxySectors);
25 25
 	//Test plotters
26 26
 	$newTime = 0;
27 27
 	$oldTime = 0;
28
-	foreach($galaxiesSectors as &$galaxySectors)
28
+	foreach ($galaxiesSectors as &$galaxySectors)
29 29
 	{
30
-		foreach($galaxySectors as &$galaxySector)
30
+		foreach ($galaxySectors as &$galaxySector)
31 31
 		{
32
-			if($galaxySector->hasPort())
32
+			if ($galaxySector->hasPort())
33 33
 			{
34
-				$goodIDs =& $galaxySector->getPort()->getAllGoodIDs();
35
-				foreach($goodIDs as $goodID)
34
+				$goodIDs = & $galaxySector->getPort()->getAllGoodIDs();
35
+				foreach ($goodIDs as $goodID)
36 36
 				{
37 37
 					$transaction = $galaxySector->getPort->getGoodTransaction($goodID);
38 38
 					$time = microtime(true);
39
-					$newDI = getGoodDistanceNew($galaxySector,$goodID,$transaction);
39
+					$newDI = getGoodDistanceNew($galaxySector, $goodID, $transaction);
40 40
 					$newTime += microtime(true) - $time;
41 41
 					
42 42
 					$time = microtime(true);
43
-					$oldDI = getGoodDistanceOld($galaxySector,$goodID,$transaction);
43
+					$oldDI = getGoodDistanceOld($galaxySector, $goodID, $transaction);
44 44
 					$oldTime += microtime(true) - $time;
45 45
 					
46
-					if($newDI!=$oldDI)
46
+					if ($newDI != $oldDI)
47 47
 					{
48
-						echo 'Difference, new: '.$newDI.', old:'.$oldDI.', sector:'.$galaxySector->getSectorID().', good:'.$goodID.EOL;
48
+						echo 'Difference, new: ' . $newDI . ', old:' . $oldDI . ', sector:' . $galaxySector->getSectorID() . ', good:' . $goodID . EOL;
49 49
 					}
50 50
 				}
51 51
 			}
52 52
 		} unset($galaxySector);
53 53
 	} unset($galaxySectors);
54
-	echo 'New time: '.$newTime.', old time:'.$oldTime.EOL;
54
+	echo 'New time: ' . $newTime . ', old time:' . $oldTime . EOL;
55 55
 }
56 56
 
57 57
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		return $var['good_distance'];
70 70
 	}
71 71
 	$x = Globals::getGood($goodID);
72
-	switch($transaction)
72
+	switch ($transaction)
73 73
 	{
74 74
 		case 'Buy':
75 75
 			$x['TransactionType'] = 'Sell';
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 			$x['TransactionType'] = 'Buy';
79 79
 	}
80 80
 	$di = Plotter::findDistanceToX($x, $sector, true);
81
-	if(is_object($di))
81
+	if (is_object($di))
82 82
 		$di = $di->getRelativeDistance();
83 83
 	$container['good_distance'] = $di;
84 84
 	return $di;
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		$distance = $sector_distance[$curr_sector_id];
115 115
 
116 116
 		// create a new sector object
117
-		$curr_sector =& SmrSector::getSector($sector->getGameID(), $curr_sector_id);
117
+		$curr_sector = & SmrSector::getSector($sector->getGameID(), $curr_sector_id);
118 118
 
119 119
 		// does the current sector buy/sell the good we're looking for?
120 120
         if ($good_distance != 0) {
Please login to merge, or discard this patch.
tools/rerunChessGames.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -6,21 +6,21 @@
 block discarded – undo
6 6
 $db = new SmrMySqlDatabase();
7 7
 $db->query('DELETE FROM player_hof WHERE type LIKE \'Chess%\'');
8 8
 $db->query('SELECT chess_game_id FROM chess_game');
9
-while($db->nextRecord()) {
9
+while ($db->nextRecord()) {
10 10
 	$chessGameID = $db->getInt('chess_game_id');
11
-	$game =& ChessGame::getChessGame($chessGameID);
12
-	echo 'Running game ' . $chessGameID . ' for white id "' . $game->getWhiteID() . '", black id "' . $game->getBlackID() .'", winner "' . $game->getWinner() . '"' . EOL;
11
+	$game = & ChessGame::getChessGame($chessGameID);
12
+	echo 'Running game ' . $chessGameID . ' for white id "' . $game->getWhiteID() . '", black id "' . $game->getBlackID() . '", winner "' . $game->getWinner() . '"' . EOL;
13 13
 	echoChessMoves($game);
14 14
 	
15 15
 	$game->rerunGame(true);
16
-	echo 'Finished game ' . $chessGameID . ' for white id "' . $game->getWhiteID() . '", black id "' . $game->getBlackID() .'", winner "' . $game->getWinner() . '"' . EOL;
16
+	echo 'Finished game ' . $chessGameID . ' for white id "' . $game->getWhiteID() . '", black id "' . $game->getBlackID() . '", winner "' . $game->getWinner() . '"' . EOL;
17 17
 	echoChessMoves($game);
18 18
 }
19 19
 
20 20
 function echoChessMoves($game) {
21 21
 	echo 'Moves: ' . EOL;
22 22
 	$moves = $game->getMoves();
23
-	foreach($moves as $move) {
23
+	foreach ($moves as $move) {
24 24
 		echo $move . EOL;
25 25
 	}
26 26
 	echo EOL;
Please login to merge, or discard this patch.
lib/autoload.inc 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,17 +54,17 @@
 block discarded – undo
54 54
 
55 55
 	$startPaths = array(ENGINE, LIB, ADMIN);
56 56
 	$midPaths = array($gameDir, 'Default/');
57
-	foreach($midPaths as $midPath) {
58
-		foreach($startPaths as $startPath) {
57
+	foreach ($midPaths as $midPath) {
58
+		foreach ($startPaths as $startPath) {
59 59
 			$filePath = $startPath . $midPath . $fileName;
60
-			if(is_file($filePath) && is_readable($filePath)) {
60
+			if (is_file($filePath) && is_readable($filePath)) {
61 61
 				$cache[$cacheKey] = $filePath;
62 62
 				return $filePath;
63 63
 			}
64 64
 		}
65 65
 	}
66 66
 	$filePath = WWW . $fileName;
67
-	if(is_file($filePath) && is_readable($filePath)) {
67
+	if (is_file($filePath) && is_readable($filePath)) {
68 68
 		$cache[$cacheKey] = $filePath;
69 69
 		return WWW . $fileName;
70 70
 	}
Please login to merge, or discard this patch.
lib/Default/DummyPlayer.class.inc 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -1,31 +1,31 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 class DummyPlayer extends AbstractSmrPlayer {
4
-	public function __construct($gameID=0,$playerName='Dummy',$raceID=1,$experience=1000,$alignment=100,$allianceID=0,$shipTypeID=60) {
4
+	public function __construct($gameID = 0, $playerName = 'Dummy', $raceID = 1, $experience = 1000, $alignment = 100, $allianceID = 0, $shipTypeID = 60) {
5 5
 		parent::__construct();
6 6
 		$this->accountID				= 0;
7
-		$this->gameID					= (int) $gameID;
8
-		$this->playerName				= (string) $playerName;
7
+		$this->gameID = (int)$gameID;
8
+		$this->playerName = (string)$playerName;
9 9
 		$this->playerID					= 0;
10 10
 		$this->sectorID					= 0;
11
-		$this->lastSectorID				= 0;
11
+		$this->lastSectorID = 0;
12 12
 		$this->turns					= 1000;
13
-		$this->newbieTurns				= 0;
13
+		$this->newbieTurns = 0;
14 14
 		$this->lastNewsUpdate			= 0;
15 15
 		$this->dead						= false;
16 16
 		$this->landedOnPlanet			= false;
17
-		$this->lastActive				= 0;
18
-		$this->lastCPLAction			= 0;
19
-		$this->raceID					= (int) $raceID;
20
-		$this->credits					= 0;
21
-		$this->experience				= (int) $experience;
22
-		$this->alignment				= (int) $alignment;
23
-		$this->militaryPayment			= 0;
24
-		$this->allianceID				= (int) $allianceID;
25
-		$this->shipID					= (int) $shipTypeID;
17
+		$this->lastActive = 0;
18
+		$this->lastCPLAction = 0;
19
+		$this->raceID = (int)$raceID;
20
+		$this->credits = 0;
21
+		$this->experience				= (int)$experience;
22
+		$this->alignment = (int)$alignment;
23
+		$this->militaryPayment = 0;
24
+		$this->allianceID				= (int)$allianceID;
25
+		$this->shipID					= (int)$shipTypeID;
26 26
 		$this->kills					= 0;
27 27
 		$this->deaths					= 0;
28
-		$this->lastPort					= 0;
28
+		$this->lastPort = 0;
29 29
 		$this->bank						= 0;
30 30
 		$this->zoom						= 0;
31 31
 		
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	}
91 91
 	
92 92
 	public function setAllianceID($ID) {
93
-		if($this->allianceID == $ID)
93
+		if ($this->allianceID == $ID)
94 94
 			return;
95
-		$this->allianceID=$ID;
95
+		$this->allianceID = $ID;
96 96
 	}
97 97
 	
98 98
 	public function &killPlayerByPlayer(AbstractSmrPlayer $killer) {
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 //		$this->sendMessage($killer->getAccountID(),MSG_PLAYER,'You <span class="red">DESTROYED</span> ' . $this->getPlayerName() . ' in sector <span class="blue">#' . $this->getSectorID() . '</span>',false);
127 127
 		
128 128
 		// The person who got the kill gains experience
129
-		$gainedExp = ceil(0.75*((((($this->getLevelID() - $killer->getLevelID()) / max($this->getLevelID(), $killer->getLevelID())) + 1) * 0.04 * $this->getExperience()) + (0.025 * $this->getExperience())));
129
+		$gainedExp = ceil(0.75 * ((((($this->getLevelID() - $killer->getLevelID()) / max($this->getLevelID(), $killer->getLevelID())) + 1) * 0.04 * $this->getExperience()) + (0.025 * $this->getExperience())));
130 130
 		
131 131
 		$return['KillerExp'] = $gainedExp;
132 132
 		$killer->increaseExperience($gainedExp);
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		// Dead player loses experience
136 136
 		$expLossPercentage = 0.20 + (($this->getLevelID() - $killer->getLevelID()) * 0.005);
137 137
 		$return['DeadExp'] = 0;
138
-		if($expLossPercentage > 0) {
138
+		if ($expLossPercentage > 0) {
139 139
 			$lostExp = floor($this->getExperience() * $expLossPercentage);
140 140
 			$return['DeadExp'] = $lostExp;
141 141
 			$this->decreaseExperience($lostExp);
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 		$relation = $relations[$killer->getRaceID()];
153 153
 
154 154
 		$alignChangePerRelation = 0.1;
155
-		if($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR)
155
+		if ($relation >= RELATIONS_PEACE || $relation <= RELATIONS_WAR)
156 156
 			$alignChangePerRelation = 0.04;
157 157
 
158 158
 		$alignChange = $relation * $alignChangePerRelation;
159 159
 		$return['KillerAlign'] = $alignChange;
160
-		if($alignChange>0)
160
+		if ($alignChange > 0)
161 161
 			$killer->increaseAlignment($alignChange);
162 162
 		else
163 163
 			$killer->decreaseAlignment(-$alignChange);
164 164
 		// War setting gives them military pay
165
-		if($relation <= RELATIONS_WAR) {
166
-			$killer->increaseMilitaryPayment(-floor($relation * 100 * (pow($gainedExp/2,0.25))));
165
+		if ($relation <= RELATIONS_WAR) {
166
+			$killer->increaseMilitaryPayment(-floor($relation * 100 * (pow($gainedExp / 2, 0.25))));
167 167
 		}
168 168
 		
169 169
 		//check for federal bounty being offered for current port raiders
@@ -192,17 +192,17 @@  discard block
 block discarded – undo
192 192
 
193 193
 		// If the alignment difference is greater than 200 then a bounty may be set
194 194
 		$alignment_diff = abs($this->getAlignment() - $killer->getAlignment());
195
-		if($alignment_diff >= 200) {
195
+		if ($alignment_diff >= 200) {
196 196
 			// If the podded players alignment makes them deputy or member then set bounty
197
-			if($this->getAlignment() >= 100) {
197
+			if ($this->getAlignment() >= 100) {
198 198
 				$bounty_type = 'HQ';
199 199
 			}
200 200
 			else if ($this->getAlignment() <= 100) {
201 201
 				$bounty_type = 'UG';
202 202
 			}
203 203
 
204
-			if(isset($bounty_type)) {
205
-				$killer->increaseCurrentBountyAmount($bounty_type,floor(pow($alignment_diff, 2.56)));
204
+			if (isset($bounty_type)) {
205
+				$killer->increaseCurrentBountyAmount($bounty_type, floor(pow($alignment_diff, 2.56)));
206 206
 			}
207 207
 		}
208 208
 		
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		$db = new SmrMySqlDatabase();
251 251
 		$db->query('REPLACE INTO cached_dummys ' .
252 252
 					'(type, id, info) ' .
253
-					'VALUES (\'DummyPlayer\', '.$db->escapeString($this->getPlayerName()).', '.$db->escapeString($cache).')');	
253
+					'VALUES (\'DummyPlayer\', ' . $db->escapeString($this->getPlayerName()) . ', ' . $db->escapeString($cache) . ')');	
254 254
 		 unserialize($cache);
255 255
 	}
256 256
 	
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 		$db->query('SELECT info FROM cached_dummys
260 260
 					WHERE type = \'DummyPlayer\'
261 261
 						AND id = ' . $db->escapeString($name) . ' LIMIT 1');
262
-		if($db->nextRecord()) {
262
+		if ($db->nextRecord()) {
263 263
 			$return = unserialize($db->getField('info'));
264 264
 			return $return;
265 265
 		}
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 		$db->query('SELECT id FROM cached_dummys
275 275
 					WHERE type = \'DummyPlayer\'');
276 276
 		$dummyNames = array();
277
-		while($db->nextRecord()) {
277
+		while ($db->nextRecord()) {
278 278
 			$dummyNames[] = $db->getField('id');
279 279
 		}
280 280
 		return $dummyNames;
Please login to merge, or discard this patch.
lib/Default/SmrScoutDrones.class.inc 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 class SmrScoutDrones extends AbstractSmrCombatWeapon {
4 4
 	protected $numberOfSDs;
5 5
 	
6
-	public function __construct($gameTypeID,$numberOfSDs) {
6
+	public function __construct($gameTypeID, $numberOfSDs) {
7 7
 		$this->gameTypeID = $gameTypeID;
8 8
 		$this->numberOfSDs = $numberOfSDs;
9 9
 		$this->name = 'Scout Drones';
@@ -25,19 +25,19 @@  discard block
 block discarded – undo
25 25
 		return $modifiedAccuracy;
26 26
 	}
27 27
 	
28
-	public function getModifiedForceAccuracyAgainstPlayer(SmrForce $forces,AbstractSmrPlayer $targetPlayer) {
29
-		return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces,$targetPlayer,mt_rand(1,7) * mt_rand(1,7));
28
+	public function getModifiedForceAccuracyAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer) {
29
+		return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces, $targetPlayer, mt_rand(1, 7) * mt_rand(1, 7));
30 30
 	}
31 31
 	
32
-	protected function getModifiedForceAccuracyAgainstPlayerUsingRandom(SmrForce $forces,AbstractSmrPlayer $targetPlayer, $random) {
32
+	protected function getModifiedForceAccuracyAgainstPlayerUsingRandom(SmrForce $forces, AbstractSmrPlayer $targetPlayer, $random) {
33 33
 		$modifiedAccuracy = $this->getModifiedAccuracy();
34 34
 		$modifiedAccuracy -= $targetPlayer->getLevelID() + $random;
35 35
 	
36
-		return max(0,min(100,$modifiedAccuracy));
36
+		return max(0, min(100, $modifiedAccuracy));
37 37
 	}
38 38
 	
39
-	public function getMaxModifiedForceAccuracyAgainstPlayer(SmrForce $forces,AbstractSmrPlayer $targetPlayer) {
40
-		return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces,$targetPlayer,49);
39
+	public function getMaxModifiedForceAccuracyAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer) {
40
+		return $this->getModifiedForceAccuracyAgainstPlayerUsingRandom($forces, $targetPlayer, 49);
41 41
 	}
42 42
 	
43 43
 	public function &getModifiedDamage() {
@@ -76,12 +76,12 @@  discard block
 block discarded – undo
76 76
 	}
77 77
 	
78 78
 	public function &getModifiedForceDamageAgainstPlayer(SmrForce $forces, AbstractSmrPlayer $targetPlayer) {
79
-		if(!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods.
79
+		if (!$this->canShootTraders()) { // If we can't shoot traders then just return a damageless array and don't waste resources calculated any damage mods.
80 80
 			$return = array('MaxDamage' => 0, 'Shield' => 0, 'Armour' => 0, 'Rollover' => $this->isDamageRollover());
81 81
 			return $return;
82 82
 		}
83
-		$damage =& $this->getModifiedDamage();
84
-		$damage['Launched'] = ceil($this->getNumberOfSDs() * $this->getModifiedForceAccuracyAgainstPlayer($forces,$targetPlayer) / 100);
83
+		$damage = & $this->getModifiedDamage();
84
+		$damage['Launched'] = ceil($this->getNumberOfSDs() * $this->getModifiedForceAccuracyAgainstPlayer($forces, $targetPlayer) / 100);
85 85
 		$damage['MaxDamage'] = ceil($damage['Launched'] * $damage['MaxDamage']);
86 86
 		$damage['Shield'] = ceil($damage['Launched'] * $damage['Shield']);
87 87
 		$damage['Armour'] = ceil($damage['Launched'] * $damage['Armour']);
Please login to merge, or discard this patch.
lib/Default/SmrSession.class.inc 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('USING_AJAX'))
4
-	define('USING_AJAX',false);
3
+if (!defined('USING_AJAX'))
4
+	define('USING_AJAX', false);
5 5
 class SmrSession {
6 6
 	const ALWAYS_AVAILABLE = 999999;
7 7
 	const TIME_BEFORE_EXPIRY = 3600;
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	public static $lastSN;
141 141
 
142 142
 	protected static $previousAjaxReturns;
143
-	protected static $ajaxReturns=array();
143
+	protected static $ajaxReturns = array();
144 144
 
145 145
 	public static function init() {
146 146
 		// Initialize the db connector here, since `init` is always called
@@ -153,9 +153,9 @@  discard block
 block discarded – undo
153 153
 		else {
154 154
 			// create a new session id
155 155
 			do {
156
-				self::$session_id = md5 (uniqid (mt_rand()) );
156
+				self::$session_id = md5(uniqid(mt_rand()));
157 157
 				self::$db->query('SELECT 1 FROM active_session WHERE session_id = ' . self::$db->escapeString(self::$session_id) . ' LIMIT 1');
158
-			} while(self::$db->nextRecord()); //Make sure we haven't somehow clashed with someone else's session.
158
+			} while (self::$db->nextRecord()); //Make sure we haven't somehow clashed with someone else's session.
159 159
 			setcookie('session_id', self::$session_id);
160 160
 		}
161 161
 
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 		self::$db->query('DELETE FROM active_session WHERE last_accessed < ' . self::$db->escapeNumber(time() - self::TIME_BEFORE_EXPIRY));
164 164
 		self::fetchVarInfo();
165 165
 
166
-		if(!USING_AJAX && isset($_REQUEST['sn']) && isset(self::$var[$_REQUEST['sn']]) && !empty(self::$var[$_REQUEST['sn']])) {
166
+		if (!USING_AJAX && isset($_REQUEST['sn']) && isset(self::$var[$_REQUEST['sn']]) && !empty(self::$var[$_REQUEST['sn']])) {
167 167
 			$var = self::$var[$_REQUEST['sn']];
168 168
 			$currentPage = $var['url'] == 'skeleton.php' ? $var['body'] : $var['url'];
169 169
 			$loadDelay = isset(self::URL_LOAD_DELAY[$currentPage]) ? self::URL_LOAD_DELAY[$currentPage] : 0;
170 170
 			$initialTimeBetweenLoads = microtime(true) - $var['PreviousRequestTime'];
171
-			while(($timeBetweenLoads = microtime(true) - $var['PreviousRequestTime']) < $loadDelay) {
172
-				$sleepTime = round(($loadDelay-$timeBetweenLoads)*1000000);
171
+			while (($timeBetweenLoads = microtime(true) - $var['PreviousRequestTime']) < $loadDelay) {
172
+				$sleepTime = round(($loadDelay - $timeBetweenLoads) * 1000000);
173 173
 			//	echo 'Sleeping for: ' . $sleepTime . 'us';
174 174
 				usleep($sleepTime);
175 175
 			}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			self::$session_id		= self::$db->getField('session_id');
187 187
 			self::$account_id		= self::$db->getInt('account_id');
188 188
 			self::$game_id			= self::$db->getInt('game_id');
189
-			self::$last_accessed	= self::$db->getInt('last_accessed');
189
+			self::$last_accessed = self::$db->getInt('last_accessed');
190 190
 			self::$var = @unserialize(@gzuncompress(self::$db->getField('session_var')));
191 191
 			self::$commonIDs	= array();
192 192
 			self::$lastSN = self::$db->getField('last_sn');
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
 			if (!empty($ajaxReturns)) {
196 196
 				self::$previousAjaxReturns = unserialize(gzuncompress($ajaxReturns));
197 197
 			}
198
-			if(!is_array(self::$var)) {
199
-				self::$account_id	= 0;
200
-				self::$game_id		= 0;
201
-				self::$var			= array();
198
+			if (!is_array(self::$var)) {
199
+				self::$account_id = 0;
200
+				self::$game_id = 0;
201
+				self::$var = array();
202 202
 			}
203 203
 			else {
204
-				foreach(self::$var as $key => &$value) {
204
+				foreach (self::$var as $key => &$value) {
205 205
 					if ($value['Expires'] > 0 && $value['Expires'] <= TIME) { // Use 0 for infinity
206 206
 						//This link is no longer valid
207 207
 						unset(self::$var[$key]);
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 					}
213 213
 					else {
214 214
 						--$value['RemainingPageLoads'];
215
-						if(isset($value['CommonID'])) {
215
+						if (isset($value['CommonID'])) {
216 216
 							self::$commonIDs[$value['CommonID']] = $key;
217 217
 						}
218 218
 					}
@@ -221,25 +221,25 @@  discard block
 block discarded – undo
221 221
 		}
222 222
 		else {
223 223
 			self::$generate = true;
224
-			self::$account_id	= 0;
224
+			self::$account_id = 0;
225 225
 			self::$game_id		= 0;
226
-			self::$var			= array();
227
-			self::$commonIDs	= array();
226
+			self::$var = array();
227
+			self::$commonIDs = array();
228 228
 		}
229 229
 	}
230 230
 
231 231
 	public static function update() {
232
-		foreach(self::$var as $key => &$value) {
232
+		foreach (self::$var as $key => &$value) {
233 233
 			if ($value['RemainingPageLoads'] <= 0) {
234 234
 				//This link was valid this load but will not be in the future, removing it now saves database space and data transfer.
235 235
 				unset(self::$var[$key]);
236 236
 			}
237 237
 		} unset($value);
238 238
 		$compressed = gzcompress(serialize(self::$var));
239
-		if(!self::$generate) {
239
+		if (!self::$generate) {
240 240
 			self::$db->query('UPDATE active_session SET account_id=' . self::$db->escapeNumber(self::$account_id) . ',game_id=' . self::$db->escapeNumber(self::$game_id) . (!USING_AJAX ? ',last_accessed=' . self::$db->escapeNumber(TIME) : '') . ',session_var=' . self::$db->escapeBinary($compressed) .
241
-					',last_sn='.self::$db->escapeString(self::$SN).
242
-					' WHERE session_id=' . self::$db->escapeString(self::$session_id) . (USING_AJAX ? ' AND last_sn='.self::$db->escapeString(self::$lastSN) : '') . ' LIMIT 1');
241
+					',last_sn=' . self::$db->escapeString(self::$SN) .
242
+					' WHERE session_id=' . self::$db->escapeString(self::$session_id) . (USING_AJAX ? ' AND last_sn=' . self::$db->escapeString(self::$lastSN) : '') . ' LIMIT 1');
243 243
 		}
244 244
 		else {
245 245
 			self::$db->query('DELETE FROM active_session WHERE account_id = ' . self::$db->escapeNumber(self::$account_id) . ' AND game_id = ' . self::$db->escapeNumber(self::$game_id));
@@ -276,8 +276,8 @@  discard block
 block discarded – undo
276 276
 	}
277 277
 
278 278
 	public static function updateSN() {
279
-		if(!USING_AJAX)
280
-			self::$db->query('UPDATE active_session SET last_sn='.self::$db->escapeString(self::$SN).
279
+		if (!USING_AJAX)
280
+			self::$db->query('UPDATE active_session SET last_sn=' . self::$db->escapeString(self::$SN) .
281 281
 				' WHERE session_id=' . self::$db->escapeString(self::$session_id) . ' LIMIT 1');
282 282
 	}
283 283
 
@@ -289,11 +289,11 @@  discard block
 block discarded – undo
289 289
 	}
290 290
 
291 291
 	public static function retrieveVar($sn) {
292
-		if(!isset(self::$var[$sn]) || empty(self::$var[$sn]))
292
+		if (!isset(self::$var[$sn]) || empty(self::$var[$sn]))
293 293
 			return false;
294 294
 		self::$SN = $sn;
295 295
 		SmrSession::updateSN();
296
-		if(isset(self::$var[$sn]['body']) && isset(self::$var[$sn]['CommonID'])) {
296
+		if (isset(self::$var[$sn]['body']) && isset(self::$var[$sn]['CommonID'])) {
297 297
 //			if(preg_match('/processing/',self::$var[$sn]['body']))
298 298
 			unset(self::$commonIDs[self::$var[$sn]['CommonID']]); //Do not store common id for current page
299 299
 			unset(self::$var[$sn]['CommonID']);
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * session so that it can still be retrieved when the page auto-refreshes.
310 310
 	 * This is the recommended way to get $_REQUEST data.
311 311
 	 */
312
-	public static function getRequestVar($varName, $default=null) {
312
+	public static function getRequestVar($varName, $default = null) {
313 313
 		global $var;
314 314
 		// Set the session var, if in $_REQUESTS or if a default is given
315 315
 		if (isset($_REQUEST[$varName])) {
@@ -325,31 +325,31 @@  discard block
 block discarded – undo
325 325
 
326 326
 	public static function resetLink($container, $sn) { //Do not allow sharing SN, useful for forwarding.
327 327
 		global $lock;
328
-		if(isset(self::$var[$sn]['CommonID'])) {
328
+		if (isset(self::$var[$sn]['CommonID'])) {
329 329
 			unset(self::$commonIDs[self::$var[$sn]['CommonID']]); //Do not store common id for reset page, to allow refreshing to always give the same page in response
330 330
 		}
331 331
 		self::$SN = $sn;
332
-		if(!isset($container['Expires'])) {
332
+		if (!isset($container['Expires'])) {
333 333
 			$container['Expires'] = 0; // Lasts forever
334 334
 		}
335
-		if(!isset($container['RemainingPageLoads'])) {
335
+		if (!isset($container['RemainingPageLoads'])) {
336 336
 			$container['RemainingPageLoads'] = 1; // Allow refreshing
337 337
 		}
338
-		if(!isset($container['PreviousRequestTime'])) {
339
-			if(isset(self::$var[$sn]['PreviousRequestTime'])) {
338
+		if (!isset($container['PreviousRequestTime'])) {
339
+			if (isset(self::$var[$sn]['PreviousRequestTime'])) {
340 340
 				$container['PreviousRequestTime'] = self::$var[$sn]['PreviousRequestTime']; // Copy across the previous request time if not explicitly set.
341 341
 			}
342 342
 		}
343 343
 
344 344
 		self::$var[$sn] = $container;
345
-		if(!$lock && !USING_AJAX)
345
+		if (!$lock && !USING_AJAX)
346 346
 			self::update();
347 347
 		return $sn;
348 348
 	}
349 349
 
350
-	public static function updateVar($key,$value) {
350
+	public static function updateVar($key, $value) {
351 351
 		global $var;
352
-		if($value===null) {
352
+		if ($value === null) {
353 353
 			unset($var[$key]);
354 354
 			unset(self::$var[self::$SN][$key]);
355 355
 		}
@@ -365,15 +365,15 @@  discard block
 block discarded – undo
365 365
 	}
366 366
 
367 367
 	public static function addLink($container, $sn = false) { // Container['ID'] MUST be unique to a specific action, if there will be two different outcomes from containers given the same ID then problems will likely arise.
368
-		if(!isset($container['Expires'])) {
368
+		if (!isset($container['Expires'])) {
369 369
 			$container['Expires'] = 0; // Lasts forever
370 370
 		}
371
-		if(!isset($container['RemainingPageLoads'])) {
371
+		if (!isset($container['RemainingPageLoads'])) {
372 372
 			$pageURL = $container['url'] == 'skeleton.php' ? $container['body'] : $container['url'];
373 373
 			$container['RemainingPageLoads'] = isset(self::URL_DEFAULT_REMAINING_PAGE_LOADS[$pageURL]) ? self::URL_DEFAULT_REMAINING_PAGE_LOADS[$pageURL] : 1; // Allow refreshing
374 374
 		}
375 375
 
376
-		if($sn === false) {
376
+		if ($sn === false) {
377 377
 			$sn = self::generateSN($container);
378 378
 		}
379 379
 		else {
@@ -386,14 +386,14 @@  discard block
 block discarded – undo
386 386
 
387 387
 	protected static function generateSN(&$container) {
388 388
 		$container['CommonID'] = self::getCommonID($container);
389
-		if(isset(self::$commonIDs[$container['CommonID']])) {
389
+		if (isset(self::$commonIDs[$container['CommonID']])) {
390 390
 			$sn = self::$commonIDs[$container['CommonID']];
391 391
 			$container['PreviousRequestTime'] = isset(self::$var[$sn]) ? self::$var[$sn]['PreviousRequestTime'] : MICRO_TIME;
392 392
 		}
393 393
 		else {
394 394
 			do {
395
-				$sn = substr(md5(mt_rand()),0,8);
396
-			} while(isset(self::$var[$sn]));
395
+				$sn = substr(md5(mt_rand()), 0, 8);
396
+			} while (isset(self::$var[$sn]));
397 397
 			$container['PreviousRequestTime'] = MICRO_TIME;
398 398
 		}
399 399
 		self::$commonIDs[$container['CommonID']] = $sn;
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
 		return md5(serialize($commonContainer));
409 409
 	}
410 410
 
411
-	public static function getNewHREF($container, $forceFullURL=false) {
412
-		$sn = self::addLink($container) . (isset($container['AJAX']) && $container['AJAX'] == true ? '&ajax=1':'');
413
-		if($forceFullURL===true||stripos($_SERVER['REQUEST_URI'],'loader.php')===false)
411
+	public static function getNewHREF($container, $forceFullURL = false) {
412
+		$sn = self::addLink($container) . (isset($container['AJAX']) && $container['AJAX'] == true ? '&ajax=1' : '');
413
+		if ($forceFullURL === true || stripos($_SERVER['REQUEST_URI'], 'loader.php') === false)
414 414
 			return '/loader.php?sn=' . $sn;
415 415
 		else
416 416
 			return '?sn=' . $sn;
417 417
 	}
418 418
 
419
-	public static function addAjaxReturns($element,$contents) {
419
+	public static function addAjaxReturns($element, $contents) {
420 420
 		self::$ajaxReturns[$element] = $contents;
421
-		return isset(self::$previousAjaxReturns[$element])&&self::$previousAjaxReturns[$element]==$contents;
421
+		return isset(self::$previousAjaxReturns[$element]) && self::$previousAjaxReturns[$element] == $contents;
422 422
 	}
423 423
 
424 424
 	public static function saveAjaxReturns() {
425
-		if(empty(self::$ajaxReturns))
425
+		if (empty(self::$ajaxReturns))
426 426
 			return;
427 427
 		$compressed = gzcompress(serialize(self::$ajaxReturns));
428 428
 		self::$db->query('UPDATE active_session SET ajax_returns=' . self::$db->escapeBinary($compressed) .
Please login to merge, or discard this patch.
lib/Default/Council.class.inc 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@  discard block
 block discarded – undo
9 9
 	}
10 10
 
11 11
 	protected static function initialiseDatabase() {
12
-		if(self::$db==null)
12
+		if (self::$db == null)
13 13
 			self::$db = new SmrMySqlDatabase();
14 14
 	}
15 15
 
16 16
 	/**
17 17
 	 * Returns an array of Account ID's of the Council for this race.
18 18
 	 */
19
-	public static function &getRaceCouncil($gameID,$raceID) {
19
+	public static function &getRaceCouncil($gameID, $raceID) {
20 20
 		if (!isset(self::$COUNCILS[$gameID][$raceID])) {
21 21
 			self::initialiseDatabase();
22 22
 			self::$COUNCILS[$gameID][$raceID] = array();
23 23
 			self::$PRESIDENTS[$gameID][$raceID] = false;
24 24
 
25
-			$i=1;
25
+			$i = 1;
26 26
 			self::$db->query('SELECT account_id, alignment
27 27
 								FROM player
28 28
 								WHERE game_id = ' . self::$db->escapeNumber($gameID) . '
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 									AND npc = \'FALSE\'
31 31
 								ORDER by experience DESC
32 32
 								LIMIT ' . MAX_COUNCIL_MEMBERS);
33
-			while(self::$db->nextRecord()) {
33
+			while (self::$db->nextRecord()) {
34 34
 				// Add this player to the council
35 35
 				self::$COUNCILS[$gameID][$raceID][$i++] = self::$db->getInt('account_id');
36 36
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		return self::$PRESIDENTS[$gameID][$raceID];
57 57
 	}
58 58
 
59
-	public static function isOnCouncil($gameID,$raceID,$accountID) {
60
-		return in_array($accountID,self::getRaceCouncil($gameID,$raceID));
59
+	public static function isOnCouncil($gameID, $raceID, $accountID) {
60
+		return in_array($accountID, self::getRaceCouncil($gameID, $raceID));
61 61
 	}
62 62
 }
Please login to merge, or discard this patch.
lib/Default/SmrGame.class.inc 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 		self::GAME_TYPE_NEWBIE => 'Newbie',
47 47
 	];
48 48
 
49
-	public static function &getGame($gameID,$forceUpdate = false) {
50
-		if($forceUpdate || !isset(self::$CACHE_GAMES[$gameID])) {
49
+	public static function &getGame($gameID, $forceUpdate = false) {
50
+		if ($forceUpdate || !isset(self::$CACHE_GAMES[$gameID])) {
51 51
 			$g = new SmrGame($gameID);
52 52
 			self::$CACHE_GAMES[$gameID] = $g;
53 53
 		}
@@ -55,45 +55,45 @@  discard block
 block discarded – undo
55 55
 	}
56 56
 
57 57
 	public static function saveGames() {
58
-		foreach(self::$CACHE_GAMES as $game) {
58
+		foreach (self::$CACHE_GAMES as $game) {
59 59
 			$game->save();
60 60
 		}
61 61
 	}
62 62
 
63 63
 	public static function &createGame($gameID) {
64
-		if(!isset(self::$CACHE_GAMES[$gameID])) {
65
-			$g = new SmrGame($gameID,true);
64
+		if (!isset(self::$CACHE_GAMES[$gameID])) {
65
+			$g = new SmrGame($gameID, true);
66 66
 			self::$CACHE_GAMES[$gameID] = $g;
67 67
 		}
68 68
 		return self::$CACHE_GAMES[$gameID];
69 69
 	}
70 70
 
71
-	protected function __construct($gameID, $create=false) {
71
+	protected function __construct($gameID, $create = false) {
72 72
 		$this->db = new SmrMySqlDatabase();
73 73
 
74 74
 		$this->db->query('SELECT * FROM game WHERE game_id = ' . $this->db->escapeNumber($gameID) . ' LIMIT 1');
75
-		if($this->db->nextRecord()) {
76
-			$this->gameID				= $this->db->getInt('game_id');
77
-			$this->name					= $this->db->getField('game_name');
78
-			$this->description			= $this->db->getField('game_description');
79
-			$this->startDate			= $this->db->getInt('start_date');
80
-			$this->startTurnsDate		= $this->db->getInt('start_turns_date');
81
-			$this->endDate				= $this->db->getInt('end_date');
75
+		if ($this->db->nextRecord()) {
76
+			$this->gameID = $this->db->getInt('game_id');
77
+			$this->name = $this->db->getField('game_name');
78
+			$this->description = $this->db->getField('game_description');
79
+			$this->startDate = $this->db->getInt('start_date');
80
+			$this->startTurnsDate = $this->db->getInt('start_turns_date');
81
+			$this->endDate = $this->db->getInt('end_date');
82 82
 			$this->maxPlayers			= $this->db->getInt('max_players');
83
-			$this->maxTurns				= $this->db->getInt('max_turns');
84
-			$this->startTurnHours		= $this->db->getInt('start_turns');
83
+			$this->maxTurns = $this->db->getInt('max_turns');
84
+			$this->startTurnHours = $this->db->getInt('start_turns');
85 85
 			$this->gameTypeID			= $this->db->getInt('game_type');
86
-			$this->creditsNeeded		= $this->db->getInt('credits_needed');
87
-			$this->gameSpeed			= $this->db->getReal('game_speed');
88
-			$this->enabled				= $this->db->getBoolean('enabled');
89
-			$this->ignoreStats			= $this->db->getBoolean('ignore_stats');
90
-			$this->allianceMaxPlayers	= $this->db->getInt('alliance_max_players');
86
+			$this->creditsNeeded = $this->db->getInt('credits_needed');
87
+			$this->gameSpeed = $this->db->getReal('game_speed');
88
+			$this->enabled = $this->db->getBoolean('enabled');
89
+			$this->ignoreStats = $this->db->getBoolean('ignore_stats');
90
+			$this->allianceMaxPlayers = $this->db->getInt('alliance_max_players');
91 91
 			$this->allianceMaxVets		= $this->db->getInt('alliance_max_vets');
92 92
 			$this->startingCredits		= $this->db->getInt('starting_credits');
93 93
 		}
94
-		else if($create===true) {
95
-			$this->gameID		= (int)$gameID;
96
-			$this->isNew		= true;
94
+		else if ($create === true) {
95
+			$this->gameID = (int)$gameID;
96
+			$this->isNew = true;
97 97
 			return;
98 98
 		}
99 99
 		else {
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
 	}
103 103
 
104 104
 	public function save() {
105
-		if($this->hasChanged) {
106
-			if($this->isNew==false) {
105
+		if ($this->hasChanged) {
106
+			if ($this->isNew == false) {
107 107
 				$this->db->query('UPDATE game SET game_name = ' . $this->db->escapeString($this->getName()) .
108 108
 										', game_description = ' . $this->db->escapeString($this->getDescription()) .
109 109
 										', start_date = ' . $this->db->escapeNumber($this->getStartDate()) .
@@ -155,11 +155,11 @@  discard block
 block discarded – undo
155 155
 	}
156 156
 
157 157
 	public function setName($name) {
158
-		if($this->name==$name) {
158
+		if ($this->name == $name) {
159 159
 			return;
160 160
 		}
161
-		$this->name=$name;
162
-		$this->hasChanged=true;
161
+		$this->name = $name;
162
+		$this->hasChanged = true;
163 163
 	}
164 164
 
165 165
 	public function getDescription() {
@@ -167,11 +167,11 @@  discard block
 block discarded – undo
167 167
 	}
168 168
 
169 169
 	public function setDescription($description) {
170
-		if($this->description==$description) {
170
+		if ($this->description == $description) {
171 171
 			return;
172 172
 		}
173
-		$this->description=$description;
174
-		$this->hasChanged=true;
173
+		$this->description = $description;
174
+		$this->hasChanged = true;
175 175
 	}
176 176
 
177 177
 	public function getStartDate() {
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 	}
180 180
 
181 181
 	public function setStartDate($startDate) {
182
-		if($this->startDate==$startDate) {
182
+		if ($this->startDate == $startDate) {
183 183
 			return;
184 184
 		}
185
-		$this->startDate=$startDate;
186
-		$this->hasChanged=true;
185
+		$this->startDate = $startDate;
186
+		$this->hasChanged = true;
187 187
 	}
188 188
 
189 189
 	public function getStartTurnsDate() {
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
 	}
192 192
 
193 193
 	public function setStartTurnsDate($startTurnsDate) {
194
-		if($this->startTurnsDate==$startTurnsDate) {
194
+		if ($this->startTurnsDate == $startTurnsDate) {
195 195
 			return;
196 196
 		}
197
-		$this->startTurnsDate=$startTurnsDate;
198
-		$this->hasChanged=true;
197
+		$this->startTurnsDate = $startTurnsDate;
198
+		$this->hasChanged = true;
199 199
 	}
200 200
 
201 201
 	public function getEndDate() {
@@ -203,11 +203,11 @@  discard block
 block discarded – undo
203 203
 	}
204 204
 
205 205
 	public function setEndDate($endDate) {
206
-		if($this->endDate==$endDate) {
206
+		if ($this->endDate == $endDate) {
207 207
 			return;
208 208
 		}
209
-		$this->endDate=$endDate;
210
-		$this->hasChanged=true;
209
+		$this->endDate = $endDate;
210
+		$this->hasChanged = true;
211 211
 	}
212 212
 
213 213
 	public function getMaxPlayers() {
@@ -215,11 +215,11 @@  discard block
 block discarded – undo
215 215
 	}
216 216
 
217 217
 	public function setMaxPlayers($maxPlayers) {
218
-		if($this->maxPlayers==$maxPlayers) {
218
+		if ($this->maxPlayers == $maxPlayers) {
219 219
 			return;
220 220
 		}
221
-		$this->maxPlayers=$maxPlayers;
222
-		$this->hasChanged=true;
221
+		$this->maxPlayers = $maxPlayers;
222
+		$this->hasChanged = true;
223 223
 	}
224 224
 
225 225
 	public function getMaxTurns() {
@@ -227,11 +227,11 @@  discard block
 block discarded – undo
227 227
 	}
228 228
 
229 229
 	public function setMaxTurns($int) {
230
-		if($this->maxTurns==$int) {
230
+		if ($this->maxTurns == $int) {
231 231
 			return;
232 232
 		}
233
-		$this->maxTurns=$int;
234
-		$this->hasChanged=true;
233
+		$this->maxTurns = $int;
234
+		$this->hasChanged = true;
235 235
 	}
236 236
 
237 237
 	public function getStartTurnHours() {
@@ -239,11 +239,11 @@  discard block
 block discarded – undo
239 239
 	}
240 240
 
241 241
 	public function setStartTurnHours($int) {
242
-		if($this->startTurnHours==$int) {
242
+		if ($this->startTurnHours == $int) {
243 243
 			return;
244 244
 		}
245
-		$this->startTurnHours=$int;
246
-		$this->hasChanged=true;
245
+		$this->startTurnHours = $int;
246
+		$this->hasChanged = true;
247 247
 	}
248 248
 
249 249
 	public function getGameType() {
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 			return;
256 256
 		}
257 257
 		$this->gameTypeID = $gameTypeID;
258
-		$this->hasChanged=true;
258
+		$this->hasChanged = true;
259 259
 	}
260 260
 
261 261
 	public function getCreditsNeeded() {
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
 	}
264 264
 
265 265
 	public function setCreditsNeeded($creditsNeeded) {
266
-		if($this->creditsNeeded==$creditsNeeded) {
266
+		if ($this->creditsNeeded == $creditsNeeded) {
267 267
 			return;
268 268
 		}
269
-		$this->creditsNeeded=$creditsNeeded;
270
-		$this->hasChanged=true;
269
+		$this->creditsNeeded = $creditsNeeded;
270
+		$this->hasChanged = true;
271 271
 	}
272 272
 
273 273
 	public function getGameSpeed() {
@@ -275,11 +275,11 @@  discard block
 block discarded – undo
275 275
 	}
276 276
 
277 277
 	public function setGameSpeed($gameSpeed) {
278
-		if($this->gameSpeed==$gameSpeed) {
278
+		if ($this->gameSpeed == $gameSpeed) {
279 279
 			return;
280 280
 		}
281
-		$this->gameSpeed=$gameSpeed;
282
-		$this->hasChanged=true;
281
+		$this->gameSpeed = $gameSpeed;
282
+		$this->hasChanged = true;
283 283
 	}
284 284
 
285 285
 	public function isEnabled() {
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
 	}
288 288
 
289 289
 	public function setEnabled($bool) {
290
-		if($this->enabled === $bool) {
290
+		if ($this->enabled === $bool) {
291 291
 			return;
292 292
 		}
293
-		$this->enabled=$bool;
294
-		$this->hasChanged=true;
293
+		$this->enabled = $bool;
294
+		$this->hasChanged = true;
295 295
 	}
296 296
 
297 297
 	public function isIgnoreStats() {
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
 	}
300 300
 
301 301
 	public function setIgnoreStats($bool) {
302
-		if($this->ignoreStats === $bool) {
302
+		if ($this->ignoreStats === $bool) {
303 303
 			return;
304 304
 		}
305
-		$this->ignoreStats=$bool;
306
-		$this->hasChanged=true;
305
+		$this->ignoreStats = $bool;
306
+		$this->hasChanged = true;
307 307
 	}
308 308
 
309 309
 	public function getAllianceMaxPlayers() {
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
 	}
312 312
 
313 313
 	public function setAllianceMaxPlayers($int) {
314
-		if($this->allianceMaxPlayers==$int) {
314
+		if ($this->allianceMaxPlayers == $int) {
315 315
 			return;
316 316
 		}
317
-		$this->allianceMaxPlayers=$int;
318
-		$this->hasChanged=true;
317
+		$this->allianceMaxPlayers = $int;
318
+		$this->hasChanged = true;
319 319
 	}
320 320
 
321 321
 	public function getAllianceMaxVets() {
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
 	}
324 324
 
325 325
 	public function setAllianceMaxVets($int) {
326
-		if($this->allianceMaxVets==$int) {
326
+		if ($this->allianceMaxVets == $int) {
327 327
 			return;
328 328
 		}
329
-		$this->allianceMaxVets=$int;
330
-		$this->hasChanged=true;
329
+		$this->allianceMaxVets = $int;
330
+		$this->hasChanged = true;
331 331
 	}
332 332
 
333 333
 	public function getStartingCredits() {
@@ -335,15 +335,15 @@  discard block
 block discarded – undo
335 335
 	}
336 336
 
337 337
 	public function setStartingCredits($int) {
338
-		if($this->startingCredits==$int) {
338
+		if ($this->startingCredits == $int) {
339 339
 			return;
340 340
 		}
341
-		$this->startingCredits=$int;
342
-		$this->hasChanged=true;
341
+		$this->startingCredits = $int;
342
+		$this->hasChanged = true;
343 343
 	}
344 344
 
345 345
 	public function getTotalPlayers() {
346
-		if(!isset($this->totalPlayers)) {
346
+		if (!isset($this->totalPlayers)) {
347 347
 			$this->db->query('SELECT count(*) FROM player WHERE game_id = ' . $this->db->escapeNumber($this->getGameID()));
348 348
 			$this->db->nextRecord();
349 349
 			$this->totalPlayers = $this->db->getInt('count(*)');
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	}
357 357
 
358 358
 	public function equals(SmrGame $otherGame) {
359
-		return $otherGame->getGameID()==$this->getGameID();
359
+		return $otherGame->getGameID() == $this->getGameID();
360 360
 	}
361 361
 
362 362
 	// Convenience function for printing the game name with id
Please login to merge, or discard this patch.
lib/Default/Template.class.inc 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
 	private $data = array();
5 5
 //	protected $ajax = array();
6 6
 //	protected $currentAjaxID=false;
7
-	private $captures=array('');
8
-	private $currentCaptureID=0;
9
-	private $ignoreMiddle=false;
7
+	private $captures = array('');
8
+	private $currentCaptureID = 0;
9
+	private $ignoreMiddle = false;
10 10
 	private $nestedIncludes = 0;
11 11
 	private $ajaxJS = array();
12 12
 	protected $jsAlerts = array();
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * Displays the template HTML. Stores any ajax-enabled elements for future
36 36
 	 * comparison, and outputs modified elements in XML for ajax if requested.
37 37
 	 */
38
-	public function display($templateName, $outputXml=false) {
38
+	public function display($templateName, $outputXml = false) {
39 39
 		// If we already started output buffering before calling `display`,
40 40
 		// we may have unwanted content in the buffer that we need to remove
41 41
 		// before we send the Content-Type headers below.
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 		}
48 48
 		ob_start();
49 49
 		$this->includeTemplate($templateName);
50
-		$this->captures[$this->currentCaptureID].=ob_get_clean();
50
+		$this->captures[$this->currentCaptureID] .= ob_get_clean();
51 51
 		$output = join('', $this->captures);
52 52
 		$this->trimWhiteSpace($output);
53 53
 
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
 
60 60
 		$ajaxEnabled = ($this->data['AJAX_ENABLE_REFRESH'] ?? false) !== false;
61 61
 		if ($ajaxEnabled) {
62
-			$ajaxXml =& $this->convertHtmlToAjaxXml($output,USING_AJAX);
62
+			$ajaxXml = & $this->convertHtmlToAjaxXml($output, USING_AJAX);
63 63
 			if ($outputXml) {
64 64
 				/* Left out for size: <?xml version="1.0" encoding="ISO-8859-1"?>*/
65
-				$ajaxXml='<all>'.$ajaxXml.'</all>';
65
+				$ajaxXml = '<all>' . $ajaxXml . '</all>';
66 66
 				echo $ajaxXml;
67 67
 			} else {
68 68
 				echo $output;
@@ -121,21 +121,21 @@  discard block
 block discarded – undo
121 121
 			return TEMPLATES_DIR . 'Default/' . $templateName;
122 122
 		}
123 123
 		elseif (file_exists($templateDir . 'default.inc')) {
124
-			return $templateDir.'default.inc';
124
+			return $templateDir . 'default.inc';
125 125
 		}
126 126
 		else {
127
-			return TEMPLATES_DIR.'Default/default.inc';//return $file_name;
127
+			return TEMPLATES_DIR . 'Default/default.inc'; //return $file_name;
128 128
 		}
129 129
 	}
130 130
 	
131 131
 	protected function includeTemplate($templateName, array $assignVars = null) {
132
-		if($this->nestedIncludes > 15) {
132
+		if ($this->nestedIncludes > 15) {
133 133
 			throw new Exception('Nested more than 15 template includes, is something wrong?');
134 134
 		}
135 135
 		foreach ($this->data as $key => $value) {
136 136
 			$$key = $value;
137 137
 		}
138
-		if($assignVars!==null) {
138
+		if ($assignVars !== null) {
139 139
 			foreach ($assignVars as $key => $value) {
140 140
 				$$key = $value;
141 141
 			}
@@ -146,14 +146,14 @@  discard block
 block discarded – undo
146 146
 	}
147 147
 	
148 148
 	protected function startCapture() {
149
-		$this->captures[$this->currentCaptureID].=ob_get_contents();
149
+		$this->captures[$this->currentCaptureID] .= ob_get_contents();
150 150
 		ob_clean();
151 151
 		$this->currentCaptureID++;
152 152
 		$this->captures[$this->currentCaptureID] = '';
153 153
 	}
154 154
 	
155 155
 	protected function &stopCapture() {
156
-		$captured =& $this->captures[$this->currentCaptureID];
156
+		$captured = & $this->captures[$this->currentCaptureID];
157 157
 		unset($this->captures[$this->currentCaptureID]);
158 158
 		$captured .= ob_get_contents();
159 159
 		ob_clean();
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 //	}
188 188
 	
189 189
 	protected function checkDisableAJAX($html) {
190
-		return preg_match('/<input'.'[^>]*'.'[^(submit)(hidden)(image)]'.'[^>]*'.'>/i', $html)!=0;
190
+		return preg_match('/<input' . '[^>]*' . '[^(submit)(hidden)(image)]' . '[^>]*' . '>/i', $html) != 0;
191 191
 	}
192 192
 	
193 193
 	protected function trimWhiteSpace(&$html) {
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
 		$html = trim(preg_replace('/> </', '><', $html));
223 223
 		
224 224
 		// replace span blocks
225
-		$this->replaceTrimHolder("@@@SMARTY:TRIM:SPAN@@@",$_span_blocks, $html);
225
+		$this->replaceTrimHolder("@@@SMARTY:TRIM:SPAN@@@", $_span_blocks, $html);
226 226
 		
227 227
 		// replace textarea blocks
228
-		$this->replaceTrimHolder("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $html);
228
+		$this->replaceTrimHolder("@@@SMARTY:TRIM:TEXTAREA@@@", $_textarea_blocks, $html);
229 229
 		
230 230
 		// replace pre blocks
231
-		$this->replaceTrimHolder("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $html);
231
+		$this->replaceTrimHolder("@@@SMARTY:TRIM:PRE@@@", $_pre_blocks, $html);
232 232
 		
233 233
 		// replace script blocks
234 234
 //		$this->replaceTrimHolder("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $html);
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	protected function replaceTrimHolder($search_str, $replace, &$subject) {
237 237
 		$_len = strlen($search_str);
238 238
 		$_pos = 0;
239
-		for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) {
240
-			if (($_pos=strpos($subject, $search_str, $_pos))!==false) {
239
+		for ($_i = 0, $_count = count($replace); $_i < $_count; $_i++) {
240
+			if (($_pos = strpos($subject, $search_str, $_pos)) !== false) {
241 241
 				$subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
242 242
 			}
243 243
 			else {
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 	}
248 248
 	
249 249
 	protected function doDamageTypeReductionDisplay(&$damageTypes) {
250
-		if($damageTypes == 3) {
250
+		if ($damageTypes == 3) {
251 251
 			echo ', ';
252 252
 		}
253
-		else if($damageTypes == 2) {
253
+		else if ($damageTypes == 2) {
254 254
 			echo ' and ';
255 255
 		}
256 256
 		$damageTypes--;
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 
259 259
 	protected function doAn($wordAfter) {
260 260
 		$char = strtoupper($wordAfter[0]);
261
-		if($char == 'A' || $char == 'E' || $char == 'I' || $char == 'O' || $char == 'U') {
261
+		if ($char == 'A' || $char == 'E' || $char == 'I' || $char == 'O' || $char == 'U') {
262 262
 			echo 'an';
263 263
 		}
264 264
 		else {
@@ -270,33 +270,33 @@  discard block
 block discarded – undo
270 270
 	 * EVAL is special (well, will be when needed and implemented in the javascript).
271 271
 	 */
272 272
 	public function addJavascriptForAjax($varName, $obj) {
273
-		if($varName == 'EVAL') {
274
-			if(!isset($this->ajaxJS['EVAL'])) {
273
+		if ($varName == 'EVAL') {
274
+			if (!isset($this->ajaxJS['EVAL'])) {
275 275
 				return $this->ajaxJS['EVAL'] = $obj;
276 276
 			}
277 277
 			return $this->ajaxJS['EVAL'] .= ';' . $obj;
278 278
 		}
279 279
 		
280
-		if(isset($this->ajaxJS[$varName])) {
280
+		if (isset($this->ajaxJS[$varName])) {
281 281
 			throw new Exception('Trying to set javascript val twice: ' . $varName);
282 282
 		}
283 283
 		return $this->ajaxJS[$varName] = json_encode($obj);
284 284
 	}
285 285
 	
286 286
 	protected function addJavascriptAlert($string) {
287
-		if(!SmrSession::addAjaxReturns('ALERT:'.$string,$string)) {
287
+		if (!SmrSession::addAjaxReturns('ALERT:' . $string, $string)) {
288 288
 			$this->jsAlerts[] = $string;
289 289
 		}
290 290
 	}
291 291
 	
292
-	protected function &convertHtmlToAjaxXml($str,$returnXml) {
293
-		if(empty($str)) {
292
+	protected function &convertHtmlToAjaxXml($str, $returnXml) {
293
+		if (empty($str)) {
294 294
 			return '';
295 295
 		}
296 296
 
297 297
 		// To get inner html, we need to construct a separate DOMDocument.
298 298
 		// See PHP Bug #76285.
299
-		$getInnerHTML = function (DOMNode $node) {
299
+		$getInnerHTML = function(DOMNode $node) {
300 300
 			$dom = new DOMDocument();
301 301
 			$dom->formatOutput = false;
302 302
 			foreach ($node->childNodes as $child) {
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 			return trim(@$dom->saveHTML());
307 307
 		};
308 308
 
309
-		$xml='';
309
+		$xml = '';
310 310
 		$dom = new DOMDocument();
311 311
 		@$dom->loadHTML($str);
312 312
 		$xpath = new DOMXpath($dom);
@@ -316,13 +316,13 @@  discard block
 block discarded – undo
316 316
 			foreach ($matchNodes as $node) {
317 317
 				$id = $node->getAttribute('id');
318 318
 				$inner = $getInnerHTML($node);
319
-				if(!SmrSession::addAjaxReturns($id,$inner) && $returnXml) {
320
-					$xml.= '<'.$id.'>'.xmlify($inner). '</'.$id.'>';
319
+				if (!SmrSession::addAjaxReturns($id, $inner) && $returnXml) {
320
+					$xml .= '<' . $id . '>' . xmlify($inner) . '</' . $id . '>';
321 321
 				}
322 322
 			}
323 323
 		}
324 324
 
325
-		if(!$this->ignoreMiddle) {
325
+		if (!$this->ignoreMiddle) {
326 326
 			$mid = $dom->getElementById('middle_panel');
327 327
 
328 328
 			$doAjaxMiddle = true;
@@ -342,28 +342,28 @@  discard block
 block discarded – undo
342 342
 				}
343 343
 			}
344 344
 
345
-			if($doAjaxMiddle) {
345
+			if ($doAjaxMiddle) {
346 346
 				$inner = $getInnerHTML($mid);
347
-				if(!$this->checkDisableAJAX($inner)) {
347
+				if (!$this->checkDisableAJAX($inner)) {
348 348
 					$id = $mid->getAttribute('id');
349
-					if(!SmrSession::addAjaxReturns($id,$inner) && $returnXml) {
350
-						$xml .= '<'.$id.'>'.xmlify($inner).'</'.$id.'>';
349
+					if (!SmrSession::addAjaxReturns($id, $inner) && $returnXml) {
350
+						$xml .= '<' . $id . '>' . xmlify($inner) . '</' . $id . '>';
351 351
 					}
352 352
 				}
353 353
 			}
354 354
 		}
355 355
 
356 356
 		$js = '';
357
-		foreach($this->ajaxJS as $varName => $JSON) {
358
-			if(!SmrSession::addAjaxReturns('JS:'.$varName,$JSON) && $returnXml) {
359
-				$js .= '<'.$varName.'>'.xmlify($JSON).'</'.$varName.'>';
357
+		foreach ($this->ajaxJS as $varName => $JSON) {
358
+			if (!SmrSession::addAjaxReturns('JS:' . $varName, $JSON) && $returnXml) {
359
+				$js .= '<' . $varName . '>' . xmlify($JSON) . '</' . $varName . '>';
360 360
 			}
361 361
 		}
362
-		if($returnXml && count($this->jsAlerts) > 0) {
363
-			$js = '<ALERT>'.json_encode($this->jsAlerts).'</ALERT>';
362
+		if ($returnXml && count($this->jsAlerts) > 0) {
363
+			$js = '<ALERT>' . json_encode($this->jsAlerts) . '</ALERT>';
364 364
 		}
365
-		if(strlen($js) > 0) {
366
-			$xml .= '<JS>'.$js.'</JS>';
365
+		if (strlen($js) > 0) {
366
+			$xml .= '<JS>' . $js . '</JS>';
367 367
 		}
368 368
 		return $xml;
369 369
 	}
Please login to merge, or discard this patch.