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

Passed
Push — master ( 1f1eac...f120a4 )
by Dan
04:33
created
lib/Default/Sorter.class.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@
 block discarded – undo
20 20
 	}
21 21
 
22 22
 	public static function cmpNum($a, $b) {
23
-		if($a == $b) return 0;
23
+		if($a == $b) {
24
+			return 0;
25
+		}
24 26
 		return (self::$reverseOrder?-1:1)*($a < $b ? -1 : 1);
25 27
 	}
26 28
 
Please login to merge, or discard this patch.
lib/Default/MySqlDatabase.class.php 1 patch
Braces   +42 added lines, -33 removed lines patch added patch discarded remove patch
@@ -63,8 +63,9 @@  discard block
 block discarded – undo
63 63
 	}
64 64
 	
65 65
 	public function nextRecord() {
66
-		if (!$this->dbResult)
67
-			$this->error('No resource to get record from.');
66
+		if (!$this->dbResult) {
67
+					$this->error('No resource to get record from.');
68
+		}
68 69
 		
69 70
 		if ($this->dbRecord = $this->dbResult->fetch_assoc()) {
70 71
 			return true;
@@ -79,9 +80,10 @@  discard block
 block discarded – undo
79 80
 	}
80 81
 	
81 82
 	public function getBoolean($name) {
82
-		if ($this->dbRecord[$name] == 'TRUE')
83
-			return true;
84
-//		if($this->dbRecord[$name] == 'FALSE')
83
+		if ($this->dbRecord[$name] == 'TRUE') {
84
+					return true;
85
+		}
86
+		//		if($this->dbRecord[$name] == 'FALSE')
85 87
 		return false;
86 88
 //		throw new Exception('Field is not a boolean');
87 89
 	}
@@ -114,8 +116,9 @@  discard block
 block discarded – undo
114 116
 	
115 117
 	public function getObject($name, $compressed = false) {
116 118
 		$object = $this->getField($name);
117
-		if ($compressed === true)
118
-			$object = gzuncompress($object);
119
+		if ($compressed === true) {
120
+					$object = gzuncompress($object);
121
+		}
119 122
 		return unserialize($object);
120 123
 	}
121 124
 	
@@ -157,38 +160,43 @@  discard block
 block discarded – undo
157 160
 	
158 161
 	public function escape($escape, $autoQuotes = true, $quotes = true) {
159 162
 		if (is_bool($escape)) {
160
-			if ($autoQuotes)
161
-				return $this->escapeBoolean($escape);
162
-			else
163
-				return $this->escapeBoolean($escape, $quotes);
163
+			if ($autoQuotes) {
164
+							return $this->escapeBoolean($escape);
165
+			} else {
166
+							return $this->escapeBoolean($escape, $quotes);
167
+			}
164 168
 		}
165 169
 		if (is_numeric($escape)) {
166 170
 			return $this->escapeNumber($escape);
167 171
 		}
168 172
 		if (is_string($escape)) {
169
-			if ($autoQuotes)
170
-				return $this->escapeString($escape);
171
-			else
172
-				return $this->escapeString($escape, $quotes);
173
+			if ($autoQuotes) {
174
+							return $this->escapeString($escape);
175
+			} else {
176
+							return $this->escapeString($escape, $quotes);
177
+			}
173 178
 		}
174 179
 		if (is_array($escape)) {
175 180
 			return $this->escapeArray($escape, $autoQuotes, $quotes);
176 181
 		}
177 182
 		if (is_object($escape)) {
178
-			if ($autoQuotes)
179
-				return $this->escapeObject($escape);
180
-			else
181
-				return $this->escapeObject($escape, $quotes);
183
+			if ($autoQuotes) {
184
+							return $this->escapeObject($escape);
185
+			} else {
186
+							return $this->escapeObject($escape, $quotes);
187
+			}
182 188
 		}
183 189
 	}
184 190
 	
185 191
 	public function escapeString($string, $quotes = true, $nullable = false) {
186
-		if ($nullable === true && ($string === null || $string === ''))
187
-			return 'NULL';
188
-		if ($string === true)
189
-			$string = 'TRUE';
190
-		else if ($string === false)
191
-			$string = 'FALSE';
192
+		if ($nullable === true && ($string === null || $string === '')) {
193
+					return 'NULL';
194
+		}
195
+		if ($string === true) {
196
+					$string = 'TRUE';
197
+		} else if ($string === false) {
198
+					$string = 'FALSE';
199
+		}
192 200
 		if (is_array($string)) {
193 201
 			$escapedString = '';
194 202
 			foreach ($string as $value) {
@@ -210,14 +218,14 @@  discard block
 block discarded – undo
210 218
 		$string = '';
211 219
 		if ($escapeIndividually) {
212 220
 			foreach ($array as $value) {
213
-				if (is_array($value))
214
-					$string .= $this->escapeArray($value, $autoQuotes, $quotes, $implodeString, $escapeIndividually) . $implodeString;
215
-				else
216
-					$string .= $this->escape($value, $autoQuotes, $quotes) . $implodeString;
221
+				if (is_array($value)) {
222
+									$string .= $this->escapeArray($value, $autoQuotes, $quotes, $implodeString, $escapeIndividually) . $implodeString;
223
+				} else {
224
+									$string .= $this->escape($value, $autoQuotes, $quotes) . $implodeString;
225
+				}
217 226
 			}
218 227
 			$string = substr($string, 0, -1);
219
-		}
220
-		else {
228
+		} else {
221 229
 			$string = $this->escape(implode($implodeString, $array), $autoQuotes, $quotes);
222 230
 		}
223 231
 		return $string;
@@ -250,8 +258,9 @@  discard block
 block discarded – undo
250 258
 	}
251 259
 	
252 260
 	public function escapeObject($object, $compress = false, $quotes = true, $nullable = false) {
253
-		if ($compress === true)
254
-			return $this->escapeBinary(gzcompress(serialize($object)));
261
+		if ($compress === true) {
262
+					return $this->escapeBinary(gzcompress(serialize($object)));
263
+		}
255 264
 		return $this->escapeString(serialize($object), $quotes, $nullable);
256 265
 	}
257 266
 
Please login to merge, or discard this patch.
lib/Default/ChessGame.class.php 1 patch
Braces   +13 added lines, -26 removed lines patch added patch discarded remove patch
@@ -81,8 +81,7 @@  discard block
 block discarded – undo
81 81
 			$this->blackID = $this->db->getInt('black_id');
82 82
 			$this->winner = $this->db->getInt('winner_id');
83 83
 			$this->resetHasMoved();
84
-		}
85
-		else {
84
+		} else {
86 85
 			throw new Exception('Chess game not found: ' . $chessGameID);
87 86
 		}
88 87
 	}
@@ -149,8 +148,7 @@  discard block
 block discarded – undo
149 148
 					break;
150 149
 				}
151 150
 			}
152
-		}
153
-		catch(Exception $e) {
151
+		} catch(Exception $e) {
154 152
 			if($debugInfo === true) {
155 153
 				echo $e->getMessage() . EOL . $e->getTraceAsString() . EOL;
156 154
 			}
@@ -189,11 +187,9 @@  discard block
 block discarded – undo
189 187
 			if(!$mate && $this->hasEnded()) {
190 188
 				if($this->getWinner() != 0) {
191 189
 					$this->moves[] = ($this->getWinner() == $this->getWhiteID() ? 'Black' : 'White') . ' Resigned.';
192
-				}
193
-				else if(count($this->moves) < 2) {
190
+				} else if(count($this->moves) < 2) {
194 191
 					$this->moves[] = 'Game Cancelled.';
195
-				}
196
-				else {
192
+				} else {
197 193
 					$this->moves[] = 'Game Drawn.';
198 194
 				}
199 195
 			}
@@ -212,8 +208,7 @@  discard block
 block discarded – undo
212 208
 			for($x=0; $x < 8; $x++) {
213 209
 				if($board[$y][$x] == null) {
214 210
 					$blanks++;
215
-				}
216
-				else {
211
+				} else {
217 212
 					if($blanks > 0) {
218 213
 						$fen .= $blanks;
219 214
 						$blanks = 0;
@@ -268,8 +263,7 @@  discard block
 block discarded – undo
268 263
 					$fen .= '3';
269 264
 				break;
270 265
 			}
271
-		}
272
-		else {
266
+		} else {
273 267
 			$fen .= '-';
274 268
 		}
275 269
 		$fen .= ' 0 ' . floor(count($this->moves)/2);
@@ -386,8 +380,7 @@  discard block
 block discarded – undo
386 380
 		}
387 381
 		if($pieceID == ChessPiece::PAWN && ($startY == 1 || $startY == 6) && ($endY == 3 || $endY == 4)) {
388 382
 			$this->hasMoved[ChessPiece::PAWN] = array($endX, $endY);
389
-		}
390
-		else {
383
+		} else {
391 384
 			$this->hasMoved[ChessPiece::PAWN] = array(-1,-1);
392 385
 		}
393 386
 		return ($castling == 'Queen' ? '0-0-0' : ($castling == 'King' ? '0-0' : ''))
@@ -493,8 +486,7 @@  discard block
 block discarded – undo
493 486
 				$board[$toY][$castling['ToX']]->setX($castling['ToX']);
494 487
 				$board[$y][$castling['X']] = null;
495 488
 			}
496
-		}
497
-		else if($p->pieceID == ChessPiece::PAWN) {
489
+		} else if($p->pieceID == ChessPiece::PAWN) {
498 490
 			if($toY == 0 || $toY == 7) {
499 491
 				$pawnPromotion = $p->promote($pawnPromotionPiece, $board);
500 492
 			}
@@ -512,8 +504,7 @@  discard block
 block discarded – undo
512 504
 				}
513 505
 				$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = null;
514 506
 			}
515
-		}
516
-		else if($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
507
+		} else if($p->pieceID == ChessPiece::ROOK && ($x == 0 || $x == 7) && $y == ($p->colour == self::PLAYER_WHITE ? 7 : 0)) {
517 508
 			//Rook moved?
518 509
 			if($hasMoved[$p->colour][ChessPiece::ROOK][$x==0?'Queen':'King'] === false) {
519 510
 				// We set rook moved in here as it's used for move info.
@@ -573,12 +564,10 @@  discard block
 block discarded – undo
573 564
 				$board[$y][$castling['X']]->setX($castling['X']);
574 565
 				$board[$toY][$castling['ToX']] = null;
575 566
 			}
576
-		}
577
-		else if($moveInfo['EnPassant'] === true) {
567
+		} else if($moveInfo['EnPassant'] === true) {
578 568
 			$board[$toY][$toX] = null;
579 569
 			$board[$hasMoved[ChessPiece::PAWN][1]][$hasMoved[ChessPiece::PAWN][0]] = $moveInfo['PieceTaken'];
580
-		}
581
-		else if($moveInfo['RookMoved'] !== false) {
570
+		} else if($moveInfo['RookMoved'] !== false) {
582 571
 			$hasMoved[$p->colour][ChessPiece::ROOK][$moveInfo['RookMoved']] = false;
583 572
 		}
584 573
 		if($moveInfo['RookTaken'] !== false) {
@@ -702,8 +691,7 @@  discard block
 block discarded – undo
702 691
 					$this->setWinner($forAccountID);
703 692
 					$return = 1;
704 693
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'You have just lost [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
705
-				}
706
-				else {
694
+				} else {
707 695
 					SmrPlayer::sendMessageFromCasino($lastTurnPlayer->getGameID(), $this->getCurrentTurnAccountID(), 'It is now your turn in [chess=' . $this->getChessGameID() . '] against [player=' . $lastTurnPlayer->getPlayerID() . '].');
708 696
 					if($checking == 'CHECK') {
709 697
 						$currentPlayer->increaseHOF(1, array($chessType,'Moves','Check Given'), HOF_PUBLIC);
@@ -853,8 +841,7 @@  discard block
 block discarded – undo
853 841
 							SET end_time=' . $this->db->escapeNumber(TIME) . '
854 842
 							WHERE chess_game_id=' . $this->db->escapeNumber($this->chessGameID) . ';');
855 843
 			return 1;
856
-		}
857
-		else {
844
+		} else {
858 845
 			$loserColour = $this->getColourForAccountID($accountID);
859 846
 			$winnerAccountID = $this->getColourID(self::getOtherColour($loserColour));
860 847
 			$results = $this->setWinner($winnerAccountID);
Please login to merge, or discard this patch.
lib/Default/DummyPlayer.class.php 1 patch
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -53,8 +53,9 @@  discard block
 block discarded – undo
53 53
 	}
54 54
 	
55 55
 	public function setAllianceID($ID) {
56
-		if($this->allianceID == $ID)
57
-			return;
56
+		if($this->allianceID == $ID) {
57
+					return;
58
+		}
58 59
 		$this->allianceID=$ID;
59 60
 	}
60 61
 	
@@ -93,8 +94,7 @@  discard block
 block discarded – undo
93 94
 		if($db->nextRecord()) {
94 95
 			$return = unserialize($db->getField('info'));
95 96
 			return $return;
96
-		}
97
-		else {
97
+		} else {
98 98
 			$return = new DummyPlayer();
99 99
 			return $return;
100 100
 		}
Please login to merge, or discard this patch.
htdocs/login_processing.php 1 patch
Braces   +31 added lines, -18 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
 				header('Location: /login_social_create.php');
32 32
 				exit;
33 33
 			}
34
-		}
35
-		else {
34
+		} else {
36 35
 			$login = (isset($_REQUEST['login']) ? $_REQUEST['login'] : (isset($var['login']) ? $var['login'] : ''));
37 36
 			$password = (isset($_REQUEST['password']) ? $_REQUEST['password'] : (isset($var['password']) ? $var['password'] : ''));
38 37
 
@@ -46,8 +45,7 @@  discard block
 block discarded – undo
46 45
 			$account = SmrAccount::getAccountByName($login);
47 46
 			if (is_object($account) && $account->checkPassword($password)) {
48 47
 				SmrSession::setAccount($account);
49
-			}
50
-			else {
48
+			} else {
51 49
 				$msg = 'Password is incorrect!';
52 50
 				header('Location: /login.php?msg=' . rawurlencode(htmlspecialchars($msg, ENT_QUOTES)));
53 51
 				exit;
@@ -142,38 +140,54 @@  discard block
 block discarded – undo
142 140
 			//convert to array
143 141
 			$old = explode('-', $db->getField('array'));
144 142
 			//get rid of old version cookie since it isn't optimal.
145
-			if ($old[0] != MULTI_CHECKING_COOKIE_VERSION) $old = array();
146
-		} else $old = array();
143
+			if ($old[0] != MULTI_CHECKING_COOKIE_VERSION) {
144
+				$old = array();
145
+			}
146
+		} else {
147
+			$old = array();
148
+		}
147 149
 		$old[0] = MULTI_CHECKING_COOKIE_VERSION;
148
-		if (!in_array($account->getAccountID(), $old)) $old[] = $account->getAccountID();
149
-	}
150
-	else {
150
+		if (!in_array($account->getAccountID(), $old)) {
151
+			$old[] = $account->getAccountID();
152
+		}
153
+	} else {
151 154
 
152 155
 		//we have a cookie so we see if we add to it etc
153 156
 		//break cookie into array
154 157
 		$cookie = explode('-', $_COOKIE['Session_Info']);
155 158
 		//check for current version
156
-		if ($cookie[0] != MULTI_CHECKING_COOKIE_VERSION) $cookie = array();
159
+		if ($cookie[0] != MULTI_CHECKING_COOKIE_VERSION) {
160
+			$cookie = array();
161
+		}
157 162
 		$cookie[0] = MULTI_CHECKING_COOKIE_VERSION;
158 163
 		//add this acc to the cookie if it isn't there
159
-		if (!in_array($account->getAccountID(), $cookie)) $cookie[] = $account->getAccountID();
164
+		if (!in_array($account->getAccountID(), $cookie)) {
165
+			$cookie[] = $account->getAccountID();
166
+		}
160 167
 
161 168
 		$db->query('SELECT * FROM multi_checking_cookie WHERE account_id = ' . $account->getAccountID());
162 169
 		if ($db->nextRecord()) {
163 170
 			//convert to array
164 171
 			$old = explode('-', $db->getField('array'));
165
-			if ($old[0] != MULTI_CHECKING_COOKIE_VERSION) $old = array();
166
-		} else $old = array();
172
+			if ($old[0] != MULTI_CHECKING_COOKIE_VERSION) {
173
+				$old = array();
174
+			}
175
+		} else {
176
+			$old = array();
177
+		}
167 178
 		$old[0] = MULTI_CHECKING_COOKIE_VERSION;
168 179
 		//merge arrays...but keys are all different so we go through each value
169
-		foreach ($cookie as $value)
170
-			if (!in_array($value, $old)) $old[] = $value;
180
+		foreach ($cookie as $value) {
181
+					if (!in_array($value, $old)) $old[] = $value;
182
+		}
171 183
 	}
172 184
 	$use = (count($old) <= 2) ? 'FALSE' : 'TRUE';
173 185
 	//check that each value is legit and add it to db string
174 186
 	$new = MULTI_CHECKING_COOKIE_VERSION;
175 187
 	foreach ($old as $accID) {
176
-		if (is_numeric($accID)) $new .= '-' . $accID;
188
+		if (is_numeric($accID)) {
189
+			$new .= '-' . $accID;
190
+		}
177 191
 	}
178 192
 	$db->query('REPLACE INTO multi_checking_cookie (account_id, array, `use`) VALUES (' . $db->escapeNumber($account->getAccountID()) . ', ' . $db->escapeString($new) . ', ' . $db->escapeString($use) . ')');
179 193
 	//now we update their cookie with the newest info
@@ -193,7 +207,6 @@  discard block
 block discarded – undo
193 207
 
194 208
 	header('Location: ' . $href);
195 209
 	exit;
196
-}
197
-catch (Throwable $e) {
210
+} catch (Throwable $e) {
198 211
 	handleException($e);
199 212
 }
Please login to merge, or discard this patch.
htdocs/login.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,7 +50,6 @@
 block discarded – undo
50 50
 	$template->assign('Body', 'login/login.php');
51 51
 	$template->display('login/skeleton.php');
52 52
 
53
-}
54
-catch (Throwable $e) {
53
+} catch (Throwable $e) {
55 54
 	handleException($e);
56 55
 }
Please login to merge, or discard this patch.
engine/Default/hall_of_fame_new.php 1 patch
Braces   +12 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,18 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php declare(strict_types=1);
2 2
 require_once(get_file_loc('hof.functions.inc'));
3 3
 $game_id = null;
4
-if (isset($var['game_id'])) $game_id = $var['game_id'];
4
+if (isset($var['game_id'])) {
5
+	$game_id = $var['game_id'];
6
+}
5 7
 
6 8
 if (empty($game_id)) {
7 9
 	$topic = 'All Time Hall of Fame';
8
-}
9
-else {
10
+} else {
10 11
 	$topic = 'Hall of Fame: ' . SmrGame::getGame($game_id)->getDisplayName();
11 12
 }
12 13
 $template->assign('PageTopic', $topic);
13 14
 
14 15
 $container = create_container('skeleton.php', 'hall_of_fame_player_detail.php');
15
-if (isset($game_id)) $container['game_id'] = $game_id;
16
+if (isset($game_id)) {
17
+	$container['game_id'] = $game_id;
18
+}
16 19
 $template->assign('PersonalHofHREF', SmrSession::getNewHREF($container));
17 20
 
18 21
 $db->query('SELECT type FROM hof_visibility WHERE visibility != ' . $db->escapeString(HOF_PRIVATE) . ' ORDER BY type');
@@ -35,8 +38,7 @@  discard block
 block discarded – undo
35 38
 if (!isset($var['view'])) {
36 39
 	$categories = getHofCategories($hofTypes, $game_id, $account->getAccountID());
37 40
 	$template->assign('Categories', $categories);
38
-}
39
-else {
41
+} else {
40 42
 	$gameIDSql = ' AND game_id ' . (isset($game_id) ? '= ' . $db->escapeNumber($game_id) : 'IN (SELECT game_id FROM game WHERE end_time < ' . TIME . ' AND ignore_stats = ' . $db->escapeBoolean(false) . ')');
41 43
 
42 44
 	$vis = HOF_PUBLIC;
@@ -44,15 +46,14 @@  discard block
 block discarded – undo
44 46
 	$foundMe = false;
45 47
 	$viewType = $var['type'];
46 48
 	$viewType[] = $var['view'];
47
-	if ($var['view'] == DONATION_NAME)
48
-		$db->query('SELECT account_id, SUM(amount) as amount FROM account_donated
49
+	if ($var['view'] == DONATION_NAME) {
50
+			$db->query('SELECT account_id, SUM(amount) as amount FROM account_donated
49 51
 					GROUP BY account_id ORDER BY amount DESC, account_id ASC LIMIT 25');
50
-	else if ($var['view'] == USER_SCORE_NAME) {
52
+	} else if ($var['view'] == USER_SCORE_NAME) {
51 53
 		$statements = SmrAccount::getUserScoreCaseStatement($db);
52 54
 		$query = 'SELECT account_id, ' . $statements['CASE'] . ' amount FROM (SELECT account_id, type, SUM(amount) amount FROM player_hof WHERE type IN (' . $statements['IN'] . ')' . $gameIDSql . ' GROUP BY account_id,type) x GROUP BY account_id ORDER BY amount DESC, account_id ASC LIMIT 25';
53 55
 		$db->query($query);
54
-	}
55
-	else {
56
+	} else {
56 57
 		$db->query('SELECT visibility FROM hof_visibility WHERE type = ' . $db->escapeArray($viewType, false, true, ':', false) . ' LIMIT 1');
57 58
 		if ($db->nextRecord()) {
58 59
 			$vis = $db->getField('visibility');
Please login to merge, or discard this patch.
engine/Default/course_plot_processing.php 1 patch
Braces   +26 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,36 +1,48 @@
 block discarded – undo
1 1
 <?php declare(strict_types=1);
2 2
 
3
-if (isset($var['from'])) $start = $var['from'];
4
-else $start = trim($_POST['from']);
5
-if (isset($var['to'])) $target = $var['to'];
6
-else $target = trim($_POST['to']);
3
+if (isset($var['from'])) {
4
+	$start = $var['from'];
5
+} else {
6
+	$start = trim($_POST['from']);
7
+}
8
+if (isset($var['to'])) {
9
+	$target = $var['to'];
10
+} else {
11
+	$target = trim($_POST['to']);
12
+}
7 13
 
8 14
 // perform some basic checks on both numbers
9
-if (empty($start) || empty($target))
15
+if (empty($start) || empty($target)) {
10 16
 	create_error('Where do you want to go today?');
17
+}
11 18
 
12 19
 
13
-if (!is_numeric($start) || !is_numeric($target))
20
+if (!is_numeric($start) || !is_numeric($target)) {
14 21
 	create_error('Please enter only numbers!');
22
+}
15 23
 
16 24
 $start = abs(str_replace('.', '', $start));
17 25
 $target = abs(str_replace('.', '', $target));
18 26
 
19
-if ($start == $target)
27
+if ($start == $target) {
20 28
 	create_error('Hmmmm...if ' . $start . '=' . $target . ' then that means...YOU\'RE ALREADY THERE! *cough*you\'re real smart*cough*');
29
+}
21 30
 
22 31
 $startExists = false;
23 32
 $targetExists = false;
24 33
 $galaxies = SmrGalaxy::getGameGalaxies($player->getGameID());
25 34
 foreach ($galaxies as $galaxy) {
26
-	if ($galaxy->contains($start))
27
-		$startExists = true;
28
-	if ($galaxy->contains($target))
29
-		$targetExists = true;
30
-}
31
-
32
-if ($startExists === false || $targetExists === false)
35
+	if ($galaxy->contains($start)) {
36
+			$startExists = true;
37
+	}
38
+	if ($galaxy->contains($target)) {
39
+			$targetExists = true;
40
+	}
41
+	}
42
+
43
+if ($startExists === false || $targetExists === false) {
33 44
 	create_error('The sectors have to exist!');
45
+}
34 46
 
35 47
 $account->log(LOG_TYPE_MOVEMENT, 'Player plots to ' . $target . '.', $player->getSectorID());
36 48
 
Please login to merge, or discard this patch.
engine/Default/planet_defense_processing.php 1 patch
Braces   +50 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,17 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php declare(strict_types=1);
2
-if (!$player->isLandedOnPlanet())
2
+if (!$player->isLandedOnPlanet()) {
3 3
 	create_error('You are not on a planet!');
4
+}
4 5
 $amount = trim($_REQUEST['amount']);
5
-if (!is_numeric($amount))
6
+if (!is_numeric($amount)) {
6 7
 	create_error('Numbers only please');
8
+}
7 9
 	
8 10
 // only whole numbers allowed
9 11
 $amount = round($amount);
10 12
 
11
-if ($amount <= 0)
13
+if ($amount <= 0) {
12 14
 	create_error('You must actually enter an amount > 0!');
13
-if ($player->getNewbieTurns() > 0)
15
+}
16
+if ($player->getNewbieTurns() > 0) {
14 17
 	create_error('You can\'t drop defenses under newbie protection!');
18
+}
15 19
 // get a planet from the sector where the player is in
16 20
 $planet = $player->getSectorPlanet();
17 21
 
@@ -21,40 +25,44 @@  discard block
 block discarded – undo
21 25
 if ($action == 'Ship') {
22 26
 	if ($type_id == HARDWARE_SHIELDS) {
23 27
 		// do we want transfer more than we have?
24
-		if ($amount > $planet->getShields())
25
-			create_error('You can\'t take more shields from planet than are on it!');
28
+		if ($amount > $planet->getShields()) {
29
+					create_error('You can\'t take more shields from planet than are on it!');
30
+		}
26 31
 
27 32
 		// do we want to transfer more than we can carry?
28
-		if ($amount > $ship->getMaxShields() - $ship->getShields())
29
-			create_error('You can\'t take more shields than you can carry!');
33
+		if ($amount > $ship->getMaxShields() - $ship->getShields()) {
34
+					create_error('You can\'t take more shields than you can carry!');
35
+		}
30 36
 
31 37
 		// now transfer
32 38
 		$planet->decreaseShields($amount);
33 39
 		$ship->increaseShields($amount);
34 40
 		$account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' shields from planet.', $player->getSectorID());
35
-	}
36
-	else if ($type_id == HARDWARE_COMBAT) {
41
+	} else if ($type_id == HARDWARE_COMBAT) {
37 42
 		// do we want transfer more than we have?
38
-		if ($amount > $planet->getCDs())
39
-			create_error('You can\'t take more drones from planet than are on it!');
43
+		if ($amount > $planet->getCDs()) {
44
+					create_error('You can\'t take more drones from planet than are on it!');
45
+		}
40 46
 
41 47
 		// do we want to transfer more than we can carry?
42
-		if ($amount > $ship->getMaxCDs() - $ship->getCDs())
43
-			create_error('You can\'t take more drones than you can carry!');
48
+		if ($amount > $ship->getMaxCDs() - $ship->getCDs()) {
49
+					create_error('You can\'t take more drones than you can carry!');
50
+		}
44 51
 
45 52
 		// now transfer
46 53
 		$planet->decreaseCDs($amount);
47 54
 		$ship->increaseCDs($amount);
48 55
 		$account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' drones from planet.', $player->getSectorID());
49
-	}
50
-	else if ($type_id == HARDWARE_ARMOUR) {
56
+	} else if ($type_id == HARDWARE_ARMOUR) {
51 57
 		// do we want transfer more than we have?
52
-		if ($amount > $planet->getArmour())
53
-			create_error('You can\'t take more armour from planet than are on it!');
58
+		if ($amount > $planet->getArmour()) {
59
+					create_error('You can\'t take more armour from planet than are on it!');
60
+		}
54 61
 
55 62
 		// do we want to transfer more than we can carry?
56
-		if ($amount > $ship->getMaxArmour() - $ship->getArmour())
57
-			create_error('You can\'t take more armour than you can carry!');
63
+		if ($amount > $ship->getMaxArmour() - $ship->getArmour()) {
64
+					create_error('You can\'t take more armour than you can carry!');
65
+		}
58 66
 
59 67
 		// now transfer
60 68
 		$planet->decreaseArmour($amount);
@@ -62,32 +70,34 @@  discard block
 block discarded – undo
62 70
 		$account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' armour from planet.', $player->getSectorID());
63 71
 	}
64 72
 	
65
-}
66
-elseif ($action == 'Planet') {
73
+} elseif ($action == 'Planet') {
67 74
 	// does the user wants to transfer shields?
68 75
 	if ($type_id == HARDWARE_SHIELDS) {
69 76
 		// do we want transfer more than we have?
70
-		if ($amount > $ship->getShields())
71
-			create_error('You can\'t transfer more shields than you carry!');
77
+		if ($amount > $ship->getShields()) {
78
+					create_error('You can\'t transfer more shields than you carry!');
79
+		}
72 80
 
73 81
 		// do we want to transfer more than the planet can hold?
74
-		if ($amount + $planet->getShields() > $planet->getMaxShields())
75
-			create_error('The planet can\'t hold more than ' . $planet->getMaxShields() . ' shields!');
82
+		if ($amount + $planet->getShields() > $planet->getMaxShields()) {
83
+					create_error('The planet can\'t hold more than ' . $planet->getMaxShields() . ' shields!');
84
+		}
76 85
 
77 86
 		// now transfer
78 87
 		$planet->increaseShields($amount);
79 88
 		$ship->decreaseShields($amount);
80 89
 		$account->log(LOG_TYPE_PLANETS, 'Player puts ' . $amount . ' shields on planet.', $player->getSectorID());
81 90
 	// does the user wants to transfer drones?
82
-	}
83
-	else if ($type_id == HARDWARE_COMBAT) {
91
+	} else if ($type_id == HARDWARE_COMBAT) {
84 92
 		// do we want transfer more than we have?
85
-		if ($amount > $ship->getCDs())
86
-			create_error('You can\'t transfer more combat drones than you carry!');
93
+		if ($amount > $ship->getCDs()) {
94
+					create_error('You can\'t transfer more combat drones than you carry!');
95
+		}
87 96
 
88 97
 		// do we want to transfer more than we can carry?
89
-		if ($amount + $planet->getCDs() > $planet->getMaxCDs())
90
-			create_error('The planet can\'t hold more than ' . $planet->getMaxCDs() . ' drones!');
98
+		if ($amount + $planet->getCDs() > $planet->getMaxCDs()) {
99
+					create_error('The planet can\'t hold more than ' . $planet->getMaxCDs() . ' drones!');
100
+		}
91 101
 
92 102
 		// now transfer
93 103
 		$planet->increaseCDs($amount);
@@ -97,12 +107,14 @@  discard block
 block discarded – undo
97 107
 	// does the user wish to transfare armour?
98 108
 	else if ($type_id == HARDWARE_ARMOUR) {
99 109
 		// do we want transfer more than we have?
100
-		if ($amount >= $ship->getArmour())
101
-			create_error('You can\'t transfer more armour than what you carry minus one!');
110
+		if ($amount >= $ship->getArmour()) {
111
+					create_error('You can\'t transfer more armour than what you carry minus one!');
112
+		}
102 113
 
103 114
 		// do we want to transfer more than we can carry?
104
-		if ($amount + $planet->getArmour() > $planet->getMaxArmour())
105
-			create_error('The planet can\'t hold more than ' . $planet->getMaxArmour() . ' armour!');
115
+		if ($amount + $planet->getArmour() > $planet->getMaxArmour()) {
116
+					create_error('The planet can\'t hold more than ' . $planet->getMaxArmour() . ' armour!');
117
+		}
106 118
 
107 119
 		// now transfer
108 120
 		$planet->increaseArmour($amount);
@@ -110,9 +122,9 @@  discard block
 block discarded – undo
110 122
 		$account->log(LOG_TYPE_PLANETS, 'Player puts ' . $amount . ' armour on planet.', $player->getSectorID());
111 123
 	}
112 124
 	
113
-}
114
-else
125
+} else {
115 126
 	create_error('You must choose if you want to transfer to planet or to the ship!');
127
+}
116 128
 
117 129
 $ship->removeUnderAttack();
118 130
 
Please login to merge, or discard this patch.