@@ -332,7 +332,7 @@ |
||
332 | 332 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
333 | 333 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
334 | 334 | |
335 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
335 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
336 | 336 | $value -= $cost_left; |
337 | 337 | }); |
338 | 338 | } |
@@ -262,7 +262,7 @@ |
||
262 | 262 | foreach ($planets as $planetId => $planet) { |
263 | 263 | $templatizedPlanet = tpl_parse_planet($user, $planet); |
264 | 264 | |
265 | - if($planet['planet_type'] == PT_MOON) { |
|
265 | + if ($planet['planet_type'] == PT_MOON) { |
|
266 | 266 | $parentPlanet = DBStaticPlanet::db_planet_by_id($planet['parent_planet']); |
267 | 267 | } else { |
268 | 268 | $parentPlanet = $planet; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
6 | 6 | |
7 | -if($user['authlevel'] < 3) |
|
7 | +if ($user['authlevel'] < 3) |
|
8 | 8 | { |
9 | 9 | SnTemplate::messageBox($lang['sys_noalloaw'], $lang['sys_noaccess']); |
10 | 10 | die(); |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | |
20 | 20 | // [#] info_best_battles 1b0 |
21 | 21 | $best_reports = array(); |
22 | -if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
22 | +if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
23 | 23 | $query = doquery(MODULE_INFO_BEST_BATTLES_QUERY); |
24 | - while($row = db_fetch($query)) { |
|
24 | + while ($row = db_fetch($query)) { |
|
25 | 25 | $best_reports[] = $row['ube_report_id']; |
26 | 26 | } |
27 | 27 | } |
@@ -204,16 +204,16 @@ discard block |
||
204 | 204 | |
205 | 205 | function sn_maintenance_pack_user_list($user_list) { |
206 | 206 | $user_list = explode(',', $user_list); |
207 | - foreach($user_list as $key => $user_id) { |
|
208 | - if(!is_numeric($user_id)) { |
|
207 | + foreach ($user_list as $key => $user_id) { |
|
208 | + if (!is_numeric($user_id)) { |
|
209 | 209 | unset($user_list[$key]); |
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | 213 | $result = array(); |
214 | - if(!empty($user_list)) { |
|
214 | + if (!empty($user_list)) { |
|
215 | 215 | $query = doquery("SELECT `id` FROM `{{users}}` WHERE `id` in (" . implode(',', $user_list) . ")"); |
216 | - while($row = db_fetch($query)) { |
|
216 | + while ($row = db_fetch($query)) { |
|
217 | 217 | $result[] = $row['id']; |
218 | 218 | } |
219 | 219 | } |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | $old_server_status == GAME_DISABLE_NONE ? SN::$config->pass()->game_disable = GAME_DISABLE_MAINTENANCE : false; |
229 | 229 | SN::db_transaction_commit(); |
230 | 230 | |
231 | -foreach($ques as $que_transaction) { |
|
231 | +foreach ($ques as $que_transaction) { |
|
232 | 232 | SN::db_transaction_start(); |
233 | 233 | |
234 | 234 | !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false; |
235 | - foreach($que_transaction as $que) { |
|
235 | + foreach ($que_transaction as $que) { |
|
236 | 236 | set_time_limit(120); |
237 | 237 | $QryResult = doquery($que); |
238 | 238 | //$msg .= '<hr>' . $que . '<hr>'; |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -define('INSIDE' , true); |
|
4 | -define('INSTALL' , false); |
|
3 | +define('INSIDE', true); |
|
4 | +define('INSTALL', false); |
|
5 | 5 | define('IN_ADMIN', true); |
6 | 6 | |
7 | 7 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | SnTemplate::messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR); |
12 | 12 | |
13 | 13 | $planet_active = sys_get_param_int('planet_active'); |
14 | -if(!$planet_active) { |
|
14 | +if (!$planet_active) { |
|
15 | 15 | $planet_type = sys_get_param_int('planet_type', 1); |
16 | 16 | $planet_type = $planet_type == 3 ? 3 : 1; |
17 | 17 | } else { |
@@ -40,8 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | $page_title = |
42 | 42 | $lang['adm_planet_list_title'] . ': ' . |
43 | - ($planet_active ? $lang['adm_planet_active'] : |
|
44 | - ($planet_type ? ($planet_type == 3 ? $lang['sys_moons'] : $lang['sys_planets']) : '') |
|
43 | + ($planet_active ? $lang['adm_planet_active'] : ($planet_type ? ($planet_type == 3 ? $lang['sys_moons'] : $lang['sys_planets']) : '') |
|
45 | 44 | ); |
46 | 45 | $template->assign_vars(array( |
47 | 46 | 'PAGE_TITLE' => $page_title, |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if(SN::$gc->modules->countModulesInGroup('payment') && !SN_GOOGLE) { |
|
5 | +if (SN::$gc->modules->countModulesInGroup('payment') && !SN_GOOGLE) { |
|
6 | 6 | sys_redirect('metamatter.php'); |
7 | 7 | } |
8 | 8 |
@@ -457,7 +457,8 @@ discard block |
||
457 | 457 | $location_info = &static::$location_info[$location_type]; |
458 | 458 | $id_field = $location_info[P_ID]; |
459 | 459 | $table_name = $location_info[P_TABLE_NAME]; |
460 | - if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
460 | + if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
461 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
461 | 462 | { |
462 | 463 | if (static::$db->db_affected_rows()) { |
463 | 464 | // Обновляем данные только если ряд был затронут |
@@ -465,6 +466,7 @@ discard block |
||
465 | 466 | |
466 | 467 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
467 | 468 | _SnCacheInternal::$data[$location_type][$record_id] = null; |
469 | + } |
|
468 | 470 | // Вытаскиваем обновленную запись |
469 | 471 | static::db_get_record_by_id($location_type, $record_id); |
470 | 472 | _SnCacheInternal::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -498,9 +500,11 @@ discard block |
||
498 | 500 | $set = trim($set); |
499 | 501 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
500 | 502 | if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
501 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
503 | + if (static::$db->db_affected_rows()) { |
|
504 | + // Обновляем данные только если ряд был затронут |
|
502 | 505 | { |
503 | 506 | $record_id = SN::$db->db_insert_id(); |
507 | + } |
|
504 | 508 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
505 | 509 | $result = static::db_get_record_by_id($location_type, $record_id); |
506 | 510 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -521,10 +525,12 @@ discard block |
||
521 | 525 | $id_field = $location_info[P_ID]; |
522 | 526 | $table_name = $location_info[P_TABLE_NAME]; |
523 | 527 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
524 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
528 | + if (static::$db->db_affected_rows()) { |
|
529 | + // Обновляем данные только если ряд был затронут |
|
525 | 530 | { |
526 | 531 | _SnCacheInternal::cache_unset($location_type, $safe_record_id); |
527 | 532 | } |
533 | + } |
|
528 | 534 | } |
529 | 535 | |
530 | 536 | return $result; |
@@ -538,11 +544,13 @@ discard block |
||
538 | 544 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
539 | 545 | |
540 | 546 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
541 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
547 | + if (static::$db->db_affected_rows()) { |
|
548 | + // Обновляем данные только если ряд был затронут |
|
542 | 549 | { |
543 | 550 | // Обнуление кэша, потому что непонятно, что поменялось |
544 | 551 | _SnCacheInternal::cache_clear($location_type); |
545 | 552 | } |
553 | + } |
|
546 | 554 | } |
547 | 555 | |
548 | 556 | return $result; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @return DbMysqliResultIterator|EmptyCountableIterator |
19 | 19 | */ |
20 | 20 | public static function dbFleetsOnHoldOnPlanetsByIds($planetIds, $time = SN_TIME_NOW) { |
21 | - if(empty($planetIds) || !is_array($planetIds)) { |
|
21 | + if (empty($planetIds) || !is_array($planetIds)) { |
|
22 | 22 | return new EmptyCountableIterator(); |
23 | 23 | } |
24 | 24 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | $speeds = array(); |
42 | 42 | if (!empty($fleet)) { |
43 | 43 | foreach ($fleet as $ship_id => $amount) { |
44 | - if ($amount && in_array($ship_id, sn_get_groups(['fleet', 'missile',]))) { |
|
44 | + if ($amount && in_array($ship_id, sn_get_groups(['fleet', 'missile', ]))) { |
|
45 | 45 | $single_ship_data = !empty($shipData[$ship_id]) ? $shipData[$ship_id] : get_ship_data($ship_id, $user); |
46 | 46 | $speeds[] = $single_ship_data['speed']; |
47 | 47 | } |
@@ -122,15 +122,15 @@ |
||
122 | 122 | SN::db_transaction_commit(); |
123 | 123 | |
124 | 124 | $this->user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
125 | - $this->browser_id = db_get_set_unique_id_value('security_browser', 'browser_id', ['browser_user_agent' => $this->user_agent,]); |
|
125 | + $this->browser_id = db_get_set_unique_id_value('security_browser', 'browser_id', ['browser_user_agent' => $this->user_agent, ]); |
|
126 | 126 | |
127 | 127 | $this->page_address = substr($_SERVER['PHP_SELF'], strlen(SN_ROOT_RELATIVE)); |
128 | - $this->page_address_id = db_get_set_unique_id_value('security_url', 'url_id', ['url_string' => $this->page_address,]); |
|
128 | + $this->page_address_id = db_get_set_unique_id_value('security_url', 'url_id', ['url_string' => $this->page_address, ]); |
|
129 | 129 | |
130 | 130 | // Not a simulator - because it can have loooooong string |
131 | 131 | if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') !== 0 && !$skip_log_query) { |
132 | 132 | $this->queryString = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; |
133 | - $this->queryStringId = db_get_set_unique_id_value('security_query_strings', 'id', ['query_string' => $this->queryString,]); |
|
133 | + $this->queryStringId = db_get_set_unique_id_value('security_query_strings', 'id', ['query_string' => $this->queryString, ]); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | $ip = sec_player_ip(); |
@@ -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::cache_repack($location_type); // Перепаковываем внутренние структуры, если нужно |