We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
@@ -1,23 +1,31 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ($player->hasNewbieTurns()) |
|
3 | +if ($player->hasNewbieTurns()) { |
|
4 | 4 | create_error('You are under newbie protection!'); |
5 | -if ($player->hasFederalProtection()) |
|
5 | +} |
|
6 | +if ($player->hasFederalProtection()) { |
|
6 | 7 | create_error('You are under federal protection!'); |
7 | -if ($player->isLandedOnPlanet()) |
|
8 | +} |
|
9 | +if ($player->isLandedOnPlanet()) { |
|
8 | 10 | create_error('You cannot attack planets whilst on a planet!'); |
9 | -if ($player->getTurns() < 3) |
|
11 | +} |
|
12 | +if ($player->getTurns() < 3) { |
|
10 | 13 | create_error('You do not have enough turns to attack this planet!'); |
11 | -if (!$ship->hasWeapons() && !$ship->hasCDs()) |
|
14 | +} |
|
15 | +if (!$ship->hasWeapons() && !$ship->hasCDs()) { |
|
12 | 16 | create_error('What are you going to do? Insult it to death?'); |
13 | -if (!$player->canFight()) |
|
17 | +} |
|
18 | +if (!$player->canFight()) { |
|
14 | 19 | create_error('You are not allowed to fight!'); |
20 | +} |
|
15 | 21 | |
16 | 22 | $planet = $player->getSectorPlanet(); |
17 | -if (!$planet->exists()) |
|
23 | +if (!$planet->exists()) { |
|
18 | 24 | create_error('This planet does not exist.'); |
19 | -if (!$planet->isClaimed()) |
|
25 | +} |
|
26 | +if (!$planet->isClaimed()) { |
|
20 | 27 | create_error('This planet is not claimed.'); |
28 | +} |
|
21 | 29 | |
22 | 30 | $planetOwner = $planet->getOwner(); |
23 | 31 | |
@@ -88,9 +96,10 @@ discard block |
||
88 | 96 | |
89 | 97 | // Update sector messages for attackers |
90 | 98 | foreach ($attackers as $attacker) { |
91 | - if (!$player->equals($attacker)) |
|
92 | - $db->query('REPLACE INTO sector_message VALUES(' . $attacker->getAccountID() . ',' . $attacker->getGameID() . ',' . $db->escapeString('[ATTACK_RESULTS]' . $logId) . ')'); |
|
93 | -} |
|
99 | + if (!$player->equals($attacker)) { |
|
100 | + $db->query('REPLACE INTO sector_message VALUES(' . $attacker->getAccountID() . ',' . $attacker->getGameID() . ',' . $db->escapeString('[ATTACK_RESULTS]' . $logId) . ')'); |
|
101 | + } |
|
102 | + } |
|
94 | 103 | |
95 | 104 | $container = create_container('skeleton.php', 'planet_attack.php'); |
96 | 105 | $container['sector_id'] = $planet->getSectorID(); |
@@ -49,12 +49,12 @@ |
||
49 | 49 | } |
50 | 50 | |
51 | 51 | foreach ($attackers as $attacker) { |
52 | - $playerResults =& $attacker->shootPlanet($planet, false); |
|
53 | - $results['Attackers']['Traders'][$attacker->getAccountID()] =& $playerResults; |
|
52 | + $playerResults = & $attacker->shootPlanet($planet, false); |
|
53 | + $results['Attackers']['Traders'][$attacker->getAccountID()] = & $playerResults; |
|
54 | 54 | $results['Attackers']['TotalDamage'] += $playerResults['TotalDamage']; |
55 | 55 | } |
56 | 56 | $results['Attackers']['Downgrades'] = $planet->checkForDowngrade($results['Attackers']['TotalDamage']); |
57 | -$results['Planet'] =& $planet->shootPlayers($attackers); |
|
57 | +$results['Planet'] = & $planet->shootPlayers($attackers); |
|
58 | 58 | |
59 | 59 | $account->log(LOG_TYPE_PLANET_BUSTING, 'Player attacks planet, the planet does ' . $results['Planet']['TotalDamage'] . ', their team does ' . $results['Attackers']['TotalDamage'] . ' and downgrades: ' . var_export($results['Attackers']['Downgrades'], true), $planet->getSectorID()); |
60 | 60 |
@@ -11,6 +11,7 @@ |
||
11 | 11 | } |
12 | 12 | |
13 | 13 | if (isset($var['Form'])) { |
14 | - if (isset($_REQUEST['weapon_reorder']) && is_array($_REQUEST['weapon_reorder'])) |
|
15 | - $ship->setWeaponLocations($_REQUEST['weapon_reorder']); |
|
16 | -} |
|
14 | + if (isset($_REQUEST['weapon_reorder']) && is_array($_REQUEST['weapon_reorder'])) { |
|
15 | + $ship->setWeaponLocations($_REQUEST['weapon_reorder']); |
|
16 | + } |
|
17 | + } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | // Send vote announcement to members of the player's council (war votes) |
40 | 40 | // or both races' councils (peace votes). |
41 | 41 | $councilMembers = Council::getRaceCouncil($player->getGameID(), |
42 | - $player->getRaceID()); |
|
42 | + $player->getRaceID()); |
|
43 | 43 | if ($type == 'PEACE') { |
44 | 44 | $otherCouncil = Council::getRaceCouncil($player->getGameID(), $race_id); |
45 | 45 | $councilMembers = array_merge($councilMembers, $otherCouncil); |
@@ -49,16 +49,16 @@ discard block |
||
49 | 49 | $color = ($type == 'PEACE' ? 'dgreen' : 'red'); |
50 | 50 | $type_fancy = "<span class=\"$color\">$type</span>"; |
51 | 51 | $message = $player->getLevelName() . " " . $player->getBBLink() |
52 | - . " has initiated a vote for $type_fancy with the " |
|
53 | - . Globals::getRaceName($race_id) |
|
54 | - . "! You have " . format_time(TIME_FOR_COUNCIL_VOTE) |
|
55 | - . " to cast your vote."; |
|
52 | + . " has initiated a vote for $type_fancy with the " |
|
53 | + . Globals::getRaceName($race_id) |
|
54 | + . "! You have " . format_time(TIME_FOR_COUNCIL_VOTE) |
|
55 | + . " to cast your vote."; |
|
56 | 56 | |
57 | 57 | foreach ($councilMembers as $accountID) { |
58 | 58 | // don't send to the player who started the vote |
59 | 59 | if ($player->getAccountID() != $accountID) { |
60 | 60 | SmrPlayer::sendMessageFromRace($player->getRaceID(), $player->getGameID(), |
61 | - $accountID, $message, $time); |
|
61 | + $accountID, $message, $time); |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | |
47 | 47 | // Don't lose more exp than you have |
48 | 48 | $lost_xp = min($player->getExperience(), |
49 | - round(SmrPort::getBaseExperience($amount, $good_distance))); |
|
49 | + round(SmrPort::getBaseExperience($amount, $good_distance))); |
|
50 | 50 | $player->decreaseExperience($lost_xp); |
51 | 51 | $player->increaseHOF($lost_xp, array('Trade', 'Experience', 'Jettisoned'), HOF_PUBLIC); |
52 | 52 |
@@ -1,36 +1,48 @@ |
||
1 | 1 | <?php |
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 |
@@ -1,17 +1,21 @@ discard block |
||
1 | 1 | <?php |
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -3,8 +3,7 @@ discard block |
||
3 | 3 | $container = create_container('skeleton.php'); |
4 | 4 | if (SmrSession::hasGame()) { |
5 | 5 | $container['body'] = 'current_sector.php'; |
6 | -} |
|
7 | -else { |
|
6 | +} else { |
|
8 | 7 | $container['body'] = 'game_play.php'; |
9 | 8 | } |
10 | 9 | $action = $_REQUEST['action']; |
@@ -17,35 +16,38 @@ discard block |
||
17 | 16 | // overwrite container |
18 | 17 | $container['body'] = 'validate.php'; |
19 | 18 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your email address, you will now need to revalidate with the code sent to the new email address.'; |
20 | -} |
|
21 | -elseif ($action == 'Change Password') { |
|
19 | +} elseif ($action == 'Change Password') { |
|
22 | 20 | $new_password = $_REQUEST['new_password']; |
23 | 21 | $old_password = $_REQUEST['old_password']; |
24 | 22 | $retype_password = $_REQUEST['retype_password']; |
25 | 23 | |
26 | - if (empty($new_password)) |
|
27 | - create_error('You must enter a non empty password!'); |
|
24 | + if (empty($new_password)) { |
|
25 | + create_error('You must enter a non empty password!'); |
|
26 | + } |
|
28 | 27 | |
29 | - if (!$account->checkPassword($old_password)) |
|
30 | - create_error('Your current password is wrong!'); |
|
28 | + if (!$account->checkPassword($old_password)) { |
|
29 | + create_error('Your current password is wrong!'); |
|
30 | + } |
|
31 | 31 | |
32 | - if ($new_password != $retype_password) |
|
33 | - create_error('The passwords you entered don\'t match!'); |
|
32 | + if ($new_password != $retype_password) { |
|
33 | + create_error('The passwords you entered don\'t match!'); |
|
34 | + } |
|
34 | 35 | |
35 | - if ($new_password == $account->getLogin()) |
|
36 | - create_error('Your chosen password is invalid!'); |
|
36 | + if ($new_password == $account->getLogin()) { |
|
37 | + create_error('Your chosen password is invalid!'); |
|
38 | + } |
|
37 | 39 | |
38 | 40 | $account->setPassword($new_password); |
39 | 41 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your password.'; |
40 | -} |
|
41 | -elseif ($action == 'Change Name') { |
|
42 | +} elseif ($action == 'Change Name') { |
|
42 | 43 | $HoF_name = trim($_REQUEST['HoF_name']); |
43 | 44 | |
44 | 45 | $limited_char = 0; |
45 | 46 | for ($i = 0; $i < strlen($HoF_name); $i++) { |
46 | 47 | // disallow certain ascii chars |
47 | - if (ord($HoF_name[$i]) < 32 || ord($HoF_name[$i]) > 127) |
|
48 | - create_error('Your Hall Of Fame name contains invalid characters!'); |
|
48 | + if (ord($HoF_name[$i]) < 32 || ord($HoF_name[$i]) > 127) { |
|
49 | + create_error('Your Hall Of Fame name contains invalid characters!'); |
|
50 | + } |
|
49 | 51 | |
50 | 52 | // numbers 48..57 |
51 | 53 | // Letters 65..90 |
@@ -57,23 +59,26 @@ discard block |
||
57 | 59 | } |
58 | 60 | } |
59 | 61 | |
60 | - if ($limited_char > 4) |
|
61 | - create_error('You cannot use a name with more than 4 special characters.'); |
|
62 | + if ($limited_char > 4) { |
|
63 | + create_error('You cannot use a name with more than 4 special characters.'); |
|
64 | + } |
|
62 | 65 | |
63 | 66 | |
64 | 67 | //disallow blank names |
65 | - if (empty($HoF_name) || $HoF_name == '') create_error('You Hall of Fame name must contain characters!'); |
|
68 | + if (empty($HoF_name) || $HoF_name == '') { |
|
69 | + create_error('You Hall of Fame name must contain characters!'); |
|
70 | + } |
|
66 | 71 | |
67 | 72 | //no duplicates |
68 | 73 | $db->query('SELECT * FROM account WHERE hof_name = ' . $db->escapeString($HoF_name) . ' AND account_id != ' . $db->escapeNumber($account->getAccountID()) . ' LIMIT 1'); |
69 | - if ($db->nextRecord()) create_error('Someone is already using that name!'); |
|
74 | + if ($db->nextRecord()) { |
|
75 | + create_error('Someone is already using that name!'); |
|
76 | + } |
|
70 | 77 | |
71 | 78 | // set the HoF name in account stat |
72 | 79 | $account->setHofName($HoF_name); |
73 | 80 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your hall of fame name.'; |
74 | -} |
|
75 | - |
|
76 | -elseif ($action == 'Change Discord ID') { |
|
81 | +} elseif ($action == 'Change Discord ID') { |
|
77 | 82 | $discordId = trim($_REQUEST['discord_id']); |
78 | 83 | |
79 | 84 | if (empty($discordId)) { |
@@ -83,20 +88,21 @@ discard block |
||
83 | 88 | } else { |
84 | 89 | // no duplicates |
85 | 90 | $db->query('SELECT * FROM account WHERE discord_id =' . $db->escapeString($discordId) . ' AND account_id != ' . $db->escapeNumber($account->getAccountID()) . ' LIMIT 1'); |
86 | - if ($db->nextRecord()) create_error('Someone is already using that Discord User ID!'); |
|
91 | + if ($db->nextRecord()) { |
|
92 | + create_error('Someone is already using that Discord User ID!'); |
|
93 | + } |
|
87 | 94 | |
88 | 95 | $account->setDiscordId($discordId); |
89 | 96 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your Discord User ID.'; |
90 | 97 | } |
91 | -} |
|
92 | - |
|
93 | -elseif ($action == 'Change IRC Nick') { |
|
98 | +} elseif ($action == 'Change IRC Nick') { |
|
94 | 99 | $ircNick = trim($_REQUEST['irc_nick']); |
95 | 100 | |
96 | 101 | for ($i = 0; $i < strlen($ircNick); $i++) { |
97 | 102 | // disallow certain ascii chars (and whitespace!) |
98 | - if (ord($ircNick[$i]) < 33 || ord($ircNick[$i]) > 127) |
|
99 | - create_error('Your IRC Nick contains invalid characters!'); |
|
103 | + if (ord($ircNick[$i]) < 33 || ord($ircNick[$i]) > 127) { |
|
104 | + create_error('Your IRC Nick contains invalid characters!'); |
|
105 | + } |
|
100 | 106 | } |
101 | 107 | |
102 | 108 | // here you can delete your registered irc nick |
@@ -107,7 +113,9 @@ discard block |
||
107 | 113 | |
108 | 114 | // no duplicates |
109 | 115 | $db->query('SELECT * FROM account WHERE irc_nick = ' . $db->escapeString($ircNick) . ' AND account_id != ' . $db->escapeNumber($account->getAccountID()) . ' LIMIT 1'); |
110 | - if ($db->nextRecord()) create_error('Someone is already using that nick!'); |
|
116 | + if ($db->nextRecord()) { |
|
117 | + create_error('Someone is already using that nick!'); |
|
118 | + } |
|
111 | 119 | |
112 | 120 | // save irc nick in db and set message |
113 | 121 | $account->setIrcNick($ircNick); |
@@ -115,8 +123,7 @@ discard block |
||
115 | 123 | |
116 | 124 | } |
117 | 125 | |
118 | -} |
|
119 | -elseif ($action == 'Yes') { |
|
126 | +} elseif ($action == 'Yes') { |
|
120 | 127 | $account_id = $var['account_id']; |
121 | 128 | $amount = $var['amount']; |
122 | 129 | |
@@ -128,33 +135,28 @@ discard block |
||
128 | 135 | // add to him |
129 | 136 | $his_account->increaseSmrCredits($amount); |
130 | 137 | $container['msg'] = '<span class="green">SUCCESS: </span>You have sent SMR credits.'; |
131 | -} |
|
132 | -elseif ($action == 'Change Timezone') { |
|
138 | +} elseif ($action == 'Change Timezone') { |
|
133 | 139 | $timez = $_REQUEST['timez']; |
134 | - if (!is_numeric($timez)) |
|
135 | - create_error('Numbers only please'); |
|
140 | + if (!is_numeric($timez)) { |
|
141 | + create_error('Numbers only please'); |
|
142 | + } |
|
136 | 143 | |
137 | 144 | $db->query('UPDATE account SET offset = ' . $db->escapeNumber($timez) . ' WHERE account_id = ' . $db->escapeNumber($account->getAccountID())); |
138 | 145 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your time offset.'; |
139 | -} |
|
140 | -elseif ($action == 'Change Date Formats') { |
|
146 | +} elseif ($action == 'Change Date Formats') { |
|
141 | 147 | $account->setShortDateFormat($_REQUEST['dateformat']); |
142 | 148 | $account->setShortTimeFormat($_REQUEST['timeformat']); |
143 | 149 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your date formats.'; |
144 | -} |
|
145 | -elseif ($action == 'Change Images') { |
|
150 | +} elseif ($action == 'Change Images') { |
|
146 | 151 | $account->setDisplayShipImages($_REQUEST['images']); |
147 | 152 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your ship images preferences.'; |
148 | -} |
|
149 | -elseif ($action == 'Change Centering') { |
|
153 | +} elseif ($action == 'Change Centering') { |
|
150 | 154 | $account->setCenterGalaxyMapOnPlayer($_REQUEST['centergalmap'] == 'Yes'); |
151 | 155 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your centering galaxy map preferences.'; |
152 | -} |
|
153 | -else if ($action == 'Change Size' && is_numeric($_REQUEST['fontsize']) && $_REQUEST['fontsize'] >= 50) { |
|
156 | +} else if ($action == 'Change Size' && is_numeric($_REQUEST['fontsize']) && $_REQUEST['fontsize'] >= 50) { |
|
154 | 157 | $account->setFontSize($_REQUEST['fontsize']); |
155 | 158 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your font size.'; |
156 | -} |
|
157 | -else if ($action == 'Change CSS Options') { |
|
159 | +} else if ($action == 'Change CSS Options') { |
|
158 | 160 | $account->setCssLink($_REQUEST['csslink']); |
159 | 161 | if ($_REQUEST['template'] == 'None') { |
160 | 162 | $account->setDefaultCSSEnabled(false); |
@@ -165,24 +167,20 @@ discard block |
||
165 | 167 | $account->setColourScheme($cssColourScheme); |
166 | 168 | } |
167 | 169 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your CSS options.'; |
168 | -} |
|
169 | -else if ($action == 'Change Kamikaze Setting') { |
|
170 | +} else if ($action == 'Change Kamikaze Setting') { |
|
170 | 171 | $player->setCombatDronesKamikazeOnMines($_REQUEST['kamikaze'] == 'Yes'); |
171 | 172 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your combat drones options.'; |
172 | -} |
|
173 | -else if ($action == 'Change Message Setting') { |
|
173 | +} else if ($action == 'Change Message Setting') { |
|
174 | 174 | $player->setForceDropMessages($_REQUEST['forceDropMessages'] == 'Yes'); |
175 | 175 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your message options.'; |
176 | -} |
|
177 | -else if ($action == 'Save Hotkeys') { |
|
176 | +} else if ($action == 'Save Hotkeys') { |
|
178 | 177 | foreach (AbstractSmrAccount::getDefaultHotkeys() as $hotkey => $binding) { |
179 | 178 | if (isset($_REQUEST[$hotkey])) { |
180 | 179 | $account->setHotkey($hotkey, explode(' ', $_REQUEST[$hotkey])); |
181 | 180 | } |
182 | 181 | } |
183 | 182 | $container['msg'] = '<span class="green">SUCCESS: </span>You have saved your hotkeys.'; |
184 | -} |
|
185 | -else if (strpos(trim($action), 'Alter Player') === 0) { |
|
183 | +} else if (strpos(trim($action), 'Alter Player') === 0) { |
|
186 | 184 | // trim input now |
187 | 185 | $player_name = trim($_POST['PlayerName']); |
188 | 186 | |
@@ -193,8 +191,9 @@ discard block |
||
193 | 191 | $limited_char = 0; |
194 | 192 | for ($i = 0; $i < strlen($player_name); $i++) { |
195 | 193 | // disallow certain ascii chars |
196 | - if (ord($player_name[$i]) < 32 || ord($player_name[$i]) > 127) |
|
197 | - create_error('The player name contains invalid characters!'); |
|
194 | + if (ord($player_name[$i]) < 32 || ord($player_name[$i]) > 127) { |
|
195 | + create_error('The player name contains invalid characters!'); |
|
196 | + } |
|
198 | 197 | |
199 | 198 | // numbers 48..57 |
200 | 199 | // Letters 65..90 |
@@ -206,11 +205,13 @@ discard block |
||
206 | 205 | } |
207 | 206 | } |
208 | 207 | |
209 | - if ($limited_char > 4) |
|
210 | - create_error('You cannot use a name with more than 4 special characters.'); |
|
208 | + if ($limited_char > 4) { |
|
209 | + create_error('You cannot use a name with more than 4 special characters.'); |
|
210 | + } |
|
211 | 211 | |
212 | - if (empty($player_name)) |
|
213 | - create_error('You must enter a player name!'); |
|
212 | + if (empty($player_name)) { |
|
213 | + create_error('You must enter a player name!'); |
|
214 | + } |
|
214 | 215 | |
215 | 216 | // Escape html elements so the name displays correctly |
216 | 217 | $player_name = htmlentities($player_name); |
@@ -237,8 +238,7 @@ discard block |
||
237 | 238 | $news = 'Please be advised that ' . $old_name . ' has changed their name to ' . $player->getBBLink(); |
238 | 239 | $db->query('INSERT INTO news (time, news_message, game_id, type) VALUES (' . $db->escapeNumber(TIME) . ',' . $db->escapeString($news) . ',' . $db->escapeNumber($player->getGameID()) . ', \'admin\')'); |
239 | 240 | $container['msg'] = '<span class="green">SUCCESS: </span>You have changed your player name.'; |
240 | -} |
|
241 | -else if ($action == 'Update Colours') { |
|
241 | +} else if ($action == 'Update Colours') { |
|
242 | 242 | $friendlyColour = $_REQUEST['friendly_color']; |
243 | 243 | $neutralColour = $_REQUEST['neutral_color']; |
244 | 244 | $enemyColour = $_REQUEST['enemy_color']; |
@@ -4,18 +4,20 @@ discard block |
||
4 | 4 | |
5 | 5 | if ($_REQUEST['action'] == 'Preview message') { |
6 | 6 | $container = create_container('skeleton.php'); |
7 | - if (isset($var['alliance_id'])) |
|
8 | - $container['body'] = 'alliance_broadcast.php'; |
|
9 | - else |
|
10 | - $container['body'] = 'message_send.php'; |
|
7 | + if (isset($var['alliance_id'])) { |
|
8 | + $container['body'] = 'alliance_broadcast.php'; |
|
9 | + } else { |
|
10 | + $container['body'] = 'message_send.php'; |
|
11 | + } |
|
11 | 12 | transfer('receiver'); |
12 | 13 | transfer('alliance_id'); |
13 | 14 | $container['preview'] = $message; |
14 | 15 | forward($container); |
15 | 16 | } |
16 | 17 | |
17 | -if (empty($message)) |
|
18 | +if (empty($message)) { |
|
18 | 19 | create_error('You have to enter a message to send!'); |
20 | +} |
|
19 | 21 | |
20 | 22 | if (isset($var['alliance_id'])) { |
21 | 23 | $db->query('SELECT account_id FROM player |
@@ -26,11 +28,9 @@ discard block |
||
26 | 28 | $player->sendMessage($db->getField('account_id'), MSG_ALLIANCE, $message, false); |
27 | 29 | } |
28 | 30 | $player->sendMessage($player->getAccountID(), MSG_ALLIANCE, $message, true, false); |
29 | -} |
|
30 | -else if (!empty($var['receiver'])) { |
|
31 | +} else if (!empty($var['receiver'])) { |
|
31 | 32 | $player->sendMessage($var['receiver'], MSG_PLAYER, $message); |
32 | -} |
|
33 | -else { |
|
33 | +} else { |
|
34 | 34 | $player->sendGlobalMessage($message); |
35 | 35 | } |
36 | 36 |
@@ -1,14 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!$player->isLandedOnPlanet()) |
|
2 | +if (!$player->isLandedOnPlanet()) { |
|
3 | 3 | create_error('You are not on a planet!'); |
4 | +} |
|
4 | 5 | $amount = $_REQUEST['amount']; |
5 | -if (!is_numeric($amount)) |
|
6 | +if (!is_numeric($amount)) { |
|
6 | 7 | create_error('Numbers only please'); |
8 | +} |
|
7 | 9 | |
8 | 10 | $amount = floor($amount); |
9 | 11 | |
10 | -if ($amount <= 0) |
|
12 | +if ($amount <= 0) { |
|
11 | 13 | create_error('You must actually enter an amount > 0!'); |
14 | +} |
|
12 | 15 | |
13 | 16 | // get a planet from the sector where the player is in |
14 | 17 | $planet = $player->getSectorPlanet(); |
@@ -17,12 +20,14 @@ discard block |
||
17 | 20 | if ($action == 'Ship') { |
18 | 21 | |
19 | 22 | // do we want transfer more than we have? |
20 | - if ($amount > $planet->getStockpile($var['good_id'])) |
|
21 | - create_error('You can\'t take more than on planet!'); |
|
23 | + if ($amount > $planet->getStockpile($var['good_id'])) { |
|
24 | + create_error('You can\'t take more than on planet!'); |
|
25 | + } |
|
22 | 26 | |
23 | 27 | // do we want to transfer more than we can carry? |
24 | - if ($amount > $ship->getEmptyHolds()) |
|
25 | - create_error('You can\'t take more than you can carry!'); |
|
28 | + if ($amount > $ship->getEmptyHolds()) { |
|
29 | + create_error('You can\'t take more than you can carry!'); |
|
30 | + } |
|
26 | 31 | |
27 | 32 | // now transfer |
28 | 33 | $planet->decreaseStockpile($var['good_id'], $amount); |
@@ -30,15 +35,16 @@ discard block |
||
30 | 35 | $account->log(LOG_TYPE_PLANETS, 'Player takes ' . $amount . ' ' . Globals::getGoodName($var['good_id']) . ' from planet.', $player->getSectorID()); |
31 | 36 | |
32 | 37 | // transfer to planet |
33 | -} |
|
34 | -elseif ($action == 'Planet') { |
|
38 | +} elseif ($action == 'Planet') { |
|
35 | 39 | // do we want transfer more than we have? |
36 | - if ($amount > $ship->getCargo($var['good_id'])) |
|
37 | - create_error('You can\'t store more than you carry!'); |
|
40 | + if ($amount > $ship->getCargo($var['good_id'])) { |
|
41 | + create_error('You can\'t store more than you carry!'); |
|
42 | + } |
|
38 | 43 | |
39 | 44 | // do we want to transfer more than the planet can hold? |
40 | - if ($amount > $planet->getRemainingStockpile($var['good_id'])) |
|
41 | - create_error('This planet cannot store more than ' . SmrPlanet::MAX_STOCKPILE . ' of each good!'); |
|
45 | + if ($amount > $planet->getRemainingStockpile($var['good_id'])) { |
|
46 | + create_error('This planet cannot store more than ' . SmrPlanet::MAX_STOCKPILE . ' of each good!'); |
|
47 | + } |
|
42 | 48 | |
43 | 49 | // now transfer |
44 | 50 | $planet->increaseStockpile($var['good_id'], $amount); |