@@ -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 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * @copyright 2008-2015 Gorlum for Project "SuperNova.WS" |
6 | 6 | */ |
7 | 7 | |
8 | -if(!defined('INSIDE')) { |
|
8 | +if (!defined('INSIDE')) { |
|
9 | 9 | die(); |
10 | 10 | } |
11 | 11 | |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | function db_change_units_perform($query, $tablename, $object_id) { |
15 | 15 | $query = implode(',', $query); |
16 | - if($query && $object_id) { |
|
16 | + if ($query && $object_id) { |
|
17 | 17 | return SN::db_upd_record_by_id($tablename == 'users' ? LOC_USER : LOC_PLANET, $object_id, $query); |
18 | 18 | } |
19 | 19 | } |
@@ -29,15 +29,15 @@ discard block |
||
29 | 29 | |
30 | 30 | $group = sn_get_groups('resources_loot'); |
31 | 31 | |
32 | - foreach($unit_list as $unit_id => $unit_amount) { |
|
33 | - if(!in_array($unit_id, $group)) { |
|
32 | + foreach ($unit_list as $unit_id => $unit_amount) { |
|
33 | + if (!in_array($unit_id, $group)) { |
|
34 | 34 | // TODO - remove later |
35 | 35 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>'); |
36 | 36 | pdump(debug_backtrace()); |
37 | 37 | die('db_change_units() вызван для не-ресурсов!'); |
38 | 38 | } |
39 | 39 | |
40 | - if(!$unit_amount) { |
|
40 | + if (!$unit_amount) { |
|
41 | 41 | continue; |
42 | 42 | } |
43 | 43 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | $unit_location = sys_get_unit_location($user, $planet, $unit_id); |
47 | 47 | |
48 | 48 | // Changing value in object |
49 | - switch($unit_location) { |
|
49 | + switch ($unit_location) { |
|
50 | 50 | case LOC_USER: |
51 | 51 | $user[$unit_db_name] += $unit_amount; |
52 | 52 | break; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS; |
15 | 15 | |
16 | 16 | $mode = sys_get_param_int('mode'); |
17 | - switch($mode) |
|
17 | + switch ($mode) |
|
18 | 18 | { |
19 | 19 | case CHAT_MODE_ALLY: |
20 | 20 | $template_result['ALLY'] = intval($user['ally_id']); |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | } |
29 | 29 | |
30 | 30 | $template_result['.']['smiles'] = array(); |
31 | - foreach(SN::$gc->design->getSmilesList() as $auth_level => $replaces) { |
|
32 | - if($auth_level > $user_auth_level) { |
|
31 | + foreach (SN::$gc->design->getSmilesList() as $auth_level => $replaces) { |
|
32 | + if ($auth_level > $user_auth_level) { |
|
33 | 33 | continue; |
34 | 34 | } |
35 | 35 | |
36 | - foreach($replaces as $bbcode => $filename) |
|
36 | + foreach ($replaces as $bbcode => $filename) |
|
37 | 37 | { |
38 | 38 | $template_result['.']['smiles'][] = array( |
39 | 39 | 'BBCODE' => $bbcode, |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | |
58 | 58 | define('IN_AJAX', true); |
59 | 59 | |
60 | - if($config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
60 | + if ($config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
61 | 61 | { |
62 | 62 | die(); |
63 | 63 | } |
64 | 64 | |
65 | - if(($message = sys_get_param_str('message')) && $user['username']) |
|
65 | + if (($message = sys_get_param_str('message')) && $user['username']) |
|
66 | 66 | { |
67 | 67 | $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0; |
68 | 68 | $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id)))); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | define('IN_AJAX', true); |
88 | 88 | |
89 | 89 | $history = sys_get_param_str('history'); |
90 | - if(!$history) |
|
90 | + if (!$history) |
|
91 | 91 | { |
92 | 92 | $config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO); |
93 | 93 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $last_message = ''; |
97 | 97 | $alliance = 0; |
98 | 98 | $template_result['.']['chat'] = array(); |
99 | - if(!$history && $config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
99 | + if (!$history && $config->getMode() != classCache::CACHER_NO_CACHE && $config->chat_timeout && SN_TIME_MICRO - $config->array_get('users', $user['id'], 'chat_last_activity') > $config->chat_timeout) |
|
100 | 100 | { |
101 | 101 | $result['disable'] = true; |
102 | 102 | $template_result['.']['chat'][] = array( |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | |
113 | 113 | $where_add = ''; |
114 | 114 | $last_message = 0; |
115 | - if($history) |
|
115 | + if ($history) |
|
116 | 116 | { |
117 | 117 | $rows = doquery("SELECT count(1) AS CNT FROM {{chat}} WHERE ally_id = '{$alliance}';", true); |
118 | 118 | $page_count = ceil($rows['CNT'] / $page_limit); |
119 | 119 | |
120 | - for($i = 0; $i < $page_count; $i++) |
|
120 | + for ($i = 0; $i < $page_count; $i++) |
|
121 | 121 | { |
122 | 122 | $template_result['.']['page'][] = array( |
123 | 123 | 'NUMBER' => $i |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | {{chat}} AS c |
140 | 140 | LEFT JOIN {{users}} AS u ON u.id = c.chat_message_sender_id |
141 | 141 | WHERE c.chat_message_recipient_id IS NULL AND c.ally_id = '{$alliance}' {$where_add} ORDER BY messageid DESC LIMIT {$start_row}, {$page_limit};"); |
142 | - while($chat_row = db_fetch($query)) |
|
142 | + while ($chat_row = db_fetch($query)) |
|
143 | 143 | { |
144 | 144 | // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick |
145 | 145 | $chat_row['user'] = player_nick_render_to_html($chat_row['user']); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $template = gettemplate('chat_messages', $template); |
169 | 169 | $template->assign_recursive($template_result); |
170 | 170 | |
171 | - if($history) |
|
171 | + if ($history) |
|
172 | 172 | { |
173 | 173 | $pageTitle = "{$lang['chat_history']} - {$lang[$alliance ? 'chat_ally' : 'chat_common']}"; |
174 | 174 | display($template, $pageTitle); |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | function sn_eco_build($que_type, &$auser, &$planet) { |
19 | 19 | global $lang, $config, $template_result; |
20 | 20 | |
21 | - if($ally_id = sys_get_param_id('ally_id')) { |
|
21 | + if ($ally_id = sys_get_param_id('ally_id')) { |
|
22 | 22 | define('SN_IN_ALLY', true); |
23 | 23 | $ranks = \Alliance\Alliance::ally_get_ranks($auser['ally']); |
24 | - if($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
24 | + if ($ranks[$auser['ally_rank_id']]['admin'] || $auser['ally']['ally_owner'] == $auser['id']) { |
|
25 | 25 | $user = &$auser['ally']['player']; |
26 | 26 | $planet = array( |
27 | 27 | 'metal' => $user['metal'], |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
34 | - if(!$user) { |
|
34 | + if (!$user) { |
|
35 | 35 | $user = &$auser; |
36 | 36 | } |
37 | 37 | |
38 | - switch($action = sys_get_param_escaped('action')) { |
|
38 | + switch ($action = sys_get_param_escaped('action')) { |
|
39 | 39 | case 'create': // Add unit to que for build |
40 | 40 | case 'create_autoconvert': // Add unit to que for build |
41 | 41 | case 'destroy': // Add unit to que for remove |
@@ -52,23 +52,23 @@ discard block |
||
52 | 52 | |
53 | 53 | $group_missile = sn_get_groups('missile'); |
54 | 54 | $silo_capacity_free = 0; |
55 | - if($que_type == QUE_STRUCTURES) { |
|
55 | + if ($que_type == QUE_STRUCTURES) { |
|
56 | 56 | $build_unit_list = sn_get_groups('build_allow'); |
57 | 57 | $build_unit_list = $build_unit_list[$planet['planet_type']]; |
58 | 58 | $artifact_id = ART_NANO_BUILDER; |
59 | 59 | $page_header = $lang['tech'][UNIT_STRUCTURES]; |
60 | - } elseif($que_type == QUE_RESEARCH) { |
|
61 | - if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
60 | + } elseif ($que_type == QUE_RESEARCH) { |
|
61 | + if (!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
|
62 | 62 | messageBox($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]); |
63 | 63 | } |
64 | 64 | |
65 | - if(eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
65 | + if (eco_unit_busy($user, $planet, UNIT_TECHNOLOGIES)) { |
|
66 | 66 | messageBox($lang['eco_bld_msg_err_laboratory_upgrading'], $lang['tech'][UNIT_TECHNOLOGIES]); |
67 | 67 | } |
68 | 68 | $build_unit_list = sn_get_groups('tech'); |
69 | 69 | $artifact_id = ART_HEURISTIC_CHIP; |
70 | 70 | $page_header = $lang['eco_bld_research_page_name'] . ($user['user_as_ally'] ? " {$lang['sys_of_ally']} {$user['username']}" : ''); |
71 | - } elseif($que_type == QUE_MERCENARY) { |
|
71 | + } elseif ($que_type == QUE_MERCENARY) { |
|
72 | 72 | // if(!mrc_get_level($user, $planet, STRUC_LABORATORY)) { |
73 | 73 | // messageBox($lang['no_laboratory'], $lang['tech'][UNIT_TECHNOLOGIES]); |
74 | 74 | // } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | $artifact_id = 0; |
81 | 81 | $page_header = $lang['tech'][UNIT_MERCENARIES] . ($user['user_as_ally'] ? " {$lang['sys_of_ally']} {$user['username']}" : ''); |
82 | 82 | } else { |
83 | - if(mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
83 | + if (mrc_get_level($user, $planet, STRUC_FACTORY_HANGAR) == 0) { |
|
84 | 84 | messageBox($lang['need_hangar'], $lang['tech'][STRUC_FACTORY_HANGAR]); |
85 | 85 | } |
86 | 86 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $artifact_id = 0; |
90 | 90 | |
91 | 91 | $silo_capacity_free = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY); |
92 | - foreach($group_missile as $unit_id) { |
|
92 | + foreach ($group_missile as $unit_id) { |
|
93 | 93 | $silo_capacity_free -= (mrc_get_level($user, $planet, $unit_id, false, true) + (isset($in_que[$unit_id]) && $in_que[$unit_id] ? $in_que[$unit_id] : 0)) * get_unit_param($unit_id, P_UNIT_SIZE); |
94 | 94 | } |
95 | 95 | $silo_capacity_free = max(0, $silo_capacity_free); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | |
108 | 108 | $template = gettemplate('buildings_builds', true); |
109 | - if(!empty($operation_result)) { |
|
109 | + if (!empty($operation_result)) { |
|
110 | 110 | $template_result['.']['result'][] = $operation_result; |
111 | 111 | } |
112 | 112 | |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | |
137 | 137 | $record_index = 0; |
138 | 138 | |
139 | - foreach($build_unit_list as $unit_id) { |
|
139 | + foreach ($build_unit_list as $unit_id) { |
|
140 | 140 | $level_base = mrc_get_level($user, $planet, $unit_id, false, true); |
141 | 141 | $level_effective = mrc_get_level($user, $planet, $unit_id); |
142 | 142 | $level_in_que = $in_que[$unit_id]; |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | $can_build = $unit_info[P_MAX_STACK] ? max(0, $unit_info[P_MAX_STACK] - $level_in_que - $level_effective) : $build_data['CAN'][BUILD_CREATE]; |
160 | 160 | // Restricting $can_build by free silo capacity |
161 | 161 | $can_build = ($unit_is_missile = in_array($unit_id, $group_missile)) ? min($can_build, floor($silo_capacity_free / $unit_info[P_UNIT_SIZE])) : $can_build; |
162 | - if(!$can_build) { |
|
163 | - if(!$build_data['CAN'][BUILD_CREATE]) { |
|
162 | + if (!$can_build) { |
|
163 | + if (!$build_data['CAN'][BUILD_CREATE]) { |
|
164 | 164 | $build_data['RESULT'][BUILD_CREATE] = BUILD_NO_RESOURCES; |
165 | - } elseif($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
165 | + } elseif ($unit_is_missile && $silo_capacity_free < $unit_info[P_UNIT_SIZE]) { |
|
166 | 166 | $build_data['RESULT'][BUILD_CREATE] = BUILD_SILO_FULL; |
167 | - } elseif($unit_info[P_MAX_STACK]) { |
|
167 | + } elseif ($unit_info[P_MAX_STACK]) { |
|
168 | 168 | $build_data['RESULT'][BUILD_CREATE] = BUILD_MAX_REACHED; |
169 | 169 | } |
170 | 170 | } |
@@ -232,14 +232,14 @@ discard block |
||
232 | 232 | 'MAP_IS_RESOURCE' => !empty($unit_info[P_UNIT_PRODUCTION]), |
233 | 233 | ); |
234 | 234 | |
235 | - if($unit_stackable) { |
|
235 | + if ($unit_stackable) { |
|
236 | 236 | $level_production_base = array( |
237 | 237 | 'ACTUAL_SHIELD' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_SHIELD), $unit_info['shield'])), |
238 | 238 | 'ACTUAL_ARMOR' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_ARMOR), $unit_info['armor'])), |
239 | 239 | 'ACTUAL_WEAPON' => HelperString::numberFloorAndFormat(mrc_modify_value($user, false, array(MRC_ADMIRAL, TECH_WEAPON), $unit_info['attack'])), |
240 | 240 | ); |
241 | 241 | |
242 | - if($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
242 | + if ($unit_info[P_UNIT_TYPE] == UNIT_SHIPS) { |
|
243 | 243 | $ship_data = get_ship_data($unit_id, $user); |
244 | 244 | |
245 | 245 | $level_production_base += array( |
@@ -249,9 +249,9 @@ discard block |
||
249 | 249 | ); |
250 | 250 | } |
251 | 251 | |
252 | - if($unit_info[P_UNIT_PRODUCTION]) { |
|
253 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
254 | - if($resource_income = |
|
252 | + if ($unit_info[P_UNIT_PRODUCTION]) { |
|
253 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
254 | + if ($resource_income = |
|
255 | 255 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc(1, 10, $user, $planet) |
256 | 256 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
257 | 257 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -261,11 +261,11 @@ discard block |
||
261 | 261 | } |
262 | 262 | } |
263 | 263 | $production['.']['resource'][] = $level_production_base; |
264 | - } elseif($unit_info[P_UNIT_PRODUCTION]) { |
|
264 | + } elseif ($unit_info[P_UNIT_PRODUCTION]) { |
|
265 | 265 | $level_production_base = array(); |
266 | 266 | $element_level_start = $level_effective + $in_que[$unit_id]; |
267 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | - if($resource_income = |
|
267 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
268 | + if ($resource_income = |
|
269 | 269 | floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($element_level_start, 10, $user, $planet) |
270 | 270 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
271 | 271 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
@@ -275,24 +275,24 @@ discard block |
||
275 | 275 | } |
276 | 276 | |
277 | 277 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
278 | - for($i = 0; $i < 6; $i++) { |
|
278 | + for ($i = 0; $i < 6; $i++) { |
|
279 | 279 | $level_production = array('LEVEL' => $level_start + $i); |
280 | - foreach($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
281 | - if( |
|
280 | + foreach ($unit_info[P_UNIT_PRODUCTION] as $resource_id => $resource_calc) { |
|
281 | + if ( |
|
282 | 282 | $resource_income = floor(mrc_modify_value($user, $planet, $sn_modifiers_resource, $resource_calc($level_start + $i, 10, $user, $planet) |
283 | 283 | * ($resource_id == RES_ENERGY ? $config_resource_multiplier_plain : $config_resource_multiplier) |
284 | 284 | * (isset($density_info[$resource_id]) ? $density_info[$resource_id] : 1))) |
285 | 285 | ) { |
286 | 286 | $level_production['R' . $resource_id] = $resource_income; |
287 | 287 | $level_production['D' . $resource_id] = $resource_income - $level_production_base[$resource_id]; |
288 | - if($level_production['D' . $resource_id] == 0) { |
|
288 | + if ($level_production['D' . $resource_id] == 0) { |
|
289 | 289 | $level_production['D' . $resource_id] = '-'; |
290 | 290 | } |
291 | 291 | } |
292 | 292 | } |
293 | 293 | $production['.']['resource'][] = $level_production; |
294 | 294 | } |
295 | - } elseif($unit_id == TECH_ASTROTECH) { |
|
295 | + } elseif ($unit_id == TECH_ASTROTECH) { |
|
296 | 296 | $element_level_start = $level_effective + $in_que[$unit_id]; |
297 | 297 | $level_production_base = array( |
298 | 298 | UNIT_PLAYER_EXPEDITIONS_MAX => get_player_max_expeditons($user, $element_level_start), |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | ); |
301 | 301 | |
302 | 302 | $level_start = $level_base_and_que > 1 ? $level_effective + $level_in_que - 1 : 1; |
303 | - for($i = 0; $i < 6; $i++) { |
|
303 | + for ($i = 0; $i < 6; $i++) { |
|
304 | 304 | $level_production = array('LEVEL' => $level_start + $i); |
305 | 305 | $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] = get_player_max_expeditons($user, $level_start + $i); |
306 | 306 | $level_production['D' . UNIT_PLAYER_EXPEDITIONS_MAX] = $level_production['R' . UNIT_PLAYER_EXPEDITIONS_MAX] - $level_production_base[UNIT_PLAYER_EXPEDITIONS_MAX]; |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | $template_result['.']['production'][] = $production; |
322 | 322 | } |
323 | 323 | |
324 | - foreach($lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
324 | + foreach ($lang['player_option_building_sort'] as $sort_id => $sort_text) { |
|
325 | 325 | $template->assign_block_vars('sort_values', array( |
326 | 326 | 'VALUE' => $sort_id, |
327 | 327 | 'TEXT' => $sort_text, |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | |
331 | 331 | $sort_option = SN::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $que_type)]; |
332 | 332 | $sort_option_inverse = SN::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $que_type)]; |
333 | - if($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
334 | - switch($sort_option) { |
|
333 | + if ($sort_option || $sort_option_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
334 | + switch ($sort_option) { |
|
335 | 335 | case PLAYER_OPTION_SORT_NAME: |
336 | 336 | $sort_option_field = 'NAME'; |
337 | 337 | break; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | break; |
347 | 347 | } |
348 | 348 | $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1; |
349 | - usort($template_result['.']['production'], function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
349 | + usort($template_result['.']['production'], function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) { |
|
350 | 350 | return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : ( |
351 | 351 | $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0 |
352 | 352 | ); |
@@ -5,9 +5,9 @@ discard block |
||
5 | 5 | // @version 1.0 |
6 | 6 | // @copyright 2008 by Chlorel for XNova |
7 | 7 | |
8 | -if($fleet_ship_sort = sys_get_param_id('sort_elements')) { |
|
8 | +if ($fleet_ship_sort = sys_get_param_id('sort_elements')) { |
|
9 | 9 | define('IN_AJAX', true); |
10 | - if(!empty($lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) { |
|
10 | + if (!empty($lang['player_option_fleet_ship_sort'][$fleet_ship_sort])) { |
|
11 | 11 | // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT, $fleet_ship_sort); |
12 | 12 | // player_save_option($user, PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE, sys_get_param_id('fleet_ship_sort_inverse', 0)); |
13 | 13 | SN::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT] = $fleet_ship_sort; |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | die(); |
17 | 17 | } |
18 | 18 | |
19 | -if(SN_IN_FLEET !== true) { |
|
19 | +if (SN_IN_FLEET !== true) { |
|
20 | 20 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
21 | 21 | } |
22 | 22 | |
23 | 23 | lng_include('overview'); |
24 | 24 | |
25 | -if(!$planetrow) { |
|
25 | +if (!$planetrow) { |
|
26 | 26 | messageBox($lang['fl_noplanetrow'], $lang['fl_error']); |
27 | 27 | } |
28 | 28 | |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | |
31 | 31 | $record_index = 0; |
32 | 32 | $ship_list = array(); |
33 | -foreach(sn_get_groups('fleet') as $n => $unit_id) { |
|
33 | +foreach (sn_get_groups('fleet') as $n => $unit_id) { |
|
34 | 34 | $unit_level = mrc_get_level($user, $planetrow, $unit_id, false, true); |
35 | - if($unit_level > 0) { |
|
35 | + if ($unit_level > 0) { |
|
36 | 36 | $ship_data = get_ship_data($unit_id, $user); |
37 | 37 | $ship_list[$unit_id] = array( |
38 | 38 | '__INDEX' => $record_index++, |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | |
53 | 53 | $fleet_ship_sort = SN::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT]; |
54 | 54 | $fleet_ship_sort_inverse = SN::$user_options[PLAYER_OPTION_FLEET_SHIP_SORT_INVERSE]; |
55 | -if($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
56 | - switch($fleet_ship_sort) { |
|
55 | +if ($fleet_ship_sort || $fleet_ship_sort_inverse != PLAYER_OPTION_SORT_ORDER_PLAIN) { |
|
56 | + switch ($fleet_ship_sort) { |
|
57 | 57 | case PLAYER_OPTION_SORT_NAME: $fleet_ship_sort_field = 'NAME'; break; |
58 | 58 | case PLAYER_OPTION_SORT_SPEED: $fleet_ship_sort_field = 'SPEED'; break; |
59 | 59 | case PLAYER_OPTION_SORT_COUNT: $fleet_ship_sort_field = 'AMOUNT'; break; |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | }); |
69 | 69 | } |
70 | 70 | |
71 | -foreach($ship_list as $ship_data) { |
|
71 | +foreach ($ship_list as $ship_data) { |
|
72 | 72 | $template->assign_block_vars('ships', $ship_data); |
73 | 73 | } |
74 | 74 | |
75 | -foreach($lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
75 | +foreach ($lang['player_option_fleet_ship_sort'] as $sort_id => $sort_text) { |
|
76 | 76 | $template->assign_block_vars('ship_sort_list', array( |
77 | 77 | 'VALUE' => $sort_id, |
78 | 78 | 'TEXT' => $sort_text, |
@@ -17,11 +17,11 @@ discard block |
||
17 | 17 | array('query' => "DELETE FROM `{{planets}}` WHERE `id_owner` = 0 AND `destruyed` < UNIX_TIMESTAMP();", 'result' => false, 'error' => '', 'affected_rows' => 0), |
18 | 18 | ); |
19 | 19 | |
20 | - foreach($queries as &$query) |
|
20 | + foreach ($queries as &$query) |
|
21 | 21 | { |
22 | 22 | $query['result'] = doquery($query['query']); |
23 | 23 | $query['error'] = SN::$db->db_error(); |
24 | - $query['affected_rows'] = SN::$db->db_affected_rows(); |
|
24 | + $query['affected_rows'] = SN::$db->db_affected_rows(); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | return $queries; |
@@ -53,30 +53,30 @@ discard block |
||
53 | 53 | $recorded_run = strtotime($recorded_run); |
54 | 54 | |
55 | 55 | $prev_run_array = getdate($recorded_run); |
56 | - $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']); |
|
56 | + $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']); |
|
57 | 57 | $today_array = getdate(SN_TIME_NOW); |
58 | - $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']); |
|
58 | + $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']); |
|
59 | 59 | $scheduleList = explode(',', $scheduleList); |
60 | 60 | array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
61 | 61 | $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule)))); |
62 | 62 | |
63 | 63 | $interval = $date_part_names_reverse[count($schedule['schedule_array'])]; |
64 | 64 | |
65 | - foreach($prev_run_array as $index => $date_part) { |
|
65 | + foreach ($prev_run_array as $index => $date_part) { |
|
66 | 66 | $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part; |
67 | 67 | $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index]; |
68 | 68 | } |
69 | - if($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
69 | + if ($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
70 | 70 | unset($schedule['array']['now']); |
71 | 71 | } |
72 | 72 | |
73 | - foreach($schedule['array'] as $name => $array) { |
|
73 | + foreach ($schedule['array'] as $name => $array) { |
|
74 | 74 | $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}"; |
75 | 75 | $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval; |
76 | 76 | $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval; |
77 | 77 | } |
78 | 78 | |
79 | - foreach($schedule['string'] as $string) { |
|
79 | + foreach ($schedule['string'] as $string) { |
|
80 | 80 | $timestamp = strtotime($string); |
81 | 81 | $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string)); |
82 | 82 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | |
87 | 87 | $prev_run = 0; |
88 | 88 | $next_run = 0; |
89 | - foreach($possible_schedules as $timestamp => $string_date) { |
|
89 | + foreach ($possible_schedules as $timestamp => $string_date) { |
|
90 | 90 | $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run; |
91 | 91 | $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run; |
92 | 92 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
27 | 27 | false, 'id, username'); |
28 | 28 | // while ($u = db_fetch($query)) |
29 | - foreach($query as $u) |
|
29 | + foreach ($query as $u) |
|
30 | 30 | { |
31 | 31 | $sendList[] = $u['id']; |
32 | 32 | $list .= "<br>{$u['username']} "; |
@@ -53,19 +53,19 @@ discard block |
||
53 | 53 | { |
54 | 54 | global $config, $user, $sn_message_class_list; |
55 | 55 | |
56 | - if(!$owners) |
|
56 | + if (!$owners) |
|
57 | 57 | { |
58 | 58 | return; |
59 | 59 | } |
60 | 60 | |
61 | 61 | $timestamp = $timestamp ? $timestamp : SN_TIME_NOW; |
62 | 62 | $sender = intval($sender); |
63 | - if(!is_array($owners)) |
|
63 | + if (!is_array($owners)) |
|
64 | 64 | { |
65 | 65 | $owners = array($owners); |
66 | 66 | } |
67 | 67 | |
68 | - if($escaped == STRING_NEED_ESCAPING) |
|
68 | + if ($escaped == STRING_NEED_ESCAPING) |
|
69 | 69 | { |
70 | 70 | $from = db_escape($from); |
71 | 71 | $subject = db_escape($subject); |
@@ -81,9 +81,9 @@ discard block |
||
81 | 81 | |
82 | 82 | $message_class_name_total = $sn_message_class_list[MSG_TYPE_NEW]['name']; |
83 | 83 | |
84 | - if($owners[0] == '*') |
|
84 | + if ($owners[0] == '*') |
|
85 | 85 | { |
86 | - if($user['authlevel'] < 3) |
|
86 | + if ($user['authlevel'] < 3) |
|
87 | 87 | { |
88 | 88 | return false; |
89 | 89 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | foreach ($owners as $owner) |
101 | 101 | { |
102 | - if($user['id'] != $owner) |
|
102 | + if ($user['id'] != $owner) |
|
103 | 103 | { |
104 | 104 | $owner_row = db_user_by_id($owner); |
105 | 105 | } |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | } |
110 | 110 | sys_user_options_unpack($owner_row); |
111 | 111 | |
112 | - if($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) |
|
112 | + if ($force || !$message_class_switchable || $owner_row["opt_{$message_class_name}"]) |
|
113 | 113 | { |
114 | 114 | $insert_values[] = sprintf($insert_template, $owner); |
115 | 115 | } |
116 | 116 | |
117 | - if($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) |
|
117 | + if ($message_class_email && $config->game_email_pm && $owner_row["opt_email_{$message_class_name}"]) |
|
118 | 118 | { |
119 | - if($message_type == MSG_TYPE_SPY) { |
|
119 | + if ($message_type == MSG_TYPE_SPY) { |
|
120 | 120 | @$result = mymail($owner_row['email'], $subject, SN::$lang['sys_spy_activity'], '', true); |
121 | 121 | } else { |
122 | 122 | @$result = mymail($owner_row['email'], $subject, $text_unescaped, '', true); |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | } |
125 | 125 | } |
126 | 126 | |
127 | - if(empty($insert_values)) |
|
127 | + if (empty($insert_values)) |
|
128 | 128 | { |
129 | 129 | return; |
130 | 130 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | } |
135 | 135 | db_user_list_set_mass_mail($owners, "`{$message_class_name}` = `{$message_class_name}` + 1, `{$message_class_name_total}` = `{$message_class_name_total}` + 1"); |
136 | 136 | |
137 | - if(in_array($user['id'], $owners) || $owners[0] == '*') |
|
137 | + if (in_array($user['id'], $owners) || $owners[0] == '*') |
|
138 | 138 | { |
139 | 139 | $user[$message_class_name]++; |
140 | 140 | $user[$message_class_name_total]++; |
@@ -22,28 +22,28 @@ discard block |
||
22 | 22 | function rpg_points_change($user_id, $change_type, $dark_matter, $comment = false, $already_changed = false) { |
23 | 23 | global $debug, $config, $dm_change_legit, $user; |
24 | 24 | |
25 | - if(!$user_id) { |
|
25 | + if (!$user_id) { |
|
26 | 26 | return false; |
27 | 27 | } |
28 | 28 | |
29 | 29 | $dm_change_legit = true; |
30 | 30 | $sn_data_dark_matter_db_name = pname_resource_name(RES_DARK_MATTER); |
31 | 31 | |
32 | - if($already_changed) { |
|
32 | + if ($already_changed) { |
|
33 | 33 | $rows_affected = 1; |
34 | 34 | } else { |
35 | 35 | $changeset = array(); |
36 | 36 | $a_user = db_user_by_id($user_id, true); |
37 | - if($dark_matter < 0) { |
|
37 | + if ($dark_matter < 0) { |
|
38 | 38 | $dark_matter_exists = mrc_get_level($a_user, null, RES_DARK_MATTER, false, true); |
39 | 39 | $dark_matter_exists < 0 ? $dark_matter_exists = 0 : false; |
40 | 40 | $metamatter_to_reduce = -$dark_matter - $dark_matter_exists; |
41 | - if($metamatter_to_reduce > 0) { |
|
41 | + if ($metamatter_to_reduce > 0) { |
|
42 | 42 | $metamatter_exists = mrc_get_level($a_user, null, RES_METAMATTER); |
43 | - if($metamatter_exists < $metamatter_to_reduce) { |
|
43 | + if ($metamatter_exists < $metamatter_to_reduce) { |
|
44 | 44 | $debug->error('Ошибка снятия ТМ - ММ+ТМ меньше, чем сумма для снятия!', 'Ошибка снятия ТМ', LOG_ERR_INT_NOT_ENOUGH_DARK_MATTER); |
45 | 45 | } |
46 | - if(is_array($comment)) { |
|
46 | + if (is_array($comment)) { |
|
47 | 47 | $comment = call_user_func_array('sprintf', $comment); |
48 | 48 | } |
49 | 49 | // mm_points_change($user_id, $change_type, -$metamatter_to_reduce, 'ММ в ТМ: ' . (-$dark_matter) . ' ТМ = ' . $dark_matter_exists . ' ТМ + ' . $metamatter_to_reduce . ' ММ. ' . $comment); |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | $rows_affected = SN::$db->db_affected_rows(); |
59 | 59 | } |
60 | 60 | |
61 | - if($rows_affected || !$dark_matter) { |
|
61 | + if ($rows_affected || !$dark_matter) { |
|
62 | 62 | $page_url = db_escape($_SERVER['SCRIPT_NAME']); |
63 | - if(is_array($comment)) { |
|
63 | + if (is_array($comment)) { |
|
64 | 64 | $comment = call_user_func_array('sprintf', $comment); |
65 | 65 | } |
66 | 66 | $comment = db_escape($comment); |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | {$dark_matter}, '{$comment}', '{$page_url}', {$user_id} |
75 | 75 | );"); |
76 | 76 | |
77 | - if($user['id'] == $user_id) { |
|
77 | + if ($user['id'] == $user_id) { |
|
78 | 78 | $user['dark_matter'] += $dark_matter; |
79 | 79 | } |
80 | 80 | |
81 | - if($dark_matter > 0) { |
|
81 | + if ($dark_matter > 0) { |
|
82 | 82 | $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1 FOR UPDATE;", '', true); |
83 | - if($old_referral['id']) { |
|
83 | + if ($old_referral['id']) { |
|
84 | 84 | doquery("UPDATE {{referrals}} SET dark_matter = dark_matter + '{$dark_matter}' WHERE `id` = {$user_id} LIMIT 1;"); |
85 | 85 | $new_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id} LIMIT 1;", '', true); |
86 | 86 | |
87 | 87 | $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0); |
88 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
88 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
89 | 89 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL, $partner_bonus, "Incoming From Referral ID {$user_id}"); |
90 | 90 | } |
91 | 91 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $q = 1.03; |
104 | 104 | |
105 | - switch($type) |
|
105 | + switch ($type) |
|
106 | 106 | { |
107 | 107 | case RPG_STRUCTURE: |
108 | 108 | $field_level = 'lvl_minier'; |
@@ -140,19 +140,19 @@ discard block |
||
140 | 140 | |
141 | 141 | $xp = &$user[$field_xp]; |
142 | 142 | |
143 | - if($xp_to_add) |
|
143 | + if ($xp_to_add) |
|
144 | 144 | { |
145 | 145 | $xp += $xp_to_add; |
146 | 146 | db_user_set_by_id($user['id'], "`{$field_xp}` = `{$field_xp}` + '{$xp_to_add}'"); |
147 | 147 | } |
148 | 148 | |
149 | 149 | $level = $user[$field_level]; |
150 | - while($xp > rpg_xp_for_level($level + 1, $b1, $q)) |
|
150 | + while ($xp > rpg_xp_for_level($level + 1, $b1, $q)) |
|
151 | 151 | { |
152 | 152 | $level++; |
153 | 153 | } |
154 | 154 | $level -= $user[$field_level]; |
155 | - if($level > 0) |
|
155 | + if ($level > 0) |
|
156 | 156 | { |
157 | 157 | db_user_set_by_id($user['id'], "`{$field_level}` = `{$field_level}` + '{$level}'"); |
158 | 158 | rpg_points_change($user['id'], $type, $level * 1000, $comment); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | function rpg_xp_for_level($level, $b1, $q) |
164 | 164 | { |
165 | - return floor($b1 * (pow($q, $level) - 1)/($q - 1)); |
|
165 | + return floor($b1 * (pow($q, $level) - 1) / ($q - 1)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | function rpg_get_miner_xp($level) |
@@ -46,8 +46,7 @@ |
||
46 | 46 | 'ANNOUNCE' => SN::$gc->bbCodeParser->expandBbCode($announce['strAnnounce'], intval($announce['authlevel'])), |
47 | 47 | 'DETAIL_URL' => $announce['detail_url'], |
48 | 48 | 'USER_NAME' => |
49 | - isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : |
|
50 | - js_safe_string($announce['user_name']), |
|
49 | + isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']), |
|
51 | 50 | 'NEW' => $announce['unix_time'] + $config->game_news_actual >= SN_TIME_NOW, |
52 | 51 | 'FUTURE' => $announce['unix_time'] > SN_TIME_NOW, |
53 | 52 | 'SURVEY_ID' => $announce['survey_id'], |