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