@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | $groups[get_unit_param($unitId, P_UNIT_TYPE)][$unitId] = $unitAmount; |
26 | 26 | } |
27 | 27 | |
28 | - foreach(static::ALLOWED_UNITS as $groupId) { |
|
29 | - if(empty($groups[$groupId])) { |
|
28 | + foreach (static::ALLOWED_UNITS as $groupId) { |
|
29 | + if (empty($groups[$groupId])) { |
|
30 | 30 | continue; |
31 | 31 | } |
32 | 32 | |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | 'NAME' => $lang['tech'][$groupId], |
36 | 36 | ]); |
37 | 37 | |
38 | - foreach($general->getGroupsById($groupId) as $unitId) { |
|
39 | - if((!isset($groups[$groupId][$unitId]) || floor($groups[$groupId][$unitId]) < 1) && $unitId != RES_ENERGY) { |
|
38 | + foreach ($general->getGroupsById($groupId) as $unitId) { |
|
39 | + if ((!isset($groups[$groupId][$unitId]) || floor($groups[$groupId][$unitId]) < 1) && $unitId != RES_ENERGY) { |
|
40 | 40 | continue; |
41 | 41 | } |
42 | 42 |
@@ -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, classSupernova::$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]++; |
@@ -15,8 +15,7 @@ discard block |
||
15 | 15 | 1.5 - copyright (c) 2010-2011 by Gorlum for http://supernova.ws |
16 | 16 | [+] SuperMassMailing - authlevel=3 player can send messages to whole server ('*' as $owners) |
17 | 17 | */ |
18 | -function msg_ali_send($message, $subject, $ally_rank_id = 0, $ally_id = 0) |
|
19 | -{ |
|
18 | +function msg_ali_send($message, $subject, $ally_rank_id = 0, $ally_id = 0) { |
|
20 | 19 | global $user; |
21 | 20 | |
22 | 21 | $ally_id = $ally_id ? $ally_id : $user['ally_id']; |
@@ -49,8 +48,7 @@ discard block |
||
49 | 48 | * @param bool $force |
50 | 49 | * @param bool $json |
51 | 50 | */ |
52 | -function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = STRING_NEED_ESCAPING, $force = false, $json = false) |
|
53 | -{ |
|
51 | +function msg_send_simple_message($owners, $sender, $timestamp, $message_type, $from, $subject, $text, $escaped = STRING_NEED_ESCAPING, $force = false, $json = false) { |
|
54 | 52 | global $config, $user, $sn_message_class_list; |
55 | 53 | |
56 | 54 | if(!$owners) |
@@ -91,8 +89,7 @@ discard block |
||
91 | 89 | // TODO Добавить $sender - рассылка может быть и от кого-то |
92 | 90 | db_message_insert_all($message_type, $from, $subject, $text); |
93 | 91 | $owners = []; |
94 | - } |
|
95 | - else |
|
92 | + } else |
|
96 | 93 | { |
97 | 94 | $insert_values = []; |
98 | 95 | $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}', '" . intval($json) . "')"); |
@@ -102,8 +99,7 @@ discard block |
||
102 | 99 | if($user['id'] != $owner) |
103 | 100 | { |
104 | 101 | $owner_row = db_user_by_id($owner); |
105 | - } |
|
106 | - else |
|
102 | + } else |
|
107 | 103 | { |
108 | 104 | $owner_row = $user; |
109 | 105 | } |
@@ -223,7 +223,7 @@ |
||
223 | 223 | 'factor' => 1, |
224 | 224 | ), |
225 | 225 | P_UNIT_PRODUCTION => array( |
226 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); }, |
|
226 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); }, |
|
227 | 227 | ), |
228 | 228 | P_MINING_IS_MANAGED => true, |
229 | 229 |
@@ -16,8 +16,8 @@ discard block |
||
16 | 16 | 'factor' => 1.5, |
17 | 17 | ), |
18 | 18 | P_UNIT_PRODUCTION => array( |
19 | - RES_METAL => function ($level, $production_factor, $user, $planet_row) { return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
19 | + RES_METAL => function($level, $production_factor, $user, $planet_row) { return 40 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
20 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
21 | 21 | ), |
22 | 22 | P_MINING_IS_MANAGED => true, |
23 | 23 | ), |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | 'factor' => 1.6, |
35 | 35 | ), |
36 | 36 | P_UNIT_PRODUCTION => array( |
37 | - RES_CRYSTAL => function ($level, $production_factor, $user, $planet_row) { return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
37 | + RES_CRYSTAL => function($level, $production_factor, $user, $planet_row) { return 32 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
38 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
39 | 39 | ), |
40 | 40 | P_MINING_IS_MANAGED => true, |
41 | 41 | ), |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | 'factor' => 1.5, |
53 | 53 | ), |
54 | 54 | P_UNIT_PRODUCTION => array( |
55 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) { return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
56 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
55 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) { return 10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); }, |
|
56 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
57 | 57 | ), |
58 | 58 | P_MINING_IS_MANAGED => true, |
59 | 59 | ), |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | 'factor' => 1.5, |
71 | 71 | ), |
72 | 72 | P_UNIT_PRODUCTION => array( |
73 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
73 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
74 | 74 | ), |
75 | 75 | P_MINING_IS_MANAGED => true, |
76 | 76 | ), |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | 'factor' => 1.8, |
89 | 89 | ), |
90 | 90 | P_UNIT_PRODUCTION => array( |
91 | - RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) { return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
92 | - RES_ENERGY => function ($level, $production_factor, $user, $planet_row) { return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
91 | + RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) { return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); }, |
|
92 | + RES_ENERGY => function($level, $production_factor, $user, $planet_row) { return 30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, "", TECH_ENERGY), $level) * (0.1 * $production_factor); }, |
|
93 | 93 | ), |
94 | 94 | P_MINING_IS_MANAGED => true, |
95 | 95 | ), |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | 'factor' => 2, |
107 | 107 | ), |
108 | 108 | 'storage' => array( |
109 | - RES_METAL => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
109 | + RES_METAL => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
110 | 110 | ), |
111 | 111 | ), |
112 | 112 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | 'factor' => 2, |
123 | 123 | ), |
124 | 124 | 'storage' => array( |
125 | - RES_CRYSTAL => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
125 | + RES_CRYSTAL => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
126 | 126 | ), |
127 | 127 | ), |
128 | 128 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 'factor' => 2, |
139 | 139 | ), |
140 | 140 | 'storage' => array( |
141 | - RES_DEUTERIUM => function ($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
141 | + RES_DEUTERIUM => function($level) { return BASE_STORAGE_SIZE * pow(1.5, $level); }, |
|
142 | 142 | ), |
143 | 143 | ), |
144 | 144 |
@@ -419,7 +419,8 @@ discard block |
||
419 | 419 | $location_info = &static::$location_info[$location_type]; |
420 | 420 | $id_field = $location_info[P_ID]; |
421 | 421 | $table_name = $location_info[P_TABLE_NAME]; |
422 | - if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
422 | + if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
423 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
423 | 424 | { |
424 | 425 | if (static::$db->db_affected_rows()) { |
425 | 426 | // Обновляем данные только если ряд был затронут |
@@ -427,6 +428,7 @@ discard block |
||
427 | 428 | |
428 | 429 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
429 | 430 | _SnCacheInternal::$data[$location_type][$record_id] = null; |
431 | + } |
|
430 | 432 | // Вытаскиваем обновленную запись |
431 | 433 | static::db_get_record_by_id($location_type, $record_id); |
432 | 434 | _SnCacheInternal::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -460,9 +462,11 @@ discard block |
||
460 | 462 | $set = trim($set); |
461 | 463 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
462 | 464 | if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
463 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
465 | + if (static::$db->db_affected_rows()) { |
|
466 | + // Обновляем данные только если ряд был затронут |
|
464 | 467 | { |
465 | 468 | $record_id = db_insert_id(); |
469 | + } |
|
466 | 470 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
467 | 471 | $result = static::db_get_record_by_id($location_type, $record_id); |
468 | 472 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -483,10 +487,12 @@ discard block |
||
483 | 487 | $id_field = $location_info[P_ID]; |
484 | 488 | $table_name = $location_info[P_TABLE_NAME]; |
485 | 489 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
486 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
490 | + if (static::$db->db_affected_rows()) { |
|
491 | + // Обновляем данные только если ряд был затронут |
|
487 | 492 | { |
488 | 493 | _SnCacheInternal::cache_unset($location_type, $safe_record_id); |
489 | 494 | } |
495 | + } |
|
490 | 496 | } |
491 | 497 | |
492 | 498 | return $result; |
@@ -500,11 +506,13 @@ discard block |
||
500 | 506 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
501 | 507 | |
502 | 508 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
503 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
509 | + if (static::$db->db_affected_rows()) { |
|
510 | + // Обновляем данные только если ряд был затронут |
|
504 | 511 | { |
505 | 512 | // Обнуление кэша, потому что непонятно, что поменялось |
506 | 513 | _SnCacheInternal::cache_clear($location_type); |
507 | 514 | } |
515 | + } |
|
508 | 516 | } |
509 | 517 | |
510 | 518 | return $result; |
@@ -52,7 +52,7 @@ |
||
52 | 52 | //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />"); |
53 | 53 | if ($hard && !empty(_SnCacheInternal::$data[$location_type])) { |
54 | 54 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
55 | - array_walk(_SnCacheInternal::$data[$location_type], function (&$item) { $item = null; }); |
|
55 | + array_walk(_SnCacheInternal::$data[$location_type], function(&$item) { $item = null; }); |
|
56 | 56 | } |
57 | 57 | _SnCacheInternal::$locator[$location_type] = []; |
58 | 58 | _SnCacheInternal::$queries[$location_type] = []; |
@@ -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 | } |
@@ -1,17 +1,17 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(SN_IN_FLEET !== true) { |
|
3 | +if (SN_IN_FLEET !== true) { |
|
4 | 4 | $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | 7 | $fleetid = sys_get_param_id('fleetid'); |
8 | 8 | |
9 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
9 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
10 | 10 | sys_redirect("fleet.php"); |
11 | 11 | } |
12 | 12 | |
13 | 13 | $fleet = db_fleet_get($fleetid); |
14 | -if(!$fleet) { |
|
14 | +if (!$fleet) { |
|
15 | 15 | messageBox($lang['fl_fleet_not_exists'], $lang['fl_error']); |
16 | 16 | } |
17 | 17 | //$query = doquery("SELECT * FROM `{{fleets}}` WHERE fleet_id = '{$fleetid}'"); |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | messageBox($lang['fl_isback'], $lang['fl_error']); |
26 | 26 | } |
27 | 27 | |
28 | -if($fleet['fleet_owner'] != $user['id']) { |
|
29 | - $debug->warning($lang['fl_aks_hack_wrong_fleet'],'Wrong Fleet Owner',301); |
|
28 | +if ($fleet['fleet_owner'] != $user['id']) { |
|
29 | + $debug->warning($lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
|
30 | 30 | messageBox($lang['fl_aks_hack_wrong_fleet'], $lang['fl_error']); |
31 | 31 | } |
32 | 32 | |
@@ -36,19 +36,19 @@ discard block |
||
36 | 36 | |
37 | 37 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
38 | 38 | |
39 | -if($userToAdd_unsafe) { |
|
39 | +if ($userToAdd_unsafe) { |
|
40 | 40 | $userToAdd = db_escape($userToAdd_unsafe); |
41 | 41 | $userToAddID = db_user_by_username($userToAdd_unsafe, true); |
42 | 42 | $userToAddID = $userToAddID['id']; |
43 | 43 | |
44 | - if($fleet['fleet_target_owner'] == $userToAddID) { |
|
44 | + if ($fleet['fleet_target_owner'] == $userToAddID) { |
|
45 | 45 | messageBox($lang['flt_aks_player_same'], $lang['fl_error']); |
46 | 46 | } |
47 | 47 | |
48 | - if($userToAddID) { |
|
49 | - if(!$aks) { |
|
48 | + if ($userToAddID) { |
|
49 | + if (!$aks) { |
|
50 | 50 | // No AСS exists - making one |
51 | - if(!$fleet['fleet_group']) { |
|
51 | + if (!$fleet['fleet_group']) { |
|
52 | 52 | doquery("INSERT INTO {{aks}} SET |
53 | 53 | `name` = '" . db_escape($lang['flt_acs_prefix'] . $fleetid) . "', |
54 | 54 | `teilnehmer` = '" . $user['id'] . "', |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | `planet` = '" . $fleet['fleet_end_planet'] . "', |
60 | 60 | `planet_type` = '" . $fleet['fleet_end_type'] . "', |
61 | 61 | `eingeladen` = '" . $user['id'] . "', |
62 | - `fleet_end_time` = '" . $fleet['fleet_end_time']. "'"); |
|
62 | + `fleet_end_time` = '" . $fleet['fleet_end_time'] . "'"); |
|
63 | 63 | |
64 | 64 | $aks = doquery("SELECT * FROM {{aks}} WHERE `flotten` = {$fleetid} LIMIT 1;", true); |
65 | 65 | |
@@ -77,26 +77,26 @@ discard block |
||
77 | 77 | |
78 | 78 | $isUserExists = false; |
79 | 79 | $invited_ar = explode(",", $aks['eingeladen']); |
80 | - foreach($invited_ar as $inv) { |
|
80 | + foreach ($invited_ar as $inv) { |
|
81 | 81 | if ($userToAddID == $inv) { |
82 | 82 | $isUserExists = true; |
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
86 | - if(count($invited_ar) >= 5) { |
|
86 | + if (count($invited_ar) >= 5) { |
|
87 | 87 | messageBox($lang['flt_aks_error_too_much_players'], $lang['fl_error']); |
88 | 88 | } |
89 | 89 | |
90 | - if($isUserExists) { |
|
90 | + if ($isUserExists) { |
|
91 | 91 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf($lang['fl_aks_player_invited_already'], $userToAdd) : false; |
92 | 92 | } else { |
93 | 93 | $add_user_message_mr = sprintf($lang['fl_aks_player_invited'], $userToAdd); |
94 | 94 | doquery("UPDATE `{{aks}}` SET `eingeladen` = concat(`eingeladen`, ',{$userToAddID}') WHERE `flotten` = {$fleetid};") |
95 | - or die(sprintf($lang['fl_aks_adding_error'],db_error())); |
|
95 | + or die(sprintf($lang['fl_aks_adding_error'], db_error())); |
|
96 | 96 | $aks['eingeladen'] .= ',' . $userToAddID; |
97 | 97 | } |
98 | - msg_send_simple_message ( $userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
|
99 | - $lang['fl_aks_invite_message_header'], sprintf( $lang['fl_aks_invite_message'], $user['username'])); |
|
98 | + msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
|
99 | + $lang['fl_aks_invite_message_header'], sprintf($lang['fl_aks_invite_message'], $user['username'])); |
|
100 | 100 | } else { |
101 | 101 | $add_user_message_mr = sprintf($lang['fl_aks_player_error'], $userToAdd); |
102 | 102 | } |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | 'MISSION_NAME' => $lang['type_mission'][MT_AKS], |
111 | 111 | )); |
112 | 112 | |
113 | -if($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
114 | - foreach($members as $row) { |
|
113 | +if ($aks['eingeladen'] && is_array($members = classSupernova::db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
114 | + foreach ($members as $row) { |
|
115 | 115 | $template->assign_block_vars('invited', array( |
116 | 116 | 'NAME' => $row['username'], |
117 | 117 | )); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | $i++; |
122 | 122 | $fleet_row = db_fleet_get($fleetid); |
123 | 123 | |
124 | -if(is_array($fleet_row) && !empty($fleet_row)) { |
|
124 | +if (is_array($fleet_row) && !empty($fleet_row)) { |
|
125 | 125 | $planet_start = DBStaticPlanet::db_planet_by_id($fleet_row['fleet_start_planet_id']); |
126 | 126 | $fleet_row['fleet_start_name'] = !empty($planet_start['name']) ? $planet_start['name'] : ''; |
127 | 127 | $planet_end = DBStaticPlanet::db_planet_by_id($fleet_row['fleet_end_planet_id']); |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | |
130 | 130 | $fleet_data = tpl_parse_fleet_db($fleet_row, $i, $user); |
131 | 131 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
132 | -foreach($fleet_data['ships'] as $ship_data) { |
|
132 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
133 | 133 | $template->assign_block_vars('fleets.ships', $ship_data); |
134 | 134 | } |
135 | 135 | } |
@@ -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(classSupernova::$db->db_affected_rows()) |
|
53 | + if (classSupernova::$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 |
@@ -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, |