@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
| 3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
| 4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | $d = sys_get_param_id('d'); |
| 12 | 12 | |
| 13 | -if($d) { |
|
| 13 | +if ($d) { |
|
| 14 | 14 | db_ally_request_deny($d); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | $id_user = sys_get_param_id('id_user'); |
| 18 | 18 | |
| 19 | -if($id_user) { |
|
| 19 | +if ($id_user) { |
|
| 20 | 20 | $ally_name_safe = db_escape($ally['ally_name']); |
| 21 | 21 | $ally_tag_safe = db_escape($ally['ally_tag']); |
| 22 | - DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0"); |
|
| 22 | + DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = ".SN_TIME_NOW.", `ally_rank_id` = 0"); |
|
| 23 | 23 | db_ally_update_member_increase($ally); |
| 24 | 24 | db_ally_request_delete_by_user_id($id_user); |
| 25 | 25 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | * <p>null - транзакция НЕ должна быть запущена</p> |
| 324 | 324 | * <p>true - транзакция должна быть запущена - для совместимости с $for_update</p> |
| 325 | 325 | * <p>false - всё равно - для совместимости с $for_update</p> |
| 326 | - * @return bool Текущий статус транзакции |
|
| 326 | + * @return null|boolean Текущий статус транзакции |
|
| 327 | 327 | */ |
| 328 | 328 | public static function db_transaction_check($status = null) { |
| 329 | 329 | $error_msg = false; |
@@ -399,7 +399,7 @@ discard block |
||
| 399 | 399 | /** |
| 400 | 400 | * Блокирует указанные таблицу/список таблиц |
| 401 | 401 | * |
| 402 | - * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
| 402 | + * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
| 403 | 403 | * <p>string - название таблицы для блокировки</p> |
| 404 | 404 | * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p> |
| 405 | 405 | */ |
@@ -587,6 +587,9 @@ discard block |
||
| 587 | 587 | return $result; |
| 588 | 588 | } |
| 589 | 589 | |
| 590 | + /** |
|
| 591 | + * @param integer $location_type |
|
| 592 | + */ |
|
| 590 | 593 | public static function db_ins_field_set($location_type, $field_set, $serialize = false) { |
| 591 | 594 | // TODO multiinsert |
| 592 | 595 | !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false; |
@@ -809,7 +812,7 @@ discard block |
||
| 809 | 812 | * @param $location_type |
| 810 | 813 | * @param $location_id |
| 811 | 814 | * |
| 812 | - * @return array|bool |
|
| 815 | + * @return boolean |
|
| 813 | 816 | */ |
| 814 | 817 | public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id) |
| 815 | 818 | { |
@@ -542,7 +542,8 @@ discard block |
||
| 542 | 542 | $location_info = &static::$location_info[$location_type]; |
| 543 | 543 | $id_field = $location_info[P_ID]; |
| 544 | 544 | $table_name = $location_info[P_TABLE_NAME]; |
| 545 | - if ($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 545 | + if ($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
| 546 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 546 | 547 | { |
| 547 | 548 | if (static::$db->db_affected_rows()) { |
| 548 | 549 | // Обновляем данные только если ряд был затронут |
@@ -550,6 +551,7 @@ discard block |
||
| 550 | 551 | |
| 551 | 552 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
| 552 | 553 | static::$data[$location_type][$record_id] = null; |
| 554 | + } |
|
| 553 | 555 | // Вытаскиваем обновленную запись |
| 554 | 556 | static::db_get_record_by_id($location_type, $record_id); |
| 555 | 557 | static::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -589,9 +591,11 @@ discard block |
||
| 589 | 591 | $set = trim($set); |
| 590 | 592 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 591 | 593 | if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
| 592 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 594 | + if (static::$db->db_affected_rows()) { |
|
| 595 | + // Обновляем данные только если ряд был затронут |
|
| 593 | 596 | { |
| 594 | 597 | $record_id = db_insert_id(); |
| 598 | + } |
|
| 595 | 599 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
| 596 | 600 | $result = static::db_get_record_by_id($location_type, $record_id); |
| 597 | 601 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | public static function cache_clear($location_type, $hard = true) { |
| 237 | 237 | if ($hard && !empty(static::$data[$location_type])) { |
| 238 | 238 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
| 239 | - array_walk(static::$data[$location_type], function (&$item) { $item = null; }); |
|
| 239 | + array_walk(static::$data[$location_type], function(&$item) { $item = null; }); |
|
| 240 | 240 | } |
| 241 | 241 | static::$locator[$location_type] = array(); |
| 242 | 242 | static::$queries[$location_type] = array(); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | |
| 355 | 355 | if (!empty($error_msg)) { |
| 356 | 356 | // TODO - Убрать позже |
| 357 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
| 357 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
| 358 | 358 | $backtrace = debug_backtrace(); |
| 359 | 359 | array_shift($backtrace); |
| 360 | 360 | pdump($backtrace); |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | public static function db_transaction_start($level = '') { |
| 368 | 368 | static::db_transaction_check(null); |
| 369 | 369 | |
| 370 | - $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
| 370 | + $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
| 371 | 371 | |
| 372 | 372 | static::$transaction_id++; |
| 373 | 373 | doquery('START TRANSACTION'); |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | public static function db_lock_tables($tables) { |
| 428 | 428 | $tables = is_array($tables) ? $tables : array($tables => ''); |
| 429 | 429 | foreach ($tables as $table_name => $condition) { |
| 430 | - self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
| 430 | + self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
| 431 | 431 | } |
| 432 | 432 | } |
| 433 | 433 | |
@@ -488,11 +488,11 @@ discard block |
||
| 488 | 488 | $query = static::db_query( |
| 489 | 489 | "SELECT |
| 490 | 490 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
| 491 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
| 492 | - ($filter ? ' WHERE ' . $filter : '') . |
|
| 491 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
| 492 | + ($filter ? ' WHERE '.$filter : ''). |
|
| 493 | 493 | ($fetch ? ' LIMIT 1' : ''), false, true); |
| 494 | 494 | |
| 495 | - while($row = db_fetch($query)) { |
|
| 495 | + while ($row = db_fetch($query)) { |
|
| 496 | 496 | // Исключаем из списка родительских ИД уже заблокированные записи |
| 497 | 497 | if (!static::cache_lock_get($owner_location_type, $row['parent_id'])) { |
| 498 | 498 | $parent_id_list[$row['parent_id']] = $row['parent_id']; |
@@ -502,16 +502,16 @@ discard block |
||
| 502 | 502 | if ($indexes_str = implode(',', $parent_id_list)) { |
| 503 | 503 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
| 504 | 504 | static::db_get_record_list($owner_location_type, |
| 505 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
| 505 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
| 506 | 506 | } |
| 507 | 507 | } |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | $query = static::db_query( |
| 511 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
| 511 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
| 512 | 512 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
| 513 | 513 | ); |
| 514 | - while($row = db_fetch($query)) { |
|
| 514 | + while ($row = db_fetch($query)) { |
|
| 515 | 515 | static::cache_set($location_type, $row); |
| 516 | 516 | $query_cache[$row[$id_field]] = &static::$data[$location_type][$row[$id_field]]; |
| 517 | 517 | } |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | $condition = trim($condition); |
| 575 | 575 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 576 | 576 | |
| 577 | - if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
| 577 | + if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
| 578 | 578 | |
| 579 | 579 | if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
| 580 | 580 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -737,11 +737,11 @@ discard block |
||
| 737 | 737 | $user = self::$db->selectRow( |
| 738 | 738 | DBStaticUser::buildSelect() |
| 739 | 739 | ->field('*') |
| 740 | - ->where(array("`username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'")) |
|
| 740 | + ->where(array("`username` ".($like ? 'LIKE' : '=')." '{$username_safe}'")) |
|
| 741 | 741 | ->setFetchOne() |
| 742 | 742 | ); |
| 743 | 743 | |
| 744 | - if(empty($user)) { |
|
| 744 | + if (empty($user)) { |
|
| 745 | 745 | $user = null; |
| 746 | 746 | } |
| 747 | 747 | |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | |
| 836 | 836 | $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id]; |
| 837 | 837 | if (!isset($query_cache)) { |
| 838 | - $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions()); |
|
| 838 | + $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".static::db_unit_time_restrictions()); |
|
| 839 | 839 | if (is_array($got_data)) { |
| 840 | 840 | foreach ($got_data as $unit_id => $unit_data) { |
| 841 | 841 | $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
| 897 | 897 | $query[] = "`que_planet_id` IS NULL"; |
| 898 | 898 | } elseif ($planet_id) { |
| 899 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
| 899 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
| 900 | 900 | } |
| 901 | 901 | if ($que_type) { |
| 902 | 902 | $query[] = "`que_type` = {$que_type}"; |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | public function db_changeset_condition_compile(&$conditions, &$table_name = '') { |
| 990 | 990 | if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) { |
| 991 | 991 | $conditions[P_LOCATION] = LOC_NONE; |
| 992 | - switch($table_name) { |
|
| 992 | + switch ($table_name) { |
|
| 993 | 993 | case 'users': |
| 994 | 994 | case LOC_USER: |
| 995 | 995 | $conditions[P_TABLE_NAME] = $table_name = 'users'; |
@@ -1017,13 +1017,13 @@ discard block |
||
| 1017 | 1017 | $condition = "`{$field_name}` = "; |
| 1018 | 1018 | $value = ''; |
| 1019 | 1019 | if ($field_data['delta']) { |
| 1020 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
| 1020 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
| 1021 | 1021 | } elseif ($field_data['set']) { |
| 1022 | 1022 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | if ($value) { |
| 1026 | - $fields[] = $condition . $value; |
|
| 1026 | + $fields[] = $condition.$value; |
|
| 1027 | 1027 | } |
| 1028 | 1028 | } |
| 1029 | 1029 | $conditions[P_FIELDS_STR] = implode(',', $fields); |
@@ -1037,9 +1037,7 @@ discard block |
||
| 1037 | 1037 | // Простое условие - $field_id = $field_value |
| 1038 | 1038 | if (is_string($field_id)) { |
| 1039 | 1039 | $field_value = |
| 1040 | - $field_value === null ? 'NULL' : |
|
| 1041 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
| 1042 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
| 1040 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
| 1043 | 1041 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
| 1044 | 1042 | } else { |
| 1045 | 1043 | die('Неподдерживаемый тип условия'); |
@@ -1051,7 +1049,7 @@ discard block |
||
| 1051 | 1049 | $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions); |
| 1052 | 1050 | } |
| 1053 | 1051 | |
| 1054 | - switch($conditions['action']) { |
|
| 1052 | + switch ($conditions['action']) { |
|
| 1055 | 1053 | case SQL_OP_DELETE: |
| 1056 | 1054 | $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}"); |
| 1057 | 1055 | break; |
@@ -1066,7 +1064,7 @@ discard block |
||
| 1066 | 1064 | die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile'); |
| 1067 | 1065 | } |
| 1068 | 1066 | |
| 1069 | - $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]); |
|
| 1067 | + $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]); |
|
| 1070 | 1068 | } |
| 1071 | 1069 | |
| 1072 | 1070 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
@@ -1088,7 +1086,7 @@ discard block |
||
| 1088 | 1086 | } // Защита от случайного удаления всех данных в таблице |
| 1089 | 1087 | |
| 1090 | 1088 | if ($conditions[P_LOCATION] != LOC_NONE) { |
| 1091 | - switch($conditions['action']) { |
|
| 1089 | + switch ($conditions['action']) { |
|
| 1092 | 1090 | case SQL_OP_DELETE: |
| 1093 | 1091 | $result = self::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result; |
| 1094 | 1092 | break; |
@@ -1164,7 +1162,7 @@ discard block |
||
| 1164 | 1162 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
| 1165 | 1163 | if (@get_magic_quotes_gpc()) { |
| 1166 | 1164 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
| 1167 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
| 1165 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
| 1168 | 1166 | $value = stripslashes($value); |
| 1169 | 1167 | }); |
| 1170 | 1168 | } |
@@ -1178,7 +1176,7 @@ discard block |
||
| 1178 | 1176 | public static function init_3_load_config_file() { |
| 1179 | 1177 | $dbsettings = array(); |
| 1180 | 1178 | |
| 1181 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
| 1179 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
| 1182 | 1180 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
| 1183 | 1181 | self::$db_name = $dbsettings['name']; |
| 1184 | 1182 | self::$sn_secret_word = $dbsettings['secretword']; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $debris_for_moon = $debris->debris_total(); |
| 72 | 72 | |
| 73 | - if(!$debris_for_moon) { |
|
| 73 | + if (!$debris_for_moon) { |
|
| 74 | 74 | return; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure |
| 79 | 79 | $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0; |
| 80 | 80 | $this->create_chance = $moon_chance; |
| 81 | - if($moon_chance) { |
|
| 82 | - if($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
| 81 | + if ($moon_chance) { |
|
| 82 | + if ($is_simulator || mt_rand(1, 100) <= $moon_chance) { |
|
| 83 | 83 | $this->status = UBE_MOON_CREATE_SUCCESS; |
| 84 | 84 | $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999)); |
| 85 | 85 | |
| 86 | - if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
| 86 | + if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) { |
|
| 87 | 87 | $debris->_reset(); |
| 88 | 88 | } else { |
| 89 | 89 | $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | protected function moon_destroy_try($reapers) { |
| 104 | 104 | // TODO: $is_simulator |
| 105 | - if($reapers <= 0) { |
|
| 105 | + if ($reapers <= 0) { |
|
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | 108 | |
@@ -120,8 +120,8 @@ discard block |
||
| 120 | 120 | * @version 2016-02-25 23:42:45 41a4.68 |
| 121 | 121 | */ |
| 122 | 122 | public function calculate_moon(UBE $ube) { |
| 123 | - if(UBE_MOON_EXISTS == $this->status) { |
|
| 124 | - if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
| 123 | + if (UBE_MOON_EXISTS == $this->status) { |
|
| 124 | + if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) { |
|
| 125 | 125 | $reapers = $ube->fleet_list->ube_calculate_attack_reapers(); |
| 126 | 126 | $this->moon_destroy_try($reapers); |
| 127 | 127 | } |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function report_generate_sql() { |
| 134 | - return "`ube_report_moon` = " . (int)$this->status . ", |
|
| 135 | - `ube_report_moon_chance` = " . (int)$this->create_chance . ", |
|
| 136 | - `ube_report_moon_size` = " . (float)$this->moon_diameter . ", |
|
| 137 | - `ube_report_moon_reapers` = " . (int)$this->reapers_status . ", |
|
| 138 | - `ube_report_moon_destroy_chance` = " . (int)$this->destroy_chance . ", |
|
| 139 | - `ube_report_moon_reapers_die_chance` = " . (int)$this->reaper_die_chance; |
|
| 134 | + return "`ube_report_moon` = ".(int) $this->status.", |
|
| 135 | + `ube_report_moon_chance` = " . (int) $this->create_chance.", |
|
| 136 | + `ube_report_moon_size` = " . (float) $this->moon_diameter.", |
|
| 137 | + `ube_report_moon_reapers` = " . (int) $this->reapers_status.", |
|
| 138 | + `ube_report_moon_destroy_chance` = " . (int) $this->destroy_chance.", |
|
| 139 | + `ube_report_moon_reapers_die_chance` = " . (int) $this->reaper_die_chance; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | public function report_render_moon() { |
@@ -166,11 +166,11 @@ discard block |
||
| 166 | 166 | * @param $planet_id |
| 167 | 167 | */ |
| 168 | 168 | public function db_apply_result($planet_info, $destination_user_id) { |
| 169 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
| 169 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
| 170 | 170 | $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false); |
| 171 | 171 | $this->moon_name = $moon_row['name']; |
| 172 | 172 | unset($moon_row); |
| 173 | - } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
| 173 | + } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) { |
|
| 174 | 174 | DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]); |
| 175 | 175 | } |
| 176 | 176 | } |
@@ -179,18 +179,18 @@ discard block |
||
| 179 | 179 | $classLocale = classLocale::$lang; |
| 180 | 180 | |
| 181 | 181 | $text_defender = ''; |
| 182 | - if($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
| 182 | + if ($this->status == UBE_MOON_CREATE_SUCCESS) { |
|
| 183 | 183 | $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />"; |
| 184 | - } elseif($this->status == UBE_MOON_CREATE_FAILED) { |
|
| 184 | + } elseif ($this->status == UBE_MOON_CREATE_FAILED) { |
|
| 185 | 185 | $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />"; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if($ube->mission_type_id == MT_DESTROY) { |
|
| 189 | - if($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
| 188 | + if ($ube->mission_type_id == MT_DESTROY) { |
|
| 189 | + if ($this->reapers_status == UBE_MOON_REAPERS_NONE) { |
|
| 190 | 190 | $text_defender .= classLocale::$lang['ube_report_moon_reapers_none']; |
| 191 | 191 | } else { |
| 192 | 192 | $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. "; |
| 193 | - $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />"; |
|
| 193 | + $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />"; |
|
| 194 | 194 | |
| 195 | 195 | $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. "; |
| 196 | 196 | $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died']; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | * @version 2016-02-25 23:42:45 41a4.68 |
| 216 | 216 | */ |
| 217 | 217 | public function ubeInitLoadStatis($destination_planet) { |
| 218 | - if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
| 218 | + if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) { |
|
| 219 | 219 | $this->status = UBE_MOON_EXISTS; |
| 220 | 220 | $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter']; |
| 221 | 221 | $this->reapers_status = UBE_MOON_REAPERS_NONE; |
@@ -15,10 +15,10 @@ discard block |
||
| 15 | 15 | // classSupernova::$db->sn_db_connect(); |
| 16 | 16 | if (!(strpos($query, '{{') === false)) { |
| 17 | 17 | foreach ($update_tables as $tableName => $cork) { |
| 18 | - $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
|
| 18 | + $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix.$tableName, $query); |
|
| 19 | 19 | } |
| 20 | 20 | } |
| 21 | - !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for ' . $query . ': ' . db_error()) : false; |
|
| 21 | + !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for '.$query.': '.db_error()) : false; |
|
| 22 | 22 | |
| 23 | 23 | return $result; |
| 24 | 24 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | global $update_tables, $update_indexes, $update_indexes_full, $update_foreigns; |
| 86 | 86 | |
| 87 | 87 | $tableName = $prefixed ? str_replace(classSupernova::$config->db_prefix, '', $prefix_table_name) : $prefix_table_name; |
| 88 | - $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix . $prefix_table_name; |
|
| 88 | + $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix.$prefix_table_name; |
|
| 89 | 89 | |
| 90 | 90 | upd_unset_table_info($tableName); |
| 91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
| 103 | + $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
| 104 | 104 | while ($r1 = db_fetch($q1)) { |
| 105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
| 106 | 106 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
| 161 | 161 | $error = db_error(); |
| 162 | 162 | if ($error) { |
| 163 | - die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
|
| 163 | + die("Creating error for table `{$table_name}`: {$error}<br />".dump($declaration)); |
|
| 164 | 164 | } |
| 165 | 165 | upd_do_query('set foreign_key_checks = 1;', true); |
| 166 | 166 | upd_load_table_info($table_name, false); |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | "SELECT {$fields} |
| 176 | 176 | FROM {{unit}} |
| 177 | 177 | WHERE |
| 178 | - `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions() . |
|
| 179 | - ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
| 180 | - ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '') . |
|
| 181 | - " LIMIT 1" . |
|
| 178 | + `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions(). |
|
| 179 | + ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
| 180 | + ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : ''). |
|
| 181 | + " LIMIT 1". |
|
| 182 | 182 | ($for_update ? ' FOR UPDATE' : '') |
| 183 | 183 | )); |
| 184 | 184 | } |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | foreach ($table_data as $record_id => $conditions) { |
| 260 | 260 | $where = ''; |
| 261 | 261 | if (!empty($conditions['where'])) { |
| 262 | - $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
|
| 262 | + $where = 'WHERE '.implode(' AND ', $conditions['where']); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | $fields = array(); |
@@ -268,12 +268,12 @@ discard block |
||
| 268 | 268 | $condition = "`{$field_name}` = "; |
| 269 | 269 | $value = ''; |
| 270 | 270 | if ($field_data['delta']) { |
| 271 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
| 271 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
| 272 | 272 | } elseif ($field_data['set']) { |
| 273 | 273 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
| 274 | 274 | } |
| 275 | 275 | if ($value) { |
| 276 | - $fields[] = $condition . $value; |
|
| 276 | + $fields[] = $condition.$value; |
|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | } |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | $unit_level = $artifact_level_old = mrc_get_level($user, null, $unit_id, true); |
| 14 | 14 | if ($unit_level > 0) { |
| 15 | 15 | $db_changeset = array(); |
| 16 | - switch($unit_id) { |
|
| 16 | + switch ($unit_id) { |
|
| 17 | 17 | case ART_LHC: |
| 18 | 18 | case ART_HOOK_SMALL: |
| 19 | 19 | case ART_HOOK_MEDIUM: |
@@ -133,6 +133,6 @@ discard block |
||
| 133 | 133 | |
| 134 | 134 | sn_db_transaction_commit(); |
| 135 | 135 | message($message, "{$classLocale['tech'][UNIT_ARTIFACTS]} - {$classLocale['tech'][$unit_id]}", |
| 136 | - ($request_uri = sys_get_param_str_unsafe('REQUEST_URI')) ? $request_uri : ('artifacts' . DOT_PHP_EX . '#' . $unit_id), |
|
| 136 | + ($request_uri = sys_get_param_str_unsafe('REQUEST_URI')) ? $request_uri : ('artifacts'.DOT_PHP_EX.'#'.$unit_id), |
|
| 137 | 137 | 5); |
| 138 | 138 | } |
@@ -21,11 +21,19 @@ discard block |
||
| 21 | 21 | return empty($result) ? null : $result; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | + /** |
|
| 25 | + * @param integer $galaxy |
|
| 26 | + * @param integer $system |
|
| 27 | + * @param integer $planet |
|
| 28 | + */ |
|
| 24 | 29 | public static function db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') { |
| 25 | 30 | return classSupernova::db_get_record_list(LOC_PLANET, |
| 26 | 31 | "{{planets}}.`galaxy` = {$galaxy} AND {{planets}}.`system` = {$system} AND {{planets}}.`planet` = {$planet} AND {{planets}}.`planet_type` = {$planet_type}", true); |
| 27 | 32 | } |
| 28 | 33 | |
| 34 | + /** |
|
| 35 | + * @param integer $planet_type |
|
| 36 | + */ |
|
| 29 | 37 | public static function db_planet_by_gspt($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') { |
| 30 | 38 | $galaxy = intval($galaxy); |
| 31 | 39 | $system = intval($system); |
@@ -120,6 +128,9 @@ discard block |
||
| 120 | 128 | "`id_owner` = '{$user_row['id']}' {$conditions} ORDER BY {$order_by}"); |
| 121 | 129 | } |
| 122 | 130 | |
| 131 | + /** |
|
| 132 | + * @param integer $planet_id |
|
| 133 | + */ |
|
| 123 | 134 | public static function db_planet_list_by_user_or_planet($user_id, $planet_id) { |
| 124 | 135 | if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) { |
| 125 | 136 | return false; |
@@ -138,6 +149,9 @@ discard block |
||
| 138 | 149 | return classSupernova::db_upd_record_by_id(LOC_PLANET, $planet_id, $set); |
| 139 | 150 | } |
| 140 | 151 | |
| 152 | + /** |
|
| 153 | + * @param integer $ui_planet_type |
|
| 154 | + */ |
|
| 141 | 155 | public static function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) { |
| 142 | 156 | if(!($set = trim($set))) { |
| 143 | 157 | return false; |
@@ -36,11 +36,10 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') { |
| 39 | - $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0; |
|
| 40 | - $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0; |
|
| 41 | - $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0; |
|
| 42 | - $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : |
|
| 43 | - (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0); |
|
| 39 | + $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0; |
|
| 40 | + $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0; |
|
| 41 | + $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0; |
|
| 42 | + $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0); |
|
| 44 | 43 | $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type; |
| 45 | 44 | |
| 46 | 45 | return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields); |
@@ -61,17 +60,17 @@ discard block |
||
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | public static function db_planet_by_parent($parent_id, $for_update = false, $fields = '*') { |
| 64 | - if(!($parent_id = idval($parent_id))) { |
|
| 63 | + if (!($parent_id = idval($parent_id))) { |
|
| 65 | 64 | return false; |
| 66 | 65 | } |
| 67 | 66 | |
| 68 | 67 | return classSupernova::db_get_record_list(LOC_PLANET, |
| 69 | - "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true); |
|
| 68 | + "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true); |
|
| 70 | 69 | } |
| 71 | 70 | |
| 72 | 71 | public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') { |
| 73 | 72 | //if(!($planet_id = intval($planet_id)) || !($owner_id = intval($owner_id))) return false; |
| 74 | - if(!($planet_id = idval($planet_id)) || !($owner_id = idval($owner_id))) { |
|
| 73 | + if (!($planet_id = idval($planet_id)) || !($owner_id = idval($owner_id))) { |
|
| 75 | 74 | return false; |
| 76 | 75 | } |
| 77 | 76 | |
@@ -82,12 +81,12 @@ discard block |
||
| 82 | 81 | |
| 83 | 82 | public static function db_planet_list_moon_other($user_id, $this_moon_id) { |
| 84 | 83 | // if(!($user_id = intval($user_id)) || !($this_moon_id = intval($this_moon_id))) return false; |
| 85 | - if(!($user_id = idval($user_id)) || !($this_moon_id = idval($this_moon_id))) { |
|
| 84 | + if (!($user_id = idval($user_id)) || !($this_moon_id = idval($this_moon_id))) { |
|
| 86 | 85 | return false; |
| 87 | 86 | } |
| 88 | 87 | |
| 89 | 88 | return classSupernova::db_get_record_list(LOC_PLANET, |
| 90 | - "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
| 89 | + "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}"); |
|
| 91 | 90 | } |
| 92 | 91 | |
| 93 | 92 | public static function db_planet_list_in_system($galaxy, $system) { |
@@ -99,7 +98,7 @@ discard block |
||
| 99 | 98 | } |
| 100 | 99 | |
| 101 | 100 | public static function db_planet_list_sorted($user_row, $skip_planet_id = false, $field_list = '', $conditions = '') { |
| 102 | - if(!is_array($user_row)) { |
|
| 101 | + if (!is_array($user_row)) { |
|
| 103 | 102 | return false; |
| 104 | 103 | } |
| 105 | 104 | // $field_list = $field_list != '*' ? "{{planets}}.`id`, `name`, `image`, {{planets}}.`galaxy`, {{planets}}.`system`, {{planets}}.`planet`, `planet_type`{$field_list}" : $field_list; |
@@ -113,7 +112,7 @@ discard block |
||
| 113 | 112 | ); |
| 114 | 113 | $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT]; |
| 115 | 114 | empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false; |
| 116 | - $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
| 115 | + $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC'); |
|
| 117 | 116 | |
| 118 | 117 | // Compilating query |
| 119 | 118 | return classSupernova::db_get_record_list(LOC_PLANET, |
@@ -121,7 +120,7 @@ discard block |
||
| 121 | 120 | } |
| 122 | 121 | |
| 123 | 122 | public static function db_planet_list_by_user_or_planet($user_id, $planet_id) { |
| 124 | - if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) { |
|
| 123 | + if (!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) { |
|
| 125 | 124 | return false; |
| 126 | 125 | } |
| 127 | 126 | |
@@ -131,7 +130,7 @@ discard block |
||
| 131 | 130 | |
| 132 | 131 | public static function db_planet_set_by_id($planet_id, $set) { |
| 133 | 132 | // if(!($planet_id = intval($planet_id))) return false; |
| 134 | - if(!($planet_id = idval($planet_id))) { |
|
| 133 | + if (!($planet_id = idval($planet_id))) { |
|
| 135 | 134 | return false; |
| 136 | 135 | } |
| 137 | 136 | |
@@ -139,7 +138,7 @@ discard block |
||
| 139 | 138 | } |
| 140 | 139 | |
| 141 | 140 | public static function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) { |
| 142 | - if(!($set = trim($set))) { |
|
| 141 | + if (!($set = trim($set))) { |
|
| 143 | 142 | return false; |
| 144 | 143 | } |
| 145 | 144 | |
@@ -153,7 +152,7 @@ discard block |
||
| 153 | 152 | |
| 154 | 153 | public static function db_planet_set_by_parent($ui_parent_id, $ss_set) { |
| 155 | 154 | //if(!($si_parent_id = intval($ui_parent_id)) || !($ss_set = trim($ss_set))) return false; |
| 156 | - if(!($si_parent_id = idval($ui_parent_id)) || !($ss_set = trim($ss_set))) { |
|
| 155 | + if (!($si_parent_id = idval($ui_parent_id)) || !($ss_set = trim($ss_set))) { |
|
| 157 | 156 | return false; |
| 158 | 157 | } |
| 159 | 158 | |
@@ -162,7 +161,7 @@ discard block |
||
| 162 | 161 | |
| 163 | 162 | public static function db_planet_set_by_owner($ui_owner_id, $ss_set) { |
| 164 | 163 | //if(!($si_owner_id = intval($ui_owner_id)) || !($ss_set = trim($ss_set))) return false; |
| 165 | - if(!($si_owner_id = idval($ui_owner_id)) || !($ss_set = trim($ss_set))) { |
|
| 164 | + if (!($si_owner_id = idval($ui_owner_id)) || !($ss_set = trim($ss_set))) { |
|
| 166 | 165 | return false; |
| 167 | 166 | } |
| 168 | 167 | |
@@ -172,11 +171,11 @@ discard block |
||
| 172 | 171 | |
| 173 | 172 | public static function db_planet_delete_by_id($planet_id) { |
| 174 | 173 | // if(!($planet_id = intval($planet_id))) return false; |
| 175 | - if(!($planet_id = idval($planet_id))) { |
|
| 174 | + if (!($planet_id = idval($planet_id))) { |
|
| 176 | 175 | return false; |
| 177 | 176 | } |
| 178 | 177 | classSupernova::db_del_record_by_id(LOC_PLANET, $planet_id); |
| 179 | - classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_location_id` = " . $planet_id); |
|
| 178 | + classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_location_id` = ".$planet_id); |
|
| 180 | 179 | |
| 181 | 180 | // Очереди очистятся автоматически по FOREIGN KEY |
| 182 | 181 | return true; |
@@ -184,11 +183,11 @@ discard block |
||
| 184 | 183 | |
| 185 | 184 | public static function db_planet_list_delete_by_owner($ui_owner_id) { |
| 186 | 185 | // if(!($si_owner_id = intval($ui_owner_id))) return false; |
| 187 | - if(!($si_owner_id = idval($ui_owner_id))) { |
|
| 186 | + if (!($si_owner_id = idval($ui_owner_id))) { |
|
| 188 | 187 | return false; |
| 189 | 188 | } |
| 190 | 189 | classSupernova::db_del_record_list(LOC_PLANET, "`id_owner` = {$si_owner_id}"); |
| 191 | - classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_player_id` = " . $si_owner_id); |
|
| 190 | + classSupernova::db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_player_id` = ".$si_owner_id); |
|
| 192 | 191 | |
| 193 | 192 | // Очереди очистятся автоматически по FOREIGN KEY |
| 194 | 193 | return true; |
@@ -56,6 +56,9 @@ discard block |
||
| 56 | 56 | WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | + /** |
|
| 60 | + * @param string $set |
|
| 61 | + */ |
|
| 59 | 62 | public static function db_unit_set_by_id($unit_id, $set) { |
| 60 | 63 | return classSupernova::db_upd_record_by_id(LOC_UNIT, $unit_id, $set); |
| 61 | 64 | } |
@@ -69,6 +72,9 @@ discard block |
||
| 69 | 72 | return classSupernova::db_ins_record(LOC_UNIT, $set); |
| 70 | 73 | } |
| 71 | 74 | |
| 75 | + /** |
|
| 76 | + * @param integer $unit_location_type |
|
| 77 | + */ |
|
| 72 | 78 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id, $unit_snid = 0) { |
| 73 | 79 | return classSupernova::db_del_record_list(LOC_UNIT, |
| 74 | 80 | "`unit_location_type` = {$unit_location_type} AND `unit_location_id` = {$unit_location_id}" . |
@@ -21,13 +21,13 @@ discard block |
||
| 21 | 21 | |
| 22 | 22 | public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) { |
| 23 | 23 | $query = doquery( |
| 24 | - "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} " . |
|
| 25 | - ($unit_type ? "AND `unit_type` = {$unit_type} " : '') . |
|
| 26 | - ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') . |
|
| 24 | + "SELECT unit_snid, sum(unit_level) as `qty` FROM {{unit}} WHERE `unit_player_id` = {$user_id} ". |
|
| 25 | + ($unit_type ? "AND `unit_type` = {$unit_type} " : ''). |
|
| 26 | + ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : ''). |
|
| 27 | 27 | 'GROUP BY `unit_snid`' |
| 28 | 28 | ); |
| 29 | 29 | $result = array(); |
| 30 | - while($row = db_fetch($query)) { |
|
| 30 | + while ($row = db_fetch($query)) { |
|
| 31 | 31 | $result[$row['unit_snid']] = $row; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | WHERE |
| 44 | 44 | f.fleet_owner = {$user_id} AND |
| 45 | 45 | (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id}) |
| 46 | - AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() . |
|
| 47 | - " LIMIT 1" . |
|
| 46 | + AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions(). |
|
| 47 | + " LIMIT 1". |
|
| 48 | 48 | ($for_update ? ' FOR UPDATE' : '') |
| 49 | 49 | , true); |
| 50 | 50 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | public static function db_unit_list_laboratories($user_id) { |
| 54 | 54 | return doquery("SELECT DISTINCT unit_location_id AS `id` |
| 55 | 55 | FROM {{unit}} |
| 56 | - WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");"); |
|
| 56 | + WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");"); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public static function db_unit_set_by_id($unit_id, $set) { |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | |
| 72 | 72 | public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) { |
| 73 | 73 | return classSupernova::db_del_record_list(LOC_UNIT, |
| 74 | - "`unit_location_type` = {$unit_location_type}" . |
|
| 75 | - ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : '') . |
|
| 76 | - ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
| 74 | + "`unit_location_type` = {$unit_location_type}". |
|
| 75 | + ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : ''). |
|
| 76 | + ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
| 77 | 77 | ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '')); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | return doquery( |
| 82 | 82 | "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount |
| 83 | 83 | FROM `{{unit}}` |
| 84 | - WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() . |
|
| 84 | + WHERE unit_level > 0 AND " . self::db_unit_time_restrictions(). |
|
| 85 | 85 | " GROUP BY unit_player_id, unit_type, unit_snid, unit_level" |
| 86 | 86 | ); |
| 87 | 87 | } |
@@ -93,15 +93,15 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | public static function db_unit_list_admin_delete_mercenaries_finished() { |
| 96 | - return doquery("DELETE FROM {{unit}} WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ") AND unit_type = " . UNIT_MERCENARIES); |
|
| 96 | + return doquery("DELETE FROM {{unit}} WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.") AND unit_type = ".UNIT_MERCENARIES); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | public static function db_unit_list_admin_set_mercenaries_expire_time($default_length) { |
| 100 | 100 | return doquery( |
| 101 | 101 | "UPDATE {{unit}} |
| 102 | 102 | SET |
| 103 | - unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "), |
|
| 104 | - unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ") |
|
| 103 | + unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."), |
|
| 104 | + unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).") |
|
| 105 | 105 | WHERE unit_type = " . UNIT_MERCENARIES |
| 106 | 106 | ); |
| 107 | 107 | } |
@@ -293,7 +293,7 @@ |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | - * @param $ranklist |
|
| 296 | + * @param string $ranklist |
|
| 297 | 297 | * @param $user |
| 298 | 298 | */ |
| 299 | 299 | public static function db_ally_update_ranklist($ranklist, $user) { |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | `ally_name` = '{$ally_name}', |
| 67 | 67 | `ally_tag` = '{$ally_tag}', |
| 68 | 68 | `ally_owner` = '{$user['id']}', |
| 69 | - `ally_owner_range` = '" . classLocale::$lang['ali_leaderRank'] . "', |
|
| 69 | + `ally_owner_range` = '".classLocale::$lang['ali_leaderRank']."', |
|
| 70 | 70 | `ally_members` = 1, |
| 71 | - `ranklist` = '" . classLocale::$lang['ali_defaultRankName'] . ",0,0,0,0,0', |
|
| 71 | + `ranklist` = '" . classLocale::$lang['ali_defaultRankName'].",0,0,0,0,0', |
|
| 72 | 72 | `ally_register_time`= " . SN_TIME_NOW |
| 73 | 73 | ); |
| 74 | 74 | } |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param $POST_text |
| 88 | 88 | */ |
| 89 | 89 | public static function db_ally_request_insert($user, $id_ally, $POST_text) { |
| 90 | - doquery("INSERT INTO {{alliance_requests}} SET `id_user` = {$user['id']}, `id_ally`='{$id_ally}', request_text ='{$POST_text}', request_time=" . SN_TIME_NOW . ";"); |
|
| 90 | + doquery("INSERT INTO {{alliance_requests}} SET `id_user` = {$user['id']}, `id_ally`='{$id_ally}', request_text ='{$POST_text}', request_time=".SN_TIME_NOW.";"); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * @param $ally |
| 138 | 138 | */ |
| 139 | 139 | public static function db_ally_update_by_changeset($ally_changeset, $ally) { |
| 140 | - doquery("UPDATE {{alliance}} SET " . implode(',', $ally_changeset) . " WHERE `id`='{$ally['id']}' LIMIT 1;"); |
|
| 140 | + doquery("UPDATE {{alliance}} SET ".implode(',', $ally_changeset)." WHERE `id`='{$ally['id']}' LIMIT 1;"); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | * @param $d |
| 249 | 249 | */ |
| 250 | 250 | public static function db_ally_request_deny($d) { |
| 251 | - doquery("UPDATE {{alliance_requests}} SET `request_denied` = 1, `request_text` = '" . classLocale::$lang['ali_req_deny_reason'] . "' WHERE `id_user`= {$d} LIMIT 1;"); |
|
| 251 | + doquery("UPDATE {{alliance_requests}} SET `request_denied` = 1, `request_text` = '".classLocale::$lang['ali_req_deny_reason']."' WHERE `id_user`= {$d} LIMIT 1;"); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | /** |
@@ -19,9 +19,9 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * @param $user_id |
| 22 | - * @param $nick |
|
| 22 | + * @param string $nick |
|
| 23 | 23 | * @param $ally_id |
| 24 | - * @param $message |
|
| 24 | + * @param string $message |
|
| 25 | 25 | * @param $chat_message_sender_name |
| 26 | 26 | * @param $chat_message_recipient_id |
| 27 | 27 | * @param $chat_message_recipient_name |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param $alliance |
| 58 | 58 | * @param $where_add |
| 59 | 59 | * @param $start_row |
| 60 | - * @param $page_limit |
|
| 60 | + * @param integer $page_limit |
|
| 61 | 61 | * |
| 62 | 62 | * @return array|bool|mysqli_result|null |
| 63 | 63 | */ |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | JOIN {{users}} AS u ON u.id = cp.chat_player_player_id |
| 13 | 13 | WHERE |
| 14 | 14 | `chat_player_refresh_last` >= '{$sql_date}' |
| 15 | - AND (`banaday` IS NULL OR `banaday` <= " . SN_TIME_NOW . ") |
|
| 15 | + AND (`banaday` IS NULL OR `banaday` <= ".SN_TIME_NOW.") |
|
| 16 | 16 | {$ally_add} |
| 17 | 17 | ORDER BY authlevel DESC, `username`"); |
| 18 | 18 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | `user` = '{$nick}', |
| 36 | 36 | `ally_id` = '{$ally_id}', |
| 37 | 37 | `message` = '{$message}', |
| 38 | - `timestamp` = " . SN_TIME_NOW . ", |
|
| 38 | + `timestamp` = ".SN_TIME_NOW.", |
|
| 39 | 39 | `chat_message_sender_name` = '{$chat_message_sender_name}', |
| 40 | 40 | `chat_message_recipient_id` = {$chat_message_recipient_id}, |
| 41 | 41 | `chat_message_recipient_name` = '{$chat_message_recipient_name}'" |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @param $user |
| 142 | 142 | */ |
| 143 | 143 | public static function db_chat_player_update($user) { |
| 144 | - doquery("UPDATE {{chat_player}} SET `chat_player_refresh_last` = " . SN_TIME_NOW . " WHERE `chat_player_player_id` = {$user['id']} LIMIT 1;"); |
|
| 144 | + doquery("UPDATE {{chat_player}} SET `chat_player_refresh_last` = ".SN_TIME_NOW." WHERE `chat_player_player_id` = {$user['id']} LIMIT 1;"); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | * @param $user |
| 213 | 213 | */ |
| 214 | 214 | public static function db_chat_player_update_activity($user) { |
| 215 | - doquery("UPDATE {{chat_player}} SET `chat_player_activity` = '" . classSupernova::$db->db_escape(SN_TIME_SQL) . "' WHERE `chat_player_player_id` = {$user['id']} LIMIT 1"); |
|
| 215 | + doquery("UPDATE {{chat_player}} SET `chat_player_activity` = '".classSupernova::$db->db_escape(SN_TIME_SQL)."' WHERE `chat_player_player_id` = {$user['id']} LIMIT 1"); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | } |
| 219 | 219 | \ No newline at end of file |