@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | "SELECT `id` AS `ID`, `username` AS `NAME`, `ally_name` AS `ALLY`, `total_points` AS `STAT_POINTS`, |
181 | 181 | `onlinetime` AS `ACTIVITY` |
182 | 182 | FROM `{{users}}` |
183 | - WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) ." ORDER BY user_as_ally, `". $TypeSort ."` ASC;"); |
|
183 | + WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) . " ORDER BY user_as_ally, `" . $TypeSort . "` ASC;"); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | return doquery("SELECT u.*, COUNT(r.id) AS referral_count, SUM(r.dark_matter) AS referral_dm FROM {{users}} as u |
196 | 196 | LEFT JOIN {{referrals}} as r on r.id_partner = u.id |
197 | 197 | WHERE" . |
198 | - ($online ? " `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
198 | + ($online ? " `onlinetime` >= " . (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
199 | 199 | " GROUP BY u.id |
200 | 200 | ORDER BY user_as_ally, {$sort} ASC"); |
201 | 201 | } |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false; |
212 | 212 | |
213 | 213 | $user_list = array(); |
214 | - foreach($user_id_list as $user_id_unsafe) { |
|
214 | + foreach ($user_id_list as $user_id_unsafe) { |
|
215 | 215 | $user = db_user_by_id($user_id_unsafe); |
216 | 216 | !empty($user) ? $user_list[$user_id_unsafe] = $user : false; |
217 | 217 | } |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
57 | 57 | sn_db_transaction_commit(); |
58 | 58 | throw new exception('buddy_err_accept_none', ERR_NONE); |
59 | - } |
|
60 | - else |
|
59 | + } else |
|
61 | 60 | { |
62 | 61 | throw new exception('buddy_err_accept_internal', ERR_ERROR); |
63 | 62 | } |
@@ -69,9 +68,11 @@ discard block |
||
69 | 68 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
70 | 69 | } |
71 | 70 | |
72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
71 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
72 | + // Existing friendship |
|
73 | 73 | { |
74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
75 | + } |
|
75 | 76 | |
76 | 77 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
77 | 78 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -79,17 +80,19 @@ discard block |
||
79 | 80 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
80 | 81 | sn_db_transaction_commit(); |
81 | 82 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
82 | - } |
|
83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
83 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
84 | + // Player's outcoming request - either denied or waiting |
|
84 | 85 | { |
85 | 86 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
87 | + } |
|
86 | 88 | sn_db_transaction_commit(); |
87 | 89 | throw new exception('buddy_err_delete_own', ERR_NONE); |
88 | - } |
|
89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
90 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
91 | + // Deny incoming request |
|
90 | 92 | { |
91 | 93 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
92 | 94 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
95 | + } |
|
93 | 96 | |
94 | 97 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_DENIED . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
95 | 98 | sn_db_transaction_commit(); |
@@ -104,8 +107,7 @@ discard block |
||
104 | 107 | if($new_friend_id = sys_get_param_id('request_user_id')) |
105 | 108 | { |
106 | 109 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
107 | - } |
|
108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
110 | + } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
109 | 111 | { |
110 | 112 | $new_friend_row = db_user_by_username($new_friend_name); |
111 | 113 | $new_friend_name = db_escape($new_friend_name); |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | sn_db_transaction_commit(); |
139 | 141 | throw new exception('buddy_err_adding_none', ERR_NONE); |
140 | 142 | } |
141 | -} |
|
142 | -catch(exception $e) |
|
143 | +} catch(exception $e) |
|
143 | 144 | { |
144 | 145 | $result[] = array( |
145 | 146 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -18,39 +18,39 @@ discard block |
||
18 | 18 | { |
19 | 19 | sn_db_transaction_start(); |
20 | 20 | |
21 | - if($buddy_id = sys_get_param_id('buddy_id')) |
|
21 | + if ($buddy_id = sys_get_param_id('buddy_id')) |
|
22 | 22 | { |
23 | 23 | $buddy_row = doquery("SELECT BUDDY_SENDER_ID, BUDDY_OWNER_ID, BUDDY_STATUS FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1 FOR UPDATE;", true); |
24 | - if(!is_array($buddy_row)) |
|
24 | + if (!is_array($buddy_row)) |
|
25 | 25 | { |
26 | 26 | throw new exception('buddy_err_not_exist', ERR_ERROR); |
27 | 27 | } |
28 | 28 | |
29 | - switch($mode = sys_get_param_str('mode')) |
|
29 | + switch ($mode = sys_get_param_str('mode')) |
|
30 | 30 | { |
31 | 31 | case 'accept': |
32 | - if($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
32 | + if ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) |
|
33 | 33 | { |
34 | 34 | throw new exception('buddy_err_accept_own', ERR_ERROR); |
35 | 35 | } |
36 | 36 | |
37 | - if($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
37 | + if ($buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
38 | 38 | { |
39 | 39 | throw new exception('buddy_err_accept_alien', ERR_ERROR); |
40 | 40 | } |
41 | 41 | |
42 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
42 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) |
|
43 | 43 | { |
44 | 44 | throw new exception('buddy_err_accept_already', ERR_WARNING); |
45 | 45 | } |
46 | 46 | |
47 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
47 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_DENIED) |
|
48 | 48 | { |
49 | 49 | throw new exception('buddy_err_accept_denied', ERR_ERROR); |
50 | 50 | } |
51 | 51 | |
52 | 52 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_ACTIVE . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
53 | - if(SN::$db->db_affected_rows()) |
|
53 | + if (SN::$db->db_affected_rows()) |
|
54 | 54 | { |
55 | 55 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_accept_title'], |
56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
@@ -64,12 +64,12 @@ discard block |
||
64 | 64 | break; |
65 | 65 | |
66 | 66 | case 'delete': |
67 | - if($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
67 | + if ($buddy_row['BUDDY_SENDER_ID'] != $user['id'] && $buddy_row['BUDDY_OWNER_ID'] != $user['id']) |
|
68 | 68 | { |
69 | 69 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
70 | 70 | } |
71 | 71 | |
72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
72 | + if ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
73 | 73 | { |
74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
75 | 75 | |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | sn_db_transaction_commit(); |
81 | 81 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
82 | 82 | } |
83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
83 | + elseif ($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
84 | 84 | { |
85 | 85 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
86 | 86 | sn_db_transaction_commit(); |
87 | 87 | throw new exception('buddy_err_delete_own', ERR_NONE); |
88 | 88 | } |
89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
89 | + elseif ($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
90 | 90 | { |
91 | 91 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
92 | 92 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
@@ -101,24 +101,24 @@ discard block |
||
101 | 101 | |
102 | 102 | // New request? |
103 | 103 | // Checking for user ID - in case if it was request from outside buddy system |
104 | - if($new_friend_id = sys_get_param_id('request_user_id')) |
|
104 | + if ($new_friend_id = sys_get_param_id('request_user_id')) |
|
105 | 105 | { |
106 | 106 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
107 | 107 | } |
108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
108 | + elseif ($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
109 | 109 | { |
110 | 110 | $new_friend_row = db_user_by_username($new_friend_name); |
111 | 111 | $new_friend_name = db_escape($new_friend_name); |
112 | 112 | } |
113 | 113 | |
114 | - if($new_friend_row['id'] == $user['id']) |
|
114 | + if ($new_friend_row['id'] == $user['id']) |
|
115 | 115 | { |
116 | 116 | unset($new_friend_row); |
117 | 117 | throw new exception('buddy_err_adding_self', ERR_ERROR); |
118 | 118 | } |
119 | 119 | |
120 | 120 | // Checking for user name & request text - in case if it was request to adding new request |
121 | - if(isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
121 | + if (isset($new_friend_row['id']) && ($new_request_text = sys_get_param_str('request_text'))) |
|
122 | 122 | { |
123 | 123 | $check_relation = doquery("SELECT `BUDDY_ID` FROM {{buddy}} WHERE |
124 | 124 | (`BUDDY_SENDER_ID` = {$user['id']} AND `BUDDY_OWNER_ID` = {$new_friend_row['id']}) |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | (`BUDDY_SENDER_ID` = {$new_friend_row['id']} AND `BUDDY_OWNER_ID` = {$user['id']}) |
127 | 127 | LIMIT 1 FOR UPDATE;" |
128 | 128 | , true); |
129 | - if(isset($check_relation['BUDDY_ID'])) |
|
129 | + if (isset($check_relation['BUDDY_ID'])) |
|
130 | 130 | { |
131 | 131 | throw new exception('buddy_err_adding_exists', ERR_WARNING); |
132 | 132 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | throw new exception('buddy_err_adding_none', ERR_NONE); |
140 | 140 | } |
141 | 141 | } |
142 | -catch(exception $e) |
|
142 | +catch (exception $e) |
|
143 | 143 | { |
144 | 144 | $result[] = array( |
145 | 145 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | sn_db_transaction_rollback(); |
151 | 151 | |
152 | 152 | $query = db_buddy_list_by_user($user['id']); |
153 | -while($row = db_fetch($query)) |
|
153 | +while ($row = db_fetch($query)) |
|
154 | 154 | { |
155 | 155 | $row['BUDDY_REQUEST'] = HelperString::nl2br($row['BUDDY_REQUEST']); |
156 | 156 |
@@ -46,7 +46,7 @@ |
||
46 | 46 | * @return bool |
47 | 47 | */ |
48 | 48 | public function changeTitle(AllianceTitle $title) { |
49 | - if(!$title instanceof AllianceTitle) { |
|
49 | + if (!$title instanceof AllianceTitle) { |
|
50 | 50 | return false; |
51 | 51 | } |
52 | 52 |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | continue; |
46 | 46 | } |
47 | 47 | |
48 | - $result[] = (string)$title; |
|
48 | + $result[] = (string) $title; |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | return implode(';', $result); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * Updates title names and access rights with current ones |
68 | 68 | */ |
69 | 69 | public function updateTitles() { |
70 | - $this->alliance->titleList = (string)$this; |
|
70 | + $this->alliance->titleList = (string) $this; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | protected function extractTitles() { |
@@ -58,8 +58,7 @@ |
||
58 | 58 | * @return int |
59 | 59 | */ |
60 | 60 | public static function calcBonusPower($unitInfo) { |
61 | - return isset($unitInfo[P_BONUS_VALUE]) ? $unitInfo[P_BONUS_VALUE] : |
|
62 | - (static::calcBonusType($unitInfo) == BONUS_ABILITY ? 1 : 0); |
|
61 | + return isset($unitInfo[P_BONUS_VALUE]) ? $unitInfo[P_BONUS_VALUE] : (static::calcBonusType($unitInfo) == BONUS_ABILITY ? 1 : 0); |
|
63 | 62 | } |
64 | 63 | |
65 | 64 | /** |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | renderFooter(); |
289 | 289 | } |
290 | 290 | |
291 | - $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;; |
|
291 | + $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false; ; |
|
292 | 292 | |
293 | 293 | sn_db_disconnect(); |
294 | 294 | |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | 'QUE_ID' => QUE_RESEARCH, |
671 | 671 | 'QUE_HTML' => 'topnav', |
672 | 672 | |
673 | - 'RESEARCH_ONGOING' => (boolean)$user['que'], |
|
673 | + 'RESEARCH_ONGOING' => (boolean) $user['que'], |
|
674 | 674 | |
675 | 675 | 'TIME_TEXT' => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'], |
676 | 676 | $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds'] |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | 'LANG' => $language ? $language : '', |
964 | 964 | 'referral' => $id_ref ? '&id_ref=' . $id_ref : '', |
965 | 965 | |
966 | - 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
966 | + 'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''), |
|
967 | 967 | 'FILENAME' => basename($_SERVER['PHP_SELF']), |
968 | 968 | )); |
969 | 969 |
@@ -58,8 +58,8 @@ |
||
58 | 58 | protected function bonusSort(BonusAtom $a, BonusAtom $b) { |
59 | 59 | static $bonusOrder = [BonusAtom::class, BonusAtomAbility::class, BonusAtomAdd::class, BonusAtomPercent::class, BonusAtomMultiply::class]; |
60 | 60 | |
61 | - $indexA = (int)array_search(get_class($a), $bonusOrder); |
|
62 | - $indexB = (int)array_search(get_class($b), $bonusOrder); |
|
61 | + $indexA = (int) array_search(get_class($a), $bonusOrder); |
|
62 | + $indexB = (int) array_search(get_class($b), $bonusOrder); |
|
63 | 63 | |
64 | 64 | return $indexA == $indexB ? 0 : ($indexA > $indexB ? +1 : -1); |
65 | 65 | } |
@@ -48,20 +48,20 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | protected function initValues() { |
51 | - $this[UNIT_SERVER_SPEED_BUILDING] = function (ValueStorage $vs) { |
|
51 | + $this[UNIT_SERVER_SPEED_BUILDING] = function(ValueStorage $vs) { |
|
52 | 52 | return new ValueBonused(UNIT_SERVER_SPEED_BUILDING, floatval($vs->getGlobalContainer()->config->game_speed)); |
53 | 53 | }; |
54 | - $this[UNIT_SERVER_SPEED_MINING] = function (ValueStorage $vs) { |
|
54 | + $this[UNIT_SERVER_SPEED_MINING] = function(ValueStorage $vs) { |
|
55 | 55 | return new ValueBonused(UNIT_SERVER_SPEED_MINING, floatval($vs->getGlobalContainer()->config->resource_multiplier)); |
56 | 56 | }; |
57 | - $this[UNIT_SERVER_SPEED_FLEET] = function (ValueStorage $vs) { |
|
57 | + $this[UNIT_SERVER_SPEED_FLEET] = function(ValueStorage $vs) { |
|
58 | 58 | return new ValueBonused(UNIT_SERVER_SPEED_FLEET, floatval($vs->getGlobalContainer()->config->fleet_speed)); |
59 | 59 | }; |
60 | - $this[UNIT_SERVER_SPEED_EXPEDITION] = function (ValueStorage $vs) { |
|
60 | + $this[UNIT_SERVER_SPEED_EXPEDITION] = function(ValueStorage $vs) { |
|
61 | 61 | return new ValueBonused(UNIT_SERVER_SPEED_EXPEDITION, floatval(1)); |
62 | 62 | }; |
63 | 63 | |
64 | - $this[UNIT_SERVER_FLEET_NOOB_POINTS] = function (ValueStorage $vs) { |
|
64 | + $this[UNIT_SERVER_FLEET_NOOB_POINTS] = function(ValueStorage $vs) { |
|
65 | 65 | $config = $vs->getGlobalContainer()->config; |
66 | 66 | |
67 | 67 | return new ValueBonused( |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | floatval($config->game_noob_points * $vs->getBase(UNIT_SERVER_SPEED_MINING)) |
70 | 70 | ); |
71 | 71 | }; |
72 | - $this[UNIT_SERVER_FLEET_NOOB_FACTOR] = function (ValueStorage $vs) { |
|
72 | + $this[UNIT_SERVER_FLEET_NOOB_FACTOR] = function(ValueStorage $vs) { |
|
73 | 73 | return new ValueBonused(UNIT_SERVER_FLEET_NOOB_FACTOR, floatval($vs->getGlobalContainer()->config->game_noob_factor)); |
74 | 74 | }; |
75 | 75 | |
76 | - $this[UNIT_SERVER_PAYMENT_MM_PER_CURRENCY] = function (ValueStorage $vs) { |
|
76 | + $this[UNIT_SERVER_PAYMENT_MM_PER_CURRENCY] = function(ValueStorage $vs) { |
|
77 | 77 | return new ValueBonused(UNIT_SERVER_PAYMENT_MM_PER_CURRENCY, floatval($vs->getGlobalContainer()->config->payment_currency_exchange_mm_)); |
78 | 78 | }; |
79 | 79 | } |
@@ -105,7 +105,7 @@ |
||
105 | 105 | * @return int |
106 | 106 | */ |
107 | 107 | public function getMaxLevel() { |
108 | - $snId = $this->getSnId(); |
|
108 | + $snId = $this->getSnId(); |
|
109 | 109 | return !empty($snId) ? get_unit_param($snId, P_MAX_STACK) : 0; |
110 | 110 | } |
111 | 111 |