@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | protected static $is_init = false; |
| 20 | 20 | |
| 21 | 21 | protected static function init() { |
| 22 | - if(!empty(static::$db)) { |
|
| 22 | + if (!empty(static::$db)) { |
|
| 23 | 23 | return; |
| 24 | 24 | } |
| 25 | 25 | static::$db = classSupernova::$db; |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | $provider_id_safe = intval($provider_id_unsafe); |
| 67 | 67 | !is_array($account_list) ? $account_list = array($account_list) : false; |
| 68 | 68 | |
| 69 | - foreach($account_list as $provider_account_id_unsafe) { |
|
| 69 | + foreach ($account_list as $provider_account_id_unsafe) { |
|
| 70 | 70 | $provider_account_id_safe = intval($provider_account_id_unsafe); |
| 71 | 71 | |
| 72 | 72 | // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером |
| 73 | 73 | $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE"); |
| 74 | - while($row = static::$db->db_fetch($query)) { |
|
| 74 | + while ($row = static::$db->db_fetch($query)) { |
|
| 75 | 75 | $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true; |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " . |
| 92 | 92 | ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') . |
| 93 | 93 | "ORDER BY `timestamp` FOR UPDATE"); |
| 94 | - while($row = static::$db->db_fetch($query)) { |
|
| 94 | + while ($row = static::$db->db_fetch($query)) { |
|
| 95 | 95 | $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row; |
| 96 | 96 | } |
| 97 | 97 | |
@@ -202,14 +202,18 @@ discard block |
||
| 202 | 202 | // Перепаковывает массив на заданную глубину, убирая поля с null |
| 203 | 203 | public static function array_repack(&$array, $level = 0) { |
| 204 | 204 | // TODO $lock_table не нужна тут |
| 205 | - if(!is_array($array)) return; |
|
| 205 | + if(!is_array($array)) { |
|
| 206 | + return; |
|
| 207 | + } |
|
| 206 | 208 | |
| 207 | 209 | foreach($array as $key => &$value) { |
| 208 | 210 | if($value === null) { |
| 209 | 211 | unset($array[$key]); |
| 210 | 212 | } elseif($level > 0 && is_array($value)) { |
| 211 | 213 | static::array_repack($value, $level - 1); |
| 212 | - if(empty($value)) unset($array[$key]); |
|
| 214 | + if(empty($value)) { |
|
| 215 | + unset($array[$key]); |
|
| 216 | + } |
|
| 213 | 217 | } |
| 214 | 218 | } |
| 215 | 219 | } |
@@ -218,7 +222,9 @@ discard block |
||
| 218 | 222 | // TODO Вынести в отдельный объект |
| 219 | 223 | public static function cache_repack($location_type, $record_id = 0) { |
| 220 | 224 | // Если есть $user_id - проверяем, а надо ли перепаковывать? |
| 221 | - if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) return; |
|
| 225 | + if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) { |
|
| 226 | + return; |
|
| 227 | + } |
|
| 222 | 228 | |
| 223 | 229 | static::array_repack(static::$data[$location_type]); |
| 224 | 230 | static::array_repack(static::$locator[$location_type], 3); // TODO У каждого типа локации - своя глубина!!!! Но можно и глубже ??? |
@@ -263,7 +269,9 @@ discard block |
||
| 263 | 269 | */ |
| 264 | 270 | public static function cache_set($location_type, $record_id, $record, $force_overwrite = false, $skip_lock = false) { |
| 265 | 271 | // нет идентификатора - выход |
| 266 | - if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) return; |
|
| 272 | + if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) { |
|
| 273 | + return; |
|
| 274 | + } |
|
| 267 | 275 | |
| 268 | 276 | $in_transaction = static::db_transaction_check(false); |
| 269 | 277 | if( |
@@ -297,8 +305,9 @@ discard block |
||
| 297 | 305 | return static::$locks[$location_type][$record_id] = true; // Не всегда - от результата |
| 298 | 306 | } |
| 299 | 307 | public static function cache_lock_unset($location_type, $record_id) { |
| 300 | - if(isset(static::$locks[$location_type][$record_id])) |
|
| 301 | - unset(static::$locks[$location_type][$record_id]); |
|
| 308 | + if(isset(static::$locks[$location_type][$record_id])) { |
|
| 309 | + unset(static::$locks[$location_type][$record_id]); |
|
| 310 | + } |
|
| 302 | 311 | return true; // Не всегда - от результата |
| 303 | 312 | } |
| 304 | 313 | public static function cache_lock_unset_all() { |
@@ -471,8 +480,9 @@ discard block |
||
| 471 | 480 | //pdump($q, 'Запрос блокировки'); |
| 472 | 481 | while($row = db_fetch($query)) { |
| 473 | 482 | // Исключаем из списка родительских ИД уже заблокированные записи |
| 474 | - if(!static::cache_lock_get($owner_location_type, $row['parent_id'])) |
|
| 475 | - $parent_id_list[$row['parent_id']] = $row['parent_id']; |
|
| 483 | + if(!static::cache_lock_get($owner_location_type, $row['parent_id'])) { |
|
| 484 | + $parent_id_list[$row['parent_id']] = $row['parent_id']; |
|
| 485 | + } |
|
| 476 | 486 | } |
| 477 | 487 | //pdump($parent_id_list, 'Выбраны родители'); |
| 478 | 488 | // Если все-таки какие-то записи еще не заблокированы - вынимаем текущие версии из базы |
@@ -506,7 +516,9 @@ discard block |
||
| 506 | 516 | if(is_array($query_cache)) { |
| 507 | 517 | foreach($query_cache as $key => $value) { |
| 508 | 518 | $result[$key] = $value; |
| 509 | - if($fetch) break; |
|
| 519 | + if($fetch) { |
|
| 520 | + break; |
|
| 521 | + } |
|
| 510 | 522 | } |
| 511 | 523 | } |
| 512 | 524 | return $fetch ? (is_array($result) ? reset($result) : false) : $result; |
@@ -515,12 +527,15 @@ discard block |
||
| 515 | 527 | |
| 516 | 528 | public static function db_upd_record_by_id($location_type, $record_id, $set) { |
| 517 | 529 | //if(!($record_id = intval($record_id)) || !($set = trim($set))) return false; |
| 518 | - if(!($record_id = idval($record_id)) || !($set = trim($set))) return false; |
|
| 530 | + if(!($record_id = idval($record_id)) || !($set = trim($set))) { |
|
| 531 | + return false; |
|
| 532 | + } |
|
| 519 | 533 | |
| 520 | 534 | $location_info = &static::$location_info[$location_type]; |
| 521 | 535 | $id_field = $location_info[P_ID]; |
| 522 | 536 | $table_name = $location_info[P_TABLE_NAME]; |
| 523 | - if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 537 | + if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
| 538 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 524 | 539 | { |
| 525 | 540 | if(static::$db->db_affected_rows()) { |
| 526 | 541 | // Обновляем данные только если ряд был затронут |
@@ -528,6 +543,7 @@ discard block |
||
| 528 | 543 | |
| 529 | 544 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
| 530 | 545 | static::$data[$location_type][$record_id] = null; |
| 546 | + } |
|
| 531 | 547 | // Вытаскиваем обновленную запись |
| 532 | 548 | static::db_get_record_by_id($location_type, $record_id); |
| 533 | 549 | static::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -537,7 +553,9 @@ discard block |
||
| 537 | 553 | return $result; |
| 538 | 554 | } |
| 539 | 555 | public static function db_upd_record_list($location_type, $condition, $set) { |
| 540 | - if(!($set = trim($set))) return false; |
|
| 556 | + if(!($set = trim($set))) { |
|
| 557 | + return false; |
|
| 558 | + } |
|
| 541 | 559 | |
| 542 | 560 | $condition = trim($condition); |
| 543 | 561 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
@@ -560,9 +578,11 @@ discard block |
||
| 560 | 578 | $set = trim($set); |
| 561 | 579 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 562 | 580 | if($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
| 563 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 581 | + if(static::$db->db_affected_rows()) { |
|
| 582 | + // Обновляем данные только если ряд был затронут |
|
| 564 | 583 | { |
| 565 | 584 | $record_id = db_insert_id(); |
| 585 | + } |
|
| 566 | 586 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
| 567 | 587 | $result = static::db_get_record_by_id($location_type, $record_id); |
| 568 | 588 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -600,24 +620,30 @@ discard block |
||
| 600 | 620 | public static function db_del_record_by_id($location_type, $safe_record_id) |
| 601 | 621 | { |
| 602 | 622 | // if(!($safe_record_id = intval($safe_record_id))) return false; |
| 603 | - if(!($safe_record_id = idval($safe_record_id))) return false; |
|
| 623 | + if(!($safe_record_id = idval($safe_record_id))) { |
|
| 624 | + return false; |
|
| 625 | + } |
|
| 604 | 626 | |
| 605 | 627 | $location_info = &static::$location_info[$location_type]; |
| 606 | 628 | $id_field = $location_info[P_ID]; |
| 607 | 629 | $table_name = $location_info[P_TABLE_NAME]; |
| 608 | 630 | if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) |
| 609 | 631 | { |
| 610 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 632 | + if(static::$db->db_affected_rows()) { |
|
| 633 | + // Обновляем данные только если ряд был затронут |
|
| 611 | 634 | { |
| 612 | 635 | static::cache_unset($location_type, $safe_record_id); |
| 613 | 636 | } |
| 637 | + } |
|
| 614 | 638 | } |
| 615 | 639 | |
| 616 | 640 | return $result; |
| 617 | 641 | } |
| 618 | 642 | public static function db_del_record_list($location_type, $condition) |
| 619 | 643 | { |
| 620 | - if(!($condition = trim($condition))) return false; |
|
| 644 | + if(!($condition = trim($condition))) { |
|
| 645 | + return false; |
|
| 646 | + } |
|
| 621 | 647 | |
| 622 | 648 | $location_info = &static::$location_info[$location_type]; |
| 623 | 649 | $table_name = $location_info[P_TABLE_NAME]; |
@@ -626,12 +652,14 @@ discard block |
||
| 626 | 652 | |
| 627 | 653 | if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) |
| 628 | 654 | { |
| 629 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 655 | + if(static::$db->db_affected_rows()) { |
|
| 656 | + // Обновляем данные только если ряд был затронут |
|
| 630 | 657 | { |
| 631 | 658 | // Обнуление кэша, потому что непонятно, что поменялось |
| 632 | 659 | // TODO - когда будет структурированный $condition можно будет делать только cache_unset по нужным записям |
| 633 | 660 | static::cache_clear($location_type); |
| 634 | 661 | } |
| 662 | + } |
|
| 635 | 663 | } |
| 636 | 664 | |
| 637 | 665 | return $result; |
@@ -673,11 +701,13 @@ discard block |
||
| 673 | 701 | public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) |
| 674 | 702 | { |
| 675 | 703 | // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ? |
| 676 | - if(!($username_unsafe = trim($username_unsafe))) return false; |
|
| 704 | + if(!($username_unsafe = trim($username_unsafe))) { |
|
| 705 | + return false; |
|
| 706 | + } |
|
| 677 | 707 | |
| 678 | 708 | $user = null; |
| 679 | - if(is_array(static::$data[LOC_USER])) |
|
| 680 | - foreach(static::$data[LOC_USER] as $user_id => $user_data) |
|
| 709 | + if(is_array(static::$data[LOC_USER])) { |
|
| 710 | + foreach(static::$data[LOC_USER] as $user_id => $user_data) |
|
| 681 | 711 | { |
| 682 | 712 | if(is_array($user_data) && isset($user_data['username'])) |
| 683 | 713 | { |
@@ -687,6 +717,7 @@ discard block |
||
| 687 | 717 | { |
| 688 | 718 | // $user_as_ally = intval($user_data['user_as_ally']); |
| 689 | 719 | $user_as_ally = idval($user_data['user_as_ally']); |
| 720 | + } |
|
| 690 | 721 | if($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) |
| 691 | 722 | { |
| 692 | 723 | $user = $user_data; |
@@ -714,7 +745,9 @@ discard block |
||
| 714 | 745 | } |
| 715 | 746 | // UNUSED |
| 716 | 747 | public static function db_get_user_by_email($email_unsafe, $use_both = false, $for_update = false, $fields = '*') { |
| 717 | - if(!($email_unsafe = strtolower(trim($email_unsafe)))) return false; |
|
| 748 | + if(!($email_unsafe = strtolower(trim($email_unsafe)))) { |
|
| 749 | + return false; |
|
| 750 | + } |
|
| 718 | 751 | |
| 719 | 752 | $user = null; |
| 720 | 753 | // TODO переделать на индексы |
@@ -794,7 +827,9 @@ discard block |
||
| 794 | 827 | public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id) |
| 795 | 828 | { |
| 796 | 829 | //if(!($location_type = intval($location_type)) || !($location_id = intval($location_id))) return false; |
| 797 | - if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) return false; |
|
| 830 | + if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) { |
|
| 831 | + return false; |
|
| 832 | + } |
|
| 798 | 833 | |
| 799 | 834 | $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id]; |
| 800 | 835 | if(!isset($query_cache)) |
@@ -861,15 +896,18 @@ discard block |
||
| 861 | 896 | $query = array(); |
| 862 | 897 | |
| 863 | 898 | // if($user_id = intval($user_id)) |
| 864 | - if($user_id = idval($user_id)) |
|
| 865 | - $query[] = "`que_player_id` = {$user_id}"; |
|
| 899 | + if($user_id = idval($user_id)) { |
|
| 900 | + $query[] = "`que_player_id` = {$user_id}"; |
|
| 901 | + } |
|
| 866 | 902 | |
| 867 | - if($que_type == QUE_RESEARCH || $planet_id === null) |
|
| 868 | - $query[] = "`que_planet_id` IS NULL"; |
|
| 869 | - elseif($planet_id) |
|
| 870 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
| 871 | - if($que_type) |
|
| 872 | - $query[] = "`que_type` = {$que_type}"; |
|
| 903 | + if($que_type == QUE_RESEARCH || $planet_id === null) { |
|
| 904 | + $query[] = "`que_planet_id` IS NULL"; |
|
| 905 | + } elseif($planet_id) { |
|
| 906 | + $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
| 907 | + } |
|
| 908 | + if($que_type) { |
|
| 909 | + $query[] = "`que_type` = {$que_type}"; |
|
| 910 | + } |
|
| 873 | 911 | |
| 874 | 912 | /* |
| 875 | 913 | $sql = ''; |
@@ -990,8 +1028,7 @@ discard block |
||
| 990 | 1028 | ), |
| 991 | 1029 | ), |
| 992 | 1030 | ); |
| 993 | - } |
|
| 994 | - else |
|
| 1031 | + } else |
|
| 995 | 1032 | { |
| 996 | 1033 | $db_changeset = array( |
| 997 | 1034 | 'action' => SQL_OP_INSERT, |
@@ -1133,7 +1170,9 @@ discard block |
||
| 1133 | 1170 | |
| 1134 | 1171 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
| 1135 | 1172 | $result = true; |
| 1136 | - if(!is_array($db_changeset) || empty($db_changeset)) return $result; |
|
| 1173 | + if(!is_array($db_changeset) || empty($db_changeset)) { |
|
| 1174 | + return $result; |
|
| 1175 | + } |
|
| 1137 | 1176 | |
| 1138 | 1177 | foreach($db_changeset as $table_name => &$table_data) { |
| 1139 | 1178 | // TODO - delayed changeset |
@@ -1147,8 +1186,13 @@ discard block |
||
| 1147 | 1186 | foreach($table_data as $record_id => &$conditions) { |
| 1148 | 1187 | static::db_changeset_condition_compile($conditions, $table_name); |
| 1149 | 1188 | |
| 1150 | - if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue; |
|
| 1151 | - if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице |
|
| 1189 | + if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) { |
|
| 1190 | + continue; |
|
| 1191 | + } |
|
| 1192 | + if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) { |
|
| 1193 | + continue; |
|
| 1194 | + } |
|
| 1195 | + // Защита от случайного удаления всех данных в таблице |
|
| 1152 | 1196 | |
| 1153 | 1197 | if($conditions[P_LOCATION] != LOC_NONE) { |
| 1154 | 1198 | //die('spec ops supernova.php line 928 Добавить работу с кэшем юнитов итд'); |
@@ -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 | { |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | |
| 193 | 193 | public static function log_file($message, $spaces = 0) { |
| 194 | - if(self::$debug) { |
|
| 194 | + if (self::$debug) { |
|
| 195 | 195 | self::$debug->log_file($message, $spaces); |
| 196 | 196 | } |
| 197 | 197 | } |
@@ -202,14 +202,14 @@ discard block |
||
| 202 | 202 | // Перепаковывает массив на заданную глубину, убирая поля с null |
| 203 | 203 | public static function array_repack(&$array, $level = 0) { |
| 204 | 204 | // TODO $lock_table не нужна тут |
| 205 | - if(!is_array($array)) return; |
|
| 205 | + if (!is_array($array)) return; |
|
| 206 | 206 | |
| 207 | - foreach($array as $key => &$value) { |
|
| 208 | - if($value === null) { |
|
| 207 | + foreach ($array as $key => &$value) { |
|
| 208 | + if ($value === null) { |
|
| 209 | 209 | unset($array[$key]); |
| 210 | - } elseif($level > 0 && is_array($value)) { |
|
| 210 | + } elseif ($level > 0 && is_array($value)) { |
|
| 211 | 211 | static::array_repack($value, $level - 1); |
| 212 | - if(empty($value)) unset($array[$key]); |
|
| 212 | + if (empty($value)) unset($array[$key]); |
|
| 213 | 213 | } |
| 214 | 214 | } |
| 215 | 215 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | // TODO Вынести в отдельный объект |
| 219 | 219 | public static function cache_repack($location_type, $record_id = 0) { |
| 220 | 220 | // Если есть $user_id - проверяем, а надо ли перепаковывать? |
| 221 | - if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) return; |
|
| 221 | + if ($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) return; |
|
| 222 | 222 | |
| 223 | 223 | static::array_repack(static::$data[$location_type]); |
| 224 | 224 | static::array_repack(static::$locator[$location_type], 3); // TODO У каждого типа локации - своя глубина!!!! Но можно и глубже ??? |
@@ -226,9 +226,9 @@ discard block |
||
| 226 | 226 | } |
| 227 | 227 | public static function cache_clear($location_type, $hard = true) { |
| 228 | 228 | //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />"); |
| 229 | - if($hard && !empty(static::$data[$location_type])) { |
|
| 229 | + if ($hard && !empty(static::$data[$location_type])) { |
|
| 230 | 230 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
| 231 | - array_walk(static::$data[$location_type], function(&$item){$item = null;}); |
|
| 231 | + array_walk(static::$data[$location_type], function(&$item) {$item = null; }); |
|
| 232 | 232 | } |
| 233 | 233 | static::$locator[$location_type] = array(); |
| 234 | 234 | static::$queries[$location_type] = array(); |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | } |
| 237 | 237 | public static function cache_clear_all($hard = true) { |
| 238 | 238 | //print('<br />CACHE CLEAR ALL<br />'); |
| 239 | - if($hard) { |
|
| 239 | + if ($hard) { |
|
| 240 | 240 | static::$data = array(); |
| 241 | 241 | static::cache_lock_unset_all(); |
| 242 | 242 | } |
@@ -263,10 +263,10 @@ discard block |
||
| 263 | 263 | */ |
| 264 | 264 | public static function cache_set($location_type, $record_id, $record, $force_overwrite = false, $skip_lock = false) { |
| 265 | 265 | // нет идентификатора - выход |
| 266 | - if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) return; |
|
| 266 | + if (!($record_id = $record[static::$location_info[$location_type][P_ID]])) return; |
|
| 267 | 267 | |
| 268 | 268 | $in_transaction = static::db_transaction_check(false); |
| 269 | - if( |
|
| 269 | + if ( |
|
| 270 | 270 | $force_overwrite |
| 271 | 271 | || |
| 272 | 272 | // Не заменяются заблокированные записи во время транзакции |
@@ -276,14 +276,14 @@ discard block |
||
| 276 | 276 | !static::cache_isset($location_type, $record_id) |
| 277 | 277 | ) { |
| 278 | 278 | static::$data[$location_type][$record_id] = $record; |
| 279 | - if($in_transaction && !$skip_lock) { |
|
| 279 | + if ($in_transaction && !$skip_lock) { |
|
| 280 | 280 | static::cache_lock_set($location_type, $record_id); |
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | public static function cache_unset($cache_id, $safe_record_id) { |
| 285 | 285 | // $record_id должен быть проверен заранее ! |
| 286 | - if(isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) { |
|
| 286 | + if (isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) { |
|
| 287 | 287 | // Выставляем запись в null |
| 288 | 288 | static::$data[$cache_id][$safe_record_id] = null; |
| 289 | 289 | // Очищаем кэш мягко - что бы удалить очистить связанные данные - кэш локаций и кэш запоросов и всё, что потребуется впредь |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | return static::$locks[$location_type][$record_id] = true; // Не всегда - от результата |
| 298 | 298 | } |
| 299 | 299 | public static function cache_lock_unset($location_type, $record_id) { |
| 300 | - if(isset(static::$locks[$location_type][$record_id])) |
|
| 300 | + if (isset(static::$locks[$location_type][$record_id])) |
|
| 301 | 301 | unset(static::$locks[$location_type][$record_id]); |
| 302 | 302 | return true; // Не всегда - от результата |
| 303 | 303 | } |
@@ -327,13 +327,13 @@ discard block |
||
| 327 | 327 | */ |
| 328 | 328 | public static function db_transaction_check($status = null) { |
| 329 | 329 | $error_msg = false; |
| 330 | - if($status && !static::$db_in_transaction) { |
|
| 330 | + if ($status && !static::$db_in_transaction) { |
|
| 331 | 331 | $error_msg = 'No transaction started for current operation'; |
| 332 | - } elseif($status === null && static::$db_in_transaction) { |
|
| 332 | + } elseif ($status === null && static::$db_in_transaction) { |
|
| 333 | 333 | $error_msg = 'Transaction is already started'; |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | - if($error_msg) { |
|
| 336 | + if ($error_msg) { |
|
| 337 | 337 | // TODO - Убрать позже |
| 338 | 338 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
| 339 | 339 | $backtrace = debug_backtrace(); |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | static::$transaction_id++; |
| 355 | 355 | doquery('START TRANSACTION'); |
| 356 | 356 | |
| 357 | - if($config->db_manual_lock_enabled) { |
|
| 357 | + if ($config->db_manual_lock_enabled) { |
|
| 358 | 358 | $config->db_loadItem('var_db_manually_locked'); |
| 359 | 359 | $config->db_saveItem('var_db_manually_locked', SN_TIME_SQL); |
| 360 | 360 | } |
@@ -369,7 +369,7 @@ discard block |
||
| 369 | 369 | public static function db_transaction_commit() { |
| 370 | 370 | static::db_transaction_check(true); |
| 371 | 371 | |
| 372 | - if(!empty(static::$delayed_changset)) { |
|
| 372 | + if (!empty(static::$delayed_changset)) { |
|
| 373 | 373 | static::db_changeset_apply(static::$delayed_changset, true); |
| 374 | 374 | // pdump(static::$delayed_changset); |
| 375 | 375 | } |
@@ -384,7 +384,7 @@ discard block |
||
| 384 | 384 | } |
| 385 | 385 | public static function db_transaction_rollback() { |
| 386 | 386 | // static::db_transaction_check(true); // TODO - вообще-то тут тоже надо проверять есть ли транзакция |
| 387 | - if(!empty(static::$delayed_changset)) { |
|
| 387 | + if (!empty(static::$delayed_changset)) { |
|
| 388 | 388 | static::db_changeset_revert(); |
| 389 | 389 | } |
| 390 | 390 | static::$delayed_changset = array(); |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | public static function db_lock_tables($tables) { |
| 407 | 407 | $tables = is_array($tables) ? $tables : array($tables => ''); |
| 408 | - foreach($tables as $table_name => $condition) { |
|
| 408 | + foreach ($tables as $table_name => $condition) { |
|
| 409 | 409 | self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
| 410 | 410 | } |
| 411 | 411 | } |
@@ -446,17 +446,17 @@ discard block |
||
| 446 | 446 | //pdump($filter, 'Выбираем ' . $location_type); |
| 447 | 447 | $query_cache = &static::$queries[$location_type][$filter]; |
| 448 | 448 | |
| 449 | - if(!isset($query_cache) || $query_cache === null) { |
|
| 449 | + if (!isset($query_cache) || $query_cache === null) { |
|
| 450 | 450 | // pdump($filter, 'Кэш пустой, начинаем возню'); |
| 451 | 451 | $location_info = &static::$location_info[$location_type]; |
| 452 | 452 | $id_field = $location_info[P_ID]; |
| 453 | 453 | $query_cache = array(); |
| 454 | 454 | |
| 455 | - if(static::db_transaction_check(false)) { |
|
| 455 | + if (static::db_transaction_check(false)) { |
|
| 456 | 456 | //pdump($filter, 'Транзакция - блокируем ' . $location_type); |
| 457 | 457 | // Проходим по всем родителям данной записи |
| 458 | 458 | // foreach($location_info[P_OWNER_INFO] as $owner_location_type => $owner_data) |
| 459 | - foreach($location_info[P_OWNER_INFO] as $owner_data) { |
|
| 459 | + foreach ($location_info[P_OWNER_INFO] as $owner_data) { |
|
| 460 | 460 | $owner_location_type = $owner_data[P_LOCATION]; |
| 461 | 461 | //pdump($filter, 'Транзакция - блокируем родителя ' . $owner_location_type); |
| 462 | 462 | $parent_id_list = array(); |
@@ -469,14 +469,14 @@ discard block |
||
| 469 | 469 | ($fetch ? ' LIMIT 1' : ''), false, true); |
| 470 | 470 | |
| 471 | 471 | //pdump($q, 'Запрос блокировки'); |
| 472 | - while($row = db_fetch($query)) { |
|
| 472 | + while ($row = db_fetch($query)) { |
|
| 473 | 473 | // Исключаем из списка родительских ИД уже заблокированные записи |
| 474 | - if(!static::cache_lock_get($owner_location_type, $row['parent_id'])) |
|
| 474 | + if (!static::cache_lock_get($owner_location_type, $row['parent_id'])) |
|
| 475 | 475 | $parent_id_list[$row['parent_id']] = $row['parent_id']; |
| 476 | 476 | } |
| 477 | 477 | //pdump($parent_id_list, 'Выбраны родители'); |
| 478 | 478 | // Если все-таки какие-то записи еще не заблокированы - вынимаем текущие версии из базы |
| 479 | - if($indexes_str = implode(',', $parent_id_list)) { |
|
| 479 | + if ($indexes_str = implode(',', $parent_id_list)) { |
|
| 480 | 480 | //pdump($indexes_str, '$indexes_str'); |
| 481 | 481 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
| 482 | 482 | static::db_get_record_list($owner_location_type, |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
| 492 | 492 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
| 493 | 493 | ); |
| 494 | - while($row = db_fetch($query)) { |
|
| 494 | + while ($row = db_fetch($query)) { |
|
| 495 | 495 | // static::db_get_record_by_id($location_type, $row[$id_field]); |
| 496 | 496 | static::cache_set($location_type, $row[$id_field], $row); |
| 497 | 497 | $query_cache[$row[$id_field]] = &static::$data[$location_type][$row[$id_field]]; |
@@ -499,14 +499,14 @@ discard block |
||
| 499 | 499 | } |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | - if($no_return) { |
|
| 502 | + if ($no_return) { |
|
| 503 | 503 | return true; |
| 504 | 504 | } else { |
| 505 | 505 | $result = false; |
| 506 | - if(is_array($query_cache)) { |
|
| 507 | - foreach($query_cache as $key => $value) { |
|
| 506 | + if (is_array($query_cache)) { |
|
| 507 | + foreach ($query_cache as $key => $value) { |
|
| 508 | 508 | $result[$key] = $value; |
| 509 | - if($fetch) break; |
|
| 509 | + if ($fetch) break; |
|
| 510 | 510 | } |
| 511 | 511 | } |
| 512 | 512 | return $fetch ? (is_array($result) ? reset($result) : false) : $result; |
@@ -522,14 +522,14 @@ discard block |
||
| 522 | 522 | */ |
| 523 | 523 | public static function db_upd_record_by_id($location_type, $record_id, $set) { |
| 524 | 524 | //if(!($record_id = intval($record_id)) || !($set = trim($set))) return false; |
| 525 | - if(!($record_id = idval($record_id)) || !($set = trim($set))) return false; |
|
| 525 | + if (!($record_id = idval($record_id)) || !($set = trim($set))) return false; |
|
| 526 | 526 | |
| 527 | 527 | $location_info = &static::$location_info[$location_type]; |
| 528 | 528 | $id_field = $location_info[P_ID]; |
| 529 | 529 | $table_name = $location_info[P_TABLE_NAME]; |
| 530 | - if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 530 | + if ($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 531 | 531 | { |
| 532 | - if(static::$db->db_affected_rows()) { |
|
| 532 | + if (static::$db->db_affected_rows()) { |
|
| 533 | 533 | // Обновляем данные только если ряд был затронут |
| 534 | 534 | // TODO - переделать под работу со структурированными $set |
| 535 | 535 | |
@@ -544,16 +544,16 @@ discard block |
||
| 544 | 544 | return $result; |
| 545 | 545 | } |
| 546 | 546 | public static function db_upd_record_list($location_type, $condition, $set) { |
| 547 | - if(!($set = trim($set))) return false; |
|
| 547 | + if (!($set = trim($set))) return false; |
|
| 548 | 548 | |
| 549 | 549 | $condition = trim($condition); |
| 550 | 550 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 551 | 551 | |
| 552 | 552 | //static::db_get_record_list($location_type, $condition, false, true); |
| 553 | 553 | |
| 554 | - if($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
| 554 | + if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
| 555 | 555 | |
| 556 | - if(static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
|
| 556 | + if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
|
| 557 | 557 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
| 558 | 558 | // TODO - когда будет структурированный $condition и $set - перепаковывать данные |
| 559 | 559 | static::cache_clear($location_type, true); |
@@ -572,8 +572,8 @@ discard block |
||
| 572 | 572 | public static function db_ins_record($location_type, $set) { |
| 573 | 573 | $set = trim($set); |
| 574 | 574 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 575 | - if($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
|
| 576 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 575 | + if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
|
| 576 | + if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 577 | 577 | { |
| 578 | 578 | $record_id = db_insert_id(); |
| 579 | 579 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
@@ -595,8 +595,8 @@ discard block |
||
| 595 | 595 | $fields = implode(',', array_keys($field_set)); |
| 596 | 596 | |
| 597 | 597 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 598 | - if($result = static::db_query("INSERT INTO `{{{$table_name}}}` ($fields) VALUES ($values);")) { |
|
| 599 | - if(static::$db->db_affected_rows()) { |
|
| 598 | + if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` ($fields) VALUES ($values);")) { |
|
| 599 | + if (static::$db->db_affected_rows()) { |
|
| 600 | 600 | // Обновляем данные только если ряд был затронут |
| 601 | 601 | $record_id = db_insert_id(); |
| 602 | 602 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
@@ -613,14 +613,14 @@ discard block |
||
| 613 | 613 | public static function db_del_record_by_id($location_type, $safe_record_id) |
| 614 | 614 | { |
| 615 | 615 | // if(!($safe_record_id = intval($safe_record_id))) return false; |
| 616 | - if(!($safe_record_id = idval($safe_record_id))) return false; |
|
| 616 | + if (!($safe_record_id = idval($safe_record_id))) return false; |
|
| 617 | 617 | |
| 618 | 618 | $location_info = &static::$location_info[$location_type]; |
| 619 | 619 | $id_field = $location_info[P_ID]; |
| 620 | 620 | $table_name = $location_info[P_TABLE_NAME]; |
| 621 | - if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) |
|
| 621 | + if ($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) |
|
| 622 | 622 | { |
| 623 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 623 | + if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 624 | 624 | { |
| 625 | 625 | static::cache_unset($location_type, $safe_record_id); |
| 626 | 626 | } |
@@ -630,16 +630,16 @@ discard block |
||
| 630 | 630 | } |
| 631 | 631 | public static function db_del_record_list($location_type, $condition) |
| 632 | 632 | { |
| 633 | - if(!($condition = trim($condition))) return false; |
|
| 633 | + if (!($condition = trim($condition))) return false; |
|
| 634 | 634 | |
| 635 | 635 | $location_info = &static::$location_info[$location_type]; |
| 636 | 636 | $table_name = $location_info[P_TABLE_NAME]; |
| 637 | 637 | |
| 638 | 638 | //static::db_get_record_list($location_type, $condition, false, true); |
| 639 | 639 | |
| 640 | - if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) |
|
| 640 | + if ($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) |
|
| 641 | 641 | { |
| 642 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 642 | + if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 643 | 643 | { |
| 644 | 644 | // Обнуление кэша, потому что непонятно, что поменялось |
| 645 | 645 | // TODO - когда будет структурированный $condition можно будет делать только cache_unset по нужным записям |
@@ -686,21 +686,21 @@ discard block |
||
| 686 | 686 | public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) |
| 687 | 687 | { |
| 688 | 688 | // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ? |
| 689 | - if(!($username_unsafe = trim($username_unsafe))) return false; |
|
| 689 | + if (!($username_unsafe = trim($username_unsafe))) return false; |
|
| 690 | 690 | |
| 691 | 691 | $user = null; |
| 692 | - if(is_array(static::$data[LOC_USER])) |
|
| 693 | - foreach(static::$data[LOC_USER] as $user_id => $user_data) |
|
| 692 | + if (is_array(static::$data[LOC_USER])) |
|
| 693 | + foreach (static::$data[LOC_USER] as $user_id => $user_data) |
|
| 694 | 694 | { |
| 695 | - if(is_array($user_data) && isset($user_data['username'])) |
|
| 695 | + if (is_array($user_data) && isset($user_data['username'])) |
|
| 696 | 696 | { |
| 697 | 697 | // проверяем поле |
| 698 | 698 | // TODO Возможно есть смысл всегда искать по strtolower - но может игрок захочет переименоваться с другим регистром? Проверить! |
| 699 | - if((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe))) |
|
| 699 | + if ((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe))) |
|
| 700 | 700 | { |
| 701 | 701 | // $user_as_ally = intval($user_data['user_as_ally']); |
| 702 | 702 | $user_as_ally = idval($user_data['user_as_ally']); |
| 703 | - if($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) |
|
| 703 | + if ($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) |
|
| 704 | 704 | { |
| 705 | 705 | $user = $user_data; |
| 706 | 706 | break; |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | } |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - if($user === null) |
|
| 712 | + if ($user === null) |
|
| 713 | 713 | { |
| 714 | 714 | // Вытаскиваем запись |
| 715 | 715 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | // self::db_get_record_list(LOC_USER, "`username` " . ($like ? 'LIKE' : '='). " '{$username_safe}'"); |
| 719 | 719 | |
| 720 | 720 | $user = static::db_query( |
| 721 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '='). " '{$username_safe}'" |
|
| 721 | + "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
| 722 | 722 | , true); |
| 723 | 723 | static::cache_set(LOC_USER, $user['id'], $user); // В кэш-юзер так же заполнять индексы |
| 724 | 724 | } |
@@ -727,15 +727,15 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | // UNUSED |
| 729 | 729 | public static function db_get_user_by_email($email_unsafe, $use_both = false, $for_update = false, $fields = '*') { |
| 730 | - if(!($email_unsafe = strtolower(trim($email_unsafe)))) return false; |
|
| 730 | + if (!($email_unsafe = strtolower(trim($email_unsafe)))) return false; |
|
| 731 | 731 | |
| 732 | 732 | $user = null; |
| 733 | 733 | // TODO переделать на индексы |
| 734 | - if(is_array(static::$data[LOC_USER])) { |
|
| 735 | - foreach(static::$data[LOC_USER] as $user_id => $user_data) { |
|
| 736 | - if(is_array($user_data) && isset($user_data['email_2'])) { |
|
| 734 | + if (is_array(static::$data[LOC_USER])) { |
|
| 735 | + foreach (static::$data[LOC_USER] as $user_id => $user_data) { |
|
| 736 | + if (is_array($user_data) && isset($user_data['email_2'])) { |
|
| 737 | 737 | // проверяем поле |
| 738 | - if(strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) { |
|
| 738 | + if (strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) { |
|
| 739 | 739 | $user = $user_data; |
| 740 | 740 | break; |
| 741 | 741 | } |
@@ -743,7 +743,7 @@ discard block |
||
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | 745 | |
| 746 | - if($user === null) { |
|
| 746 | + if ($user === null) { |
|
| 747 | 747 | // Вытаскиваем запись |
| 748 | 748 | $email_safe = db_escape($email_unsafe); |
| 749 | 749 | $user = static::db_query( |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | $user = null; |
| 762 | 762 | // TODO переделать на индексы |
| 763 | 763 | |
| 764 | - if($user === null && !empty($where_safe)) { |
|
| 764 | + if ($user === null && !empty($where_safe)) { |
|
| 765 | 765 | // Вытаскиваем запись |
| 766 | 766 | $user = static::db_query("SELECT * FROM {{users}} WHERE {$where_safe}", true); |
| 767 | 767 | |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | { |
| 797 | 797 | // TODO запихивать в $data[LOC_LOCATION][$location_type][$location_id] |
| 798 | 798 | $unit = static::db_get_record_by_id(LOC_UNIT, $unit_id, $for_update, $fields); |
| 799 | - if(is_array($unit)) |
|
| 799 | + if (is_array($unit)) |
|
| 800 | 800 | { |
| 801 | 801 | static::$locator[LOC_UNIT][$unit['unit_location_type']][$unit['unit_location_id']][$unit['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
| 802 | 802 | } |
@@ -814,15 +814,15 @@ discard block |
||
| 814 | 814 | public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id) |
| 815 | 815 | { |
| 816 | 816 | //if(!($location_type = intval($location_type)) || !($location_id = intval($location_id))) return false; |
| 817 | - if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) return false; |
|
| 817 | + if (!($location_type = idval($location_type)) || !($location_id = idval($location_id))) return false; |
|
| 818 | 818 | |
| 819 | 819 | $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id]; |
| 820 | - if(!isset($query_cache)) |
|
| 820 | + if (!isset($query_cache)) |
|
| 821 | 821 | { |
| 822 | 822 | $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()); |
| 823 | - if(is_array($got_data)) |
|
| 823 | + if (is_array($got_data)) |
|
| 824 | 824 | { |
| 825 | - foreach($got_data as $unit_id => $unit_data) |
|
| 825 | + foreach ($got_data as $unit_id => $unit_data) |
|
| 826 | 826 | { |
| 827 | 827 | // static::$data[LOC_LOCATION][$location_type][$location_id][$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
| 828 | 828 | $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
@@ -831,8 +831,8 @@ discard block |
||
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | $result = false; |
| 834 | - if(is_array($query_cache)) { |
|
| 835 | - foreach($query_cache as $key => $value) { |
|
| 834 | + if (is_array($query_cache)) { |
|
| 835 | + foreach ($query_cache as $key => $value) { |
|
| 836 | 836 | $result[$key] = $value; |
| 837 | 837 | } |
| 838 | 838 | } |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false) |
| 872 | 872 | { |
| 873 | - if(!$user_id) |
|
| 873 | + if (!$user_id) |
|
| 874 | 874 | { |
| 875 | 875 | pdump(debug_backtrace()); |
| 876 | 876 | die('No user_id for que_get_que()'); |
@@ -881,14 +881,14 @@ discard block |
||
| 881 | 881 | $query = array(); |
| 882 | 882 | |
| 883 | 883 | // if($user_id = intval($user_id)) |
| 884 | - if($user_id = idval($user_id)) |
|
| 884 | + if ($user_id = idval($user_id)) |
|
| 885 | 885 | $query[] = "`que_player_id` = {$user_id}"; |
| 886 | 886 | |
| 887 | - if($que_type == QUE_RESEARCH || $planet_id === null) |
|
| 887 | + if ($que_type == QUE_RESEARCH || $planet_id === null) |
|
| 888 | 888 | $query[] = "`que_planet_id` IS NULL"; |
| 889 | - elseif($planet_id) |
|
| 889 | + elseif ($planet_id) |
|
| 890 | 890 | $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
| 891 | - if($que_type) |
|
| 891 | + if ($que_type) |
|
| 892 | 892 | $query[] = "`que_type` = {$que_type}"; |
| 893 | 893 | |
| 894 | 894 | /* |
@@ -957,14 +957,14 @@ discard block |
||
| 957 | 957 | |
| 958 | 958 | public static function db_changeset_prepare_unit($unit_id, $unit_value, $user, $planet_id = null) |
| 959 | 959 | { |
| 960 | - if(!is_array($user)) |
|
| 960 | + if (!is_array($user)) |
|
| 961 | 961 | { |
| 962 | 962 | // TODO - remove later |
| 963 | 963 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>'); |
| 964 | 964 | pdump(debug_backtrace()); |
| 965 | 965 | die('USER is not ARRAY'); |
| 966 | 966 | } |
| 967 | - if(!isset($user['id']) || !$user['id']) |
|
| 967 | + if (!isset($user['id']) || !$user['id']) |
|
| 968 | 968 | { |
| 969 | 969 | // TODO - remove later |
| 970 | 970 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>'); |
@@ -980,7 +980,7 @@ discard block |
||
| 980 | 980 | |
| 981 | 981 | $db_changeset = array(); |
| 982 | 982 | $temp = db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
| 983 | - if($temp['unit_id']) |
|
| 983 | + if ($temp['unit_id']) |
|
| 984 | 984 | { |
| 985 | 985 | $db_changeset = array( |
| 986 | 986 | 'action' => SQL_OP_UPDATE, |
@@ -1055,9 +1055,9 @@ discard block |
||
| 1055 | 1055 | } |
| 1056 | 1056 | |
| 1057 | 1057 | public function db_changeset_condition_compile(&$conditions, &$table_name = '') { |
| 1058 | - if(!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) { |
|
| 1058 | + if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) { |
|
| 1059 | 1059 | $conditions[P_LOCATION] = LOC_NONE; |
| 1060 | - switch($table_name) { |
|
| 1060 | + switch ($table_name) { |
|
| 1061 | 1061 | case 'users': |
| 1062 | 1062 | case LOC_USER: |
| 1063 | 1063 | $conditions[P_TABLE_NAME] = $table_name = 'users'; |
@@ -1079,18 +1079,18 @@ discard block |
||
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | $conditions[P_FIELDS_STR] = ''; |
| 1082 | - if($conditions['fields']) { |
|
| 1082 | + if ($conditions['fields']) { |
|
| 1083 | 1083 | $fields = array(); |
| 1084 | - foreach($conditions['fields'] as $field_name => $field_data) { |
|
| 1084 | + foreach ($conditions['fields'] as $field_name => $field_data) { |
|
| 1085 | 1085 | $condition = "`{$field_name}` = "; |
| 1086 | 1086 | $value = ''; |
| 1087 | - if($field_data['delta']) { |
|
| 1087 | + if ($field_data['delta']) { |
|
| 1088 | 1088 | $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
| 1089 | - } elseif($field_data['set']) { |
|
| 1090 | - $value = (is_string($field_data['set']) ? "'{$field_data['set']}'": $field_data['set']); |
|
| 1089 | + } elseif ($field_data['set']) { |
|
| 1090 | + $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
|
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | - if($value) { |
|
| 1093 | + if ($value) { |
|
| 1094 | 1094 | $fields[] = $condition . $value; |
| 1095 | 1095 | } |
| 1096 | 1096 | } |
@@ -1098,16 +1098,14 @@ discard block |
||
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | $conditions[P_WHERE_STR] = ''; |
| 1101 | - if(!empty($conditions['where'])) { |
|
| 1102 | - if($conditions[P_VERSION] == 1) { |
|
| 1101 | + if (!empty($conditions['where'])) { |
|
| 1102 | + if ($conditions[P_VERSION] == 1) { |
|
| 1103 | 1103 | $the_conditions = array(); |
| 1104 | - foreach($conditions['where'] as $field_id => $field_value) { |
|
| 1104 | + foreach ($conditions['where'] as $field_id => $field_value) { |
|
| 1105 | 1105 | // Простое условие - $field_id = $field_value |
| 1106 | - if(is_string($field_id)) { |
|
| 1106 | + if (is_string($field_id)) { |
|
| 1107 | 1107 | $field_value = |
| 1108 | - $field_value === null ? 'NULL' : |
|
| 1109 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
| 1110 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
| 1108 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
| 1111 | 1109 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
| 1112 | 1110 | } else { |
| 1113 | 1111 | die('Неподдерживаемый тип условия'); |
@@ -1124,7 +1122,7 @@ discard block |
||
| 1124 | 1122 | $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions); |
| 1125 | 1123 | } |
| 1126 | 1124 | |
| 1127 | - switch($conditions['action']) { |
|
| 1125 | + switch ($conditions['action']) { |
|
| 1128 | 1126 | case SQL_OP_DELETE: $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}"); break; |
| 1129 | 1127 | case SQL_OP_UPDATE: $conditions[P_ACTION_STR] = ("UPDATE {{{$table_name}}} SET"); break; |
| 1130 | 1128 | case SQL_OP_INSERT: $conditions[P_ACTION_STR] = ("INSERT INTO {{{$table_name}}} SET"); break; |
@@ -1137,9 +1135,9 @@ discard block |
||
| 1137 | 1135 | |
| 1138 | 1136 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
| 1139 | 1137 | $result = true; |
| 1140 | - if(!is_array($db_changeset) || empty($db_changeset)) return $result; |
|
| 1138 | + if (!is_array($db_changeset) || empty($db_changeset)) return $result; |
|
| 1141 | 1139 | |
| 1142 | - foreach($db_changeset as $table_name => &$table_data) { |
|
| 1140 | + foreach ($db_changeset as $table_name => &$table_data) { |
|
| 1143 | 1141 | // TODO - delayed changeset |
| 1144 | 1142 | /* |
| 1145 | 1143 | if(static::db_transaction_check(false) && !$flush_delayed && ($table_name == 'users' || $table_name == 'planets' || $table_name == 'unit')) |
@@ -1148,15 +1146,15 @@ discard block |
||
| 1148 | 1146 | continue; |
| 1149 | 1147 | } |
| 1150 | 1148 | */ |
| 1151 | - foreach($table_data as $record_id => &$conditions) { |
|
| 1149 | + foreach ($table_data as $record_id => &$conditions) { |
|
| 1152 | 1150 | static::db_changeset_condition_compile($conditions, $table_name); |
| 1153 | 1151 | |
| 1154 | - if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue; |
|
| 1155 | - if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице |
|
| 1152 | + if ($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) continue; |
|
| 1153 | + if ($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) continue; // Защита от случайного удаления всех данных в таблице |
|
| 1156 | 1154 | |
| 1157 | - if($conditions[P_LOCATION] != LOC_NONE) { |
|
| 1155 | + if ($conditions[P_LOCATION] != LOC_NONE) { |
|
| 1158 | 1156 | //die('spec ops supernova.php line 928 Добавить работу с кэшем юнитов итд'); |
| 1159 | - switch($conditions['action']) |
|
| 1157 | + switch ($conditions['action']) |
|
| 1160 | 1158 | { |
| 1161 | 1159 | case SQL_OP_DELETE: $result = self::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result; break; |
| 1162 | 1160 | case SQL_OP_UPDATE: $result = self::db_upd_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR], $conditions[P_FIELDS_STR]) && $result; break; |
@@ -1237,16 +1235,16 @@ discard block |
||
| 1237 | 1235 | } |
| 1238 | 1236 | |
| 1239 | 1237 | |
| 1240 | - public static function init_0_prepare () { |
|
| 1238 | + public static function init_0_prepare() { |
|
| 1241 | 1239 | // Отключаем magic_quotes |
| 1242 | 1240 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
| 1243 | - if(@get_magic_quotes_gpc()) { |
|
| 1241 | + if (@get_magic_quotes_gpc()) { |
|
| 1244 | 1242 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
| 1245 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
| 1243 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
| 1246 | 1244 | $value = stripslashes($value); |
| 1247 | 1245 | }); |
| 1248 | 1246 | } |
| 1249 | - if(function_exists('set_magic_quotes_runtime')) { |
|
| 1247 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 1250 | 1248 | @set_magic_quotes_runtime(0); |
| 1251 | 1249 | @ini_set('magic_quotes_runtime', 0); |
| 1252 | 1250 | @ini_set('magic_quotes_sybase', 0); |
@@ -1324,7 +1322,7 @@ discard block |
||
| 1324 | 1322 | } |
| 1325 | 1323 | |
| 1326 | 1324 | public static function init_debug_state() { |
| 1327 | - if($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) { |
|
| 1325 | + if ($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) { |
|
| 1328 | 1326 | define('BE_DEBUG', true); |
| 1329 | 1327 | } |
| 1330 | 1328 | // define('DEBUG_SQL_ONLINE', true); // Полный дамп запросов в рил-тайме. Подойдет любое значение |
@@ -1336,7 +1334,7 @@ discard block |
||
| 1336 | 1334 | defined('DEBUG_SQL_ERROR') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false; |
| 1337 | 1335 | defined('DEBUG_SQL_COMMENT_LONG') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false; |
| 1338 | 1336 | |
| 1339 | - if(defined('BE_DEBUG') || static::$config->debug) { |
|
| 1337 | + if (defined('BE_DEBUG') || static::$config->debug) { |
|
| 1340 | 1338 | @define('BE_DEBUG', true); |
| 1341 | 1339 | @ini_set('display_errors', 1); |
| 1342 | 1340 | @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | */ |
| 36 | 36 | // OK 4.9 |
| 37 | 37 | public function __construct($filename = __FILE__) { |
| 38 | - if($this->provider_id == ACCOUNT_PROVIDER_NONE) { |
|
| 38 | + if ($this->provider_id == ACCOUNT_PROVIDER_NONE) { |
|
| 39 | 39 | die('У всех провайдеров должен быть $provider_id!'); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | // OK 4.6 |
| 134 | 134 | public function player_name_suggest() { |
| 135 | 135 | $name = ''; |
| 136 | - if(is_object($this->account) && !empty($this->account->account_email)) { |
|
| 136 | + if (is_object($this->account) && !empty($this->account->account_email)) { |
|
| 137 | 137 | list($name) = explode('@', $this->account->account_email); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * Инициализация харнилища скинов |
| 153 | 153 | */ |
| 154 | 154 | protected static function init() { |
| 155 | - if(static::$is_init) { |
|
| 155 | + if (static::$is_init) { |
|
| 156 | 156 | return; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | // Загружены ли уже данные по текущему скину? |
| 167 | 167 | //pdump(static::$skin_list[$ini_path], 'static'); |
| 168 | - if(empty(static::$skin_list[$skin_path])) { |
|
| 168 | + if (empty(static::$skin_list[$skin_path])) { |
|
| 169 | 169 | // Прогружаем текущий скин |
| 170 | 170 | static::$skin_list[$skin_path] = new skin($skin_path); |
| 171 | 171 | static::$active = static::$skin_list[$skin_path]; |
@@ -201,22 +201,22 @@ discard block |
||
| 201 | 201 | |
| 202 | 202 | $this->is_ini_present = false; |
| 203 | 203 | // Проверка на корректность и существование пути |
| 204 | - if(is_file($this->root_physical_absolute . 'skin.ini')) { |
|
| 204 | + if (is_file($this->root_physical_absolute . 'skin.ini')) { |
|
| 205 | 205 | // Пытаемся распарсить файл |
| 206 | 206 | |
| 207 | 207 | // По секциям? images и config? Что бы не копировать конфигурацию? Или просто unset(__inherit) а затем заново записать |
| 208 | 208 | $this->config = parse_ini_file($this->root_physical_absolute . 'skin.ini'); |
| 209 | - if(!empty($this->config)) { |
|
| 209 | + if (!empty($this->config)) { |
|
| 210 | 210 | |
| 211 | 211 | $this->is_ini_present = true; |
| 212 | 212 | |
| 213 | - if(!empty($this->config['_inherit'])) { |
|
| 213 | + if (!empty($this->config['_inherit'])) { |
|
| 214 | 214 | // Если скин наследует себя... |
| 215 | - if($this->config['_inherit'] == $skin_path) { |
|
| 215 | + if ($this->config['_inherit'] == $skin_path) { |
|
| 216 | 216 | // TODO - определять более сложные случаи циклических ссылок в _inherit |
| 217 | 217 | die('">circular skin inheritance!'); |
| 218 | 218 | } |
| 219 | - if(empty(static::$skin_list[$this->config['_inherit']])) { |
|
| 219 | + if (empty(static::$skin_list[$this->config['_inherit']])) { |
|
| 220 | 220 | static::$skin_list[$this->config['_inherit']] = new skin($this->config['_inherit']); |
| 221 | 221 | } |
| 222 | 222 | $this->parent = static::$skin_list[$this->config['_inherit']]; |
@@ -232,12 +232,12 @@ discard block |
||
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | // Пытаемся скомпилировать _no_image заранее |
| 235 | - if(!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
| 235 | + if (!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
| 236 | 236 | $this->container[SKIN_IMAGE_MISSED_FIELD] = $this->compile_try_path(SKIN_IMAGE_MISSED_FIELD, $this->config[SKIN_IMAGE_MISSED_FIELD]); |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | // Если нет заглушки |
| 240 | - if(empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
| 240 | + if (empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
| 241 | 241 | $this->container[SKIN_IMAGE_MISSED_FIELD] = empty($this->parent) |
| 242 | 242 | // Если нет парента - берем хардкод |
| 243 | 243 | ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL . SKIN_IMAGE_MISSED_FILE_PATH |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | $image_tag = $this->image_tag_parse($image_tag, $template); |
| 268 | 268 | |
| 269 | 269 | // Проверяем наличие ключа RIT в хранилища. В нём не может быть несуществующих файлов по построению |
| 270 | - if(!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
| 270 | + if (!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
| 271 | 271 | return $this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]]; |
| 272 | 272 | } |
| 273 | 273 | |
@@ -285,7 +285,7 @@ discard block |
||
| 285 | 285 | // Нет - image ID не является путём к файлу. Пора обратиться к предкам за помощью... |
| 286 | 286 | // Пытаемся вытащить путь из родителя и применить к нему свои параметры |
| 287 | 287 | // Тащим по ID изображения, а не по ТЭГУ - мало ли что там делает с путём родитель и как преобразовывает его в строку? |
| 288 | - if(empty($this->container[$image_id]) && !empty($this->parent)) { |
|
| 288 | + if (empty($this->container[$image_id]) && !empty($this->parent)) { |
|
| 289 | 289 | $this->container[$image_id] = $this->parent->compile_image($image_id, $template); |
| 290 | 290 | |
| 291 | 291 | // Если у родителя нет картинки - он вернет пустую строку. Тогда нам надо использовать заглушку - свою или родительскую |
@@ -306,18 +306,18 @@ discard block |
||
| 306 | 306 | protected function image_tag_parse($image_tag, $template) { |
| 307 | 307 | $image_tag_ptl_resolved = $image_tag; |
| 308 | 308 | // Есть переменные из темплейта ? |
| 309 | - if(strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
| 309 | + if (strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
| 310 | 310 | // Что бы лишний раз не запускать регексп |
| 311 | 311 | // TODO - многоуровневые вложения ?! Надо ли и где их можно применить |
| 312 | 312 | preg_match_all('#(\[.+?\])#', $image_tag_ptl_resolved, $matches); |
| 313 | - foreach($matches[0] as &$match) { |
|
| 313 | + foreach ($matches[0] as &$match) { |
|
| 314 | 314 | $var_name = str_replace(array('[', ']'), '', $match); |
| 315 | - if(strpos($var_name, '.') !== false) { |
|
| 315 | + if (strpos($var_name, '.') !== false) { |
|
| 316 | 316 | // Вложенная переменная темплейта - на текущем уровне |
| 317 | 317 | // TODO Вложенная переменная из корня через "!" |
| 318 | 318 | list($block_name, $block_var) = explode('.', $var_name); |
| 319 | 319 | isset($template->_block_value[$block_name][$block_var]) ? $image_tag_ptl_resolved = str_replace($match, $template->_block_value[$block_name][$block_var], $image_tag_ptl_resolved) : false; |
| 320 | - } elseif(strpos($var_name, '$') !== false) { |
|
| 320 | + } elseif (strpos($var_name, '$') !== false) { |
|
| 321 | 321 | // Корневой DEFINE |
| 322 | 322 | $define_name = substr($var_name, 1); |
| 323 | 323 | isset($template->_tpldata['DEFINE']['.'][$define_name]) ? $image_tag_ptl_resolved = str_replace($match, $template->_tpldata['DEFINE']['.'][$define_name], $image_tag_ptl_resolved) : false; |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | - if(strpos($image_tag_ptl_resolved, '|') !== false) { |
|
| 331 | + if (strpos($image_tag_ptl_resolved, '|') !== false) { |
|
| 332 | 332 | $params = explode('|', $image_tag_ptl_resolved); |
| 333 | 333 | $image_id = $params[0]; |
| 334 | 334 | unset($params[0]); |
@@ -392,11 +392,11 @@ discard block |
||
| 392 | 392 | $image_string = $this->container[$image_tag]; |
| 393 | 393 | |
| 394 | 394 | // Нет параметров - просто возвращаем значение по $image_name из контейнера |
| 395 | - if(!empty($params) && is_array($params)) { |
|
| 395 | + if (!empty($params) && is_array($params)) { |
|
| 396 | 396 | // Здесь автоматически произойдёт упорядочивание параметров |
| 397 | 397 | |
| 398 | 398 | // Параметр 'html' - выводить изображение в виде HTML-тэга |
| 399 | - if(in_array('html', $params)) { |
|
| 399 | + if (in_array('html', $params)) { |
|
| 400 | 400 | $image_tag = $image_tag . '|html'; |
| 401 | 401 | $image_string = '<img src="' . $image_string . '" />'; |
| 402 | 402 | $this->container[$image_tag] = $image_string; |
@@ -332,8 +332,8 @@ discard block |
||
| 332 | 332 | upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;"); |
| 333 | 333 | upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;"); |
| 334 | 334 | upd_alter_table('planets', array( |
| 335 | - "DROP COLUMN `b_building`", |
|
| 336 | - "DROP COLUMN `b_building_id`" |
|
| 335 | + "DROP COLUMN `b_building`", |
|
| 336 | + "DROP COLUMN `b_building_id`" |
|
| 337 | 337 | ), $update_tables['planets']['b_building']); |
| 338 | 338 | |
| 339 | 339 | upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');"); |
@@ -587,8 +587,8 @@ discard block |
||
| 587 | 587 | upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
| 588 | 588 | |
| 589 | 589 | upd_alter_table('users', array( |
| 590 | - "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 591 | - "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 590 | + "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 591 | + "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 592 | 592 | ), !$update_foreigns['users']['FK_users_ally_id']); |
| 593 | 593 | } |
| 594 | 594 | |
@@ -1155,46 +1155,46 @@ discard block |
||
| 1155 | 1155 | upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
| 1156 | 1156 | |
| 1157 | 1157 | upd_alter_table('statpoints', array( |
| 1158 | - "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST", |
|
| 1159 | - "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1160 | - "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1161 | - "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0", |
|
| 1162 | - "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1163 | - |
|
| 1164 | - "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1165 | - "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1166 | - "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1167 | - "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1168 | - |
|
| 1169 | - "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1170 | - "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1171 | - "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1172 | - "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1173 | - |
|
| 1174 | - "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1175 | - "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1176 | - "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1177 | - "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1178 | - |
|
| 1179 | - "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1180 | - "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1181 | - "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1182 | - "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1183 | - |
|
| 1184 | - "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`", |
|
| 1185 | - "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`", |
|
| 1186 | - "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`", |
|
| 1187 | - "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`", |
|
| 1188 | - |
|
| 1189 | - "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1190 | - "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1191 | - "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1192 | - "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1193 | - |
|
| 1194 | - "ADD KEY `I_stats_id_ally` (`id_ally`)", |
|
| 1195 | - |
|
| 1196 | - "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1197 | - "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1158 | + "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST", |
|
| 1159 | + "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1160 | + "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1161 | + "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0", |
|
| 1162 | + "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1163 | + |
|
| 1164 | + "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1165 | + "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1166 | + "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1167 | + "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1168 | + |
|
| 1169 | + "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1170 | + "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1171 | + "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1172 | + "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1173 | + |
|
| 1174 | + "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1175 | + "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1176 | + "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1177 | + "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1178 | + |
|
| 1179 | + "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1180 | + "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1181 | + "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1182 | + "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1183 | + |
|
| 1184 | + "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`", |
|
| 1185 | + "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`", |
|
| 1186 | + "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`", |
|
| 1187 | + "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`", |
|
| 1188 | + |
|
| 1189 | + "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1190 | + "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1191 | + "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1192 | + "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1193 | + |
|
| 1194 | + "ADD KEY `I_stats_id_ally` (`id_ally`)", |
|
| 1195 | + |
|
| 1196 | + "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1197 | + "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1198 | 1198 | ), true); |
| 1199 | 1199 | } |
| 1200 | 1200 | |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('IN_UPDATE') || IN_UPDATE !== true) |
|
| 3 | +if (!defined('IN_UPDATE') || IN_UPDATE !== true) |
|
| 4 | 4 | { |
| 5 | 5 | die('Hack attempt'); |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | -switch($new_version) |
|
| 8 | +switch ($new_version) |
|
| 9 | 9 | { |
| 10 | 10 | case 0: |
| 11 | 11 | case 1: |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | ); |
| 35 | 35 | upd_drop_table('lunas'); |
| 36 | 36 | |
| 37 | - if($update_tables['galaxy']) |
|
| 37 | + if ($update_tables['galaxy']) |
|
| 38 | 38 | { |
| 39 | 39 | upd_do_query( |
| 40 | 40 | 'UPDATE `{{planets}}` |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | ); |
| 86 | 86 | upd_add_more_time(); |
| 87 | 87 | |
| 88 | - if($update_tables['users']['rpg_points']) |
|
| 88 | + if ($update_tables['users']['rpg_points']) |
|
| 89 | 89 | { |
| 90 | 90 | upd_do_query( |
| 91 | 91 | "UPDATE {{users}} AS u |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | |
| 147 | 147 | upd_drop_table('update'); |
| 148 | 148 | |
| 149 | - upd_check_key('fleet_speed', $config->fleet_speed/2500, $config->fleet_speed >= 2500); |
|
| 149 | + upd_check_key('fleet_speed', $config->fleet_speed / 2500, $config->fleet_speed >= 2500); |
|
| 150 | 150 | upd_check_key('game_counter', 0); |
| 151 | 151 | upd_check_key('game_default_language', 'ru'); |
| 152 | 152 | upd_check_key('game_default_skin', 'skins/EpicBlue/'); |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | upd_check_key('game_news_actual', 259200); |
| 156 | 156 | upd_check_key('game_noob_factor', 5, !isset($config->game_noob_factor)); |
| 157 | 157 | upd_check_key('game_noob_points', 5000, !isset($config->game_noob_points)); |
| 158 | - upd_check_key('game_speed', $config->game_speed/2500, $config->game_speed >= 2500); |
|
| 158 | + upd_check_key('game_speed', $config->game_speed / 2500, $config->game_speed >= 2500); |
|
| 159 | 159 | upd_check_key('int_format_date', 'd.m.Y'); |
| 160 | 160 | upd_check_key('int_format_time', 'H:i:s', true); |
| 161 | 161 | upd_check_key('int_banner_background', 'design/images/banner.png', true); |
@@ -179,22 +179,22 @@ discard block |
||
| 179 | 179 | upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
| 180 | 180 | upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
| 181 | 181 | |
| 182 | - if($update_tables['planets']['b_building']) |
|
| 182 | + if ($update_tables['planets']['b_building']) |
|
| 183 | 183 | { |
| 184 | 184 | $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
| 185 | 185 | $const_que_structures = QUE_STRUCTURES; |
| 186 | - while($planet_data = db_fetch($planet_query)) |
|
| 186 | + while ($planet_data = db_fetch($planet_query)) |
|
| 187 | 187 | { |
| 188 | 188 | $old_que = explode(';', $planet_data['b_building_id']); |
| 189 | - foreach($old_que as $old_que_item_string) |
|
| 189 | + foreach ($old_que as $old_que_item_string) |
|
| 190 | 190 | { |
| 191 | - if(!$old_que_item_string) |
|
| 191 | + if (!$old_que_item_string) |
|
| 192 | 192 | { |
| 193 | 193 | continue; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | $old_que_item = explode(',', $old_que_item_string); |
| 197 | - if($old_que_item[4] == 'build') |
|
| 197 | + if ($old_que_item[4] == 'build') |
|
| 198 | 198 | { |
| 199 | 199 | $old_que_item[4] = BUILD_CREATE; |
| 200 | 200 | } |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 231 | 231 | ); |
| 232 | 232 | |
| 233 | - if($update_tables['users']['urlaubs_until']) |
|
| 233 | + if ($update_tables['users']['urlaubs_until']) |
|
| 234 | 234 | { |
| 235 | 235 | upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
| 236 | 236 | upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
@@ -281,10 +281,10 @@ discard block |
||
| 281 | 281 | ), !$update_tables['logs']['log_timestamp']); |
| 282 | 282 | upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
| 283 | 283 | |
| 284 | - if($update_tables['errors']) |
|
| 284 | + if ($update_tables['errors']) |
|
| 285 | 285 | { |
| 286 | 286 | upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;'); |
| 287 | - if($update_tables['errors_backup']) |
|
| 287 | + if ($update_tables['errors_backup']) |
|
| 288 | 288 | { |
| 289 | 289 | upd_drop_table('errors_backup'); |
| 290 | 290 | } |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | |
| 351 | 351 | upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
| 352 | 352 | |
| 353 | - if(!$update_tables['shortcut']) |
|
| 353 | + if (!$update_tables['shortcut']) |
|
| 354 | 354 | { |
| 355 | 355 | upd_create_table('shortcut', |
| 356 | 356 | "( |
@@ -375,12 +375,12 @@ discard block |
||
| 375 | 375 | $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
| 376 | 376 | |
| 377 | 377 | $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
| 378 | - while($user_data = db_fetch($query)) |
|
| 378 | + while ($user_data = db_fetch($query)) |
|
| 379 | 379 | { |
| 380 | 380 | $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
| 381 | - foreach($shortcuts as $shortcut) |
|
| 381 | + foreach ($shortcuts as $shortcut) |
|
| 382 | 382 | { |
| 383 | - if(!$shortcut) |
|
| 383 | + if (!$shortcut) |
|
| 384 | 384 | { |
| 385 | 385 | continue; |
| 386 | 386 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | $shortcut[3] = intval($shortcut[3]); |
| 393 | 393 | $shortcut[4] = intval($shortcut[4]); |
| 394 | 394 | |
| 395 | - if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) |
|
| 395 | + if ($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) |
|
| 396 | 396 | { |
| 397 | 397 | upd_do_query("INSERT INTO {$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true); |
| 398 | 398 | } |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | |
| 547 | 547 | upd_check_key('quest_total', 0, !isset($config->quest_total)); |
| 548 | 548 | |
| 549 | - for($i = 0; $i < 25; $i++) |
|
| 549 | + for ($i = 0; $i < 25; $i++) |
|
| 550 | 550 | { |
| 551 | 551 | upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
| 552 | 552 | upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
@@ -575,7 +575,7 @@ discard block |
||
| 575 | 575 | "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
| 576 | 576 | ), !$update_tables['users']['msg_admin']); |
| 577 | 577 | |
| 578 | - if(!$update_foreigns['users']['FK_users_ally_id']) |
|
| 578 | + if (!$update_foreigns['users']['FK_users_ally_id']) |
|
| 579 | 579 | { |
| 580 | 580 | upd_alter_table('users', array( |
| 581 | 581 | 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
| 599 | 599 | |
| 600 | 600 | $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);"); |
| 601 | - while($illegal_moon_row = db_fetch($illegal_moon_query)) |
|
| 601 | + while ($illegal_moon_row = db_fetch($illegal_moon_query)) |
|
| 602 | 602 | { |
| 603 | 603 | upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
| 604 | 604 | } |
@@ -613,8 +613,8 @@ discard block |
||
| 613 | 613 | upd_log_version_update(); |
| 614 | 614 | |
| 615 | 615 | upd_check_key('game_email_pm', 0, !isset($config->game_email_pm)); |
| 616 | - upd_check_key('player_vacation_time', 2*24*60*60, !isset($config->player_vacation_time)); |
|
| 617 | - upd_check_key('player_delete_time', 45*24*60*60, !isset($config->player_delete_time)); |
|
| 616 | + upd_check_key('player_vacation_time', 2 * 24 * 60 * 60, !isset($config->player_vacation_time)); |
|
| 617 | + upd_check_key('player_delete_time', 45 * 24 * 60 * 60, !isset($config->player_delete_time)); |
|
| 618 | 618 | |
| 619 | 619 | upd_create_table('log_dark_matter', |
| 620 | 620 | "( |
@@ -636,18 +636,18 @@ discard block |
||
| 636 | 636 | upd_do_query('COMMIT;', true); |
| 637 | 637 | |
| 638 | 638 | $records = 1; |
| 639 | - while($records) |
|
| 639 | + while ($records) |
|
| 640 | 640 | { |
| 641 | 641 | upd_do_query('START TRANSACTION;', true); |
| 642 | 642 | $query = upd_do_query("SELECT * FROM {{logs}} WHERE log_code = 102 order by log_id LIMIT 1000;"); |
| 643 | 643 | $records = db_num_rows($query); |
| 644 | - while($row = db_fetch($query)) |
|
| 644 | + while ($row = db_fetch($query)) |
|
| 645 | 645 | { |
| 646 | 646 | $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
| 647 | 647 | |
| 648 | 648 | $reason = RPG_NONE; |
| 649 | 649 | $comment = $matches[3]; |
| 650 | - switch($matches[3]) |
|
| 650 | + switch ($matches[3]) |
|
| 651 | 651 | { |
| 652 | 652 | case 'Level Up For Structure Building': |
| 653 | 653 | $reason = RPG_STRUCTURE; |
@@ -664,21 +664,21 @@ discard block |
||
| 664 | 664 | break; |
| 665 | 665 | |
| 666 | 666 | default: |
| 667 | - if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) |
|
| 667 | + if (preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) |
|
| 668 | 668 | { |
| 669 | 669 | $reason = RPG_MARKET; |
| 670 | 670 | } |
| 671 | - elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) |
|
| 671 | + elseif (preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) |
|
| 672 | 672 | { |
| 673 | 673 | $reason = RPG_MERCENARY; |
| 674 | 674 | $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}"; |
| 675 | 675 | } |
| 676 | - elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) |
|
| 676 | + elseif (preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) |
|
| 677 | 677 | { |
| 678 | 678 | $reason = RPG_REFERRAL; |
| 679 | 679 | $comment = "Incoming from referral ID {$matches[1]}"; |
| 680 | 680 | } |
| 681 | - elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) |
|
| 681 | + elseif (preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) |
|
| 682 | 682 | { |
| 683 | 683 | $reason = RPG_ADMIN; |
| 684 | 684 | $comment = $matches2[1]; |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | break; |
| 687 | 687 | } |
| 688 | 688 | |
| 689 | - if($matches[2]) |
|
| 689 | + if ($matches[2]) |
|
| 690 | 690 | { |
| 691 | 691 | $row['log_username'] = db_escape($row['log_username']); |
| 692 | 692 | $row['log_page'] = db_escape($row['log_page']); |
@@ -706,14 +706,14 @@ discard block |
||
| 706 | 706 | upd_do_query('COMMIT;', true); |
| 707 | 707 | } |
| 708 | 708 | |
| 709 | - foreach($update_tables as $table_name => $cork) |
|
| 709 | + foreach ($update_tables as $table_name => $cork) |
|
| 710 | 710 | { |
| 711 | 711 | $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$config->db_prefix}{$table_name}';", true)); |
| 712 | - if($row['ENGINE'] != 'InnoDB') |
|
| 712 | + if ($row['ENGINE'] != 'InnoDB') |
|
| 713 | 713 | { |
| 714 | 714 | upd_alter_table($table_name, 'ENGINE=InnoDB', true); |
| 715 | 715 | } |
| 716 | - if($row['TABLE_COLLATION'] != 'utf8_general_ci') |
|
| 716 | + if ($row['TABLE_COLLATION'] != 'utf8_general_ci') |
|
| 717 | 717 | { |
| 718 | 718 | upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true); |
| 719 | 719 | } |
@@ -734,7 +734,7 @@ discard block |
||
| 734 | 734 | "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
| 735 | 735 | ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
| 736 | 736 | |
| 737 | - if($update_tables['users']['rpg_geologue']) |
|
| 737 | + if ($update_tables['users']['rpg_geologue']) |
|
| 738 | 738 | { |
| 739 | 739 | doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
| 740 | 740 | |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | ), $update_tables['users']['rpg_geologue']); |
| 749 | 749 | } |
| 750 | 750 | |
| 751 | - if($update_tables['users']['rpg_bunker']) |
|
| 751 | + if ($update_tables['users']['rpg_bunker']) |
|
| 752 | 752 | { |
| 753 | 753 | doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
| 754 | 754 | |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | ), !isset($update_tables['alliance']['total_rank'])); |
| 800 | 800 | doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;"); |
| 801 | 801 | |
| 802 | - if(!isset($update_tables['users']['ally_tag'])) |
|
| 802 | + if (!isset($update_tables['users']['ally_tag'])) |
|
| 803 | 803 | { |
| 804 | 804 | upd_alter_table('users', array( |
| 805 | 805 | "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
@@ -815,7 +815,7 @@ discard block |
||
| 815 | 815 | "ADD COLUMN `player_artifact_list` TEXT", |
| 816 | 816 | ), !isset($update_tables['users']['player_artifact_list'])); |
| 817 | 817 | |
| 818 | - if(!isset($update_tables['users']['player_rpg_tech_xp'])) |
|
| 818 | + if (!isset($update_tables['users']['player_rpg_tech_xp'])) |
|
| 819 | 819 | { |
| 820 | 820 | upd_check_key('eco_scale_storage', 1, !isset($config->eco_scale_storage)); |
| 821 | 821 | |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
| 847 | 847 | ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
| 848 | 848 | |
| 849 | - if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 849 | + if (strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 850 | 850 | { |
| 851 | 851 | upd_alter_table('alliance_diplomacy', array( |
| 852 | 852 | "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | ), true); |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | - if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 865 | + if (strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 866 | 866 | { |
| 867 | 867 | upd_alter_table('alliance_negotiation', array( |
| 868 | 868 | "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
@@ -879,7 +879,7 @@ discard block |
||
| 879 | 879 | ), true); |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 882 | + if (strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 883 | 883 | { |
| 884 | 884 | upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
| 885 | 885 | |
@@ -894,7 +894,7 @@ discard block |
||
| 894 | 894 | ), true); |
| 895 | 895 | } |
| 896 | 896 | |
| 897 | - if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 897 | + if (strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 898 | 898 | { |
| 899 | 899 | upd_do_query('DELETE FROM {{annonce}} WHERE user NOT IN (SELECT username FROM {{users}});', true); |
| 900 | 900 | |
@@ -908,7 +908,7 @@ discard block |
||
| 908 | 908 | ), true); |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | - if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 911 | + if (strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 912 | 912 | { |
| 913 | 913 | upd_alter_table('bashing', array( |
| 914 | 914 | "DROP FOREIGN KEY `FK_bashing_user_id`", |
@@ -924,7 +924,7 @@ discard block |
||
| 924 | 924 | ), true); |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | - if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 927 | + if (strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 928 | 928 | { |
| 929 | 929 | upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR owner NOT IN (SELECT id FROM {{users}});', true); |
| 930 | 930 | |
@@ -963,7 +963,7 @@ discard block |
||
| 963 | 963 | "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
| 964 | 964 | ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
| 965 | 965 | |
| 966 | - if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 966 | + if (strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 967 | 967 | { |
| 968 | 968 | upd_do_query('DELETE FROM {{iraks}} WHERE owner NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
| 969 | 969 | |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | ), true); |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | - if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 991 | + if (strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 992 | 992 | { |
| 993 | 993 | upd_do_query('DELETE FROM {{notes}} WHERE owner NOT IN (SELECT id FROM {{users}});', true); |
| 994 | 994 | |
@@ -1114,7 +1114,7 @@ discard block |
||
| 1114 | 1114 | "DROP COLUMN `b_hangar_plus`", |
| 1115 | 1115 | ), isset($update_tables['planets']['b_hangar_plus'])); |
| 1116 | 1116 | |
| 1117 | - if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1117 | + if (strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1118 | 1118 | { |
| 1119 | 1119 | upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
| 1120 | 1120 | |
@@ -1134,7 +1134,7 @@ discard block |
||
| 1134 | 1134 | "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
| 1135 | 1135 | ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
| 1136 | 1136 | |
| 1137 | - if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1137 | + if (strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1138 | 1138 | { |
| 1139 | 1139 | upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true); |
| 1140 | 1140 | |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | ), true); |
| 1151 | 1151 | } |
| 1152 | 1152 | |
| 1153 | - if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1153 | + if (strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1154 | 1154 | { |
| 1155 | 1155 | upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
| 1156 | 1156 | |
@@ -1305,7 +1305,7 @@ discard block |
||
| 1305 | 1305 | "DROP COLUMN `settings_allylogo`", |
| 1306 | 1306 | ), isset($update_tables['users']['settings_allylogo'])); |
| 1307 | 1307 | |
| 1308 | - if(!isset($update_tables['powerup'])) |
|
| 1308 | + if (!isset($update_tables['powerup'])) |
|
| 1309 | 1309 | { |
| 1310 | 1310 | upd_do_query("DROP TABLE IF EXISTS {$config->db_prefix}mercenaries;"); |
| 1311 | 1311 | |
@@ -1336,13 +1336,13 @@ discard block |
||
| 1336 | 1336 | |
| 1337 | 1337 | $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
| 1338 | 1338 | $user_list = upd_do_query("SELECT * FROM {{users}};"); |
| 1339 | - while($user_row = db_fetch($user_list)) |
|
| 1339 | + while ($user_row = db_fetch($user_list)) |
|
| 1340 | 1340 | { |
| 1341 | 1341 | $update_query_str = ''; |
| 1342 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) |
|
| 1342 | + foreach (sn_get_groups('mercenaries') as $mercenary_id) |
|
| 1343 | 1343 | { |
| 1344 | 1344 | $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
| 1345 | - if($mercenary_level = $user_row[$mercenary_data_name]) |
|
| 1345 | + if ($mercenary_level = $user_row[$mercenary_data_name]) |
|
| 1346 | 1346 | { |
| 1347 | 1347 | $update_query_str = ", `{$mercenary_data_name}` = 0"; |
| 1348 | 1348 | upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
@@ -1350,14 +1350,14 @@ discard block |
||
| 1350 | 1350 | } |
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | - if($update_query_str) |
|
| 1353 | + if ($update_query_str) |
|
| 1354 | 1354 | { |
| 1355 | 1355 | upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
| 1356 | 1356 | } |
| 1357 | 1357 | } |
| 1358 | 1358 | } |
| 1359 | 1359 | |
| 1360 | - if(!isset($update_tables['universe'])) |
|
| 1360 | + if (!isset($update_tables['universe'])) |
|
| 1361 | 1361 | { |
| 1362 | 1362 | upd_create_table('universe', |
| 1363 | 1363 | "( |
@@ -1381,7 +1381,7 @@ discard block |
||
| 1381 | 1381 | |
| 1382 | 1382 | // ------------------------------------------------------------------------ |
| 1383 | 1383 | // Modifying tables |
| 1384 | - if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1384 | + if (strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1385 | 1385 | { |
| 1386 | 1386 | upd_alter_table('users', array( |
| 1387 | 1387 | "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
@@ -1403,7 +1403,7 @@ discard block |
||
| 1403 | 1403 | // ------------------------------------------------------------------------ |
| 1404 | 1404 | // Creating players for allies |
| 1405 | 1405 | $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
| 1406 | - while($ally_row = db_fetch($ally_row_list)) |
|
| 1406 | + while ($ally_row = db_fetch($ally_row_list)) |
|
| 1407 | 1407 | { |
| 1408 | 1408 | $ally_user_name = db_escape("[{$ally_row['ally_tag']}]"); |
| 1409 | 1409 | doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};"); |
@@ -1418,7 +1418,7 @@ discard block |
||
| 1418 | 1418 | // ------------------------------------------------------------------------ |
| 1419 | 1419 | // Creating planets for allies |
| 1420 | 1420 | $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
| 1421 | - while($ally_user_row = db_fetch($ally_user_list)) |
|
| 1421 | + while ($ally_user_row = db_fetch($ally_user_list)) |
|
| 1422 | 1422 | { |
| 1423 | 1423 | $ally_planet_name = db_escape($ally_user_row['username']); |
| 1424 | 1424 | doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};"); |
@@ -1450,10 +1450,10 @@ discard block |
||
| 1450 | 1450 | // Adding db field |
| 1451 | 1451 | upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
| 1452 | 1452 | // Converting old data to new one and dropping old fields |
| 1453 | - if($update_tables['users']['b_tech_planet']) |
|
| 1453 | + if ($update_tables['users']['b_tech_planet']) |
|
| 1454 | 1454 | { |
| 1455 | 1455 | $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;"); |
| 1456 | - while($planet_row = db_fetch($query)) |
|
| 1456 | + while ($planet_row = db_fetch($query)) |
|
| 1457 | 1457 | { |
| 1458 | 1458 | $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
| 1459 | 1459 | doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
@@ -1467,7 +1467,7 @@ discard block |
||
| 1467 | 1467 | upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
| 1468 | 1468 | } |
| 1469 | 1469 | |
| 1470 | - if(!$update_tables['powerup']['powerup_category']) |
|
| 1470 | + if (!$update_tables['powerup']['powerup_category']) |
|
| 1471 | 1471 | { |
| 1472 | 1472 | upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
| 1473 | 1473 | |
@@ -1489,7 +1489,7 @@ discard block |
||
| 1489 | 1489 | upd_check_key('ali_bonus_brackets', 10, !isset($config->ali_bonus_brackets)); |
| 1490 | 1490 | upd_check_key('ali_bonus_brackets_divisor', 50, !isset($config->ali_bonus_brackets_divisor)); |
| 1491 | 1491 | |
| 1492 | - if(!$config->db_loadItem('rpg_flt_explore')) |
|
| 1492 | + if (!$config->db_loadItem('rpg_flt_explore')) |
|
| 1493 | 1493 | { |
| 1494 | 1494 | $inflation_rate = 1000; |
| 1495 | 1495 | |
@@ -1507,20 +1507,20 @@ discard block |
||
| 1507 | 1507 | doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
| 1508 | 1508 | |
| 1509 | 1509 | $query = doquery("SELECT * FROM {{quest}}"); |
| 1510 | - while($row = db_fetch($query)) |
|
| 1510 | + while ($row = db_fetch($query)) |
|
| 1511 | 1511 | { |
| 1512 | 1512 | $query_add = ''; |
| 1513 | 1513 | $quest_reward_list = explode(';', $row['quest_rewards']); |
| 1514 | - foreach($quest_reward_list as &$quest_reward) |
|
| 1514 | + foreach ($quest_reward_list as &$quest_reward) |
|
| 1515 | 1515 | { |
| 1516 | 1516 | list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
| 1517 | - if($reward_resource == RES_DARK_MATTER) |
|
| 1517 | + if ($reward_resource == RES_DARK_MATTER) |
|
| 1518 | 1518 | { |
| 1519 | 1519 | $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
| 1520 | 1520 | } |
| 1521 | 1521 | } |
| 1522 | 1522 | $new_rewards = implode(';', $quest_reward_list); |
| 1523 | - if($new_rewards != $row['quest_rewards']) |
|
| 1523 | + if ($new_rewards != $row['quest_rewards']) |
|
| 1524 | 1524 | { |
| 1525 | 1525 | doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
| 1526 | 1526 | } |
@@ -1551,7 +1551,7 @@ discard block |
||
| 1551 | 1551 | upd_check_key('user_birthday_range', 30, !isset($config->user_birthday_range)); |
| 1552 | 1552 | upd_check_key('user_birthday_celebrate', 0, !isset($config->user_birthday_celebrate)); |
| 1553 | 1553 | |
| 1554 | - if(!isset($update_tables['payment'])) |
|
| 1554 | + if (!isset($update_tables['payment'])) |
|
| 1555 | 1555 | { |
| 1556 | 1556 | upd_alter_table('users', array( |
| 1557 | 1557 | "ADD KEY `I_user_id_name` (`id`, `username`)", |
@@ -1603,7 +1603,7 @@ discard block |
||
| 1603 | 1603 | ), !$update_tables['iraks']['fleet_start_type']); |
| 1604 | 1604 | |
| 1605 | 1605 | |
| 1606 | - if(!$update_tables['payment']['payment_status']) |
|
| 1606 | + if (!$update_tables['payment']['payment_status']) |
|
| 1607 | 1607 | { |
| 1608 | 1608 | upd_alter_table('payment', array( |
| 1609 | 1609 | "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
@@ -1688,7 +1688,7 @@ discard block |
||
| 1688 | 1688 | "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
| 1689 | 1689 | ), !$update_indexes['notes']['I_owner_priority_time']); |
| 1690 | 1690 | |
| 1691 | - if(!$update_tables['buddy']['BUDDY_ID']) |
|
| 1691 | + if (!$update_tables['buddy']['BUDDY_ID']) |
|
| 1692 | 1692 | { |
| 1693 | 1693 | upd_alter_table('buddy', array( |
| 1694 | 1694 | "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'", |
@@ -1710,10 +1710,10 @@ discard block |
||
| 1710 | 1710 | |
| 1711 | 1711 | $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
| 1712 | 1712 | $found = $lost = array(); |
| 1713 | - while($row = db_fetch($query)) |
|
| 1713 | + while ($row = db_fetch($query)) |
|
| 1714 | 1714 | { |
| 1715 | 1715 | $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
| 1716 | - if(!isset($found[$index])) |
|
| 1716 | + if (!isset($found[$index])) |
|
| 1717 | 1717 | { |
| 1718 | 1718 | $found[$index] = $row['BUDDY_ID']; |
| 1719 | 1719 | } |
@@ -1723,7 +1723,7 @@ discard block |
||
| 1723 | 1723 | } |
| 1724 | 1724 | } |
| 1725 | 1725 | $lost = implode(',', $lost); |
| 1726 | - if($lost) |
|
| 1726 | + if ($lost) |
|
| 1727 | 1727 | { |
| 1728 | 1728 | upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
| 1729 | 1729 | } |
@@ -1745,7 +1745,7 @@ discard block |
||
| 1745 | 1745 | |
| 1746 | 1746 | upd_do_query("UPDATE {{users}} SET `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL"); |
| 1747 | 1747 | |
| 1748 | - if(!$update_tables['ube_report']) |
|
| 1748 | + if (!$update_tables['ube_report']) |
|
| 1749 | 1749 | { |
| 1750 | 1750 | upd_create_table('ube_report', |
| 1751 | 1751 | "( |
@@ -1787,7 +1787,7 @@ discard block |
||
| 1787 | 1787 | ); |
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | - if(!$update_tables['ube_report_player']) |
|
| 1790 | + if (!$update_tables['ube_report_player']) |
|
| 1791 | 1791 | { |
| 1792 | 1792 | upd_create_table('ube_report_player', |
| 1793 | 1793 | "( |
@@ -1809,7 +1809,7 @@ discard block |
||
| 1809 | 1809 | ); |
| 1810 | 1810 | } |
| 1811 | 1811 | |
| 1812 | - if(!$update_tables['ube_report_fleet']) |
|
| 1812 | + if (!$update_tables['ube_report_fleet']) |
|
| 1813 | 1813 | { |
| 1814 | 1814 | upd_create_table('ube_report_fleet', |
| 1815 | 1815 | "( |
@@ -1840,7 +1840,7 @@ discard block |
||
| 1840 | 1840 | ); |
| 1841 | 1841 | } |
| 1842 | 1842 | |
| 1843 | - if(!$update_tables['ube_report_unit']) |
|
| 1843 | + if (!$update_tables['ube_report_unit']) |
|
| 1844 | 1844 | { |
| 1845 | 1845 | // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
| 1846 | 1846 | // Может сохранять имена удаленных кораблей долго? |
@@ -1878,7 +1878,7 @@ discard block |
||
| 1878 | 1878 | ); |
| 1879 | 1879 | } |
| 1880 | 1880 | |
| 1881 | - if(!$update_tables['ube_report_outcome_fleet']) |
|
| 1881 | + if (!$update_tables['ube_report_outcome_fleet']) |
|
| 1882 | 1882 | { |
| 1883 | 1883 | upd_create_table('ube_report_outcome_fleet', |
| 1884 | 1884 | "( |
@@ -1908,7 +1908,7 @@ discard block |
||
| 1908 | 1908 | ); |
| 1909 | 1909 | } |
| 1910 | 1910 | |
| 1911 | - if(!$update_tables['ube_report_outcome_unit']) |
|
| 1911 | + if (!$update_tables['ube_report_outcome_unit']) |
|
| 1912 | 1912 | { |
| 1913 | 1913 | upd_create_table('ube_report_outcome_unit', |
| 1914 | 1914 | "( |
@@ -1930,7 +1930,7 @@ discard block |
||
| 1930 | 1930 | ); |
| 1931 | 1931 | } |
| 1932 | 1932 | |
| 1933 | - if(!$update_tables['unit']) |
|
| 1933 | + if (!$update_tables['unit']) |
|
| 1934 | 1934 | { |
| 1935 | 1935 | upd_create_table('unit', |
| 1936 | 1936 | "( |
@@ -1950,7 +1950,7 @@ discard block |
||
| 1950 | 1950 | ); |
| 1951 | 1951 | } |
| 1952 | 1952 | |
| 1953 | - if(!$update_tables['captain']) |
|
| 1953 | + if (!$update_tables['captain']) |
|
| 1954 | 1954 | { |
| 1955 | 1955 | upd_create_table('captain', |
| 1956 | 1956 | "( |
@@ -1971,7 +1971,7 @@ discard block |
||
| 1971 | 1971 | ); |
| 1972 | 1972 | } |
| 1973 | 1973 | |
| 1974 | - if(!$update_tables['fleets']['fleet_start_planet_id']) |
|
| 1974 | + if (!$update_tables['fleets']['fleet_start_planet_id']) |
|
| 1975 | 1975 | { |
| 1976 | 1976 | upd_alter_table('fleets', array( |
| 1977 | 1977 | "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
@@ -1994,7 +1994,7 @@ discard block |
||
| 1994 | 1994 | |
| 1995 | 1995 | upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
| 1996 | 1996 | |
| 1997 | - if(!$update_tables['chat_player']) |
|
| 1997 | + if (!$update_tables['chat_player']) |
|
| 1998 | 1998 | { |
| 1999 | 1999 | upd_create_table('chat_player', |
| 2000 | 2000 | "( |
@@ -2057,7 +2057,7 @@ discard block |
||
| 2057 | 2057 | "DROP FOREIGN KEY `FK_payment_user`", |
| 2058 | 2058 | ), $update_foreigns['payment']['FK_payment_user']); |
| 2059 | 2059 | |
| 2060 | - if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') |
|
| 2060 | + if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') |
|
| 2061 | 2061 | { |
| 2062 | 2062 | upd_alter_table('chat', array( |
| 2063 | 2063 | "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
@@ -2091,7 +2091,7 @@ discard block |
||
| 2091 | 2091 | "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
| 2092 | 2092 | ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
| 2093 | 2093 | |
| 2094 | - if(!$update_tables['unit']['unit_time_start']) |
|
| 2094 | + if (!$update_tables['unit']['unit_time_start']) |
|
| 2095 | 2095 | { |
| 2096 | 2096 | upd_alter_table('unit', array( |
| 2097 | 2097 | "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
@@ -2108,7 +2108,7 @@ discard block |
||
| 2108 | 2108 | ); |
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | - if(!$update_tables['que']) |
|
| 2111 | + if (!$update_tables['que']) |
|
| 2112 | 2112 | { |
| 2113 | 2113 | upd_create_table('que', |
| 2114 | 2114 | "( |
@@ -2141,15 +2141,15 @@ discard block |
||
| 2141 | 2141 | } |
| 2142 | 2142 | |
| 2143 | 2143 | // Конвертирум очередь исследований |
| 2144 | - if($update_tables['users']['que']) |
|
| 2144 | + if ($update_tables['users']['que']) |
|
| 2145 | 2145 | { |
| 2146 | 2146 | $que_lines = array(); |
| 2147 | 2147 | $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
| 2148 | - while($que_row = db_fetch($que_query)) |
|
| 2148 | + while ($que_row = db_fetch($que_query)) |
|
| 2149 | 2149 | { |
| 2150 | 2150 | $que_data = explode(',', $que_row['que']); |
| 2151 | 2151 | |
| 2152 | - if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) |
|
| 2152 | + if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) |
|
| 2153 | 2153 | { |
| 2154 | 2154 | continue; |
| 2155 | 2155 | } |
@@ -2157,14 +2157,14 @@ discard block |
||
| 2157 | 2157 | $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
| 2158 | 2158 | // Если планета пустая - ставим главку |
| 2159 | 2159 | $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
| 2160 | - if($que_data[QI_PLANET_ID]) |
|
| 2160 | + if ($que_data[QI_PLANET_ID]) |
|
| 2161 | 2161 | { |
| 2162 | 2162 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
| 2163 | - if(!$que_planet_check['id']) |
|
| 2163 | + if (!$que_planet_check['id']) |
|
| 2164 | 2164 | { |
| 2165 | 2165 | $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
| 2166 | 2166 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
| 2167 | - if(!$que_planet_check['id']) |
|
| 2167 | + if (!$que_planet_check['id']) |
|
| 2168 | 2168 | { |
| 2169 | 2169 | $que_data[QI_PLANET_ID] = 'NULL'; |
| 2170 | 2170 | } |
@@ -2181,9 +2181,9 @@ discard block |
||
| 2181 | 2181 | $price_increase = pow($unit_factor, $unit_level); |
| 2182 | 2182 | $unit_level++; |
| 2183 | 2183 | $unit_cost = array(); |
| 2184 | - foreach($unit_info[P_COST] as $resource_id => $resource_amount) |
|
| 2184 | + foreach ($unit_info[P_COST] as $resource_id => $resource_amount) |
|
| 2185 | 2185 | { |
| 2186 | - if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) |
|
| 2186 | + if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) |
|
| 2187 | 2187 | { |
| 2188 | 2188 | continue; |
| 2189 | 2189 | } |
@@ -2195,7 +2195,7 @@ discard block |
||
| 2195 | 2195 | BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
| 2196 | 2196 | } |
| 2197 | 2197 | |
| 2198 | - if(!empty($que_lines)) |
|
| 2198 | + if (!empty($que_lines)) |
|
| 2199 | 2199 | { |
| 2200 | 2200 | upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines)); |
| 2201 | 2201 | } |
@@ -2210,7 +2210,7 @@ discard block |
||
| 2210 | 2210 | |
| 2211 | 2211 | |
| 2212 | 2212 | // Ковертируем технологии в таблицы |
| 2213 | - if($update_tables['users']['graviton_tech']) |
|
| 2213 | + if ($update_tables['users']['graviton_tech']) |
|
| 2214 | 2214 | { |
| 2215 | 2215 | upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
| 2216 | 2216 | |
@@ -2218,18 +2218,18 @@ discard block |
||
| 2218 | 2218 | $user_query = upd_do_query("SELECT * FROM {{users}}"); |
| 2219 | 2219 | upd_add_more_time(300); |
| 2220 | 2220 | $sn_group_tech = sn_get_groups('tech'); |
| 2221 | - while($user_row = db_fetch($user_query)) |
|
| 2221 | + while ($user_row = db_fetch($user_query)) |
|
| 2222 | 2222 | { |
| 2223 | - foreach($sn_group_tech as $tech_id) |
|
| 2223 | + foreach ($sn_group_tech as $tech_id) |
|
| 2224 | 2224 | { |
| 2225 | - if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) |
|
| 2225 | + if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) |
|
| 2226 | 2226 | { |
| 2227 | 2227 | $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
| 2228 | 2228 | } |
| 2229 | 2229 | } |
| 2230 | 2230 | } |
| 2231 | 2231 | |
| 2232 | - if(!empty($que_lines)) |
|
| 2232 | + if (!empty($que_lines)) |
|
| 2233 | 2233 | { |
| 2234 | 2234 | upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines)); |
| 2235 | 2235 | } |
@@ -2239,30 +2239,30 @@ discard block |
||
| 2239 | 2239 | ), $update_tables['users']['graviton_tech']); |
| 2240 | 2240 | } |
| 2241 | 2241 | |
| 2242 | - if(!$update_indexes['unit']['I_unit_record_search']) |
|
| 2242 | + if (!$update_indexes['unit']['I_unit_record_search']) |
|
| 2243 | 2243 | { |
| 2244 | 2244 | upd_alter_table('unit', array( |
| 2245 | 2245 | "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
| 2246 | 2246 | ), !$update_indexes['unit']['I_unit_record_search']); |
| 2247 | 2247 | |
| 2248 | - foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) |
|
| 2248 | + foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) |
|
| 2249 | 2249 | { |
| 2250 | 2250 | $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
| 2251 | 2251 | } |
| 2252 | 2252 | $drop_index = array(); |
| 2253 | 2253 | $create_index = &$drop_index; // array(); |
| 2254 | - foreach($planet_units as $unit_name => $unit_create) |
|
| 2254 | + foreach ($planet_units as $unit_name => $unit_create) |
|
| 2255 | 2255 | { |
| 2256 | - if($update_indexes['planets']['I_' . $unit_name]) |
|
| 2256 | + if ($update_indexes['planets']['I_' . $unit_name]) |
|
| 2257 | 2257 | { |
| 2258 | 2258 | $drop_index[] = "DROP KEY I_{$unit_name}"; |
| 2259 | 2259 | } |
| 2260 | - if($update_indexes['planets']['i_' . $unit_name]) |
|
| 2260 | + if ($update_indexes['planets']['i_' . $unit_name]) |
|
| 2261 | 2261 | { |
| 2262 | 2262 | $drop_index[] = "DROP KEY i_{$unit_name}"; |
| 2263 | 2263 | } |
| 2264 | 2264 | |
| 2265 | - if($unit_create) |
|
| 2265 | + if ($unit_create) |
|
| 2266 | 2266 | { |
| 2267 | 2267 | $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
| 2268 | 2268 | } |
@@ -2274,7 +2274,7 @@ discard block |
||
| 2274 | 2274 | "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
| 2275 | 2275 | ), !$update_tables['users']['user_time_utc_offset']); |
| 2276 | 2276 | |
| 2277 | - if(!$update_foreigns['alliance']['FK_alliance_owner']) |
|
| 2277 | + if (!$update_foreigns['alliance']['FK_alliance_owner']) |
|
| 2278 | 2278 | { |
| 2279 | 2279 | upd_do_query("UPDATE {{alliance}} SET ally_owner = null WHERE ally_owner not in (select id from {{users}})"); |
| 2280 | 2280 | |
@@ -2295,7 +2295,7 @@ discard block |
||
| 2295 | 2295 | |
| 2296 | 2296 | upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !$config->chat_highlight_developer); |
| 2297 | 2297 | |
| 2298 | - if(!$update_tables['player_name_history']) |
|
| 2298 | + if (!$update_tables['player_name_history']) |
|
| 2299 | 2299 | { |
| 2300 | 2300 | upd_check_key('game_user_changename_cost', 100000, !$config->game_user_changename_cost); |
| 2301 | 2301 | upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
@@ -2325,7 +2325,7 @@ discard block |
||
| 2325 | 2325 | "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
| 2326 | 2326 | ), !$update_tables['planets']['density_index']); |
| 2327 | 2327 | |
| 2328 | - if($update_tables['users']['player_artifact_list']) |
|
| 2328 | + if ($update_tables['users']['player_artifact_list']) |
|
| 2329 | 2329 | { |
| 2330 | 2330 | upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
| 2331 | 2331 | |
@@ -2336,17 +2336,17 @@ discard block |
||
| 2336 | 2336 | $db_changeset = array(); |
| 2337 | 2337 | |
| 2338 | 2338 | $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
| 2339 | - while($row = db_fetch($query)) |
|
| 2339 | + while ($row = db_fetch($query)) |
|
| 2340 | 2340 | { |
| 2341 | 2341 | $artifact_list = explode(';', $row['player_artifact_list']); |
| 2342 | - if(!$row['player_artifact_list'] || empty($artifact_list)) |
|
| 2342 | + if (!$row['player_artifact_list'] || empty($artifact_list)) |
|
| 2343 | 2343 | { |
| 2344 | 2344 | continue; |
| 2345 | 2345 | } |
| 2346 | - foreach($artifact_list as $key => &$value) |
|
| 2346 | + foreach ($artifact_list as $key => &$value) |
|
| 2347 | 2347 | { |
| 2348 | 2348 | $value = explode(',', $value); |
| 2349 | - if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) |
|
| 2349 | + if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) |
|
| 2350 | 2350 | { |
| 2351 | 2351 | unset($artifact_list[$key]); |
| 2352 | 2352 | continue; |
@@ -2378,14 +2378,14 @@ discard block |
||
| 2378 | 2378 | "DROP COLUMN `colonisation_tech`", |
| 2379 | 2379 | ), $update_tables['users']['spy_tech']); |
| 2380 | 2380 | |
| 2381 | - upd_check_key('payment_currency_exchange_dm_', 2500, !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000); |
|
| 2381 | + upd_check_key('payment_currency_exchange_dm_', 2500, !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000); |
|
| 2382 | 2382 | upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !$config->payment_currency_exchange_eur); |
| 2383 | - upd_check_key('payment_currency_exchange_rub', 4.0, !$config->payment_currency_exchange_rub); |
|
| 2384 | - upd_check_key('payment_currency_exchange_usd', 0.125, !$config->payment_currency_exchange_usd); |
|
| 2385 | - upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !$config->payment_currency_exchange_usd); |
|
| 2386 | - upd_check_key('payment_currency_exchange_wmr', 4.1, !$config->payment_currency_exchange_wmr); |
|
| 2387 | - upd_check_key('payment_currency_exchange_wmu', 1.05, !$config->payment_currency_exchange_wmu); |
|
| 2388 | - upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !$config->payment_currency_exchange_wmz); |
|
| 2383 | + upd_check_key('payment_currency_exchange_rub', 4.0, !$config->payment_currency_exchange_rub); |
|
| 2384 | + upd_check_key('payment_currency_exchange_usd', 0.125, !$config->payment_currency_exchange_usd); |
|
| 2385 | + upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !$config->payment_currency_exchange_usd); |
|
| 2386 | + upd_check_key('payment_currency_exchange_wmr', 4.1, !$config->payment_currency_exchange_wmr); |
|
| 2387 | + upd_check_key('payment_currency_exchange_wmu', 1.05, !$config->payment_currency_exchange_wmu); |
|
| 2388 | + upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !$config->payment_currency_exchange_wmz); |
|
| 2389 | 2389 | |
| 2390 | 2390 | upd_do_query('COMMIT;', true); |
| 2391 | 2391 | $new_version = 37; |
@@ -197,8 +197,7 @@ discard block |
||
| 197 | 197 | if($old_que_item[4] == 'build') |
| 198 | 198 | { |
| 199 | 199 | $old_que_item[4] = BUILD_CREATE; |
| 200 | - } |
|
| 201 | - else |
|
| 200 | + } else |
|
| 202 | 201 | { |
| 203 | 202 | $old_que_item[4] = BUILD_DESTROY; |
| 204 | 203 | } |
@@ -667,18 +666,15 @@ discard block |
||
| 667 | 666 | if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) |
| 668 | 667 | { |
| 669 | 668 | $reason = RPG_MARKET; |
| 670 | - } |
|
| 671 | - elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) |
|
| 669 | + } elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) |
|
| 672 | 670 | { |
| 673 | 671 | $reason = RPG_MERCENARY; |
| 674 | 672 | $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}"; |
| 675 | - } |
|
| 676 | - elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) |
|
| 673 | + } elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) |
|
| 677 | 674 | { |
| 678 | 675 | $reason = RPG_REFERRAL; |
| 679 | 676 | $comment = "Incoming from referral ID {$matches[1]}"; |
| 680 | - } |
|
| 681 | - elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) |
|
| 677 | + } elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) |
|
| 682 | 678 | { |
| 683 | 679 | $reason = RPG_ADMIN; |
| 684 | 680 | $comment = $matches2[1]; |
@@ -1716,8 +1712,7 @@ discard block |
||
| 1716 | 1712 | if(!isset($found[$index])) |
| 1717 | 1713 | { |
| 1718 | 1714 | $found[$index] = $row['BUDDY_ID']; |
| 1719 | - } |
|
| 1720 | - else |
|
| 1715 | + } else |
|
| 1721 | 1716 | { |
| 1722 | 1717 | $lost[] = $row['BUDDY_ID']; |
| 1723 | 1718 | } |
@@ -2169,8 +2164,7 @@ discard block |
||
| 2169 | 2164 | $que_data[QI_PLANET_ID] = 'NULL'; |
| 2170 | 2165 | } |
| 2171 | 2166 | } |
| 2172 | - } |
|
| 2173 | - else |
|
| 2167 | + } else |
|
| 2174 | 2168 | { |
| 2175 | 2169 | $que_data[QI_PLANET_ID] = 'NULL'; |
| 2176 | 2170 | } |
@@ -7,48 +7,48 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | switch($new_version) |
| 9 | 9 | { |
| 10 | - case 0: |
|
| 11 | - case 1: |
|
| 12 | - case 2: |
|
| 13 | - case 3: |
|
| 14 | - case 4: |
|
| 15 | - case 5: |
|
| 16 | - case 6: |
|
| 17 | - case 7: |
|
| 18 | - case 8: |
|
| 19 | - case 9: |
|
| 20 | - upd_log_version_update(); |
|
| 21 | - |
|
| 22 | - upd_alter_table('planets', "ADD `debris_metal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_metal']); |
|
| 23 | - upd_alter_table('planets', "ADD `debris_crystal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_crystal']); |
|
| 24 | - |
|
| 25 | - upd_alter_table('planets', array( |
|
| 26 | - "ADD `parent_planet` bigint(11) unsigned DEFAULT '0'", |
|
| 27 | - "ADD KEY `i_parent_planet` (`parent_planet`)" |
|
| 28 | - ), !$update_tables['planets']['parent_planet']); |
|
| 29 | - upd_do_query( |
|
| 30 | - "UPDATE `{{planets}}` AS lu |
|
| 10 | + case 0: |
|
| 11 | + case 1: |
|
| 12 | + case 2: |
|
| 13 | + case 3: |
|
| 14 | + case 4: |
|
| 15 | + case 5: |
|
| 16 | + case 6: |
|
| 17 | + case 7: |
|
| 18 | + case 8: |
|
| 19 | + case 9: |
|
| 20 | + upd_log_version_update(); |
|
| 21 | + |
|
| 22 | + upd_alter_table('planets', "ADD `debris_metal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_metal']); |
|
| 23 | + upd_alter_table('planets', "ADD `debris_crystal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_crystal']); |
|
| 24 | + |
|
| 25 | + upd_alter_table('planets', array( |
|
| 26 | + "ADD `parent_planet` bigint(11) unsigned DEFAULT '0'", |
|
| 27 | + "ADD KEY `i_parent_planet` (`parent_planet`)" |
|
| 28 | + ), !$update_tables['planets']['parent_planet']); |
|
| 29 | + upd_do_query( |
|
| 30 | + "UPDATE `{{planets}}` AS lu |
|
| 31 | 31 | LEFT JOIN `{{planets}}` AS pl |
| 32 | 32 | ON pl.galaxy=lu.galaxy AND pl.system=lu.system AND pl.planet=lu.planet AND pl.planet_type=1 |
| 33 | 33 | SET lu.parent_planet=pl.id WHERE lu.planet_type=3;" |
| 34 | - ); |
|
| 35 | - upd_drop_table('lunas'); |
|
| 34 | + ); |
|
| 35 | + upd_drop_table('lunas'); |
|
| 36 | 36 | |
| 37 | - if($update_tables['galaxy']) |
|
| 38 | - { |
|
| 39 | - upd_do_query( |
|
| 40 | - 'UPDATE `{{planets}}` |
|
| 37 | + if($update_tables['galaxy']) |
|
| 38 | + { |
|
| 39 | + upd_do_query( |
|
| 40 | + 'UPDATE `{{planets}}` |
|
| 41 | 41 | LEFT JOIN `{{galaxy}}` ON {{galaxy}}.id_planet = {{planets}}.id |
| 42 | 42 | SET |
| 43 | 43 | {{planets}}.debris_metal = {{galaxy}}.metal, |
| 44 | 44 | {{planets}}.debris_crystal = {{galaxy}}.crystal |
| 45 | 45 | WHERE {{galaxy}}.metal>0 OR {{galaxy}}.crystal>0;' |
| 46 | - ); |
|
| 47 | - } |
|
| 48 | - upd_drop_table('galaxy'); |
|
| 46 | + ); |
|
| 47 | + } |
|
| 48 | + upd_drop_table('galaxy'); |
|
| 49 | 49 | |
| 50 | - upd_create_table('counter', |
|
| 51 | - "( |
|
| 50 | + upd_create_table('counter', |
|
| 51 | + "( |
|
| 52 | 52 | `id` bigint(11) NOT NULL AUTO_INCREMENT, |
| 53 | 53 | `time` int(11) NOT NULL DEFAULT '0', |
| 54 | 54 | `page` varchar(255) CHARACTER SET utf8 DEFAULT '0', |
@@ -58,63 +58,63 @@ discard block |
||
| 58 | 58 | KEY `i_user_id` (`user_id`), |
| 59 | 59 | KEY `i_ip` (`ip`) |
| 60 | 60 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 61 | - ); |
|
| 62 | - upd_alter_table('counter', "ADD `url` varchar(255) CHARACTER SET utf8 DEFAULT ''", !$update_tables['counter']['url']); |
|
| 61 | + ); |
|
| 62 | + upd_alter_table('counter', "ADD `url` varchar(255) CHARACTER SET utf8 DEFAULT ''", !$update_tables['counter']['url']); |
|
| 63 | 63 | |
| 64 | - upd_alter_table('fleets', array( |
|
| 65 | - "ADD KEY `fleet_mess` (`fleet_mess`)", |
|
| 66 | - "ADD KEY `fleet_group` (`fleet_group`)" |
|
| 67 | - ), !$update_indexes['fleets']['fleet_mess']); |
|
| 64 | + upd_alter_table('fleets', array( |
|
| 65 | + "ADD KEY `fleet_mess` (`fleet_mess`)", |
|
| 66 | + "ADD KEY `fleet_group` (`fleet_group`)" |
|
| 67 | + ), !$update_indexes['fleets']['fleet_mess']); |
|
| 68 | 68 | |
| 69 | - upd_alter_table('referrals', "ADD `dark_matter` bigint(11) NOT NULL DEFAULT '0' COMMENT 'How much player have aquired Dark Matter'", !$update_tables['referrals']['dark_matter']); |
|
| 70 | - upd_alter_table('referrals', "ADD KEY `id_partner` (`id_partner`)", !$update_indexes['referrals']['id_partner']); |
|
| 69 | + upd_alter_table('referrals', "ADD `dark_matter` bigint(11) NOT NULL DEFAULT '0' COMMENT 'How much player have aquired Dark Matter'", !$update_tables['referrals']['dark_matter']); |
|
| 70 | + upd_alter_table('referrals', "ADD KEY `id_partner` (`id_partner`)", !$update_indexes['referrals']['id_partner']); |
|
| 71 | 71 | |
| 72 | - upd_check_key('rpg_bonus_divisor', 10); |
|
| 72 | + upd_check_key('rpg_bonus_divisor', 10); |
|
| 73 | 73 | |
| 74 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('BannerURL', 'banner_source_post', 'BannerOverviewFrame', |
|
| 74 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('BannerURL', 'banner_source_post', 'BannerOverviewFrame', |
|
| 75 | 75 | 'close_reason', 'dbVersion', 'ForumUserBarFrame', 'OverviewBanner', 'OverviewClickBanner', 'OverviewExternChat', |
| 76 | 76 | 'OverviewExternChatCmd', 'OverviewNewsText', 'UserbarURL', 'userbar_source');"); |
| 77 | 77 | |
| 78 | - $dm_change_legit = true; |
|
| 78 | + $dm_change_legit = true; |
|
| 79 | 79 | |
| 80 | - upd_do_query( |
|
| 81 | - "UPDATE {{referrals}} AS r |
|
| 80 | + upd_do_query( |
|
| 81 | + "UPDATE {{referrals}} AS r |
|
| 82 | 82 | LEFT JOIN {{users}} AS u |
| 83 | 83 | ON u.id = r.id |
| 84 | 84 | SET r.dark_matter = u.lvl_minier + u.lvl_raid;" |
| 85 | - ); |
|
| 86 | - upd_add_more_time(); |
|
| 85 | + ); |
|
| 86 | + upd_add_more_time(); |
|
| 87 | 87 | |
| 88 | - if($update_tables['users']['rpg_points']) |
|
| 89 | - { |
|
| 90 | - upd_do_query( |
|
| 91 | - "UPDATE {{users}} AS u |
|
| 88 | + if($update_tables['users']['rpg_points']) |
|
| 89 | + { |
|
| 90 | + upd_do_query( |
|
| 91 | + "UPDATE {{users}} AS u |
|
| 92 | 92 | RIGHT JOIN {{referrals}} AS r |
| 93 | 93 | ON r.id_partner = u.id AND r.dark_matter >= {$config->rpg_bonus_divisor} |
| 94 | 94 | SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/{$config->rpg_bonus_divisor});" |
| 95 | - ); |
|
| 96 | - } |
|
| 95 | + ); |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - $dm_change_legit = false; |
|
| 99 | - upd_do_query('COMMIT;', true); |
|
| 100 | - $new_version = 10; |
|
| 101 | - |
|
| 102 | - case 10: |
|
| 103 | - case 11: |
|
| 104 | - case 12: |
|
| 105 | - case 13: |
|
| 106 | - case 14: |
|
| 107 | - case 15: |
|
| 108 | - case 16: |
|
| 109 | - case 17: |
|
| 110 | - case 18: |
|
| 111 | - case 19: |
|
| 112 | - case 20: |
|
| 113 | - case 21: |
|
| 114 | - upd_log_version_update(); |
|
| 115 | - |
|
| 116 | - upd_create_table('alliance_requests', |
|
| 117 | - "( |
|
| 98 | + $dm_change_legit = false; |
|
| 99 | + upd_do_query('COMMIT;', true); |
|
| 100 | + $new_version = 10; |
|
| 101 | + |
|
| 102 | + case 10: |
|
| 103 | + case 11: |
|
| 104 | + case 12: |
|
| 105 | + case 13: |
|
| 106 | + case 14: |
|
| 107 | + case 15: |
|
| 108 | + case 16: |
|
| 109 | + case 17: |
|
| 110 | + case 18: |
|
| 111 | + case 19: |
|
| 112 | + case 20: |
|
| 113 | + case 21: |
|
| 114 | + upd_log_version_update(); |
|
| 115 | + |
|
| 116 | + upd_create_table('alliance_requests', |
|
| 117 | + "( |
|
| 118 | 118 | `id_user` int(11) NOT NULL, |
| 119 | 119 | `id_ally` int(11) NOT NULL DEFAULT '0', |
| 120 | 120 | `request_text` text, |
@@ -122,103 +122,103 @@ discard block |
||
| 122 | 122 | `request_denied` tinyint(1) unsigned NOT NULL DEFAULT '0', |
| 123 | 123 | PRIMARY KEY (`id_user`,`id_ally`) |
| 124 | 124 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;" |
| 125 | - ); |
|
| 126 | - |
|
| 127 | - upd_alter_table('announce', "ADD `detail_url` varchar(250) NOT NULL DEFAULT '' COMMENT 'Link to more details about update'", !$update_tables['announce']['detail_url']); |
|
| 128 | - |
|
| 129 | - upd_alter_table('counter', array("MODIFY `ip` VARCHAR(250) COMMENT 'User last IP'", "ADD `proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['counter']['proxy']); |
|
| 130 | - |
|
| 131 | - upd_alter_table('statpoints', array( |
|
| 132 | - "ADD `res_rank` INT(11) DEFAULT 0 COMMENT 'Rank by resources'", |
|
| 133 | - "ADD `res_old_rank` INT(11) DEFAULT 0 COMMENT 'Old rank by resources'", |
|
| 134 | - "ADD `res_points` BIGINT(20) DEFAULT 0 COMMENT 'Resource stat points'", |
|
| 135 | - "ADD `res_count` BIGINT(20) DEFAULT 0 COMMENT 'Old rank by resources'" |
|
| 136 | - ), !$update_tables['statpoints']['res_rank']); |
|
| 137 | - |
|
| 138 | - upd_alter_table('planets', "ADD `supercargo` bigint(11) NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count'", !$update_tables['planets']['supercargo']); |
|
| 139 | - |
|
| 140 | - upd_alter_table('users', "DROP COLUMN `current_luna`", $update_tables['users']['current_luna']); |
|
| 141 | - upd_alter_table('users', array("DROP COLUMN `aktywnosc`", "DROP COLUMN `time_aktyw`", "DROP COLUMN `kiler`", |
|
| 142 | - "DROP COLUMN `kod_aktywujacy`", "DROP COLUMN `ataker`", "DROP COLUMN `atakin`"), $update_tables['users']['ataker']); |
|
| 143 | - upd_alter_table('users', "ADD `options` TEXT COMMENT 'Packed user options'", !$update_tables['users']['options']); |
|
| 144 | - upd_alter_table('users', "ADD `news_lastread` int(11) NOT NULL DEFAULT '0' COMMENT 'News last read date'", !$update_tables['users']['news_lastread']); |
|
| 145 | - upd_alter_table('users', array("MODIFY `user_lastip` VARCHAR(250) COMMENT 'User last IP'", "ADD `user_proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['users']['user_proxy']); |
|
| 146 | - |
|
| 147 | - upd_drop_table('update'); |
|
| 148 | - |
|
| 149 | - upd_check_key('fleet_speed', $config->fleet_speed/2500, $config->fleet_speed >= 2500); |
|
| 150 | - upd_check_key('game_counter', 0); |
|
| 151 | - upd_check_key('game_default_language', 'ru'); |
|
| 152 | - upd_check_key('game_default_skin', 'skins/EpicBlue/'); |
|
| 153 | - upd_check_key('game_default_template', 'OpenGame'); |
|
| 154 | - upd_check_key('game_news_overview', 3); |
|
| 155 | - upd_check_key('game_news_actual', 259200); |
|
| 156 | - upd_check_key('game_noob_factor', 5, !isset($config->game_noob_factor)); |
|
| 157 | - upd_check_key('game_noob_points', 5000, !isset($config->game_noob_points)); |
|
| 158 | - upd_check_key('game_speed', $config->game_speed/2500, $config->game_speed >= 2500); |
|
| 159 | - upd_check_key('int_format_date', 'd.m.Y'); |
|
| 160 | - upd_check_key('int_format_time', 'H:i:s', true); |
|
| 161 | - upd_check_key('int_banner_background', 'design/images/banner.png', true); |
|
| 162 | - upd_check_key('int_userbar_background', 'design/images/userbar.png', true); |
|
| 163 | - upd_check_key('player_max_colonies', $config->player_max_planets ? ($config->player_max_planets - 1) : 9); |
|
| 164 | - upd_check_key('url_forum', $config->forum_url, !isset($config->url_forum)); |
|
| 165 | - upd_check_key('url_rules', $config->rules_url, !isset($config->url_rules)); |
|
| 166 | - upd_check_key('url_dark_matter', '', !isset($config->url_dark_matter)); |
|
| 167 | - |
|
| 168 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ( |
|
| 125 | + ); |
|
| 126 | + |
|
| 127 | + upd_alter_table('announce', "ADD `detail_url` varchar(250) NOT NULL DEFAULT '' COMMENT 'Link to more details about update'", !$update_tables['announce']['detail_url']); |
|
| 128 | + |
|
| 129 | + upd_alter_table('counter', array("MODIFY `ip` VARCHAR(250) COMMENT 'User last IP'", "ADD `proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['counter']['proxy']); |
|
| 130 | + |
|
| 131 | + upd_alter_table('statpoints', array( |
|
| 132 | + "ADD `res_rank` INT(11) DEFAULT 0 COMMENT 'Rank by resources'", |
|
| 133 | + "ADD `res_old_rank` INT(11) DEFAULT 0 COMMENT 'Old rank by resources'", |
|
| 134 | + "ADD `res_points` BIGINT(20) DEFAULT 0 COMMENT 'Resource stat points'", |
|
| 135 | + "ADD `res_count` BIGINT(20) DEFAULT 0 COMMENT 'Old rank by resources'" |
|
| 136 | + ), !$update_tables['statpoints']['res_rank']); |
|
| 137 | + |
|
| 138 | + upd_alter_table('planets', "ADD `supercargo` bigint(11) NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count'", !$update_tables['planets']['supercargo']); |
|
| 139 | + |
|
| 140 | + upd_alter_table('users', "DROP COLUMN `current_luna`", $update_tables['users']['current_luna']); |
|
| 141 | + upd_alter_table('users', array("DROP COLUMN `aktywnosc`", "DROP COLUMN `time_aktyw`", "DROP COLUMN `kiler`", |
|
| 142 | + "DROP COLUMN `kod_aktywujacy`", "DROP COLUMN `ataker`", "DROP COLUMN `atakin`"), $update_tables['users']['ataker']); |
|
| 143 | + upd_alter_table('users', "ADD `options` TEXT COMMENT 'Packed user options'", !$update_tables['users']['options']); |
|
| 144 | + upd_alter_table('users', "ADD `news_lastread` int(11) NOT NULL DEFAULT '0' COMMENT 'News last read date'", !$update_tables['users']['news_lastread']); |
|
| 145 | + upd_alter_table('users', array("MODIFY `user_lastip` VARCHAR(250) COMMENT 'User last IP'", "ADD `user_proxy` VARCHAR(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)'"), !$update_tables['users']['user_proxy']); |
|
| 146 | + |
|
| 147 | + upd_drop_table('update'); |
|
| 148 | + |
|
| 149 | + upd_check_key('fleet_speed', $config->fleet_speed/2500, $config->fleet_speed >= 2500); |
|
| 150 | + upd_check_key('game_counter', 0); |
|
| 151 | + upd_check_key('game_default_language', 'ru'); |
|
| 152 | + upd_check_key('game_default_skin', 'skins/EpicBlue/'); |
|
| 153 | + upd_check_key('game_default_template', 'OpenGame'); |
|
| 154 | + upd_check_key('game_news_overview', 3); |
|
| 155 | + upd_check_key('game_news_actual', 259200); |
|
| 156 | + upd_check_key('game_noob_factor', 5, !isset($config->game_noob_factor)); |
|
| 157 | + upd_check_key('game_noob_points', 5000, !isset($config->game_noob_points)); |
|
| 158 | + upd_check_key('game_speed', $config->game_speed/2500, $config->game_speed >= 2500); |
|
| 159 | + upd_check_key('int_format_date', 'd.m.Y'); |
|
| 160 | + upd_check_key('int_format_time', 'H:i:s', true); |
|
| 161 | + upd_check_key('int_banner_background', 'design/images/banner.png', true); |
|
| 162 | + upd_check_key('int_userbar_background', 'design/images/userbar.png', true); |
|
| 163 | + upd_check_key('player_max_colonies', $config->player_max_planets ? ($config->player_max_planets - 1) : 9); |
|
| 164 | + upd_check_key('url_forum', $config->forum_url, !isset($config->url_forum)); |
|
| 165 | + upd_check_key('url_rules', $config->rules_url, !isset($config->url_rules)); |
|
| 166 | + upd_check_key('url_dark_matter', '', !isset($config->url_dark_matter)); |
|
| 167 | + |
|
| 168 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ( |
|
| 169 | 169 | 'game_date_withTime', 'player_max_planets', 'OverviewNewsFrame', 'forum_url', 'rules_url' |
| 170 | 170 | );"); |
| 171 | 171 | |
| 172 | - upd_do_query('COMMIT;', true); |
|
| 173 | - $new_version = 22; |
|
| 172 | + upd_do_query('COMMIT;', true); |
|
| 173 | + $new_version = 22; |
|
| 174 | 174 | |
| 175 | - case 22: |
|
| 176 | - upd_log_version_update(); |
|
| 175 | + case 22: |
|
| 176 | + upd_log_version_update(); |
|
| 177 | 177 | |
| 178 | - upd_alter_table('planets', "ADD `governor` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Planet governor'", !$update_tables['planets']['governor']); |
|
| 179 | - upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
|
| 180 | - upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
|
| 178 | + upd_alter_table('planets', "ADD `governor` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Planet governor'", !$update_tables['planets']['governor']); |
|
| 179 | + upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
|
| 180 | + upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
|
| 181 | 181 | |
| 182 | - if($update_tables['planets']['b_building']) |
|
| 183 | - { |
|
| 184 | - $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
|
| 185 | - $const_que_structures = QUE_STRUCTURES; |
|
| 186 | - while($planet_data = db_fetch($planet_query)) |
|
| 182 | + if($update_tables['planets']['b_building']) |
|
| 187 | 183 | { |
| 188 | - $old_que = explode(';', $planet_data['b_building_id']); |
|
| 189 | - foreach($old_que as $old_que_item_string) |
|
| 184 | + $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
|
| 185 | + $const_que_structures = QUE_STRUCTURES; |
|
| 186 | + while($planet_data = db_fetch($planet_query)) |
|
| 190 | 187 | { |
| 191 | - if(!$old_que_item_string) |
|
| 188 | + $old_que = explode(';', $planet_data['b_building_id']); |
|
| 189 | + foreach($old_que as $old_que_item_string) |
|
| 192 | 190 | { |
| 193 | - continue; |
|
| 194 | - } |
|
| 191 | + if(!$old_que_item_string) |
|
| 192 | + { |
|
| 193 | + continue; |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - $old_que_item = explode(',', $old_que_item_string); |
|
| 197 | - if($old_que_item[4] == 'build') |
|
| 198 | - { |
|
| 199 | - $old_que_item[4] = BUILD_CREATE; |
|
| 200 | - } |
|
| 201 | - else |
|
| 202 | - { |
|
| 203 | - $old_que_item[4] = BUILD_DESTROY; |
|
| 204 | - } |
|
| 196 | + $old_que_item = explode(',', $old_que_item_string); |
|
| 197 | + if($old_que_item[4] == 'build') |
|
| 198 | + { |
|
| 199 | + $old_que_item[4] = BUILD_CREATE; |
|
| 200 | + } |
|
| 201 | + else |
|
| 202 | + { |
|
| 203 | + $old_que_item[4] = BUILD_DESTROY; |
|
| 204 | + } |
|
| 205 | 205 | |
| 206 | - $old_que_item[3] = $old_que_item[3] > $planet_data['last_update'] ? $old_que_item[3] - $planet_data['last_update'] : 1; |
|
| 207 | - $planet_data['que'] = "{$old_que_item[0]},1,{$old_que_item[3]},{$old_que_item[4]},{$const_que_structures};{$planet_data['que']}"; |
|
| 206 | + $old_que_item[3] = $old_que_item[3] > $planet_data['last_update'] ? $old_que_item[3] - $planet_data['last_update'] : 1; |
|
| 207 | + $planet_data['que'] = "{$old_que_item[0]},1,{$old_que_item[3]},{$old_que_item[4]},{$const_que_structures};{$planet_data['que']}"; |
|
| 208 | + } |
|
| 209 | + upd_do_query("UPDATE {{planets}} SET `que` = '{$planet_data['que']}', `b_building` = '0', `b_building_id` = '0' WHERE `id` = '{$planet_data['id']}' LIMIT 1;", true); |
|
| 208 | 210 | } |
| 209 | - upd_do_query("UPDATE {{planets}} SET `que` = '{$planet_data['que']}', `b_building` = '0', `b_building_id` = '0' WHERE `id` = '{$planet_data['id']}' LIMIT 1;", true); |
|
| 210 | 211 | } |
| 211 | - } |
|
| 212 | 212 | |
| 213 | - upd_do_query('COMMIT;', true); |
|
| 214 | - $new_version = 23; |
|
| 213 | + upd_do_query('COMMIT;', true); |
|
| 214 | + $new_version = 23; |
|
| 215 | 215 | |
| 216 | - case 23: |
|
| 217 | - case 24: |
|
| 218 | - upd_log_version_update(); |
|
| 216 | + case 23: |
|
| 217 | + case 24: |
|
| 218 | + upd_log_version_update(); |
|
| 219 | 219 | |
| 220 | - upd_create_table('confirmations', |
|
| 221 | - "( |
|
| 220 | + upd_create_table('confirmations', |
|
| 221 | + "( |
|
| 222 | 222 | `id` bigint(11) NOT NULL AUTO_INCREMENT, |
| 223 | 223 | `id_user` bigint(11) NOT NULL DEFAULT 0, |
| 224 | 224 | `type` SMALLINT NOT NULL DEFAULT 0, |
@@ -228,130 +228,130 @@ discard block |
||
| 228 | 228 | PRIMARY KEY (`id`), |
| 229 | 229 | KEY `i_code_email` (`code`, `email`) |
| 230 | 230 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 231 | - ); |
|
| 231 | + ); |
|
| 232 | 232 | |
| 233 | - if($update_tables['users']['urlaubs_until']) |
|
| 234 | - { |
|
| 235 | - upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
|
| 236 | - upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
|
| 237 | - upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']); |
|
| 238 | - } |
|
| 233 | + if($update_tables['users']['urlaubs_until']) |
|
| 234 | + { |
|
| 235 | + upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
|
| 236 | + upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
|
| 237 | + upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']); |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | - upd_check_key('user_vacation_disable', $config->urlaubs_modus_erz, !isset($config->user_vacation_disable)); |
|
| 241 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('urlaubs_modus_erz');"); |
|
| 240 | + upd_check_key('user_vacation_disable', $config->urlaubs_modus_erz, !isset($config->user_vacation_disable)); |
|
| 241 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('urlaubs_modus_erz');"); |
|
| 242 | 242 | |
| 243 | - upd_do_query('COMMIT;', true); |
|
| 244 | - $new_version = 25; |
|
| 245 | - |
|
| 246 | - case 25: |
|
| 247 | - upd_log_version_update(); |
|
| 248 | - |
|
| 249 | - upd_alter_table('rw', array( |
|
| 250 | - "DROP COLUMN `a_zestrzelona`", |
|
| 251 | - "DROP INDEX `rid`", |
|
| 252 | - "ADD COLUMN `report_id` bigint(11) NOT NULL AUTO_INCREMENT FIRST", |
|
| 253 | - "ADD PRIMARY KEY (`report_id`)", |
|
| 254 | - "ADD INDEX `i_rid` (`rid`)" |
|
| 255 | - ), !$update_tables['rw']['report_id']); |
|
| 256 | - |
|
| 257 | - upd_add_more_time(); |
|
| 258 | - upd_create_table('logs_backup', "AS (SELECT * FROM {$config->db_prefix}logs);"); |
|
| 259 | - |
|
| 260 | - upd_alter_table('logs', array( |
|
| 261 | - "MODIFY COLUMN `log_id` INT(1)", |
|
| 262 | - "DROP PRIMARY KEY" |
|
| 263 | - ), !$update_tables['logs']['log_timestamp']); |
|
| 264 | - |
|
| 265 | - upd_alter_table('logs', array( |
|
| 266 | - "DROP COLUMN `log_id`", |
|
| 267 | - "ADD COLUMN `log_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp' FIRST", |
|
| 268 | - "ADD COLUMN `log_username` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Username' AFTER `log_timestamp`", |
|
| 269 | - "MODIFY COLUMN `log_title` VARCHAR(64) NOT NULL DEFAULT 'Log entry' COMMENT 'Short description' AFTER `log_username`", |
|
| 270 | - "MODIFY COLUMN `log_page` VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log' AFTER `log_text`", |
|
| 271 | - "CHANGE COLUMN `log_type` `log_code` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `log_page`", |
|
| 272 | - "MODIFY COLUMN `log_sender` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ID which make log record' AFTER `log_code`", |
|
| 273 | - "MODIFY COLUMN `log_time` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Machine-readable timestamp' AFTER `log_sender`", |
|
| 274 | - "ADD COLUMN `log_dump` TEXT NOT NULL DEFAULT '' COMMENT 'Machine-readable dump of variables' AFTER `log_time`", |
|
| 275 | - "ADD INDEX `i_log_username` (`log_username`)", |
|
| 276 | - "ADD INDEX `i_log_time` (`log_time`)", |
|
| 277 | - "ADD INDEX `i_log_sender` (`log_sender`)", |
|
| 278 | - "ADD INDEX `i_log_code` (`log_code`)", |
|
| 279 | - "ADD INDEX `i_log_page` (`log_page`)", |
|
| 280 | - "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" |
|
| 281 | - ), !$update_tables['logs']['log_timestamp']); |
|
| 282 | - upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
|
| 283 | - |
|
| 284 | - if($update_tables['errors']) |
|
| 285 | - { |
|
| 286 | - upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;'); |
|
| 287 | - if($update_tables['errors_backup']) |
|
| 243 | + upd_do_query('COMMIT;', true); |
|
| 244 | + $new_version = 25; |
|
| 245 | + |
|
| 246 | + case 25: |
|
| 247 | + upd_log_version_update(); |
|
| 248 | + |
|
| 249 | + upd_alter_table('rw', array( |
|
| 250 | + "DROP COLUMN `a_zestrzelona`", |
|
| 251 | + "DROP INDEX `rid`", |
|
| 252 | + "ADD COLUMN `report_id` bigint(11) NOT NULL AUTO_INCREMENT FIRST", |
|
| 253 | + "ADD PRIMARY KEY (`report_id`)", |
|
| 254 | + "ADD INDEX `i_rid` (`rid`)" |
|
| 255 | + ), !$update_tables['rw']['report_id']); |
|
| 256 | + |
|
| 257 | + upd_add_more_time(); |
|
| 258 | + upd_create_table('logs_backup', "AS (SELECT * FROM {$config->db_prefix}logs);"); |
|
| 259 | + |
|
| 260 | + upd_alter_table('logs', array( |
|
| 261 | + "MODIFY COLUMN `log_id` INT(1)", |
|
| 262 | + "DROP PRIMARY KEY" |
|
| 263 | + ), !$update_tables['logs']['log_timestamp']); |
|
| 264 | + |
|
| 265 | + upd_alter_table('logs', array( |
|
| 266 | + "DROP COLUMN `log_id`", |
|
| 267 | + "ADD COLUMN `log_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp' FIRST", |
|
| 268 | + "ADD COLUMN `log_username` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Username' AFTER `log_timestamp`", |
|
| 269 | + "MODIFY COLUMN `log_title` VARCHAR(64) NOT NULL DEFAULT 'Log entry' COMMENT 'Short description' AFTER `log_username`", |
|
| 270 | + "MODIFY COLUMN `log_page` VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log' AFTER `log_text`", |
|
| 271 | + "CHANGE COLUMN `log_type` `log_code` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `log_page`", |
|
| 272 | + "MODIFY COLUMN `log_sender` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ID which make log record' AFTER `log_code`", |
|
| 273 | + "MODIFY COLUMN `log_time` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Machine-readable timestamp' AFTER `log_sender`", |
|
| 274 | + "ADD COLUMN `log_dump` TEXT NOT NULL DEFAULT '' COMMENT 'Machine-readable dump of variables' AFTER `log_time`", |
|
| 275 | + "ADD INDEX `i_log_username` (`log_username`)", |
|
| 276 | + "ADD INDEX `i_log_time` (`log_time`)", |
|
| 277 | + "ADD INDEX `i_log_sender` (`log_sender`)", |
|
| 278 | + "ADD INDEX `i_log_code` (`log_code`)", |
|
| 279 | + "ADD INDEX `i_log_page` (`log_page`)", |
|
| 280 | + "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" |
|
| 281 | + ), !$update_tables['logs']['log_timestamp']); |
|
| 282 | + upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
|
| 283 | + |
|
| 284 | + if($update_tables['errors']) |
|
| 288 | 285 | { |
| 289 | - upd_drop_table('errors_backup'); |
|
| 290 | - } |
|
| 291 | -// __db_query("ALTER TABLE {$config->db_prefix}errors RENAME TO {$config->db_prefix}errors_backup;"); |
|
| 292 | -// classSupernova::$db->__db_query("ALTER TABLE {$config->db_prefix}errors RENAME TO {$config->db_prefix}errors_backup;"); |
|
| 293 | - upd_alter_table('errors', ' RENAME TO {$config->db_prefix}errors_backup'); |
|
| 286 | + upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;'); |
|
| 287 | + if($update_tables['errors_backup']) |
|
| 288 | + { |
|
| 289 | + upd_drop_table('errors_backup'); |
|
| 290 | + } |
|
| 291 | + // __db_query("ALTER TABLE {$config->db_prefix}errors RENAME TO {$config->db_prefix}errors_backup;"); |
|
| 292 | + // classSupernova::$db->__db_query("ALTER TABLE {$config->db_prefix}errors RENAME TO {$config->db_prefix}errors_backup;"); |
|
| 293 | + upd_alter_table('errors', ' RENAME TO {$config->db_prefix}errors_backup'); |
|
| 294 | 294 | |
| 295 | - upd_drop_table('errors'); |
|
| 296 | - } |
|
| 295 | + upd_drop_table('errors'); |
|
| 296 | + } |
|
| 297 | 297 | |
| 298 | - upd_alter_table('logs', 'ORDER BY log_time'); |
|
| 298 | + upd_alter_table('logs', 'ORDER BY log_time'); |
|
| 299 | 299 | |
| 300 | - upd_alter_table('logs', array("ADD COLUMN `log_id` SERIAL", "ADD PRIMARY KEY (`log_id`)"), !$update_tables['logs']['log_id']); |
|
| 300 | + upd_alter_table('logs', array("ADD COLUMN `log_id` SERIAL", "ADD PRIMARY KEY (`log_id`)"), !$update_tables['logs']['log_id']); |
|
| 301 | 301 | |
| 302 | - upd_do_query('UPDATE `{{logs}}` SET `log_timestamp` = FROM_UNIXTIME(`log_time`);'); |
|
| 303 | - upd_do_query('UPDATE `{{logs}}` AS l LEFT JOIN `{{users}}` AS u ON u.id = l.log_sender SET l.log_username = u.username WHERE l.log_username IS NOT NULL;'); |
|
| 302 | + upd_do_query('UPDATE `{{logs}}` SET `log_timestamp` = FROM_UNIXTIME(`log_time`);'); |
|
| 303 | + upd_do_query('UPDATE `{{logs}}` AS l LEFT JOIN `{{users}}` AS u ON u.id = l.log_sender SET l.log_username = u.username WHERE l.log_username IS NOT NULL;'); |
|
| 304 | 304 | |
| 305 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 190 WHERE `log_code` = 100 AND `log_title` = 'Stat update';"); |
|
| 306 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 191 WHERE `log_code` = 101 AND `log_title` = 'Stat update';"); |
|
| 307 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 192 WHERE `log_code` = 102 AND `log_title` = 'Stat update';"); |
|
| 308 | - $sys_log_disabled = false; |
|
| 305 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 190 WHERE `log_code` = 100 AND `log_title` = 'Stat update';"); |
|
| 306 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 191 WHERE `log_code` = 101 AND `log_title` = 'Stat update';"); |
|
| 307 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 192 WHERE `log_code` = 102 AND `log_title` = 'Stat update';"); |
|
| 308 | + $sys_log_disabled = false; |
|
| 309 | 309 | |
| 310 | - upd_do_query('COMMIT;', true); |
|
| 311 | - $new_version = 26; |
|
| 310 | + upd_do_query('COMMIT;', true); |
|
| 311 | + $new_version = 26; |
|
| 312 | 312 | |
| 313 | - case 26: |
|
| 314 | - upd_log_version_update(); |
|
| 313 | + case 26: |
|
| 314 | + upd_log_version_update(); |
|
| 315 | 315 | |
| 316 | - $sys_log_disabled = false; |
|
| 316 | + $sys_log_disabled = false; |
|
| 317 | 317 | |
| 318 | - upd_alter_table('planets', "ADD INDEX `i_parent_planet` (`parent_planet`)", !$update_indexes['planets']['i_parent_planet']); |
|
| 319 | - upd_alter_table('messages', "DROP INDEX `owner`", $update_indexes['messages']['owner']); |
|
| 320 | - upd_alter_table('messages', "DROP INDEX `owner_type`", $update_indexes['messages']['owner_type']); |
|
| 321 | - upd_alter_table('messages', "DROP INDEX `sender_type`", $update_indexes['messages']['sender_type']); |
|
| 318 | + upd_alter_table('planets', "ADD INDEX `i_parent_planet` (`parent_planet`)", !$update_indexes['planets']['i_parent_planet']); |
|
| 319 | + upd_alter_table('messages', "DROP INDEX `owner`", $update_indexes['messages']['owner']); |
|
| 320 | + upd_alter_table('messages', "DROP INDEX `owner_type`", $update_indexes['messages']['owner_type']); |
|
| 321 | + upd_alter_table('messages', "DROP INDEX `sender_type`", $update_indexes['messages']['sender_type']); |
|
| 322 | 322 | |
| 323 | - upd_alter_table('messages', array( |
|
| 324 | - "ADD INDEX `i_owner_time` (`message_owner`, `message_time`)", |
|
| 325 | - "ADD INDEX `i_sender_time` (`message_sender`, `message_time`)", |
|
| 326 | - "ADD INDEX `i_time` (`message_time`)" |
|
| 327 | - ), !$update_indexes['messages']['i_owner_time']); |
|
| 323 | + upd_alter_table('messages', array( |
|
| 324 | + "ADD INDEX `i_owner_time` (`message_owner`, `message_time`)", |
|
| 325 | + "ADD INDEX `i_sender_time` (`message_sender`, `message_time`)", |
|
| 326 | + "ADD INDEX `i_time` (`message_time`)" |
|
| 327 | + ), !$update_indexes['messages']['i_owner_time']); |
|
| 328 | 328 | |
| 329 | - upd_drop_table('fleet_log'); |
|
| 329 | + upd_drop_table('fleet_log'); |
|
| 330 | 330 | |
| 331 | - upd_do_query("UPDATE `{{planets}}` SET `metal` = 0 WHERE `metal` < 0;"); |
|
| 332 | - upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;"); |
|
| 333 | - upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;"); |
|
| 334 | - upd_alter_table('planets', array( |
|
| 335 | - "DROP COLUMN `b_building`", |
|
| 336 | - "DROP COLUMN `b_building_id`" |
|
| 337 | - ), $update_tables['planets']['b_building']); |
|
| 331 | + upd_do_query("UPDATE `{{planets}}` SET `metal` = 0 WHERE `metal` < 0;"); |
|
| 332 | + upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;"); |
|
| 333 | + upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;"); |
|
| 334 | + upd_alter_table('planets', array( |
|
| 335 | + "DROP COLUMN `b_building`", |
|
| 336 | + "DROP COLUMN `b_building_id`" |
|
| 337 | + ), $update_tables['planets']['b_building']); |
|
| 338 | 338 | |
| 339 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');"); |
|
| 339 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');"); |
|
| 340 | 340 | |
| 341 | - upd_do_query("DELETE FROM `{{logs}}` WHERE `log_code` = 501;"); |
|
| 342 | - upd_do_query("DELETE FROM `{{logs}}` WHERE `log_title` IN ('Canceling Hangar Que', 'Building Planet Defense');"); |
|
| 341 | + upd_do_query("DELETE FROM `{{logs}}` WHERE `log_code` = 501;"); |
|
| 342 | + upd_do_query("DELETE FROM `{{logs}}` WHERE `log_title` IN ('Canceling Hangar Que', 'Building Planet Defense');"); |
|
| 343 | 343 | |
| 344 | - upd_check_key('chat_admin_highlight', '<font color=purple>$1</font>', !isset($config->chat_admin_highlight)); |
|
| 344 | + upd_check_key('chat_admin_highlight', '<font color=purple>$1</font>', !isset($config->chat_admin_highlight)); |
|
| 345 | 345 | |
| 346 | - upd_check_key('int_banner_URL', 'banner.php?type=banner', $config->int_banner_URL == '/banner.php?type=banner'); |
|
| 347 | - upd_check_key('int_userbar_URL', 'banner.php?type=userbar', $config->int_userbar_URL == '/banner.php?type=userbar'); |
|
| 346 | + upd_check_key('int_banner_URL', 'banner.php?type=banner', $config->int_banner_URL == '/banner.php?type=banner'); |
|
| 347 | + upd_check_key('int_userbar_URL', 'banner.php?type=userbar', $config->int_userbar_URL == '/banner.php?type=userbar'); |
|
| 348 | 348 | |
| 349 | - upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
|
| 349 | + upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
|
| 350 | 350 | |
| 351 | - if(!$update_tables['shortcut']) |
|
| 352 | - { |
|
| 353 | - upd_create_table('shortcut', |
|
| 354 | - "( |
|
| 351 | + if(!$update_tables['shortcut']) |
|
| 352 | + { |
|
| 353 | + upd_create_table('shortcut', |
|
| 354 | + "( |
|
| 355 | 355 | `shortcut_id` SERIAL, |
| 356 | 356 | `shortcut_user_id` BIGINT(11) UNSIGNED NOT NULL DEFAULT 0, |
| 357 | 357 | `shortcut_planet_id` bigint(11) NOT NULL DEFAULT 0, |
@@ -368,75 +368,75 @@ discard block |
||
| 368 | 368 | CONSTRAINT `FK_shortcut_user_id` FOREIGN KEY (`shortcut_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 369 | 369 | |
| 370 | 370 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 371 | - ); |
|
| 371 | + ); |
|
| 372 | 372 | |
| 373 | - $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
|
| 373 | + $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
|
| 374 | 374 | |
| 375 | - $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
|
| 376 | - while($user_data = db_fetch($query)) |
|
| 377 | - { |
|
| 378 | - $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
|
| 379 | - foreach($shortcuts as $shortcut) |
|
| 375 | + $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
|
| 376 | + while($user_data = db_fetch($query)) |
|
| 380 | 377 | { |
| 381 | - if(!$shortcut) |
|
| 378 | + $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
|
| 379 | + foreach($shortcuts as $shortcut) |
|
| 382 | 380 | { |
| 383 | - continue; |
|
| 384 | - } |
|
| 381 | + if(!$shortcut) |
|
| 382 | + { |
|
| 383 | + continue; |
|
| 384 | + } |
|
| 385 | 385 | |
| 386 | - $shortcut = explode(',', $shortcut); |
|
| 387 | - $shortcut[0] = db_escape($shortcut[0]); |
|
| 388 | - $shortcut[1] = intval($shortcut[1]); |
|
| 389 | - $shortcut[2] = intval($shortcut[2]); |
|
| 390 | - $shortcut[3] = intval($shortcut[3]); |
|
| 391 | - $shortcut[4] = intval($shortcut[4]); |
|
| 386 | + $shortcut = explode(',', $shortcut); |
|
| 387 | + $shortcut[0] = db_escape($shortcut[0]); |
|
| 388 | + $shortcut[1] = intval($shortcut[1]); |
|
| 389 | + $shortcut[2] = intval($shortcut[2]); |
|
| 390 | + $shortcut[3] = intval($shortcut[3]); |
|
| 391 | + $shortcut[4] = intval($shortcut[4]); |
|
| 392 | 392 | |
| 393 | - if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) |
|
| 394 | - { |
|
| 395 | - upd_do_query("INSERT INTO {$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true); |
|
| 393 | + if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) |
|
| 394 | + { |
|
| 395 | + upd_do_query("INSERT INTO {$config->db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true); |
|
| 396 | + } |
|
| 396 | 397 | } |
| 397 | 398 | } |
| 398 | - } |
|
| 399 | 399 | |
| 400 | - upd_alter_table('users', 'DROP COLUMN `fleet_shortcut`'); |
|
| 401 | - }; |
|
| 400 | + upd_alter_table('users', 'DROP COLUMN `fleet_shortcut`'); |
|
| 401 | + }; |
|
| 402 | 402 | |
| 403 | - upd_check_key('url_faq', '', !isset($config->url_faq)); |
|
| 403 | + upd_check_key('url_faq', '', !isset($config->url_faq)); |
|
| 404 | 404 | |
| 405 | - upd_do_query('COMMIT;', true); |
|
| 406 | - $new_version = 27; |
|
| 407 | - |
|
| 408 | - case 27: |
|
| 409 | - upd_log_version_update(); |
|
| 410 | - |
|
| 411 | - upd_check_key('chat_highlight_moderator', '<font color=green>$1</font>', !isset($config->chat_highlight_moderator)); |
|
| 412 | - upd_check_key('chat_highlight_operator', '<font color=red>$1</font>', !isset($config->chat_highlight_operator)); |
|
| 413 | - upd_check_key('chat_highlight_admin', $config->chat_admin_highlight ? $config->chat_admin_highlight : '<font color=puple>$1</font>', !isset($config->chat_highlight_admin)); |
|
| 414 | - |
|
| 415 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('chat_admin_highlight');"); |
|
| 416 | - |
|
| 417 | - upd_alter_table('banned', array( |
|
| 418 | - "CHANGE COLUMN id ban_id bigint(20) unsigned NOT NULL AUTO_INCREMENT", |
|
| 419 | - "CHANGE COLUMN `who` `ban_user_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
| 420 | - "CHANGE COLUMN `theme` `ban_reason` VARCHAR(128) NOT NULL DEFAULT ''", |
|
| 421 | - "CHANGE COLUMN `time` `ban_time` int(11) NOT NULL DEFAULT 0", |
|
| 422 | - "CHANGE COLUMN `longer` `ban_until` int(11) NOT NULL DEFAULT 0", |
|
| 423 | - "CHANGE COLUMN `author` `ban_issuer_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
| 424 | - "CHANGE COLUMN `email` `ban_issuer_email` VARCHAR(64) NOT NULL DEFAULT ''", |
|
| 425 | - "DROP COLUMN who2", |
|
| 426 | - "ADD PRIMARY KEY (`ban_id`)"/*, |
|
| 405 | + upd_do_query('COMMIT;', true); |
|
| 406 | + $new_version = 27; |
|
| 407 | + |
|
| 408 | + case 27: |
|
| 409 | + upd_log_version_update(); |
|
| 410 | + |
|
| 411 | + upd_check_key('chat_highlight_moderator', '<font color=green>$1</font>', !isset($config->chat_highlight_moderator)); |
|
| 412 | + upd_check_key('chat_highlight_operator', '<font color=red>$1</font>', !isset($config->chat_highlight_operator)); |
|
| 413 | + upd_check_key('chat_highlight_admin', $config->chat_admin_highlight ? $config->chat_admin_highlight : '<font color=puple>$1</font>', !isset($config->chat_highlight_admin)); |
|
| 414 | + |
|
| 415 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('chat_admin_highlight');"); |
|
| 416 | + |
|
| 417 | + upd_alter_table('banned', array( |
|
| 418 | + "CHANGE COLUMN id ban_id bigint(20) unsigned NOT NULL AUTO_INCREMENT", |
|
| 419 | + "CHANGE COLUMN `who` `ban_user_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
| 420 | + "CHANGE COLUMN `theme` `ban_reason` VARCHAR(128) NOT NULL DEFAULT ''", |
|
| 421 | + "CHANGE COLUMN `time` `ban_time` int(11) NOT NULL DEFAULT 0", |
|
| 422 | + "CHANGE COLUMN `longer` `ban_until` int(11) NOT NULL DEFAULT 0", |
|
| 423 | + "CHANGE COLUMN `author` `ban_issuer_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
| 424 | + "CHANGE COLUMN `email` `ban_issuer_email` VARCHAR(64) NOT NULL DEFAULT ''", |
|
| 425 | + "DROP COLUMN who2", |
|
| 426 | + "ADD PRIMARY KEY (`ban_id`)"/*, |
|
| 427 | 427 | "RENAME TO {$config->db_prefix}ban"*/ |
| 428 | - ), !$update_tables['banned']['ban_id']); |
|
| 429 | - |
|
| 430 | - upd_alter_table('alliance', array( |
|
| 431 | - "MODIFY COLUMN `id` SERIAL", |
|
| 432 | - "ADD CONSTRAINT UNIQUE KEY `i_ally_name` (`ally_name`)", |
|
| 433 | - "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", |
|
| 434 | - "ENGINE=InnoDB" |
|
| 435 | - ), !$update_indexes['alliance']['i_ally_name']); |
|
| 436 | - |
|
| 437 | - $upd_relation_types = "'neutral', 'war', 'peace', 'confederation', 'federation', 'union', 'master', 'slave'"; |
|
| 438 | - upd_create_table('alliance_diplomacy', |
|
| 439 | - "( |
|
| 428 | + ), !$update_tables['banned']['ban_id']); |
|
| 429 | + |
|
| 430 | + upd_alter_table('alliance', array( |
|
| 431 | + "MODIFY COLUMN `id` SERIAL", |
|
| 432 | + "ADD CONSTRAINT UNIQUE KEY `i_ally_name` (`ally_name`)", |
|
| 433 | + "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", |
|
| 434 | + "ENGINE=InnoDB" |
|
| 435 | + ), !$update_indexes['alliance']['i_ally_name']); |
|
| 436 | + |
|
| 437 | + $upd_relation_types = "'neutral', 'war', 'peace', 'confederation', 'federation', 'union', 'master', 'slave'"; |
|
| 438 | + upd_create_table('alliance_diplomacy', |
|
| 439 | + "( |
|
| 440 | 440 | `alliance_diplomacy_id` SERIAL, |
| 441 | 441 | `alliance_diplomacy_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
| 442 | 442 | `alliance_diplomacy_contr_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
@@ -453,10 +453,10 @@ discard block |
||
| 453 | 453 | ,CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 454 | 454 | ,CONSTRAINT `FK_diplomacy_contr_ally_name` FOREIGN KEY (`alliance_diplomacy_contr_ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE CASCADE ON UPDATE CASCADE |
| 455 | 455 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
| 456 | - ); |
|
| 456 | + ); |
|
| 457 | 457 | |
| 458 | - upd_create_table('alliance_negotiation', |
|
| 459 | - "( |
|
| 458 | + upd_create_table('alliance_negotiation', |
|
| 459 | + "( |
|
| 460 | 460 | `alliance_negotiation_id` SERIAL, |
| 461 | 461 | `alliance_negotiation_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
| 462 | 462 | `alliance_negotiation_ally_name` varchar(32) DEFAULT '', |
@@ -477,13 +477,13 @@ discard block |
||
| 477 | 477 | ,CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 478 | 478 | ,CONSTRAINT `FK_negotiation_contr_ally_name` FOREIGN KEY (`alliance_negotiation_contr_ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE CASCADE ON UPDATE CASCADE |
| 479 | 479 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
| 480 | - ); |
|
| 480 | + ); |
|
| 481 | 481 | |
| 482 | - upd_alter_table('users', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
| 483 | - upd_alter_table('planets', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
| 482 | + upd_alter_table('users', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
| 483 | + upd_alter_table('planets', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
| 484 | 484 | |
| 485 | - upd_create_table('bashing', |
|
| 486 | - "( |
|
| 485 | + upd_create_table('bashing', |
|
| 486 | + "( |
|
| 487 | 487 | `bashing_id` SERIAL, |
| 488 | 488 | `bashing_user_id` bigint(11) UNSIGNED DEFAULT NULL, |
| 489 | 489 | `bashing_planet_id` bigint(11) UNSIGNED DEFAULT NULL, |
@@ -497,23 +497,23 @@ discard block |
||
| 497 | 497 | CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 498 | 498 | ,CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 499 | 499 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
| 500 | - ); |
|
| 500 | + ); |
|
| 501 | 501 | |
| 502 | - upd_check_key('fleet_bashing_war_delay', 12 * 60 * 60, !isset($config->fleet_bashing_war_delay)); |
|
| 503 | - upd_check_key('fleet_bashing_scope', 24 * 60 * 60, !isset($config->fleet_bashing_scope)); |
|
| 504 | - upd_check_key('fleet_bashing_interval', 30 * 60, !isset($config->fleet_bashing_interval)); |
|
| 505 | - upd_check_key('fleet_bashing_waves', 3, !isset($config->fleet_bashing_waves)); |
|
| 506 | - upd_check_key('fleet_bashing_attacks', 3, !isset($config->fleet_bashing_attacks)); |
|
| 502 | + upd_check_key('fleet_bashing_war_delay', 12 * 60 * 60, !isset($config->fleet_bashing_war_delay)); |
|
| 503 | + upd_check_key('fleet_bashing_scope', 24 * 60 * 60, !isset($config->fleet_bashing_scope)); |
|
| 504 | + upd_check_key('fleet_bashing_interval', 30 * 60, !isset($config->fleet_bashing_interval)); |
|
| 505 | + upd_check_key('fleet_bashing_waves', 3, !isset($config->fleet_bashing_waves)); |
|
| 506 | + upd_check_key('fleet_bashing_attacks', 3, !isset($config->fleet_bashing_attacks)); |
|
| 507 | 507 | |
| 508 | - upd_do_query('COMMIT;', true); |
|
| 509 | - $new_version = 28; |
|
| 508 | + upd_do_query('COMMIT;', true); |
|
| 509 | + $new_version = 28; |
|
| 510 | 510 | |
| 511 | - case 28: |
|
| 512 | - case 28.1: |
|
| 513 | - upd_log_version_update(); |
|
| 511 | + case 28: |
|
| 512 | + case 28.1: |
|
| 513 | + upd_log_version_update(); |
|
| 514 | 514 | |
| 515 | - upd_create_table('quest', |
|
| 516 | - "( |
|
| 515 | + upd_create_table('quest', |
|
| 516 | + "( |
|
| 517 | 517 | `quest_id` SERIAL, |
| 518 | 518 | `quest_name` VARCHAR(255) DEFAULT NULL, |
| 519 | 519 | `quest_description` TEXT, |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | PRIMARY KEY (`quest_id`) |
| 526 | 526 | ,KEY (`quest_type`, `quest_order`) |
| 527 | 527 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
| 528 | - ); |
|
| 528 | + ); |
|
| 529 | 529 | |
| 530 | - upd_create_table('quest_status', |
|
| 531 | - "( |
|
| 530 | + upd_create_table('quest_status', |
|
| 531 | + "( |
|
| 532 | 532 | `quest_status_id` SERIAL, |
| 533 | 533 | `quest_status_quest_id` bigint(20) UNSIGNED DEFAULT NULL, |
| 534 | 534 | `quest_status_user_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0', |
@@ -540,82 +540,82 @@ discard block |
||
| 540 | 540 | ,CONSTRAINT `FK_quest_status_quest_id` FOREIGN KEY (`quest_status_quest_id`) REFERENCES `{$config->db_prefix}quest` (`quest_id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 541 | 541 | ,CONSTRAINT `FK_quest_status_user_id` FOREIGN KEY (`quest_status_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 542 | 542 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
| 543 | - ); |
|
| 544 | - |
|
| 545 | - upd_check_key('quest_total', 0, !isset($config->quest_total)); |
|
| 546 | - |
|
| 547 | - for($i = 0; $i < 25; $i++) |
|
| 548 | - { |
|
| 549 | - upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
|
| 550 | - upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
|
| 551 | - upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]); |
|
| 552 | - } |
|
| 553 | - |
|
| 554 | - upd_alter_table('alliance', array('DROP INDEX `id`',), $update_indexes['alliance']['id']); |
|
| 555 | - upd_alter_table('alliance', array('DROP INDEX `ally_name`',), $update_indexes['alliance']['ally_name']); |
|
| 556 | - upd_alter_table('alliance', array('ADD UNIQUE INDEX `i_ally_tag` (`ally_tag`)',), !$update_indexes['alliance']['i_ally_tag']); |
|
| 557 | - upd_alter_table('alliance', array('MODIFY COLUMN `ranklist` TEXT',), true); |
|
| 543 | + ); |
|
| 558 | 544 | |
| 559 | - upd_alter_table('users', array('DROP INDEX `id`',), $update_indexes['users']['id']); |
|
| 560 | - upd_alter_table('users', "CHANGE COLUMN `rpg_points` `dark_matter` int(11) DEFAULT 0", $update_tables['users']['rpg_points']); |
|
| 545 | + upd_check_key('quest_total', 0, !isset($config->quest_total)); |
|
| 561 | 546 | |
| 562 | - upd_alter_table('users', array( |
|
| 563 | - 'DROP COLUMN `ally_request`', |
|
| 564 | - 'DROP COLUMN `ally_request_text`', |
|
| 565 | - ), $update_tables['users']['ally_request_text']); |
|
| 547 | + for($i = 0; $i < 25; $i++) |
|
| 548 | + { |
|
| 549 | + upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
|
| 550 | + upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
|
| 551 | + upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]); |
|
| 552 | + } |
|
| 566 | 553 | |
| 567 | - upd_alter_table('users', array( |
|
| 568 | - 'ADD INDEX `i_ally_id` (`ally_id`)', |
|
| 569 | - 'ADD INDEX `i_ally_name` (`ally_name`)', |
|
| 570 | - ), !$update_indexes['users']['i_ally_id']); |
|
| 554 | + upd_alter_table('alliance', array('DROP INDEX `id`',), $update_indexes['alliance']['id']); |
|
| 555 | + upd_alter_table('alliance', array('DROP INDEX `ally_name`',), $update_indexes['alliance']['ally_name']); |
|
| 556 | + upd_alter_table('alliance', array('ADD UNIQUE INDEX `i_ally_tag` (`ally_tag`)',), !$update_indexes['alliance']['i_ally_tag']); |
|
| 557 | + upd_alter_table('alliance', array('MODIFY COLUMN `ranklist` TEXT',), true); |
|
| 571 | 558 | |
| 572 | - upd_alter_table('users', array( |
|
| 573 | - "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
|
| 574 | - ), !$update_tables['users']['msg_admin']); |
|
| 559 | + upd_alter_table('users', array('DROP INDEX `id`',), $update_indexes['users']['id']); |
|
| 560 | + upd_alter_table('users', "CHANGE COLUMN `rpg_points` `dark_matter` int(11) DEFAULT 0", $update_tables['users']['rpg_points']); |
|
| 575 | 561 | |
| 576 | - if(!$update_foreigns['users']['FK_users_ally_id']) |
|
| 577 | - { |
|
| 578 | 562 | upd_alter_table('users', array( |
| 579 | - 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
|
| 580 | - 'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
| 581 | - ), strtoupper($update_tables['users']['ally_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 563 | + 'DROP COLUMN `ally_request`', |
|
| 564 | + 'DROP COLUMN `ally_request_text`', |
|
| 565 | + ), $update_tables['users']['ally_request_text']); |
|
| 582 | 566 | |
| 583 | - upd_do_query('DELETE FROM {{alliance}} WHERE id not in (select ally_id from {{users}} group by ally_id);'); |
|
| 584 | - upd_do_query("UPDATE {{users}} SET `ally_id` = null, ally_name = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` NOT IN (SELECT id FROM {{alliance}});"); |
|
| 585 | - upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
|
| 567 | + upd_alter_table('users', array( |
|
| 568 | + 'ADD INDEX `i_ally_id` (`ally_id`)', |
|
| 569 | + 'ADD INDEX `i_ally_name` (`ally_name`)', |
|
| 570 | + ), !$update_indexes['users']['i_ally_id']); |
|
| 586 | 571 | |
| 587 | 572 | upd_alter_table('users', array( |
| 588 | - "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 589 | - "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 590 | - ), !$update_foreigns['users']['FK_users_ally_id']); |
|
| 591 | - } |
|
| 573 | + "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
|
| 574 | + ), !$update_tables['users']['msg_admin']); |
|
| 592 | 575 | |
| 593 | - upd_alter_table('planets', array( |
|
| 594 | - "MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
| 595 | - "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
| 596 | - ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 576 | + if(!$update_foreigns['users']['FK_users_ally_id']) |
|
| 577 | + { |
|
| 578 | + upd_alter_table('users', array( |
|
| 579 | + 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
|
| 580 | + 'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
| 581 | + ), strtoupper($update_tables['users']['ally_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 582 | + |
|
| 583 | + upd_do_query('DELETE FROM {{alliance}} WHERE id not in (select ally_id from {{users}} group by ally_id);'); |
|
| 584 | + upd_do_query("UPDATE {{users}} SET `ally_id` = null, ally_name = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` NOT IN (SELECT id FROM {{alliance}});"); |
|
| 585 | + upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
|
| 586 | + |
|
| 587 | + upd_alter_table('users', array( |
|
| 588 | + "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 589 | + "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{$config->db_prefix}alliance` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 590 | + ), !$update_foreigns['users']['FK_users_ally_id']); |
|
| 591 | + } |
|
| 597 | 592 | |
| 598 | - $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);"); |
|
| 599 | - while($illegal_moon_row = db_fetch($illegal_moon_query)) |
|
| 600 | - { |
|
| 601 | - upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
|
| 602 | - } |
|
| 593 | + upd_alter_table('planets', array( |
|
| 594 | + "MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
| 595 | + "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
| 596 | + ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 603 | 597 | |
| 604 | - upd_check_key('allow_buffing', isset($config->fleet_buffing_check) ? !$config->fleet_buffing_check : 0, !isset($config->allow_buffing)); |
|
| 605 | - upd_check_key('ally_help_weak', 0, !isset($config->ally_help_weak)); |
|
| 598 | + $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);"); |
|
| 599 | + while($illegal_moon_row = db_fetch($illegal_moon_query)) |
|
| 600 | + { |
|
| 601 | + upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
|
| 602 | + } |
|
| 606 | 603 | |
| 607 | - upd_do_query('COMMIT;', true); |
|
| 608 | - $new_version = 29; |
|
| 604 | + upd_check_key('allow_buffing', isset($config->fleet_buffing_check) ? !$config->fleet_buffing_check : 0, !isset($config->allow_buffing)); |
|
| 605 | + upd_check_key('ally_help_weak', 0, !isset($config->ally_help_weak)); |
|
| 606 | + |
|
| 607 | + upd_do_query('COMMIT;', true); |
|
| 608 | + $new_version = 29; |
|
| 609 | 609 | |
| 610 | - case 29: |
|
| 611 | - upd_log_version_update(); |
|
| 610 | + case 29: |
|
| 611 | + upd_log_version_update(); |
|
| 612 | 612 | |
| 613 | - upd_check_key('game_email_pm', 0, !isset($config->game_email_pm)); |
|
| 614 | - upd_check_key('player_vacation_time', 2*24*60*60, !isset($config->player_vacation_time)); |
|
| 615 | - upd_check_key('player_delete_time', 45*24*60*60, !isset($config->player_delete_time)); |
|
| 613 | + upd_check_key('game_email_pm', 0, !isset($config->game_email_pm)); |
|
| 614 | + upd_check_key('player_vacation_time', 2*24*60*60, !isset($config->player_vacation_time)); |
|
| 615 | + upd_check_key('player_delete_time', 45*24*60*60, !isset($config->player_delete_time)); |
|
| 616 | 616 | |
| 617 | - upd_create_table('log_dark_matter', |
|
| 618 | - "( |
|
| 617 | + upd_create_table('log_dark_matter', |
|
| 618 | + "( |
|
| 619 | 619 | `log_dark_matter_id` SERIAL, |
| 620 | 620 | `log_dark_matter_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp', |
| 621 | 621 | `log_dark_matter_username` varchar(64) NOT NULL DEFAULT '' COMMENT 'Username', |
@@ -630,23 +630,23 @@ discard block |
||
| 630 | 630 | KEY `i_log_dark_matter_reason_sender_id` (`log_dark_matter_reason`, `log_dark_matter_sender`, `log_dark_matter_id`), |
| 631 | 631 | KEY `i_log_dark_matter_amount` (`log_dark_matter_amount`) |
| 632 | 632 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
| 633 | - ); |
|
| 634 | - upd_do_query('COMMIT;', true); |
|
| 633 | + ); |
|
| 634 | + upd_do_query('COMMIT;', true); |
|
| 635 | 635 | |
| 636 | - $records = 1; |
|
| 637 | - while($records) |
|
| 638 | - { |
|
| 639 | - upd_do_query('START TRANSACTION;', true); |
|
| 640 | - $query = upd_do_query("SELECT * FROM {{logs}} WHERE log_code = 102 order by log_id LIMIT 1000;"); |
|
| 641 | - $records = db_num_rows($query); |
|
| 642 | - while($row = db_fetch($query)) |
|
| 636 | + $records = 1; |
|
| 637 | + while($records) |
|
| 643 | 638 | { |
| 644 | - $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
|
| 645 | - |
|
| 646 | - $reason = RPG_NONE; |
|
| 647 | - $comment = $matches[3]; |
|
| 648 | - switch($matches[3]) |
|
| 639 | + upd_do_query('START TRANSACTION;', true); |
|
| 640 | + $query = upd_do_query("SELECT * FROM {{logs}} WHERE log_code = 102 order by log_id LIMIT 1000;"); |
|
| 641 | + $records = db_num_rows($query); |
|
| 642 | + while($row = db_fetch($query)) |
|
| 649 | 643 | { |
| 644 | + $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
|
| 645 | + |
|
| 646 | + $reason = RPG_NONE; |
|
| 647 | + $comment = $matches[3]; |
|
| 648 | + switch($matches[3]) |
|
| 649 | + { |
|
| 650 | 650 | case 'Level Up For Structure Building': |
| 651 | 651 | $reason = RPG_STRUCTURE; |
| 652 | 652 | break; |
@@ -682,7 +682,7 @@ discard block |
||
| 682 | 682 | $comment = $matches2[1]; |
| 683 | 683 | } |
| 684 | 684 | break; |
| 685 | - } |
|
| 685 | + } |
|
| 686 | 686 | |
| 687 | 687 | if($matches[2]) |
| 688 | 688 | { |
@@ -720,595 +720,595 @@ discard block |
||
| 720 | 720 | upd_do_query('COMMIT;', true); |
| 721 | 721 | $new_version = 30; |
| 722 | 722 | |
| 723 | - case 30: |
|
| 724 | - upd_log_version_update(); |
|
| 723 | + case 30: |
|
| 724 | + upd_log_version_update(); |
|
| 725 | 725 | |
| 726 | - upd_alter_table('users', array( |
|
| 727 | - "ADD `player_que` TEXT" |
|
| 728 | - ), !$update_tables['users']['player_que']); |
|
| 726 | + upd_alter_table('users', array( |
|
| 727 | + "ADD `player_que` TEXT" |
|
| 728 | + ), !$update_tables['users']['player_que']); |
|
| 729 | 729 | |
| 730 | - upd_alter_table('planets', array( |
|
| 731 | - "CHANGE COLUMN `governor` `PLANET_GOVERNOR_ID` SMALLINT(5) NOT NULL DEFAULT 0", |
|
| 732 | - "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
|
| 733 | - ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
|
| 730 | + upd_alter_table('planets', array( |
|
| 731 | + "CHANGE COLUMN `governor` `PLANET_GOVERNOR_ID` SMALLINT(5) NOT NULL DEFAULT 0", |
|
| 732 | + "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
|
| 733 | + ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
|
| 734 | 734 | |
| 735 | - if($update_tables['users']['rpg_geologue']) |
|
| 736 | - { |
|
| 737 | - doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
|
| 735 | + if($update_tables['users']['rpg_geologue']) |
|
| 736 | + { |
|
| 737 | + doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
|
| 738 | + |
|
| 739 | + upd_alter_table('users', array( |
|
| 740 | + "DROP COLUMN `rpg_geologue`", |
|
| 741 | + "DROP COLUMN `rpg_ingenieur`", |
|
| 742 | + "DROP COLUMN `rpg_constructeur`", |
|
| 743 | + "DROP COLUMN `rpg_technocrate`", |
|
| 744 | + "DROP COLUMN `rpg_scientifique`", |
|
| 745 | + "DROP COLUMN `rpg_defenseur`", |
|
| 746 | + ), $update_tables['users']['rpg_geologue']); |
|
| 747 | + } |
|
| 738 | 748 | |
| 739 | - upd_alter_table('users', array( |
|
| 740 | - "DROP COLUMN `rpg_geologue`", |
|
| 741 | - "DROP COLUMN `rpg_ingenieur`", |
|
| 742 | - "DROP COLUMN `rpg_constructeur`", |
|
| 743 | - "DROP COLUMN `rpg_technocrate`", |
|
| 744 | - "DROP COLUMN `rpg_scientifique`", |
|
| 745 | - "DROP COLUMN `rpg_defenseur`", |
|
| 746 | - ), $update_tables['users']['rpg_geologue']); |
|
| 747 | - } |
|
| 749 | + if($update_tables['users']['rpg_bunker']) |
|
| 750 | + { |
|
| 751 | + doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
|
| 748 | 752 | |
| 749 | - if($update_tables['users']['rpg_bunker']) |
|
| 750 | - { |
|
| 751 | - doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
|
| 753 | + upd_alter_table('users', array( |
|
| 754 | + "DROP COLUMN `rpg_bunker`", |
|
| 755 | + ), $update_tables['users']['rpg_bunker']); |
|
| 756 | + } |
|
| 752 | 757 | |
| 753 | 758 | upd_alter_table('users', array( |
| 754 | - "DROP COLUMN `rpg_bunker`", |
|
| 755 | - ), $update_tables['users']['rpg_bunker']); |
|
| 756 | - } |
|
| 759 | + "DROP COLUMN `p_infligees`", |
|
| 760 | + "MODIFY COLUMN `dark_matter` BIGINT(20) DEFAULT '0' AFTER `lvl_raid`", |
|
| 761 | + ), $update_tables['users']['p_infligees']); |
|
| 757 | 762 | |
| 758 | - upd_alter_table('users', array( |
|
| 759 | - "DROP COLUMN `p_infligees`", |
|
| 760 | - "MODIFY COLUMN `dark_matter` BIGINT(20) DEFAULT '0' AFTER `lvl_raid`", |
|
| 761 | - ), $update_tables['users']['p_infligees']); |
|
| 762 | - |
|
| 763 | - upd_alter_table('users', array( |
|
| 764 | - "ADD COLUMN `mrc_academic` SMALLINT(3) DEFAULT 0", |
|
| 765 | - ), !$update_tables['users']['mrc_academic']); |
|
| 766 | - |
|
| 767 | - upd_alter_table('users', array( |
|
| 768 | - "DROP COLUMN `db_deaktjava`", |
|
| 769 | - "DROP COLUMN `kolorminus`", |
|
| 770 | - "DROP COLUMN `kolorplus`", |
|
| 771 | - "DROP COLUMN `kolorpoziom`", |
|
| 772 | - "DROP COLUMN `deleteme`", |
|
| 773 | - |
|
| 774 | - "MODIFY COLUMN `xpraid` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 775 | - "MODIFY COLUMN `xpminier` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 776 | - "MODIFY COLUMN `raids` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 777 | - "MODIFY COLUMN `raidsloose` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 778 | - "MODIFY COLUMN `raidswin` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 779 | - |
|
| 780 | - "MODIFY COLUMN `register_time` INT(10) UNSIGNED DEFAULT '0'", |
|
| 781 | - "MODIFY COLUMN `onlinetime` INT(10) UNSIGNED DEFAULT '0'", |
|
| 782 | - "MODIFY COLUMN `news_lastread` INT(10) UNSIGNED DEFAULT '0'", |
|
| 783 | - "MODIFY COLUMN `deltime` INT(10) UNSIGNED DEFAULT '0'", |
|
| 784 | - "MODIFY COLUMN `banaday` INT(10) UNSIGNED DEFAULT '0'", |
|
| 785 | - "MODIFY COLUMN `vacation` INT(10) UNSIGNED DEFAULT '0'", |
|
| 786 | - ), strtoupper($update_tables['users']['xpraid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 787 | - |
|
| 788 | - upd_alter_table('users', array( |
|
| 789 | - "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
| 790 | - "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
| 791 | - ), !isset($update_tables['users']['total_rank'])); |
|
| 792 | - doquery("UPDATE {{users}} AS u JOIN {{statpoints}} AS sp ON sp.id_owner = u.id AND sp.stat_code = 1 AND sp.stat_type = 1 SET u.total_rank = sp.total_rank, u.total_points = sp.total_points;"); |
|
| 793 | - |
|
| 794 | - upd_alter_table('alliance', array( |
|
| 795 | - "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
| 796 | - "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
| 797 | - ), !isset($update_tables['alliance']['total_rank'])); |
|
| 798 | - doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;"); |
|
| 799 | - |
|
| 800 | - if(!isset($update_tables['users']['ally_tag'])) |
|
| 801 | - { |
|
| 802 | 763 | upd_alter_table('users', array( |
| 803 | - "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
| 804 | - ), !isset($update_tables['users']['ally_tag'])); |
|
| 805 | - doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_tag = a.ally_tag, u.ally_name = a.ally_name;"); |
|
| 806 | - doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_id = NULL, u.ally_tag = NULL, u.ally_name = NULL, u.ally_register_time = 0, ally_rank_id = 0 WHERE a.id is NULL;"); |
|
| 764 | + "ADD COLUMN `mrc_academic` SMALLINT(3) DEFAULT 0", |
|
| 765 | + ), !$update_tables['users']['mrc_academic']); |
|
| 766 | + |
|
| 807 | 767 | upd_alter_table('users', array( |
| 808 | - "ADD CONSTRAINT `FK_users_ally_tag` FOREIGN KEY (`ally_tag`) REFERENCES `{$config->db_prefix}alliance` (`ally_tag`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 809 | - ), !$update_foreigns['users']['FK_users_ally_tag']); |
|
| 810 | - } |
|
| 768 | + "DROP COLUMN `db_deaktjava`", |
|
| 769 | + "DROP COLUMN `kolorminus`", |
|
| 770 | + "DROP COLUMN `kolorplus`", |
|
| 771 | + "DROP COLUMN `kolorpoziom`", |
|
| 772 | + "DROP COLUMN `deleteme`", |
|
| 773 | + |
|
| 774 | + "MODIFY COLUMN `xpraid` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 775 | + "MODIFY COLUMN `xpminier` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 776 | + "MODIFY COLUMN `raids` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 777 | + "MODIFY COLUMN `raidsloose` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 778 | + "MODIFY COLUMN `raidswin` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
| 779 | + |
|
| 780 | + "MODIFY COLUMN `register_time` INT(10) UNSIGNED DEFAULT '0'", |
|
| 781 | + "MODIFY COLUMN `onlinetime` INT(10) UNSIGNED DEFAULT '0'", |
|
| 782 | + "MODIFY COLUMN `news_lastread` INT(10) UNSIGNED DEFAULT '0'", |
|
| 783 | + "MODIFY COLUMN `deltime` INT(10) UNSIGNED DEFAULT '0'", |
|
| 784 | + "MODIFY COLUMN `banaday` INT(10) UNSIGNED DEFAULT '0'", |
|
| 785 | + "MODIFY COLUMN `vacation` INT(10) UNSIGNED DEFAULT '0'", |
|
| 786 | + ), strtoupper($update_tables['users']['xpraid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 811 | 787 | |
| 812 | - upd_alter_table('users', array( |
|
| 813 | - "ADD COLUMN `player_artifact_list` TEXT", |
|
| 814 | - ), !isset($update_tables['users']['player_artifact_list'])); |
|
| 788 | + upd_alter_table('users', array( |
|
| 789 | + "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
| 790 | + "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
| 791 | + ), !isset($update_tables['users']['total_rank'])); |
|
| 792 | + doquery("UPDATE {{users}} AS u JOIN {{statpoints}} AS sp ON sp.id_owner = u.id AND sp.stat_code = 1 AND sp.stat_type = 1 SET u.total_rank = sp.total_rank, u.total_points = sp.total_points;"); |
|
| 815 | 793 | |
| 816 | - if(!isset($update_tables['users']['player_rpg_tech_xp'])) |
|
| 817 | - { |
|
| 818 | - upd_check_key('eco_scale_storage', 1, !isset($config->eco_scale_storage)); |
|
| 794 | + upd_alter_table('alliance', array( |
|
| 795 | + "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
| 796 | + "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
| 797 | + ), !isset($update_tables['alliance']['total_rank'])); |
|
| 798 | + doquery("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;"); |
|
| 799 | + |
|
| 800 | + if(!isset($update_tables['users']['ally_tag'])) |
|
| 801 | + { |
|
| 802 | + upd_alter_table('users', array( |
|
| 803 | + "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
| 804 | + ), !isset($update_tables['users']['ally_tag'])); |
|
| 805 | + doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_tag = a.ally_tag, u.ally_name = a.ally_name;"); |
|
| 806 | + doquery("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON a.id = u.ally_id SET u.ally_id = NULL, u.ally_tag = NULL, u.ally_name = NULL, u.ally_register_time = 0, ally_rank_id = 0 WHERE a.id is NULL;"); |
|
| 807 | + upd_alter_table('users', array( |
|
| 808 | + "ADD CONSTRAINT `FK_users_ally_tag` FOREIGN KEY (`ally_tag`) REFERENCES `{$config->db_prefix}alliance` (`ally_tag`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 809 | + ), !$update_foreigns['users']['FK_users_ally_tag']); |
|
| 810 | + } |
|
| 819 | 811 | |
| 820 | 812 | upd_alter_table('users', array( |
| 821 | - "ADD COLUMN `player_rpg_tech_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
| 822 | - "ADD COLUMN `player_rpg_tech_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
| 823 | - ), !isset($update_tables['users']['player_rpg_tech_xp'])); |
|
| 813 | + "ADD COLUMN `player_artifact_list` TEXT", |
|
| 814 | + ), !isset($update_tables['users']['player_artifact_list'])); |
|
| 824 | 815 | |
| 825 | - doquery("UPDATE {{users}} AS u LEFT JOIN {{statpoints}} AS s ON s.id_owner = u.id AND s.stat_type = 1 AND s.stat_code = 1 SET u.player_rpg_tech_xp = s.tech_points;"); |
|
| 826 | - } |
|
| 816 | + if(!isset($update_tables['users']['player_rpg_tech_xp'])) |
|
| 817 | + { |
|
| 818 | + upd_check_key('eco_scale_storage', 1, !isset($config->eco_scale_storage)); |
|
| 827 | 819 | |
| 828 | - upd_alter_table('planets', array( |
|
| 829 | - "ADD COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `big_ship_cargo`", |
|
| 830 | - ), !isset($update_tables['planets']['planet_cargo_hyper'])); |
|
| 820 | + upd_alter_table('users', array( |
|
| 821 | + "ADD COLUMN `player_rpg_tech_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
| 822 | + "ADD COLUMN `player_rpg_tech_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
| 823 | + ), !isset($update_tables['users']['player_rpg_tech_xp'])); |
|
| 831 | 824 | |
| 832 | - upd_do_query('COMMIT;', true); |
|
| 833 | - $new_version = 31; |
|
| 825 | + doquery("UPDATE {{users}} AS u LEFT JOIN {{statpoints}} AS s ON s.id_owner = u.id AND s.stat_type = 1 AND s.stat_code = 1 SET u.player_rpg_tech_xp = s.tech_points;"); |
|
| 826 | + } |
|
| 834 | 827 | |
| 835 | - case 31: |
|
| 836 | - upd_log_version_update(); |
|
| 828 | + upd_alter_table('planets', array( |
|
| 829 | + "ADD COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `big_ship_cargo`", |
|
| 830 | + ), !isset($update_tables['planets']['planet_cargo_hyper'])); |
|
| 837 | 831 | |
| 838 | - upd_alter_table('aks', array( |
|
| 839 | - "MODIFY COLUMN `planet_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
| 840 | - ), strtoupper($update_tables['aks']['planet_type']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
| 832 | + upd_do_query('COMMIT;', true); |
|
| 833 | + $new_version = 31; |
|
| 841 | 834 | |
| 842 | - upd_alter_table('alliance', array( |
|
| 843 | - "MODIFY COLUMN `ally_request_notallow` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
| 844 | - "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 845 | - ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 835 | + case 31: |
|
| 836 | + upd_log_version_update(); |
|
| 846 | 837 | |
| 847 | - if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 848 | - { |
|
| 849 | - upd_alter_table('alliance_diplomacy', array( |
|
| 850 | - "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
|
| 851 | - "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`" |
|
| 852 | - ), true); |
|
| 853 | - |
|
| 854 | - upd_alter_table('alliance_diplomacy', array( |
|
| 855 | - "MODIFY COLUMN `alliance_diplomacy_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 856 | - "MODIFY COLUMN `alliance_diplomacy_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 857 | - |
|
| 858 | - "ADD CONSTRAINT `FK_diplomacy_ally_id` FOREIGN KEY (`alliance_diplomacy_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 859 | - "ADD CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 860 | - ), true); |
|
| 861 | - } |
|
| 838 | + upd_alter_table('aks', array( |
|
| 839 | + "MODIFY COLUMN `planet_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
| 840 | + ), strtoupper($update_tables['aks']['planet_type']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
| 862 | 841 | |
| 863 | - if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 864 | - { |
|
| 865 | - upd_alter_table('alliance_negotiation', array( |
|
| 866 | - "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
|
| 867 | - "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`" |
|
| 868 | - ), true); |
|
| 869 | - |
|
| 870 | - upd_alter_table('alliance_negotiation', array( |
|
| 871 | - "MODIFY COLUMN `alliance_negotiation_status` TINYINT(1) NOT NULL DEFAULT 0", |
|
| 872 | - "MODIFY COLUMN `alliance_negotiation_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 873 | - "MODIFY COLUMN `alliance_negotiation_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 874 | - |
|
| 875 | - "ADD CONSTRAINT `FK_negotiation_ally_id` FOREIGN KEY (`alliance_negotiation_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 876 | - "ADD CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 877 | - ), true); |
|
| 878 | - } |
|
| 842 | + upd_alter_table('alliance', array( |
|
| 843 | + "MODIFY COLUMN `ally_request_notallow` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
| 844 | + "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 845 | + ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 879 | 846 | |
| 880 | - if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 881 | - { |
|
| 882 | - upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
|
| 847 | + if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 848 | + { |
|
| 849 | + upd_alter_table('alliance_diplomacy', array( |
|
| 850 | + "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
|
| 851 | + "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`" |
|
| 852 | + ), true); |
|
| 853 | + |
|
| 854 | + upd_alter_table('alliance_diplomacy', array( |
|
| 855 | + "MODIFY COLUMN `alliance_diplomacy_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 856 | + "MODIFY COLUMN `alliance_diplomacy_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 857 | + |
|
| 858 | + "ADD CONSTRAINT `FK_diplomacy_ally_id` FOREIGN KEY (`alliance_diplomacy_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 859 | + "ADD CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 860 | + ), true); |
|
| 861 | + } |
|
| 883 | 862 | |
| 884 | - upd_alter_table('alliance_requests', array( |
|
| 885 | - "MODIFY COLUMN `id_user` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 886 | - "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 863 | + if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 864 | + { |
|
| 865 | + upd_alter_table('alliance_negotiation', array( |
|
| 866 | + "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
|
| 867 | + "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`" |
|
| 868 | + ), true); |
|
| 869 | + |
|
| 870 | + upd_alter_table('alliance_negotiation', array( |
|
| 871 | + "MODIFY COLUMN `alliance_negotiation_status` TINYINT(1) NOT NULL DEFAULT 0", |
|
| 872 | + "MODIFY COLUMN `alliance_negotiation_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 873 | + "MODIFY COLUMN `alliance_negotiation_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 874 | + |
|
| 875 | + "ADD CONSTRAINT `FK_negotiation_ally_id` FOREIGN KEY (`alliance_negotiation_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 876 | + "ADD CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 877 | + ), true); |
|
| 878 | + } |
|
| 887 | 879 | |
| 888 | - "ADD KEY `I_alliance_requests_id_ally` (`id_ally`, `id_user`)", |
|
| 880 | + if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 881 | + { |
|
| 882 | + upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
|
| 889 | 883 | |
| 890 | - "ADD CONSTRAINT `FK_alliance_request_user_id` FOREIGN KEY (`id_user`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 891 | - "ADD CONSTRAINT `FK_alliance_request_ally_id` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 892 | - ), true); |
|
| 893 | - } |
|
| 884 | + upd_alter_table('alliance_requests', array( |
|
| 885 | + "MODIFY COLUMN `id_user` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 886 | + "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 894 | 887 | |
| 895 | - if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 896 | - { |
|
| 897 | - upd_do_query('DELETE FROM {{annonce}} WHERE user NOT IN (SELECT username FROM {{users}});', true); |
|
| 888 | + "ADD KEY `I_alliance_requests_id_ally` (`id_ally`, `id_user`)", |
|
| 898 | 889 | |
| 899 | - upd_alter_table('annonce', array( |
|
| 900 | - "MODIFY COLUMN `id` SERIAL", |
|
| 901 | - "MODIFY COLUMN `user` VARCHAR(64) DEFAULT NULL", |
|
| 890 | + "ADD CONSTRAINT `FK_alliance_request_user_id` FOREIGN KEY (`id_user`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 891 | + "ADD CONSTRAINT `FK_alliance_request_ally_id` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 892 | + ), true); |
|
| 893 | + } |
|
| 902 | 894 | |
| 903 | - "ADD KEY `I_annonce_user` (`user`, `id`)", |
|
| 895 | + if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 896 | + { |
|
| 897 | + upd_do_query('DELETE FROM {{annonce}} WHERE user NOT IN (SELECT username FROM {{users}});', true); |
|
| 904 | 898 | |
| 905 | - "ADD CONSTRAINT `FK_annonce_user` FOREIGN KEY (`user`) REFERENCES `{$config->db_prefix}users` (`username`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 906 | - ), true); |
|
| 907 | - } |
|
| 899 | + upd_alter_table('annonce', array( |
|
| 900 | + "MODIFY COLUMN `id` SERIAL", |
|
| 901 | + "MODIFY COLUMN `user` VARCHAR(64) DEFAULT NULL", |
|
| 908 | 902 | |
| 909 | - if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 910 | - { |
|
| 911 | - upd_alter_table('bashing', array( |
|
| 912 | - "DROP FOREIGN KEY `FK_bashing_user_id`", |
|
| 913 | - "DROP FOREIGN KEY `FK_bashing_planet_id`", |
|
| 914 | - ), true); |
|
| 915 | - |
|
| 916 | - upd_alter_table('bashing', array( |
|
| 917 | - "MODIFY COLUMN `bashing_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 918 | - "MODIFY COLUMN `bashing_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 919 | - |
|
| 920 | - "ADD CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 921 | - "ADD CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 922 | - ), true); |
|
| 923 | - } |
|
| 903 | + "ADD KEY `I_annonce_user` (`user`, `id`)", |
|
| 924 | 904 | |
| 925 | - if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 926 | - { |
|
| 927 | - upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR owner NOT IN (SELECT id FROM {{users}});', true); |
|
| 905 | + "ADD CONSTRAINT `FK_annonce_user` FOREIGN KEY (`user`) REFERENCES `{$config->db_prefix}users` (`username`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 906 | + ), true); |
|
| 907 | + } |
|
| 928 | 908 | |
| 929 | - upd_alter_table('buddy', array( |
|
| 930 | - "MODIFY COLUMN `id` SERIAL", |
|
| 931 | - "MODIFY COLUMN `sender` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 932 | - "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 933 | - "MODIFY COLUMN `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
| 909 | + if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 910 | + { |
|
| 911 | + upd_alter_table('bashing', array( |
|
| 912 | + "DROP FOREIGN KEY `FK_bashing_user_id`", |
|
| 913 | + "DROP FOREIGN KEY `FK_bashing_planet_id`", |
|
| 914 | + ), true); |
|
| 915 | + |
|
| 916 | + upd_alter_table('bashing', array( |
|
| 917 | + "MODIFY COLUMN `bashing_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 918 | + "MODIFY COLUMN `bashing_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 919 | + |
|
| 920 | + "ADD CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 921 | + "ADD CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 922 | + ), true); |
|
| 923 | + } |
|
| 934 | 924 | |
| 935 | - "ADD KEY `I_buddy_sender` (`sender`)", |
|
| 936 | - "ADD KEY `I_buddy_owner` (`owner`)", |
|
| 925 | + if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 926 | + { |
|
| 927 | + upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR owner NOT IN (SELECT id FROM {{users}});', true); |
|
| 937 | 928 | |
| 938 | - "ADD CONSTRAINT `FK_buddy_sender_id` FOREIGN KEY (`sender`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 939 | - "ADD CONSTRAINT `FK_buddy_owner_id` FOREIGN KEY (`owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 940 | - ), true); |
|
| 941 | - } |
|
| 929 | + upd_alter_table('buddy', array( |
|
| 930 | + "MODIFY COLUMN `id` SERIAL", |
|
| 931 | + "MODIFY COLUMN `sender` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 932 | + "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 933 | + "MODIFY COLUMN `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
| 942 | 934 | |
| 943 | - upd_alter_table('chat', array( |
|
| 944 | - "MODIFY COLUMN `messageid` SERIAL", |
|
| 945 | - ), strtoupper($update_tables['chat']['messageid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 935 | + "ADD KEY `I_buddy_sender` (`sender`)", |
|
| 936 | + "ADD KEY `I_buddy_owner` (`owner`)", |
|
| 946 | 937 | |
| 947 | - upd_alter_table('counter', array( |
|
| 948 | - "CHANGE COLUMN `id` `counter_id` SERIAL", |
|
| 938 | + "ADD CONSTRAINT `FK_buddy_sender_id` FOREIGN KEY (`sender`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 939 | + "ADD CONSTRAINT `FK_buddy_owner_id` FOREIGN KEY (`owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 940 | + ), true); |
|
| 941 | + } |
|
| 949 | 942 | |
| 950 | - "MODIFY COLUMN `user_id` BIGINT(20) UNSIGNED DEFAULT 0", |
|
| 943 | + upd_alter_table('chat', array( |
|
| 944 | + "MODIFY COLUMN `messageid` SERIAL", |
|
| 945 | + ), strtoupper($update_tables['chat']['messageid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 951 | 946 | |
| 952 | - "ADD COLUMN `user_name` VARCHAR(64) DEFAULT '' AFTER `user_id`", |
|
| 947 | + upd_alter_table('counter', array( |
|
| 948 | + "CHANGE COLUMN `id` `counter_id` SERIAL", |
|
| 953 | 949 | |
| 954 | - "ADD KEY `I_counter_user_name` (`user_name`)", |
|
| 955 | - ), strtoupper($update_tables['counter']['counter_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 950 | + "MODIFY COLUMN `user_id` BIGINT(20) UNSIGNED DEFAULT 0", |
|
| 956 | 951 | |
| 957 | - upd_alter_table('fleets', array( |
|
| 958 | - "MODIFY COLUMN `fleet_id` SERIAL", |
|
| 959 | - "MODIFY COLUMN `fleet_resource_metal` DECIMAL(65,0) DEFAULT '0'", |
|
| 960 | - "MODIFY COLUMN `fleet_resource_crystal` DECIMAL(65,0) DEFAULT '0'", |
|
| 961 | - "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
|
| 962 | - ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
|
| 952 | + "ADD COLUMN `user_name` VARCHAR(64) DEFAULT '' AFTER `user_id`", |
|
| 963 | 953 | |
| 964 | - if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 965 | - { |
|
| 966 | - upd_do_query('DELETE FROM {{iraks}} WHERE owner NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
|
| 954 | + "ADD KEY `I_counter_user_name` (`user_name`)", |
|
| 955 | + ), strtoupper($update_tables['counter']['counter_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 967 | 956 | |
| 968 | - upd_alter_table('iraks', array( |
|
| 969 | - "CHANGE COLUMN `zeit` `fleet_end_time` INT(11) UNSIGNED NOT NULL DEFAULT 0", |
|
| 970 | - "CHANGE COLUMN `zielid` `fleet_target_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 971 | - "CHANGE COLUMN `owner` `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 972 | - "CHANGE COLUMN `anzahl` `fleet_amount` BIGINT(20) UNSIGNED DEFAULT 0", |
|
| 973 | - "CHANGE COLUMN `galaxy_angreifer` `fleet_start_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
| 974 | - "CHANGE COLUMN `system_angreifer` `fleet_start_system` INT(4) UNSIGNED DEFAULT 0", |
|
| 975 | - "CHANGE COLUMN `planet_angreifer` `fleet_start_planet` INT(2) UNSIGNED DEFAULT 0", |
|
| 976 | - |
|
| 977 | - "CHANGE COLUMN `galaxy` `fleet_end_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
| 978 | - "CHANGE COLUMN `system` `fleet_end_system` INT(4) UNSIGNED DEFAULT 0", |
|
| 979 | - "CHANGE COLUMN `planet` `fleet_end_planet` INT(2) UNSIGNED DEFAULT 0", |
|
| 980 | - |
|
| 981 | - "ADD KEY `I_iraks_fleet_owner` (`fleet_owner`)", |
|
| 982 | - "ADD KEY `I_iraks_fleet_target_owner` (`fleet_target_owner`)", |
|
| 983 | - |
|
| 984 | - "ADD CONSTRAINT `FK_iraks_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 985 | - "ADD CONSTRAINT `FK_iraks_fleet_target_owner` FOREIGN KEY (`fleet_target_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 986 | - ), true); |
|
| 987 | - } |
|
| 957 | + upd_alter_table('fleets', array( |
|
| 958 | + "MODIFY COLUMN `fleet_id` SERIAL", |
|
| 959 | + "MODIFY COLUMN `fleet_resource_metal` DECIMAL(65,0) DEFAULT '0'", |
|
| 960 | + "MODIFY COLUMN `fleet_resource_crystal` DECIMAL(65,0) DEFAULT '0'", |
|
| 961 | + "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
|
| 962 | + ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
|
| 988 | 963 | |
| 989 | - if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 990 | - { |
|
| 991 | - upd_do_query('DELETE FROM {{notes}} WHERE owner NOT IN (SELECT id FROM {{users}});', true); |
|
| 964 | + if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 965 | + { |
|
| 966 | + upd_do_query('DELETE FROM {{iraks}} WHERE owner NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
|
| 967 | + |
|
| 968 | + upd_alter_table('iraks', array( |
|
| 969 | + "CHANGE COLUMN `zeit` `fleet_end_time` INT(11) UNSIGNED NOT NULL DEFAULT 0", |
|
| 970 | + "CHANGE COLUMN `zielid` `fleet_target_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 971 | + "CHANGE COLUMN `owner` `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 972 | + "CHANGE COLUMN `anzahl` `fleet_amount` BIGINT(20) UNSIGNED DEFAULT 0", |
|
| 973 | + "CHANGE COLUMN `galaxy_angreifer` `fleet_start_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
| 974 | + "CHANGE COLUMN `system_angreifer` `fleet_start_system` INT(4) UNSIGNED DEFAULT 0", |
|
| 975 | + "CHANGE COLUMN `planet_angreifer` `fleet_start_planet` INT(2) UNSIGNED DEFAULT 0", |
|
| 976 | + |
|
| 977 | + "CHANGE COLUMN `galaxy` `fleet_end_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
| 978 | + "CHANGE COLUMN `system` `fleet_end_system` INT(4) UNSIGNED DEFAULT 0", |
|
| 979 | + "CHANGE COLUMN `planet` `fleet_end_planet` INT(2) UNSIGNED DEFAULT 0", |
|
| 980 | + |
|
| 981 | + "ADD KEY `I_iraks_fleet_owner` (`fleet_owner`)", |
|
| 982 | + "ADD KEY `I_iraks_fleet_target_owner` (`fleet_target_owner`)", |
|
| 983 | + |
|
| 984 | + "ADD CONSTRAINT `FK_iraks_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 985 | + "ADD CONSTRAINT `FK_iraks_fleet_target_owner` FOREIGN KEY (`fleet_target_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 986 | + ), true); |
|
| 987 | + } |
|
| 992 | 988 | |
| 993 | - upd_alter_table('notes', array( |
|
| 994 | - "MODIFY COLUMN id SERIAL", |
|
| 995 | - "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 989 | + if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 990 | + { |
|
| 991 | + upd_do_query('DELETE FROM {{notes}} WHERE owner NOT IN (SELECT id FROM {{users}});', true); |
|
| 996 | 992 | |
| 997 | - "ADD KEY `I_notes_owner` (`owner`)", |
|
| 993 | + upd_alter_table('notes', array( |
|
| 994 | + "MODIFY COLUMN id SERIAL", |
|
| 995 | + "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 998 | 996 | |
| 999 | - "ADD CONSTRAINT `FK_notes_owner` FOREIGN KEY (`owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1000 | - ), true); |
|
| 1001 | - } |
|
| 997 | + "ADD KEY `I_notes_owner` (`owner`)", |
|
| 1002 | 998 | |
| 1003 | - upd_alter_table('planets', array( |
|
| 1004 | - "MODIFY COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT", |
|
| 1005 | - "MODIFY COLUMN `name` VARCHAR(64) DEFAULT 'Planet' NOT NULL", |
|
| 1006 | - "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1007 | - "MODIFY COLUMN `galaxy` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1008 | - "MODIFY COLUMN `system` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1009 | - "MODIFY COLUMN `planet` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1010 | - "MODIFY COLUMN `planet_type` TINYINT NOT NULL DEFAULT '1'", |
|
| 1011 | - |
|
| 1012 | - "MODIFY COLUMN `metal` DECIMAL(65,5) NOT NULL DEFAULT '0'", |
|
| 1013 | - "MODIFY COLUMN `crystal` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `metal`", |
|
| 1014 | - "MODIFY COLUMN `deuterium` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `crystal`", |
|
| 1015 | - "MODIFY COLUMN `energy_max` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `deuterium`", |
|
| 1016 | - "MODIFY COLUMN `energy_used` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `energy_max`", |
|
| 1017 | - |
|
| 1018 | - "MODIFY COLUMN `metal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1019 | - "MODIFY COLUMN `crystal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1020 | - "MODIFY COLUMN `deuterium_sintetizer` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1021 | - "MODIFY COLUMN `solar_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1022 | - "MODIFY COLUMN `fusion_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1023 | - "MODIFY COLUMN `robot_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1024 | - "MODIFY COLUMN `nano_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1025 | - "MODIFY COLUMN `hangar` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1026 | - "MODIFY COLUMN `metal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1027 | - "MODIFY COLUMN `crystal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1028 | - "MODIFY COLUMN `deuterium_store` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1029 | - "MODIFY COLUMN `laboratory` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1030 | - "MODIFY COLUMN `nano` SMALLINT DEFAULT '0' AFTER `laboratory`", |
|
| 1031 | - "MODIFY COLUMN `terraformer` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1032 | - "MODIFY COLUMN `ally_deposit` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1033 | - "MODIFY COLUMN `silo` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1034 | - "MODIFY COLUMN `mondbasis` SMALLINT NOT NULL DEFAULT '0' AFTER `silo`", |
|
| 1035 | - "MODIFY COLUMN `phalanx` SMALLINT NOT NULL DEFAULT '0' AFTER `mondbasis`", |
|
| 1036 | - "MODIFY COLUMN `sprungtor` SMALLINT NOT NULL DEFAULT '0' AFTER `phalanx`", |
|
| 1037 | - "MODIFY COLUMN `last_jump_time` int(11) NOT NULL DEFAULT '0' AFTER `sprungtor`", |
|
| 1038 | - |
|
| 1039 | - "MODIFY COLUMN `small_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1040 | - "MODIFY COLUMN `big_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1041 | - "MODIFY COLUMN `supercargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count' AFTER `big_ship_cargo`", |
|
| 1042 | - "MODIFY COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `supercargo`", |
|
| 1043 | - "MODIFY COLUMN `recycler` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `planet_cargo_hyper`", |
|
| 1044 | - "MODIFY COLUMN `colonizer` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `recycler`", |
|
| 1045 | - "MODIFY COLUMN `spy_sonde` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `colonizer`", |
|
| 1046 | - "MODIFY COLUMN `solar_satelit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `spy_sonde`", |
|
| 1047 | - |
|
| 1048 | - "MODIFY COLUMN `light_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1049 | - "MODIFY COLUMN `heavy_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1050 | - "MODIFY COLUMN `crusher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1051 | - "MODIFY COLUMN `battle_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1052 | - "MODIFY COLUMN `bomber_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1053 | - "MODIFY COLUMN `battleship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `bomber_ship`", |
|
| 1054 | - "MODIFY COLUMN `destructor` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1055 | - "MODIFY COLUMN `dearth_star` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1056 | - "MODIFY COLUMN `supernova` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1057 | - |
|
| 1058 | - "MODIFY COLUMN `misil_launcher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1059 | - "MODIFY COLUMN `small_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1060 | - "MODIFY COLUMN `big_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1061 | - "MODIFY COLUMN `gauss_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1062 | - "MODIFY COLUMN `ionic_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1063 | - "MODIFY COLUMN `buster_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1064 | - |
|
| 1065 | - "MODIFY COLUMN `small_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
| 1066 | - "MODIFY COLUMN `big_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
| 1067 | - "MODIFY COLUMN `planet_protector` tinyint(1) NOT NULL DEFAULT '0'", |
|
| 1068 | - |
|
| 1069 | - "MODIFY COLUMN `interceptor_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1070 | - "MODIFY COLUMN `interplanetary_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1071 | - |
|
| 1072 | - "MODIFY COLUMN `metal_perhour` INT NOT NULL DEFAULT '0' AFTER `interplanetary_misil`", |
|
| 1073 | - "MODIFY COLUMN `crystal_perhour` INT NOT NULL DEFAULT '0' AFTER `metal_perhour`", |
|
| 1074 | - "MODIFY COLUMN `deuterium_perhour` INT NOT NULL DEFAULT '0' AFTER `crystal_perhour`", |
|
| 1075 | - |
|
| 1076 | - "MODIFY COLUMN `metal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1077 | - "MODIFY COLUMN `crystal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1078 | - "MODIFY COLUMN `deuterium_sintetizer_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1079 | - "MODIFY COLUMN `solar_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1080 | - "MODIFY COLUMN `fusion_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1081 | - "MODIFY COLUMN `solar_satelit_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1082 | - |
|
| 1083 | - "MODIFY COLUMN `que` TEXT COMMENT 'Planet que' AFTER `solar_satelit_porcent`", |
|
| 1084 | -// "MODIFY COLUMN `b_tech` INT(11) NOT NULL DEFAULT 0 AFTER `que`", |
|
| 1085 | -// "MODIFY COLUMN `b_tech_id` SMALLINT NOT NULL DEFAULT 0 AFTER `b_tech`", |
|
| 1086 | - "MODIFY COLUMN `b_hangar` INT(11) NOT NULL DEFAULT '0' AFTER `que`", |
|
| 1087 | - "MODIFY COLUMN `b_hangar_id` TEXT AFTER `b_hangar`", |
|
| 1088 | - "MODIFY COLUMN `last_update` INT(11) DEFAULT NULL AFTER `b_hangar_id`", |
|
| 1089 | - |
|
| 1090 | - "MODIFY COLUMN `image` varchar(64) NOT NULL DEFAULT 'normaltempplanet01' AFTER `last_update`", |
|
| 1091 | - "MODIFY COLUMN `points` bigint(20) DEFAULT '0' AFTER `image`", |
|
| 1092 | - "MODIFY COLUMN `ranks` bigint(20) DEFAULT '0' AFTER `points`", |
|
| 1093 | - "MODIFY COLUMN `id_level` TINYINT NOT NULL DEFAULT '0' AFTER `ranks`", |
|
| 1094 | - "MODIFY COLUMN `destruyed` int(11) NOT NULL DEFAULT '0' AFTER `id_level`", |
|
| 1095 | - "MODIFY COLUMN `diameter` int(11) NOT NULL DEFAULT '12800' AFTER `destruyed`", |
|
| 1096 | - "MODIFY COLUMN `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT '163' AFTER `diameter`", |
|
| 1097 | - "MODIFY COLUMN `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT '0' AFTER `field_max`", |
|
| 1098 | - "MODIFY COLUMN `temp_min` SMALLINT NOT NULL DEFAULT '0' AFTER `field_current`", |
|
| 1099 | - "MODIFY COLUMN `temp_max` SMALLINT NOT NULL DEFAULT '40' AFTER `temp_min`", |
|
| 1100 | - |
|
| 1101 | - "MODIFY COLUMN `metal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `temp_max`", |
|
| 1102 | - "MODIFY COLUMN `crystal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `metal_max`", |
|
| 1103 | - "MODIFY COLUMN `deuterium_max` DECIMAL(65,0) DEFAULT '100000' AFTER `crystal_max`", |
|
| 1104 | - |
|
| 1105 | - "MODIFY COLUMN `debris_metal` bigint(20) unsigned DEFAULT '0'", |
|
| 1106 | - "MODIFY COLUMN `debris_crystal` bigint(20) unsigned DEFAULT '0'", |
|
| 1107 | - "MODIFY COLUMN `PLANET_GOVERNOR_ID` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1108 | - "MODIFY COLUMN `PLANET_GOVERNOR_LEVEL` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1109 | - |
|
| 1110 | - "MODIFY COLUMN `parent_planet` BIGINT(20) unsigned DEFAULT '0'", |
|
| 1111 | - |
|
| 1112 | - "DROP COLUMN `b_hangar_plus`", |
|
| 1113 | - ), isset($update_tables['planets']['b_hangar_plus'])); |
|
| 1114 | - |
|
| 1115 | - if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1116 | - { |
|
| 1117 | - upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
|
| 999 | + "ADD CONSTRAINT `FK_notes_owner` FOREIGN KEY (`owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1000 | + ), true); |
|
| 1001 | + } |
|
| 1118 | 1002 | |
| 1119 | - upd_alter_table('referrals', array( |
|
| 1120 | - "MODIFY COLUMN `id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1121 | - "MODIFY COLUMN `id_partner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1122 | - "MODIFY COLUMN `dark_matter` DECIMAL(65,0) NOT NULL DEFAULT '0'", |
|
| 1003 | + upd_alter_table('planets', array( |
|
| 1004 | + "MODIFY COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT", |
|
| 1005 | + "MODIFY COLUMN `name` VARCHAR(64) DEFAULT 'Planet' NOT NULL", |
|
| 1006 | + "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1007 | + "MODIFY COLUMN `galaxy` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1008 | + "MODIFY COLUMN `system` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1009 | + "MODIFY COLUMN `planet` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1010 | + "MODIFY COLUMN `planet_type` TINYINT NOT NULL DEFAULT '1'", |
|
| 1011 | + |
|
| 1012 | + "MODIFY COLUMN `metal` DECIMAL(65,5) NOT NULL DEFAULT '0'", |
|
| 1013 | + "MODIFY COLUMN `crystal` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `metal`", |
|
| 1014 | + "MODIFY COLUMN `deuterium` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `crystal`", |
|
| 1015 | + "MODIFY COLUMN `energy_max` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `deuterium`", |
|
| 1016 | + "MODIFY COLUMN `energy_used` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `energy_max`", |
|
| 1017 | + |
|
| 1018 | + "MODIFY COLUMN `metal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1019 | + "MODIFY COLUMN `crystal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1020 | + "MODIFY COLUMN `deuterium_sintetizer` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1021 | + "MODIFY COLUMN `solar_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1022 | + "MODIFY COLUMN `fusion_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1023 | + "MODIFY COLUMN `robot_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1024 | + "MODIFY COLUMN `nano_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1025 | + "MODIFY COLUMN `hangar` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1026 | + "MODIFY COLUMN `metal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1027 | + "MODIFY COLUMN `crystal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1028 | + "MODIFY COLUMN `deuterium_store` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1029 | + "MODIFY COLUMN `laboratory` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1030 | + "MODIFY COLUMN `nano` SMALLINT DEFAULT '0' AFTER `laboratory`", |
|
| 1031 | + "MODIFY COLUMN `terraformer` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1032 | + "MODIFY COLUMN `ally_deposit` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1033 | + "MODIFY COLUMN `silo` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1034 | + "MODIFY COLUMN `mondbasis` SMALLINT NOT NULL DEFAULT '0' AFTER `silo`", |
|
| 1035 | + "MODIFY COLUMN `phalanx` SMALLINT NOT NULL DEFAULT '0' AFTER `mondbasis`", |
|
| 1036 | + "MODIFY COLUMN `sprungtor` SMALLINT NOT NULL DEFAULT '0' AFTER `phalanx`", |
|
| 1037 | + "MODIFY COLUMN `last_jump_time` int(11) NOT NULL DEFAULT '0' AFTER `sprungtor`", |
|
| 1038 | + |
|
| 1039 | + "MODIFY COLUMN `small_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1040 | + "MODIFY COLUMN `big_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1041 | + "MODIFY COLUMN `supercargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count' AFTER `big_ship_cargo`", |
|
| 1042 | + "MODIFY COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `supercargo`", |
|
| 1043 | + "MODIFY COLUMN `recycler` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `planet_cargo_hyper`", |
|
| 1044 | + "MODIFY COLUMN `colonizer` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `recycler`", |
|
| 1045 | + "MODIFY COLUMN `spy_sonde` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `colonizer`", |
|
| 1046 | + "MODIFY COLUMN `solar_satelit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `spy_sonde`", |
|
| 1047 | + |
|
| 1048 | + "MODIFY COLUMN `light_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1049 | + "MODIFY COLUMN `heavy_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1050 | + "MODIFY COLUMN `crusher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1051 | + "MODIFY COLUMN `battle_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1052 | + "MODIFY COLUMN `bomber_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1053 | + "MODIFY COLUMN `battleship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `bomber_ship`", |
|
| 1054 | + "MODIFY COLUMN `destructor` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1055 | + "MODIFY COLUMN `dearth_star` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1056 | + "MODIFY COLUMN `supernova` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1057 | + |
|
| 1058 | + "MODIFY COLUMN `misil_launcher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1059 | + "MODIFY COLUMN `small_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1060 | + "MODIFY COLUMN `big_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1061 | + "MODIFY COLUMN `gauss_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1062 | + "MODIFY COLUMN `ionic_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1063 | + "MODIFY COLUMN `buster_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1064 | + |
|
| 1065 | + "MODIFY COLUMN `small_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
| 1066 | + "MODIFY COLUMN `big_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
| 1067 | + "MODIFY COLUMN `planet_protector` tinyint(1) NOT NULL DEFAULT '0'", |
|
| 1068 | + |
|
| 1069 | + "MODIFY COLUMN `interceptor_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1070 | + "MODIFY COLUMN `interplanetary_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1071 | + |
|
| 1072 | + "MODIFY COLUMN `metal_perhour` INT NOT NULL DEFAULT '0' AFTER `interplanetary_misil`", |
|
| 1073 | + "MODIFY COLUMN `crystal_perhour` INT NOT NULL DEFAULT '0' AFTER `metal_perhour`", |
|
| 1074 | + "MODIFY COLUMN `deuterium_perhour` INT NOT NULL DEFAULT '0' AFTER `crystal_perhour`", |
|
| 1075 | + |
|
| 1076 | + "MODIFY COLUMN `metal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1077 | + "MODIFY COLUMN `crystal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1078 | + "MODIFY COLUMN `deuterium_sintetizer_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1079 | + "MODIFY COLUMN `solar_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1080 | + "MODIFY COLUMN `fusion_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1081 | + "MODIFY COLUMN `solar_satelit_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
| 1082 | + |
|
| 1083 | + "MODIFY COLUMN `que` TEXT COMMENT 'Planet que' AFTER `solar_satelit_porcent`", |
|
| 1084 | + // "MODIFY COLUMN `b_tech` INT(11) NOT NULL DEFAULT 0 AFTER `que`", |
|
| 1085 | + // "MODIFY COLUMN `b_tech_id` SMALLINT NOT NULL DEFAULT 0 AFTER `b_tech`", |
|
| 1086 | + "MODIFY COLUMN `b_hangar` INT(11) NOT NULL DEFAULT '0' AFTER `que`", |
|
| 1087 | + "MODIFY COLUMN `b_hangar_id` TEXT AFTER `b_hangar`", |
|
| 1088 | + "MODIFY COLUMN `last_update` INT(11) DEFAULT NULL AFTER `b_hangar_id`", |
|
| 1089 | + |
|
| 1090 | + "MODIFY COLUMN `image` varchar(64) NOT NULL DEFAULT 'normaltempplanet01' AFTER `last_update`", |
|
| 1091 | + "MODIFY COLUMN `points` bigint(20) DEFAULT '0' AFTER `image`", |
|
| 1092 | + "MODIFY COLUMN `ranks` bigint(20) DEFAULT '0' AFTER `points`", |
|
| 1093 | + "MODIFY COLUMN `id_level` TINYINT NOT NULL DEFAULT '0' AFTER `ranks`", |
|
| 1094 | + "MODIFY COLUMN `destruyed` int(11) NOT NULL DEFAULT '0' AFTER `id_level`", |
|
| 1095 | + "MODIFY COLUMN `diameter` int(11) NOT NULL DEFAULT '12800' AFTER `destruyed`", |
|
| 1096 | + "MODIFY COLUMN `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT '163' AFTER `diameter`", |
|
| 1097 | + "MODIFY COLUMN `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT '0' AFTER `field_max`", |
|
| 1098 | + "MODIFY COLUMN `temp_min` SMALLINT NOT NULL DEFAULT '0' AFTER `field_current`", |
|
| 1099 | + "MODIFY COLUMN `temp_max` SMALLINT NOT NULL DEFAULT '40' AFTER `temp_min`", |
|
| 1100 | + |
|
| 1101 | + "MODIFY COLUMN `metal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `temp_max`", |
|
| 1102 | + "MODIFY COLUMN `crystal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `metal_max`", |
|
| 1103 | + "MODIFY COLUMN `deuterium_max` DECIMAL(65,0) DEFAULT '100000' AFTER `crystal_max`", |
|
| 1104 | + |
|
| 1105 | + "MODIFY COLUMN `debris_metal` bigint(20) unsigned DEFAULT '0'", |
|
| 1106 | + "MODIFY COLUMN `debris_crystal` bigint(20) unsigned DEFAULT '0'", |
|
| 1107 | + "MODIFY COLUMN `PLANET_GOVERNOR_ID` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1108 | + "MODIFY COLUMN `PLANET_GOVERNOR_LEVEL` SMALLINT NOT NULL DEFAULT '0'", |
|
| 1109 | + |
|
| 1110 | + "MODIFY COLUMN `parent_planet` BIGINT(20) unsigned DEFAULT '0'", |
|
| 1111 | + |
|
| 1112 | + "DROP COLUMN `b_hangar_plus`", |
|
| 1113 | + ), isset($update_tables['planets']['b_hangar_plus'])); |
|
| 1114 | + |
|
| 1115 | + if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1116 | + { |
|
| 1117 | + upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
|
| 1123 | 1118 | |
| 1124 | - "ADD CONSTRAINT `FK_referrals_id` FOREIGN KEY (`id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1125 | - "ADD CONSTRAINT `FK_referrals_id_partner` FOREIGN KEY (`id_partner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1126 | - ), true); |
|
| 1127 | - } |
|
| 1119 | + upd_alter_table('referrals', array( |
|
| 1120 | + "MODIFY COLUMN `id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1121 | + "MODIFY COLUMN `id_partner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1122 | + "MODIFY COLUMN `dark_matter` DECIMAL(65,0) NOT NULL DEFAULT '0'", |
|
| 1128 | 1123 | |
| 1129 | - upd_alter_table('rw', array( |
|
| 1130 | - "MODIFY COLUMN `report_id` SERIAL", |
|
| 1131 | - "MODIFY COLUMN `id_owner1` BIGINT(20) UNSIGNED", |
|
| 1132 | - "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
|
| 1133 | - ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 1124 | + "ADD CONSTRAINT `FK_referrals_id` FOREIGN KEY (`id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1125 | + "ADD CONSTRAINT `FK_referrals_id_partner` FOREIGN KEY (`id_partner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1126 | + ), true); |
|
| 1127 | + } |
|
| 1134 | 1128 | |
| 1135 | - if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1136 | - { |
|
| 1137 | - upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true); |
|
| 1138 | - |
|
| 1139 | - upd_alter_table('shortcut', array( |
|
| 1140 | - "MODIFY COLUMN `shortcut_id` SERIAL", |
|
| 1141 | - "MODIFY COLUMN `shortcut_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1142 | - "MODIFY COLUMN `shortcut_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1143 | - "MODIFY COLUMN `shortcut_galaxy` TINYINT UNSIGNED DEFAULT 0", |
|
| 1144 | - "MODIFY COLUMN `shortcut_system` SMALLINT UNSIGNED DEFAULT 0", |
|
| 1145 | - "MODIFY COLUMN `shortcut_planet` TINYINT UNSIGNED DEFAULT 0", |
|
| 1146 | - |
|
| 1147 | - "ADD CONSTRAINT `FK_shortcut_planet_id` FOREIGN KEY (`shortcut_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1148 | - ), true); |
|
| 1149 | - } |
|
| 1129 | + upd_alter_table('rw', array( |
|
| 1130 | + "MODIFY COLUMN `report_id` SERIAL", |
|
| 1131 | + "MODIFY COLUMN `id_owner1` BIGINT(20) UNSIGNED", |
|
| 1132 | + "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
|
| 1133 | + ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 1150 | 1134 | |
| 1151 | - if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1152 | - { |
|
| 1153 | - upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
|
| 1135 | + if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1136 | + { |
|
| 1137 | + upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true); |
|
| 1138 | + |
|
| 1139 | + upd_alter_table('shortcut', array( |
|
| 1140 | + "MODIFY COLUMN `shortcut_id` SERIAL", |
|
| 1141 | + "MODIFY COLUMN `shortcut_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1142 | + "MODIFY COLUMN `shortcut_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1143 | + "MODIFY COLUMN `shortcut_galaxy` TINYINT UNSIGNED DEFAULT 0", |
|
| 1144 | + "MODIFY COLUMN `shortcut_system` SMALLINT UNSIGNED DEFAULT 0", |
|
| 1145 | + "MODIFY COLUMN `shortcut_planet` TINYINT UNSIGNED DEFAULT 0", |
|
| 1146 | + |
|
| 1147 | + "ADD CONSTRAINT `FK_shortcut_planet_id` FOREIGN KEY (`shortcut_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1148 | + ), true); |
|
| 1149 | + } |
|
| 1154 | 1150 | |
| 1155 | - upd_alter_table('statpoints', array( |
|
| 1156 | - "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST", |
|
| 1157 | - "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1158 | - "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1159 | - "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0", |
|
| 1160 | - "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1161 | - |
|
| 1162 | - "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1163 | - "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1164 | - "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1165 | - "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1166 | - |
|
| 1167 | - "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1168 | - "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1169 | - "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1170 | - "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1171 | - |
|
| 1172 | - "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1173 | - "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1174 | - "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1175 | - "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1176 | - |
|
| 1177 | - "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1178 | - "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1179 | - "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1180 | - "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1181 | - |
|
| 1182 | - "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`", |
|
| 1183 | - "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`", |
|
| 1184 | - "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`", |
|
| 1185 | - "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`", |
|
| 1186 | - |
|
| 1187 | - "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1188 | - "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1189 | - "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1190 | - "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1191 | - |
|
| 1192 | - "ADD KEY `I_stats_id_ally` (`id_ally`)", |
|
| 1193 | - |
|
| 1194 | - "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1195 | - "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1196 | - ), true); |
|
| 1197 | - } |
|
| 1151 | + if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1152 | + { |
|
| 1153 | + upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true); |
|
| 1154 | + |
|
| 1155 | + upd_alter_table('statpoints', array( |
|
| 1156 | + "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST", |
|
| 1157 | + "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1158 | + "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1159 | + "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0", |
|
| 1160 | + "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1161 | + |
|
| 1162 | + "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1163 | + "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1164 | + "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1165 | + "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1166 | + |
|
| 1167 | + "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1168 | + "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1169 | + "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1170 | + "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1171 | + |
|
| 1172 | + "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1173 | + "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1174 | + "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1175 | + "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1176 | + |
|
| 1177 | + "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1178 | + "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1179 | + "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1180 | + "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1181 | + |
|
| 1182 | + "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`", |
|
| 1183 | + "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`", |
|
| 1184 | + "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`", |
|
| 1185 | + "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`", |
|
| 1186 | + |
|
| 1187 | + "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1188 | + "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1189 | + "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1190 | + "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1191 | + |
|
| 1192 | + "ADD KEY `I_stats_id_ally` (`id_ally`)", |
|
| 1193 | + |
|
| 1194 | + "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1195 | + "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1196 | + ), true); |
|
| 1197 | + } |
|
| 1198 | 1198 | |
| 1199 | - upd_alter_table('users', array( |
|
| 1200 | - "MODIFY COLUMN `authlevel` tinyint unsigned NOT NULL DEFAULT '0' AFTER `username`", |
|
| 1201 | - "MODIFY COLUMN `vacation` int(11) unsigned DEFAULT '0' AFTER `authlevel`", |
|
| 1202 | - "MODIFY COLUMN `banaday` int(11) unsigned DEFAULT '0' AFTER `vacation`", |
|
| 1203 | - "MODIFY COLUMN `dark_matter` bigint(20) DEFAULT '0' AFTER `banaday`", |
|
| 1204 | - "MODIFY COLUMN `spy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1205 | - "MODIFY COLUMN `computer_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1206 | - "MODIFY COLUMN `military_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1207 | - "MODIFY COLUMN `defence_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1208 | - "MODIFY COLUMN `shield_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1209 | - "MODIFY COLUMN `energy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1210 | - "MODIFY COLUMN `hyperspace_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1211 | - "MODIFY COLUMN `combustion_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1212 | - "MODIFY COLUMN `impulse_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1213 | - "MODIFY COLUMN `hyperspace_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1214 | - "MODIFY COLUMN `laser_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1215 | - "MODIFY COLUMN `ionic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1216 | - "MODIFY COLUMN `buster_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1217 | - "MODIFY COLUMN `intergalactic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1218 | - "MODIFY COLUMN `expedition_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1219 | - "MODIFY COLUMN `colonisation_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1220 | - "MODIFY COLUMN `graviton_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1221 | - "MODIFY COLUMN `player_artifact_list` text AFTER `graviton_tech`", |
|
| 1222 | - "MODIFY COLUMN `ally_id` bigint(20) unsigned DEFAULT NULL AFTER `player_artifact_list`", |
|
| 1223 | - "MODIFY COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
| 1224 | - "MODIFY COLUMN `ally_name` varchar(32) DEFAULT NULL AFTER `ally_tag`", |
|
| 1225 | - "MODIFY COLUMN `ally_register_time` int(11) NOT NULL DEFAULT '0' AFTER `ally_name`", |
|
| 1226 | - "MODIFY COLUMN `ally_rank_id` int(11) NOT NULL DEFAULT '0' AFTER `ally_register_time`", |
|
| 1227 | - "MODIFY COLUMN `player_que` text AFTER `ally_rank_id`", |
|
| 1228 | - "MODIFY COLUMN `lvl_minier` bigint(20) unsigned NOT NULL DEFAULT '1'", |
|
| 1229 | - "MODIFY COLUMN `xpminier` bigint(20) unsigned DEFAULT '0' AFTER `lvl_minier`", |
|
| 1230 | - "MODIFY COLUMN `player_rpg_tech_xp` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
| 1231 | - "MODIFY COLUMN `player_rpg_tech_level` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
| 1232 | - "MODIFY COLUMN `lvl_raid` bigint(20) unsigned NOT NULL DEFAULT '1' AFTER `player_rpg_tech_level`", |
|
| 1233 | - "MODIFY COLUMN `xpraid` bigint(20) unsigned DEFAULT '0'", |
|
| 1234 | - "MODIFY COLUMN `raids` bigint(20) unsigned DEFAULT '0'", |
|
| 1235 | - "MODIFY COLUMN `raidsloose` bigint(20) unsigned DEFAULT '0'", |
|
| 1236 | - "MODIFY COLUMN `raidswin` bigint(20) unsigned DEFAULT '0'", |
|
| 1237 | - "MODIFY COLUMN `new_message` int(11) NOT NULL DEFAULT '0' AFTER `raidswin`", |
|
| 1238 | - "MODIFY COLUMN `mnl_alliance` int(11) NOT NULL DEFAULT '0'", |
|
| 1239 | - "MODIFY COLUMN `mnl_joueur` int(11) NOT NULL DEFAULT '0'", |
|
| 1240 | - "MODIFY COLUMN `mnl_attaque` int(11) NOT NULL DEFAULT '0'", |
|
| 1241 | - "MODIFY COLUMN `mnl_spy` int(11) NOT NULL DEFAULT '0'", |
|
| 1242 | - "MODIFY COLUMN `mnl_exploit` int(11) NOT NULL DEFAULT '0'", |
|
| 1243 | - "MODIFY COLUMN `mnl_transport` int(11) NOT NULL DEFAULT '0'", |
|
| 1244 | - "MODIFY COLUMN `mnl_expedition` int(11) NOT NULL DEFAULT '0'", |
|
| 1245 | - "MODIFY COLUMN `mnl_buildlist` int(11) NOT NULL DEFAULT '0'", |
|
| 1246 | - "MODIFY COLUMN `msg_admin` bigint(11) unsigned DEFAULT '0'", |
|
| 1247 | -// "MODIFY COLUMN `b_tech_planet` int(11) NOT NULL DEFAULT '0' AFTER `msg_admin`", |
|
| 1248 | - "MODIFY COLUMN `deltime` int(10) unsigned DEFAULT '0'", |
|
| 1249 | - "MODIFY COLUMN `news_lastread` int(10) unsigned DEFAULT '0'", |
|
| 1250 | - "MODIFY COLUMN `total_rank` int(10) unsigned NOT NULL DEFAULT '0'", |
|
| 1251 | - "MODIFY COLUMN `total_points` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
| 1252 | - "MODIFY COLUMN `password` varchar(64) NOT NULL DEFAULT '' AFTER `total_points`", |
|
| 1253 | - "MODIFY COLUMN `email` varchar(64) NOT NULL DEFAULT '' AFTER `password`", |
|
| 1254 | - "MODIFY COLUMN `email_2` varchar(64) NOT NULL DEFAULT '' AFTER `email`", |
|
| 1255 | - "MODIFY COLUMN `lang` varchar(8) NOT NULL DEFAULT 'ru' AFTER `email_2`", |
|
| 1256 | - "MODIFY COLUMN `sex` char(1) DEFAULT NULL AFTER `lang`", |
|
| 1257 | - "MODIFY COLUMN `avatar` varchar(255) NOT NULL DEFAULT '' AFTER `sex`", |
|
| 1258 | - "MODIFY COLUMN `sign` mediumtext AFTER `avatar`", |
|
| 1259 | - "MODIFY COLUMN `id_planet` int(11) NOT NULL DEFAULT '0' AFTER `sign`", |
|
| 1260 | - "MODIFY COLUMN `galaxy` int(11) NOT NULL DEFAULT '0' AFTER `id_planet`", |
|
| 1261 | - "MODIFY COLUMN `system` int(11) NOT NULL DEFAULT '0' AFTER `galaxy`", |
|
| 1262 | - "MODIFY COLUMN `planet` int(11) NOT NULL DEFAULT '0' AFTER `system`", |
|
| 1263 | - "MODIFY COLUMN `current_planet` int(11) NOT NULL DEFAULT '0' AFTER `planet`", |
|
| 1264 | - "MODIFY COLUMN `user_agent` mediumtext NOT NULL AFTER `current_planet`", |
|
| 1265 | - "MODIFY COLUMN `user_lastip` varchar(250) DEFAULT NULL COMMENT 'User last IP' AFTER `user_agent`", |
|
| 1266 | - "MODIFY COLUMN `user_proxy` varchar(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)' AFTER `user_lastip`", |
|
| 1267 | - "MODIFY COLUMN `register_time` int(10) unsigned DEFAULT '0' AFTER `user_proxy`", |
|
| 1268 | - "MODIFY COLUMN `onlinetime` int(10) unsigned DEFAULT '0' AFTER `register_time`", |
|
| 1269 | - "MODIFY COLUMN `dpath` varchar(255) NOT NULL DEFAULT '' AFTER `onlinetime`", |
|
| 1270 | - "MODIFY COLUMN `design` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `dpath`", |
|
| 1271 | - "MODIFY COLUMN `noipcheck` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `design`", |
|
| 1272 | - "MODIFY COLUMN `options` mediumtext COMMENT 'Packed user options' AFTER `noipcheck`", |
|
| 1273 | - "MODIFY COLUMN `planet_sort` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `options`", |
|
| 1274 | - "MODIFY COLUMN `planet_sort_order` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `planet_sort`", |
|
| 1275 | - "MODIFY COLUMN `spio_anz` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `planet_sort_order`", |
|
| 1276 | - "MODIFY COLUMN `settings_tooltiptime` tinyint(1) unsigned NOT NULL DEFAULT '5' AFTER `spio_anz`", |
|
| 1277 | - "MODIFY COLUMN `settings_fleetactions` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_tooltiptime`", |
|
| 1278 | - "MODIFY COLUMN `settings_esp` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_allylogo`", |
|
| 1279 | - "MODIFY COLUMN `settings_wri` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_esp`", |
|
| 1280 | - "MODIFY COLUMN `settings_bud` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_wri`", |
|
| 1281 | - "MODIFY COLUMN `settings_mis` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_bud`", |
|
| 1282 | - "MODIFY COLUMN `settings_rep` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_mis`", |
|
| 1283 | - ), strtoupper($update_tables['users']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 1199 | + upd_alter_table('users', array( |
|
| 1200 | + "MODIFY COLUMN `authlevel` tinyint unsigned NOT NULL DEFAULT '0' AFTER `username`", |
|
| 1201 | + "MODIFY COLUMN `vacation` int(11) unsigned DEFAULT '0' AFTER `authlevel`", |
|
| 1202 | + "MODIFY COLUMN `banaday` int(11) unsigned DEFAULT '0' AFTER `vacation`", |
|
| 1203 | + "MODIFY COLUMN `dark_matter` bigint(20) DEFAULT '0' AFTER `banaday`", |
|
| 1204 | + "MODIFY COLUMN `spy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1205 | + "MODIFY COLUMN `computer_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1206 | + "MODIFY COLUMN `military_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1207 | + "MODIFY COLUMN `defence_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1208 | + "MODIFY COLUMN `shield_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1209 | + "MODIFY COLUMN `energy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1210 | + "MODIFY COLUMN `hyperspace_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1211 | + "MODIFY COLUMN `combustion_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1212 | + "MODIFY COLUMN `impulse_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1213 | + "MODIFY COLUMN `hyperspace_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1214 | + "MODIFY COLUMN `laser_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1215 | + "MODIFY COLUMN `ionic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1216 | + "MODIFY COLUMN `buster_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1217 | + "MODIFY COLUMN `intergalactic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1218 | + "MODIFY COLUMN `expedition_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1219 | + "MODIFY COLUMN `colonisation_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1220 | + "MODIFY COLUMN `graviton_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
| 1221 | + "MODIFY COLUMN `player_artifact_list` text AFTER `graviton_tech`", |
|
| 1222 | + "MODIFY COLUMN `ally_id` bigint(20) unsigned DEFAULT NULL AFTER `player_artifact_list`", |
|
| 1223 | + "MODIFY COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
| 1224 | + "MODIFY COLUMN `ally_name` varchar(32) DEFAULT NULL AFTER `ally_tag`", |
|
| 1225 | + "MODIFY COLUMN `ally_register_time` int(11) NOT NULL DEFAULT '0' AFTER `ally_name`", |
|
| 1226 | + "MODIFY COLUMN `ally_rank_id` int(11) NOT NULL DEFAULT '0' AFTER `ally_register_time`", |
|
| 1227 | + "MODIFY COLUMN `player_que` text AFTER `ally_rank_id`", |
|
| 1228 | + "MODIFY COLUMN `lvl_minier` bigint(20) unsigned NOT NULL DEFAULT '1'", |
|
| 1229 | + "MODIFY COLUMN `xpminier` bigint(20) unsigned DEFAULT '0' AFTER `lvl_minier`", |
|
| 1230 | + "MODIFY COLUMN `player_rpg_tech_xp` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
| 1231 | + "MODIFY COLUMN `player_rpg_tech_level` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
| 1232 | + "MODIFY COLUMN `lvl_raid` bigint(20) unsigned NOT NULL DEFAULT '1' AFTER `player_rpg_tech_level`", |
|
| 1233 | + "MODIFY COLUMN `xpraid` bigint(20) unsigned DEFAULT '0'", |
|
| 1234 | + "MODIFY COLUMN `raids` bigint(20) unsigned DEFAULT '0'", |
|
| 1235 | + "MODIFY COLUMN `raidsloose` bigint(20) unsigned DEFAULT '0'", |
|
| 1236 | + "MODIFY COLUMN `raidswin` bigint(20) unsigned DEFAULT '0'", |
|
| 1237 | + "MODIFY COLUMN `new_message` int(11) NOT NULL DEFAULT '0' AFTER `raidswin`", |
|
| 1238 | + "MODIFY COLUMN `mnl_alliance` int(11) NOT NULL DEFAULT '0'", |
|
| 1239 | + "MODIFY COLUMN `mnl_joueur` int(11) NOT NULL DEFAULT '0'", |
|
| 1240 | + "MODIFY COLUMN `mnl_attaque` int(11) NOT NULL DEFAULT '0'", |
|
| 1241 | + "MODIFY COLUMN `mnl_spy` int(11) NOT NULL DEFAULT '0'", |
|
| 1242 | + "MODIFY COLUMN `mnl_exploit` int(11) NOT NULL DEFAULT '0'", |
|
| 1243 | + "MODIFY COLUMN `mnl_transport` int(11) NOT NULL DEFAULT '0'", |
|
| 1244 | + "MODIFY COLUMN `mnl_expedition` int(11) NOT NULL DEFAULT '0'", |
|
| 1245 | + "MODIFY COLUMN `mnl_buildlist` int(11) NOT NULL DEFAULT '0'", |
|
| 1246 | + "MODIFY COLUMN `msg_admin` bigint(11) unsigned DEFAULT '0'", |
|
| 1247 | + // "MODIFY COLUMN `b_tech_planet` int(11) NOT NULL DEFAULT '0' AFTER `msg_admin`", |
|
| 1248 | + "MODIFY COLUMN `deltime` int(10) unsigned DEFAULT '0'", |
|
| 1249 | + "MODIFY COLUMN `news_lastread` int(10) unsigned DEFAULT '0'", |
|
| 1250 | + "MODIFY COLUMN `total_rank` int(10) unsigned NOT NULL DEFAULT '0'", |
|
| 1251 | + "MODIFY COLUMN `total_points` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
| 1252 | + "MODIFY COLUMN `password` varchar(64) NOT NULL DEFAULT '' AFTER `total_points`", |
|
| 1253 | + "MODIFY COLUMN `email` varchar(64) NOT NULL DEFAULT '' AFTER `password`", |
|
| 1254 | + "MODIFY COLUMN `email_2` varchar(64) NOT NULL DEFAULT '' AFTER `email`", |
|
| 1255 | + "MODIFY COLUMN `lang` varchar(8) NOT NULL DEFAULT 'ru' AFTER `email_2`", |
|
| 1256 | + "MODIFY COLUMN `sex` char(1) DEFAULT NULL AFTER `lang`", |
|
| 1257 | + "MODIFY COLUMN `avatar` varchar(255) NOT NULL DEFAULT '' AFTER `sex`", |
|
| 1258 | + "MODIFY COLUMN `sign` mediumtext AFTER `avatar`", |
|
| 1259 | + "MODIFY COLUMN `id_planet` int(11) NOT NULL DEFAULT '0' AFTER `sign`", |
|
| 1260 | + "MODIFY COLUMN `galaxy` int(11) NOT NULL DEFAULT '0' AFTER `id_planet`", |
|
| 1261 | + "MODIFY COLUMN `system` int(11) NOT NULL DEFAULT '0' AFTER `galaxy`", |
|
| 1262 | + "MODIFY COLUMN `planet` int(11) NOT NULL DEFAULT '0' AFTER `system`", |
|
| 1263 | + "MODIFY COLUMN `current_planet` int(11) NOT NULL DEFAULT '0' AFTER `planet`", |
|
| 1264 | + "MODIFY COLUMN `user_agent` mediumtext NOT NULL AFTER `current_planet`", |
|
| 1265 | + "MODIFY COLUMN `user_lastip` varchar(250) DEFAULT NULL COMMENT 'User last IP' AFTER `user_agent`", |
|
| 1266 | + "MODIFY COLUMN `user_proxy` varchar(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)' AFTER `user_lastip`", |
|
| 1267 | + "MODIFY COLUMN `register_time` int(10) unsigned DEFAULT '0' AFTER `user_proxy`", |
|
| 1268 | + "MODIFY COLUMN `onlinetime` int(10) unsigned DEFAULT '0' AFTER `register_time`", |
|
| 1269 | + "MODIFY COLUMN `dpath` varchar(255) NOT NULL DEFAULT '' AFTER `onlinetime`", |
|
| 1270 | + "MODIFY COLUMN `design` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `dpath`", |
|
| 1271 | + "MODIFY COLUMN `noipcheck` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `design`", |
|
| 1272 | + "MODIFY COLUMN `options` mediumtext COMMENT 'Packed user options' AFTER `noipcheck`", |
|
| 1273 | + "MODIFY COLUMN `planet_sort` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `options`", |
|
| 1274 | + "MODIFY COLUMN `planet_sort_order` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `planet_sort`", |
|
| 1275 | + "MODIFY COLUMN `spio_anz` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `planet_sort_order`", |
|
| 1276 | + "MODIFY COLUMN `settings_tooltiptime` tinyint(1) unsigned NOT NULL DEFAULT '5' AFTER `spio_anz`", |
|
| 1277 | + "MODIFY COLUMN `settings_fleetactions` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_tooltiptime`", |
|
| 1278 | + "MODIFY COLUMN `settings_esp` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_allylogo`", |
|
| 1279 | + "MODIFY COLUMN `settings_wri` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_esp`", |
|
| 1280 | + "MODIFY COLUMN `settings_bud` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_wri`", |
|
| 1281 | + "MODIFY COLUMN `settings_mis` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_bud`", |
|
| 1282 | + "MODIFY COLUMN `settings_rep` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_mis`", |
|
| 1283 | + ), strtoupper($update_tables['users']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 1284 | 1284 | |
| 1285 | - upd_do_query('COMMIT;', true); |
|
| 1286 | - $new_version = 32; |
|
| 1285 | + upd_do_query('COMMIT;', true); |
|
| 1286 | + $new_version = 32; |
|
| 1287 | 1287 | |
| 1288 | - case 32: |
|
| 1289 | - upd_log_version_update(); |
|
| 1288 | + case 32: |
|
| 1289 | + upd_log_version_update(); |
|
| 1290 | 1290 | |
| 1291 | - upd_check_key('avatar_max_width', 128, !isset($config->avatar_max_width)); |
|
| 1292 | - upd_check_key('avatar_max_height', 128, !isset($config->avatar_max_height)); |
|
| 1291 | + upd_check_key('avatar_max_width', 128, !isset($config->avatar_max_width)); |
|
| 1292 | + upd_check_key('avatar_max_height', 128, !isset($config->avatar_max_height)); |
|
| 1293 | 1293 | |
| 1294 | - upd_alter_table('users', array( |
|
| 1295 | - "MODIFY COLUMN `avatar` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
| 1296 | - ), strtoupper($update_tables['users']['avatar']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
| 1294 | + upd_alter_table('users', array( |
|
| 1295 | + "MODIFY COLUMN `avatar` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
| 1296 | + ), strtoupper($update_tables['users']['avatar']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
| 1297 | 1297 | |
| 1298 | - upd_alter_table('alliance', array( |
|
| 1299 | - "MODIFY COLUMN `ally_image` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
| 1300 | - ), strtoupper($update_tables['alliance']['ally_image']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
| 1298 | + upd_alter_table('alliance', array( |
|
| 1299 | + "MODIFY COLUMN `ally_image` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
| 1300 | + ), strtoupper($update_tables['alliance']['ally_image']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
| 1301 | 1301 | |
| 1302 | - upd_alter_table('users', array( |
|
| 1303 | - "DROP COLUMN `settings_allylogo`", |
|
| 1304 | - ), isset($update_tables['users']['settings_allylogo'])); |
|
| 1302 | + upd_alter_table('users', array( |
|
| 1303 | + "DROP COLUMN `settings_allylogo`", |
|
| 1304 | + ), isset($update_tables['users']['settings_allylogo'])); |
|
| 1305 | 1305 | |
| 1306 | - if(!isset($update_tables['powerup'])) |
|
| 1307 | - { |
|
| 1308 | - upd_do_query("DROP TABLE IF EXISTS {$config->db_prefix}mercenaries;"); |
|
| 1306 | + if(!isset($update_tables['powerup'])) |
|
| 1307 | + { |
|
| 1308 | + upd_do_query("DROP TABLE IF EXISTS {$config->db_prefix}mercenaries;"); |
|
| 1309 | 1309 | |
| 1310 | - upd_create_table('powerup', |
|
| 1311 | - "( |
|
| 1310 | + upd_create_table('powerup', |
|
| 1311 | + "( |
|
| 1312 | 1312 | `powerup_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 1313 | 1313 | `powerup_user_id` bigint(20) UNSIGNED NULL DEFAULT NULL, |
| 1314 | 1314 | `powerup_planet_id` bigint(20) UNSIGNED NULL DEFAULT NULL, |
@@ -1327,38 +1327,38 @@ discard block |
||
| 1327 | 1327 | CONSTRAINT `FK_powerup_user_id` FOREIGN KEY (`powerup_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, |
| 1328 | 1328 | CONSTRAINT `FK_powerup_planet_id` FOREIGN KEY (`powerup_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
| 1329 | 1329 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1330 | - ); |
|
| 1330 | + ); |
|
| 1331 | 1331 | |
| 1332 | - upd_check_key('empire_mercenary_temporary', 0, !isset($config->empire_mercenary_temporary)); |
|
| 1333 | - upd_check_key('empire_mercenary_base_period', PERIOD_MONTH, !isset($config->empire_mercenary_base_period)); |
|
| 1332 | + upd_check_key('empire_mercenary_temporary', 0, !isset($config->empire_mercenary_temporary)); |
|
| 1333 | + upd_check_key('empire_mercenary_base_period', PERIOD_MONTH, !isset($config->empire_mercenary_base_period)); |
|
| 1334 | 1334 | |
| 1335 | - $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
|
| 1336 | - $user_list = upd_do_query("SELECT * FROM {{users}};"); |
|
| 1337 | - while($user_row = db_fetch($user_list)) |
|
| 1338 | - { |
|
| 1339 | - $update_query_str = ''; |
|
| 1340 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) |
|
| 1335 | + $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
|
| 1336 | + $user_list = upd_do_query("SELECT * FROM {{users}};"); |
|
| 1337 | + while($user_row = db_fetch($user_list)) |
|
| 1341 | 1338 | { |
| 1342 | - $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
|
| 1343 | - if($mercenary_level = $user_row[$mercenary_data_name]) |
|
| 1339 | + $update_query_str = ''; |
|
| 1340 | + foreach(sn_get_groups('mercenaries') as $mercenary_id) |
|
| 1344 | 1341 | { |
| 1345 | - $update_query_str = ", `{$mercenary_data_name}` = 0"; |
|
| 1346 | - upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
|
| 1347 | - upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};"); |
|
| 1342 | + $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
|
| 1343 | + if($mercenary_level = $user_row[$mercenary_data_name]) |
|
| 1344 | + { |
|
| 1345 | + $update_query_str = ", `{$mercenary_data_name}` = 0"; |
|
| 1346 | + upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
|
| 1347 | + upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};"); |
|
| 1348 | + } |
|
| 1348 | 1349 | } |
| 1349 | - } |
|
| 1350 | 1350 | |
| 1351 | - if($update_query_str) |
|
| 1352 | - { |
|
| 1353 | - upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
|
| 1351 | + if($update_query_str) |
|
| 1352 | + { |
|
| 1353 | + upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
|
| 1354 | + } |
|
| 1354 | 1355 | } |
| 1355 | 1356 | } |
| 1356 | - } |
|
| 1357 | 1357 | |
| 1358 | - if(!isset($update_tables['universe'])) |
|
| 1359 | - { |
|
| 1360 | - upd_create_table('universe', |
|
| 1361 | - "( |
|
| 1358 | + if(!isset($update_tables['universe'])) |
|
| 1359 | + { |
|
| 1360 | + upd_create_table('universe', |
|
| 1361 | + "( |
|
| 1362 | 1362 | `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0', |
| 1363 | 1363 | `universe_system` SMALLINT UNSIGNED NOT NULL DEFAULT '0', |
| 1364 | 1364 | `universe_name` varchar(32) NOT NULL DEFAULT '', |
@@ -1366,197 +1366,197 @@ discard block |
||
| 1366 | 1366 | |
| 1367 | 1367 | PRIMARY KEY (`universe_galaxy`, `universe_system`) |
| 1368 | 1368 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1369 | - ); |
|
| 1370 | - |
|
| 1371 | - upd_check_key('uni_price_galaxy', 10000, !isset($config->uni_price_galaxy)); |
|
| 1372 | - upd_check_key('uni_price_system', 1000, !isset($config->uni_price_system)); |
|
| 1373 | - } |
|
| 1369 | + ); |
|
| 1374 | 1370 | |
| 1375 | - // ======================================================================== |
|
| 1376 | - // Ally player |
|
| 1377 | - // Adding config variable |
|
| 1378 | - upd_check_key('ali_bonus_members', 10, !isset($config->ali_bonus_members)); |
|
| 1371 | + upd_check_key('uni_price_galaxy', 10000, !isset($config->uni_price_galaxy)); |
|
| 1372 | + upd_check_key('uni_price_system', 1000, !isset($config->uni_price_system)); |
|
| 1373 | + } |
|
| 1379 | 1374 | |
| 1380 | - // ------------------------------------------------------------------------ |
|
| 1381 | - // Modifying tables |
|
| 1382 | - if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1383 | - { |
|
| 1384 | - upd_alter_table('users', array( |
|
| 1385 | - "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1375 | + // ======================================================================== |
|
| 1376 | + // Ally player |
|
| 1377 | + // Adding config variable |
|
| 1378 | + upd_check_key('ali_bonus_members', 10, !isset($config->ali_bonus_members)); |
|
| 1386 | 1379 | |
| 1387 | - "ADD KEY `I_user_user_as_ally` (`user_as_ally`)", |
|
| 1380 | + // ------------------------------------------------------------------------ |
|
| 1381 | + // Modifying tables |
|
| 1382 | + if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') |
|
| 1383 | + { |
|
| 1384 | + upd_alter_table('users', array( |
|
| 1385 | + "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1388 | 1386 | |
| 1389 | - "ADD CONSTRAINT `FK_user_user_as_ally` FOREIGN KEY (`user_as_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1390 | - ), true); |
|
| 1387 | + "ADD KEY `I_user_user_as_ally` (`user_as_ally`)", |
|
| 1391 | 1388 | |
| 1392 | - upd_alter_table('alliance', array( |
|
| 1393 | - "ADD COLUMN ally_user_id BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1389 | + "ADD CONSTRAINT `FK_user_user_as_ally` FOREIGN KEY (`user_as_ally`) REFERENCES `{$config->db_prefix}alliance` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1390 | + ), true); |
|
| 1394 | 1391 | |
| 1395 | - "ADD KEY `I_ally_user_id` (`ally_user_id`)", |
|
| 1392 | + upd_alter_table('alliance', array( |
|
| 1393 | + "ADD COLUMN ally_user_id BIGINT(20) UNSIGNED DEFAULT NULL", |
|
| 1396 | 1394 | |
| 1397 | - "ADD CONSTRAINT `FK_ally_ally_user_id` FOREIGN KEY (`ally_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1398 | - ), true); |
|
| 1399 | - } |
|
| 1395 | + "ADD KEY `I_ally_user_id` (`ally_user_id`)", |
|
| 1400 | 1396 | |
| 1401 | - // ------------------------------------------------------------------------ |
|
| 1402 | - // Creating players for allies |
|
| 1403 | - $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
|
| 1404 | - while($ally_row = db_fetch($ally_row_list)) |
|
| 1405 | - { |
|
| 1406 | - $ally_user_name = db_escape("[{$ally_row['ally_tag']}]"); |
|
| 1407 | - doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};"); |
|
| 1408 | - $ally_user_id = db_insert_id(); |
|
| 1409 | - doquery("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;"); |
|
| 1410 | - } |
|
| 1411 | - // Renaming old ally players TODO: Remove on release |
|
| 1412 | - upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.user_as_ally = a.id SET u.username = CONCAT('[', a.ally_tag, ']') WHERE u.user_as_ally IS NOT NULL AND u.username = '';"); |
|
| 1413 | - // Setting last online time to old ally players TODO: Remove on release |
|
| 1414 | - upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;"); |
|
| 1415 | - |
|
| 1416 | - // ------------------------------------------------------------------------ |
|
| 1417 | - // Creating planets for allies |
|
| 1418 | - $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
|
| 1419 | - while($ally_user_row = db_fetch($ally_user_list)) |
|
| 1420 | - { |
|
| 1421 | - $ally_planet_name = db_escape($ally_user_row['username']); |
|
| 1422 | - doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};"); |
|
| 1423 | - $ally_planet_id = db_insert_id(); |
|
| 1424 | - doquery("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;"); |
|
| 1425 | - } |
|
| 1397 | + "ADD CONSTRAINT `FK_ally_ally_user_id` FOREIGN KEY (`ally_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1398 | + ), true); |
|
| 1399 | + } |
|
| 1426 | 1400 | |
| 1427 | - upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
|
| 1428 | - |
|
| 1429 | - upd_alter_table('users', array( |
|
| 1430 | - "DROP COLUMN `rpg_amiral`", |
|
| 1431 | - "DROP COLUMN `mrc_academic`", |
|
| 1432 | - "DROP COLUMN `rpg_espion`", |
|
| 1433 | - "DROP COLUMN `rpg_commandant`", |
|
| 1434 | - "DROP COLUMN `rpg_stockeur`", |
|
| 1435 | - "DROP COLUMN `rpg_destructeur`", |
|
| 1436 | - "DROP COLUMN `rpg_general`", |
|
| 1437 | - "DROP COLUMN `rpg_raideur`", |
|
| 1438 | - "DROP COLUMN `rpg_empereur`", |
|
| 1439 | - |
|
| 1440 | - "ADD COLUMN `metal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
| 1441 | - "ADD COLUMN `crystal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
| 1442 | - "ADD COLUMN `deuterium` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
| 1443 | - ), $update_tables['users']['rpg_amiral']); |
|
| 1444 | - |
|
| 1445 | - |
|
| 1446 | - // ======================================================================== |
|
| 1447 | - // User que |
|
| 1448 | - // Adding db field |
|
| 1449 | - upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
|
| 1450 | - // Converting old data to new one and dropping old fields |
|
| 1451 | - if($update_tables['users']['b_tech_planet']) |
|
| 1452 | - { |
|
| 1453 | - $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;"); |
|
| 1454 | - while($planet_row = db_fetch($query)) |
|
| 1401 | + // ------------------------------------------------------------------------ |
|
| 1402 | + // Creating players for allies |
|
| 1403 | + $ally_row_list = doquery("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
|
| 1404 | + while($ally_row = db_fetch($ally_row_list)) |
|
| 1405 | + { |
|
| 1406 | + $ally_user_name = db_escape("[{$ally_row['ally_tag']}]"); |
|
| 1407 | + doquery("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};"); |
|
| 1408 | + $ally_user_id = db_insert_id(); |
|
| 1409 | + doquery("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;"); |
|
| 1410 | + } |
|
| 1411 | + // Renaming old ally players TODO: Remove on release |
|
| 1412 | + upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.user_as_ally = a.id SET u.username = CONCAT('[', a.ally_tag, ']') WHERE u.user_as_ally IS NOT NULL AND u.username = '';"); |
|
| 1413 | + // Setting last online time to old ally players TODO: Remove on release |
|
| 1414 | + upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;"); |
|
| 1415 | + |
|
| 1416 | + // ------------------------------------------------------------------------ |
|
| 1417 | + // Creating planets for allies |
|
| 1418 | + $ally_user_list = doquery("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
|
| 1419 | + while($ally_user_row = db_fetch($ally_user_list)) |
|
| 1455 | 1420 | { |
| 1456 | - $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
|
| 1457 | - doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
|
| 1421 | + $ally_planet_name = db_escape($ally_user_row['username']); |
|
| 1422 | + doquery("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};"); |
|
| 1423 | + $ally_planet_id = db_insert_id(); |
|
| 1424 | + doquery("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;"); |
|
| 1458 | 1425 | } |
| 1459 | 1426 | |
| 1460 | - upd_alter_table('planets', array( |
|
| 1461 | - "DROP COLUMN `b_tech`", |
|
| 1462 | - "DROP COLUMN `b_tech_id`", |
|
| 1463 | - ), $update_tables['planets']['b_tech']); |
|
| 1427 | + upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.ally_id = a.id SET u.ally_name = a.ally_name, u.ally_tag = a.ally_tag WHERE u.ally_id IS NOT NULL;"); |
|
| 1464 | 1428 | |
| 1465 | - upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
|
| 1466 | - } |
|
| 1429 | + upd_alter_table('users', array( |
|
| 1430 | + "DROP COLUMN `rpg_amiral`", |
|
| 1431 | + "DROP COLUMN `mrc_academic`", |
|
| 1432 | + "DROP COLUMN `rpg_espion`", |
|
| 1433 | + "DROP COLUMN `rpg_commandant`", |
|
| 1434 | + "DROP COLUMN `rpg_stockeur`", |
|
| 1435 | + "DROP COLUMN `rpg_destructeur`", |
|
| 1436 | + "DROP COLUMN `rpg_general`", |
|
| 1437 | + "DROP COLUMN `rpg_raideur`", |
|
| 1438 | + "DROP COLUMN `rpg_empereur`", |
|
| 1439 | + |
|
| 1440 | + "ADD COLUMN `metal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
| 1441 | + "ADD COLUMN `crystal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
| 1442 | + "ADD COLUMN `deuterium` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
| 1443 | + ), $update_tables['users']['rpg_amiral']); |
|
| 1444 | + |
|
| 1445 | + |
|
| 1446 | + // ======================================================================== |
|
| 1447 | + // User que |
|
| 1448 | + // Adding db field |
|
| 1449 | + upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
|
| 1450 | + // Converting old data to new one and dropping old fields |
|
| 1451 | + if($update_tables['users']['b_tech_planet']) |
|
| 1452 | + { |
|
| 1453 | + $query = doquery("SELECT * FROM {{planets}} WHERE `b_tech_id` <> 0;"); |
|
| 1454 | + while($planet_row = db_fetch($query)) |
|
| 1455 | + { |
|
| 1456 | + $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
|
| 1457 | + doquery("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
|
| 1458 | + } |
|
| 1467 | 1459 | |
| 1468 | - if(!$update_tables['powerup']['powerup_category']) |
|
| 1469 | - { |
|
| 1470 | - upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
|
| 1460 | + upd_alter_table('planets', array( |
|
| 1461 | + "DROP COLUMN `b_tech`", |
|
| 1462 | + "DROP COLUMN `b_tech_id`", |
|
| 1463 | + ), $update_tables['planets']['b_tech']); |
|
| 1471 | 1464 | |
| 1472 | - doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
|
| 1473 | - } |
|
| 1465 | + upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
|
| 1466 | + } |
|
| 1467 | + |
|
| 1468 | + if(!$update_tables['powerup']['powerup_category']) |
|
| 1469 | + { |
|
| 1470 | + upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
|
| 1471 | + |
|
| 1472 | + doquery("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
|
| 1473 | + } |
|
| 1474 | 1474 | |
| 1475 | - upd_check_key('rpg_cost_info', 10000, !isset($config->rpg_cost_info)); |
|
| 1476 | - upd_check_key('tpl_minifier', 0, !isset($config->tpl_minifier)); |
|
| 1475 | + upd_check_key('rpg_cost_info', 10000, !isset($config->rpg_cost_info)); |
|
| 1476 | + upd_check_key('tpl_minifier', 0, !isset($config->tpl_minifier)); |
|
| 1477 | 1477 | |
| 1478 | - upd_check_key('server_updater_check_auto', 0, !isset($config->server_updater_check_auto)); |
|
| 1479 | - upd_check_key('server_updater_check_period', PERIOD_DAY, !isset($config->server_updater_check_period)); |
|
| 1480 | - upd_check_key('server_updater_check_last', 0, !isset($config->server_updater_check_last)); |
|
| 1481 | - upd_check_key('server_updater_check_result', SNC_VER_NEVER, !isset($config->server_updater_check_result)); |
|
| 1482 | - upd_check_key('server_updater_key', '', !isset($config->server_updater_key)); |
|
| 1483 | - upd_check_key('server_updater_id', 0, !isset($config->server_updater_id)); |
|
| 1478 | + upd_check_key('server_updater_check_auto', 0, !isset($config->server_updater_check_auto)); |
|
| 1479 | + upd_check_key('server_updater_check_period', PERIOD_DAY, !isset($config->server_updater_check_period)); |
|
| 1480 | + upd_check_key('server_updater_check_last', 0, !isset($config->server_updater_check_last)); |
|
| 1481 | + upd_check_key('server_updater_check_result', SNC_VER_NEVER, !isset($config->server_updater_check_result)); |
|
| 1482 | + upd_check_key('server_updater_key', '', !isset($config->server_updater_key)); |
|
| 1483 | + upd_check_key('server_updater_id', 0, !isset($config->server_updater_id)); |
|
| 1484 | 1484 | |
| 1485 | - upd_check_key('ali_bonus_algorithm', 0, !isset($config->ali_bonus_algorithm)); |
|
| 1486 | - upd_check_key('ali_bonus_divisor', 10000000, !isset($config->ali_bonus_divisor)); |
|
| 1487 | - upd_check_key('ali_bonus_brackets', 10, !isset($config->ali_bonus_brackets)); |
|
| 1488 | - upd_check_key('ali_bonus_brackets_divisor', 50, !isset($config->ali_bonus_brackets_divisor)); |
|
| 1485 | + upd_check_key('ali_bonus_algorithm', 0, !isset($config->ali_bonus_algorithm)); |
|
| 1486 | + upd_check_key('ali_bonus_divisor', 10000000, !isset($config->ali_bonus_divisor)); |
|
| 1487 | + upd_check_key('ali_bonus_brackets', 10, !isset($config->ali_bonus_brackets)); |
|
| 1488 | + upd_check_key('ali_bonus_brackets_divisor', 50, !isset($config->ali_bonus_brackets_divisor)); |
|
| 1489 | 1489 | |
| 1490 | - if(!$config->db_loadItem('rpg_flt_explore')) |
|
| 1491 | - { |
|
| 1492 | - $inflation_rate = 1000; |
|
| 1490 | + if(!$config->db_loadItem('rpg_flt_explore')) |
|
| 1491 | + { |
|
| 1492 | + $inflation_rate = 1000; |
|
| 1493 | 1493 | |
| 1494 | - $config->db_saveItem('rpg_cost_banker', $config->rpg_cost_banker * $inflation_rate); |
|
| 1495 | - $config->db_saveItem('rpg_cost_exchange', $config->rpg_cost_exchange * $inflation_rate); |
|
| 1496 | - $config->db_saveItem('rpg_cost_pawnshop', $config->rpg_cost_pawnshop * $inflation_rate); |
|
| 1497 | - $config->db_saveItem('rpg_cost_scraper', $config->rpg_cost_scraper * $inflation_rate); |
|
| 1498 | - $config->db_saveItem('rpg_cost_stockman', $config->rpg_cost_stockman * $inflation_rate); |
|
| 1499 | - $config->db_saveItem('rpg_cost_trader', $config->rpg_cost_trader * $inflation_rate); |
|
| 1494 | + $config->db_saveItem('rpg_cost_banker', $config->rpg_cost_banker * $inflation_rate); |
|
| 1495 | + $config->db_saveItem('rpg_cost_exchange', $config->rpg_cost_exchange * $inflation_rate); |
|
| 1496 | + $config->db_saveItem('rpg_cost_pawnshop', $config->rpg_cost_pawnshop * $inflation_rate); |
|
| 1497 | + $config->db_saveItem('rpg_cost_scraper', $config->rpg_cost_scraper * $inflation_rate); |
|
| 1498 | + $config->db_saveItem('rpg_cost_stockman', $config->rpg_cost_stockman * $inflation_rate); |
|
| 1499 | + $config->db_saveItem('rpg_cost_trader', $config->rpg_cost_trader * $inflation_rate); |
|
| 1500 | 1500 | |
| 1501 | - $config->db_saveItem('rpg_exchange_darkMatter', $config->rpg_exchange_darkMatter / $inflation_rate * 4); |
|
| 1501 | + $config->db_saveItem('rpg_exchange_darkMatter', $config->rpg_exchange_darkMatter / $inflation_rate * 4); |
|
| 1502 | 1502 | |
| 1503 | - $config->db_saveItem('rpg_flt_explore', $inflation_rate); |
|
| 1503 | + $config->db_saveItem('rpg_flt_explore', $inflation_rate); |
|
| 1504 | 1504 | |
| 1505 | - doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
|
| 1505 | + doquery("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
|
| 1506 | 1506 | |
| 1507 | - $query = doquery("SELECT * FROM {{quest}}"); |
|
| 1508 | - while($row = db_fetch($query)) |
|
| 1509 | - { |
|
| 1510 | - $query_add = ''; |
|
| 1511 | - $quest_reward_list = explode(';', $row['quest_rewards']); |
|
| 1512 | - foreach($quest_reward_list as &$quest_reward) |
|
| 1507 | + $query = doquery("SELECT * FROM {{quest}}"); |
|
| 1508 | + while($row = db_fetch($query)) |
|
| 1513 | 1509 | { |
| 1514 | - list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
|
| 1515 | - if($reward_resource == RES_DARK_MATTER) |
|
| 1510 | + $query_add = ''; |
|
| 1511 | + $quest_reward_list = explode(';', $row['quest_rewards']); |
|
| 1512 | + foreach($quest_reward_list as &$quest_reward) |
|
| 1516 | 1513 | { |
| 1517 | - $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
|
| 1514 | + list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
|
| 1515 | + if($reward_resource == RES_DARK_MATTER) |
|
| 1516 | + { |
|
| 1517 | + $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
|
| 1518 | + } |
|
| 1519 | + } |
|
| 1520 | + $new_rewards = implode(';', $quest_reward_list); |
|
| 1521 | + if($new_rewards != $row['quest_rewards']) |
|
| 1522 | + { |
|
| 1523 | + doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
|
| 1518 | 1524 | } |
| 1519 | - } |
|
| 1520 | - $new_rewards = implode(';', $quest_reward_list); |
|
| 1521 | - if($new_rewards != $row['quest_rewards']) |
|
| 1522 | - { |
|
| 1523 | - doquery("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
|
| 1524 | 1525 | } |
| 1525 | 1526 | } |
| 1526 | - } |
|
| 1527 | 1527 | |
| 1528 | - upd_check_key('rpg_bonus_minimum', 10000, !isset($config->rpg_bonus_minimum)); |
|
| 1529 | - upd_check_key('rpg_bonus_divisor', |
|
| 1530 | - !isset($config->rpg_bonus_divisor) ? 10 : ($config->rpg_bonus_divisor >= 1000 ? floor($config->rpg_bonus_divisor / 1000) : $config->rpg_bonus_divisor), |
|
| 1531 | - !isset($config->rpg_bonus_divisor) || $config->rpg_bonus_divisor >= 1000); |
|
| 1528 | + upd_check_key('rpg_bonus_minimum', 10000, !isset($config->rpg_bonus_minimum)); |
|
| 1529 | + upd_check_key('rpg_bonus_divisor', |
|
| 1530 | + !isset($config->rpg_bonus_divisor) ? 10 : ($config->rpg_bonus_divisor >= 1000 ? floor($config->rpg_bonus_divisor / 1000) : $config->rpg_bonus_divisor), |
|
| 1531 | + !isset($config->rpg_bonus_divisor) || $config->rpg_bonus_divisor >= 1000); |
|
| 1532 | 1532 | |
| 1533 | - upd_check_key('var_news_last', 0, !isset($config->var_news_last)); |
|
| 1533 | + upd_check_key('var_news_last', 0, !isset($config->var_news_last)); |
|
| 1534 | 1534 | |
| 1535 | - upd_do_query('COMMIT;', true); |
|
| 1536 | - $new_version = 33; |
|
| 1535 | + upd_do_query('COMMIT;', true); |
|
| 1536 | + $new_version = 33; |
|
| 1537 | 1537 | |
| 1538 | - case 33: |
|
| 1539 | - upd_log_version_update(); |
|
| 1538 | + case 33: |
|
| 1539 | + upd_log_version_update(); |
|
| 1540 | 1540 | |
| 1541 | - upd_alter_table('users', array( |
|
| 1542 | - "ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'", |
|
| 1543 | - "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'", |
|
| 1541 | + upd_alter_table('users', array( |
|
| 1542 | + "ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'", |
|
| 1543 | + "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'", |
|
| 1544 | 1544 | |
| 1545 | - "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)", |
|
| 1546 | - ), !$update_tables['users']['user_birthday']); |
|
| 1545 | + "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)", |
|
| 1546 | + ), !$update_tables['users']['user_birthday']); |
|
| 1547 | 1547 | |
| 1548 | - upd_check_key('user_birthday_gift', 0, !isset($config->user_birthday_gift)); |
|
| 1549 | - upd_check_key('user_birthday_range', 30, !isset($config->user_birthday_range)); |
|
| 1550 | - upd_check_key('user_birthday_celebrate', 0, !isset($config->user_birthday_celebrate)); |
|
| 1548 | + upd_check_key('user_birthday_gift', 0, !isset($config->user_birthday_gift)); |
|
| 1549 | + upd_check_key('user_birthday_range', 30, !isset($config->user_birthday_range)); |
|
| 1550 | + upd_check_key('user_birthday_celebrate', 0, !isset($config->user_birthday_celebrate)); |
|
| 1551 | 1551 | |
| 1552 | - if(!isset($update_tables['payment'])) |
|
| 1553 | - { |
|
| 1554 | - upd_alter_table('users', array( |
|
| 1555 | - "ADD KEY `I_user_id_name` (`id`, `username`)", |
|
| 1556 | - ), !$update_indexes['users']['I_user_id_name']); |
|
| 1552 | + if(!isset($update_tables['payment'])) |
|
| 1553 | + { |
|
| 1554 | + upd_alter_table('users', array( |
|
| 1555 | + "ADD KEY `I_user_id_name` (`id`, `username`)", |
|
| 1556 | + ), !$update_indexes['users']['I_user_id_name']); |
|
| 1557 | 1557 | |
| 1558 | - upd_create_table('payment', |
|
| 1559 | - "( |
|
| 1558 | + upd_create_table('payment', |
|
| 1559 | + "( |
|
| 1560 | 1560 | `payment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Internal payment ID', |
| 1561 | 1561 | `payment_user_id` BIGINT(20) UNSIGNED DEFAULT NULL, |
| 1562 | 1562 | `payment_user_name` VARCHAR(64) DEFAULT NULL, |
@@ -1576,177 +1576,177 @@ discard block |
||
| 1576 | 1576 | |
| 1577 | 1577 | CONSTRAINT `FK_payment_user` FOREIGN KEY (`payment_user_id`, `payment_user_name`) REFERENCES `{$config->db_prefix}users` (`id`, `username`) ON UPDATE CASCADE ON DELETE NO ACTION |
| 1578 | 1578 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1579 | - ); |
|
| 1579 | + ); |
|
| 1580 | 1580 | |
| 1581 | - upd_check_key('payment_currency_default', 'UAH', !isset($config->payment_currency_default)); |
|
| 1582 | - } |
|
| 1583 | - upd_check_key('payment_lot_size', 1000, !isset($config->payment_lot_size)); |
|
| 1584 | - upd_check_key('payment_lot_price', 1, !isset($config->payment_lot_price)); |
|
| 1581 | + upd_check_key('payment_currency_default', 'UAH', !isset($config->payment_currency_default)); |
|
| 1582 | + } |
|
| 1583 | + upd_check_key('payment_lot_size', 1000, !isset($config->payment_lot_size)); |
|
| 1584 | + upd_check_key('payment_lot_price', 1, !isset($config->payment_lot_price)); |
|
| 1585 | 1585 | |
| 1586 | - // Updating category for Mercenaries |
|
| 1587 | - upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
| 1586 | + // Updating category for Mercenaries |
|
| 1587 | + upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
| 1588 | 1588 | |
| 1589 | - // Convert Destructor to Death Star schematic |
|
| 1590 | - upd_do_query("UPDATE {{powerup}} |
|
| 1589 | + // Convert Destructor to Death Star schematic |
|
| 1590 | + upd_do_query("UPDATE {{powerup}} |
|
| 1591 | 1591 | SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . " |
| 1592 | 1592 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;"); |
| 1593 | - // Convert Assasin to SuperNova schematic |
|
| 1594 | - upd_do_query("UPDATE {{powerup}} |
|
| 1593 | + // Convert Assasin to SuperNova schematic |
|
| 1594 | + upd_do_query("UPDATE {{powerup}} |
|
| 1595 | 1595 | SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . " |
| 1596 | 1596 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;"); |
| 1597 | 1597 | |
| 1598 | - upd_alter_table('iraks', array( |
|
| 1599 | - "ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1", |
|
| 1600 | - "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1", |
|
| 1601 | - ), !$update_tables['iraks']['fleet_start_type']); |
|
| 1602 | - |
|
| 1603 | - |
|
| 1604 | - if(!$update_tables['payment']['payment_status']) |
|
| 1605 | - { |
|
| 1606 | - upd_alter_table('payment', array( |
|
| 1607 | - "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
|
| 1598 | + upd_alter_table('iraks', array( |
|
| 1599 | + "ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1", |
|
| 1600 | + "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1", |
|
| 1601 | + ), !$update_tables['iraks']['fleet_start_type']); |
|
| 1608 | 1602 | |
| 1609 | - "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'", |
|
| 1610 | - "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`", |
|
| 1611 | 1603 | |
| 1612 | - "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'", |
|
| 1613 | - "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'", |
|
| 1614 | - "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'", |
|
| 1615 | - "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'", |
|
| 1616 | - "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'", |
|
| 1617 | - ), !$update_tables['payment']['payment_status']); |
|
| 1618 | - } |
|
| 1604 | + if(!$update_tables['payment']['payment_status']) |
|
| 1605 | + { |
|
| 1606 | + upd_alter_table('payment', array( |
|
| 1607 | + "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
|
| 1608 | + |
|
| 1609 | + "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'", |
|
| 1610 | + "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`", |
|
| 1611 | + |
|
| 1612 | + "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'", |
|
| 1613 | + "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'", |
|
| 1614 | + "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'", |
|
| 1615 | + "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'", |
|
| 1616 | + "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'", |
|
| 1617 | + ), !$update_tables['payment']['payment_status']); |
|
| 1618 | + } |
|
| 1619 | 1619 | |
| 1620 | - upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";"); |
|
| 1620 | + upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";"); |
|
| 1621 | 1621 | |
| 1622 | - upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset($config->server_start_date)); |
|
| 1623 | - upd_check_key('server_que_length_structures', 5, !isset($config->server_que_length_structures)); |
|
| 1624 | - upd_check_key('server_que_length_hangar', 5, !isset($config->server_que_length_hangar)); |
|
| 1622 | + upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset($config->server_start_date)); |
|
| 1623 | + upd_check_key('server_que_length_structures', 5, !isset($config->server_que_length_structures)); |
|
| 1624 | + upd_check_key('server_que_length_hangar', 5, !isset($config->server_que_length_hangar)); |
|
| 1625 | 1625 | |
| 1626 | - upd_check_key('chat_highlight_moderator', '<span class="nick_moderator">$1</span>', $config->chat_highlight_admin == '<font color=green>$1</font>'); |
|
| 1627 | - upd_check_key('chat_highlight_operator', '<span class="nick_operator">$1</span>', $config->chat_highlight_admin == '<font color=red>$1</font>'); |
|
| 1628 | - upd_check_key('chat_highlight_admin', '<span class="nick_admin">$1</span>', $config->chat_highlight_admin == '<font color=purple>$1</font>'); |
|
| 1626 | + upd_check_key('chat_highlight_moderator', '<span class="nick_moderator">$1</span>', $config->chat_highlight_admin == '<font color=green>$1</font>'); |
|
| 1627 | + upd_check_key('chat_highlight_operator', '<span class="nick_operator">$1</span>', $config->chat_highlight_admin == '<font color=red>$1</font>'); |
|
| 1628 | + upd_check_key('chat_highlight_admin', '<span class="nick_admin">$1</span>', $config->chat_highlight_admin == '<font color=purple>$1</font>'); |
|
| 1629 | 1629 | |
| 1630 | - upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset($config->chat_highlight_premium)); |
|
| 1630 | + upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset($config->chat_highlight_premium)); |
|
| 1631 | 1631 | |
| 1632 | - upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = " . MRC_ENGINEER . " AND `PLANET_GOVERNOR_LEVEL` > 8;"); |
|
| 1632 | + upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = " . MRC_ENGINEER . " AND `PLANET_GOVERNOR_LEVEL` > 8;"); |
|
| 1633 | 1633 | |
| 1634 | 1634 | |
| 1635 | - upd_do_query('COMMIT;', true); |
|
| 1636 | - $new_version = 34; |
|
| 1635 | + upd_do_query('COMMIT;', true); |
|
| 1636 | + $new_version = 34; |
|
| 1637 | 1637 | |
| 1638 | - case 34: |
|
| 1639 | - upd_log_version_update(); |
|
| 1638 | + case 34: |
|
| 1639 | + upd_log_version_update(); |
|
| 1640 | 1640 | |
| 1641 | - upd_alter_table('planets', array( |
|
| 1642 | - "ADD COLUMN `planet_teleport_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next teleport time'", |
|
| 1643 | - ), !$update_tables['planets']['planet_teleport_next']); |
|
| 1641 | + upd_alter_table('planets', array( |
|
| 1642 | + "ADD COLUMN `planet_teleport_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next teleport time'", |
|
| 1643 | + ), !$update_tables['planets']['planet_teleport_next']); |
|
| 1644 | 1644 | |
| 1645 | - upd_check_key('planet_teleport_cost', 50000, !isset($config->planet_teleport_cost)); |
|
| 1646 | - upd_check_key('planet_teleport_timeout', PERIOD_DAY * 1, !isset($config->planet_teleport_timeout)); |
|
| 1645 | + upd_check_key('planet_teleport_cost', 50000, !isset($config->planet_teleport_cost)); |
|
| 1646 | + upd_check_key('planet_teleport_timeout', PERIOD_DAY * 1, !isset($config->planet_teleport_timeout)); |
|
| 1647 | 1647 | |
| 1648 | - upd_check_key('planet_capital_cost', 25000, !isset($config->planet_capital_cost)); |
|
| 1648 | + upd_check_key('planet_capital_cost', 25000, !isset($config->planet_capital_cost)); |
|
| 1649 | 1649 | |
| 1650 | - upd_alter_table('users', array( |
|
| 1651 | - "ADD COLUMN `player_race` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player\'s race'", |
|
| 1652 | - ), !$update_tables['users']['player_race']); |
|
| 1650 | + upd_alter_table('users', array( |
|
| 1651 | + "ADD COLUMN `player_race` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player\'s race'", |
|
| 1652 | + ), !$update_tables['users']['player_race']); |
|
| 1653 | 1653 | |
| 1654 | - upd_alter_table('chat', array( |
|
| 1655 | - "MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'", |
|
| 1656 | - ), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT'); |
|
| 1654 | + upd_alter_table('chat', array( |
|
| 1655 | + "MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'", |
|
| 1656 | + ), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT'); |
|
| 1657 | 1657 | |
| 1658 | - upd_alter_table('planets', array( |
|
| 1659 | - "ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'", |
|
| 1660 | - "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'", |
|
| 1661 | - "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'", |
|
| 1662 | - "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'", |
|
| 1663 | - "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'", |
|
| 1664 | - "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'", |
|
| 1665 | - ), !$update_tables['planets']['ship_sattelite_sloth']); |
|
| 1658 | + upd_alter_table('planets', array( |
|
| 1659 | + "ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'", |
|
| 1660 | + "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'", |
|
| 1661 | + "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'", |
|
| 1662 | + "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'", |
|
| 1663 | + "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'", |
|
| 1664 | + "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'", |
|
| 1665 | + ), !$update_tables['planets']['ship_sattelite_sloth']); |
|
| 1666 | 1666 | |
| 1667 | - upd_alter_table('planets', array( |
|
| 1668 | - "ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'", |
|
| 1669 | - "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)", |
|
| 1670 | - "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)", |
|
| 1671 | - "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)", |
|
| 1672 | - "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)", |
|
| 1673 | - "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)", |
|
| 1674 | - "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)", |
|
| 1675 | - ), !$update_tables['planets']['ship_sattelite_sloth_porcent']); |
|
| 1667 | + upd_alter_table('planets', array( |
|
| 1668 | + "ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'", |
|
| 1669 | + "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)", |
|
| 1670 | + "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)", |
|
| 1671 | + "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)", |
|
| 1672 | + "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)", |
|
| 1673 | + "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)", |
|
| 1674 | + "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)", |
|
| 1675 | + ), !$update_tables['planets']['ship_sattelite_sloth_porcent']); |
|
| 1676 | 1676 | |
| 1677 | - upd_check_key('stats_hide_admins', 1, !isset($config->stats_hide_admins)); |
|
| 1678 | - upd_check_key('stats_hide_player_list', '', !isset($config->stats_hide_player_list)); |
|
| 1677 | + upd_check_key('stats_hide_admins', 1, !isset($config->stats_hide_admins)); |
|
| 1678 | + upd_check_key('stats_hide_player_list', '', !isset($config->stats_hide_player_list)); |
|
| 1679 | 1679 | |
| 1680 | - upd_check_key('adv_seo_meta_description', '', !isset($config->adv_seo_meta_description)); |
|
| 1681 | - upd_check_key('adv_seo_meta_keywords', '', !isset($config->adv_seo_meta_keywords)); |
|
| 1680 | + upd_check_key('adv_seo_meta_description', '', !isset($config->adv_seo_meta_description)); |
|
| 1681 | + upd_check_key('adv_seo_meta_keywords', '', !isset($config->adv_seo_meta_keywords)); |
|
| 1682 | 1682 | |
| 1683 | - upd_check_key('stats_hide_pm_link', '0', !isset($config->stats_hide_pm_link)); |
|
| 1683 | + upd_check_key('stats_hide_pm_link', '0', !isset($config->stats_hide_pm_link)); |
|
| 1684 | 1684 | |
| 1685 | - upd_alter_table('notes', array( |
|
| 1686 | - "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
|
| 1687 | - ), !$update_indexes['notes']['I_owner_priority_time']); |
|
| 1685 | + upd_alter_table('notes', array( |
|
| 1686 | + "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
|
| 1687 | + ), !$update_indexes['notes']['I_owner_priority_time']); |
|
| 1688 | 1688 | |
| 1689 | - if(!$update_tables['buddy']['BUDDY_ID']) |
|
| 1690 | - { |
|
| 1691 | - upd_alter_table('buddy', array( |
|
| 1692 | - "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'", |
|
| 1693 | - "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'", |
|
| 1694 | - "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy request text'", // 255 chars |
|
| 1695 | - |
|
| 1696 | - "DROP INDEX `id`", |
|
| 1697 | - |
|
| 1698 | - "DROP FOREIGN KEY `FK_buddy_sender_id`", |
|
| 1699 | - "DROP FOREIGN KEY `FK_buddy_owner_id`", |
|
| 1700 | - "DROP INDEX `I_buddy_sender`", |
|
| 1701 | - "DROP INDEX `I_buddy_owner`", |
|
| 1702 | - ), !$update_tables['buddy']['BUDDY_ID']); |
|
| 1703 | - |
|
| 1704 | - upd_alter_table('buddy', array( |
|
| 1705 | - "CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request sender ID'", |
|
| 1706 | - "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request recipient ID'", |
|
| 1707 | - ), !$update_tables['buddy']['BUDDY_SENDER']); |
|
| 1708 | - |
|
| 1709 | - $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
|
| 1710 | - $found = $lost = array(); |
|
| 1711 | - while($row = db_fetch($query)) |
|
| 1689 | + if(!$update_tables['buddy']['BUDDY_ID']) |
|
| 1712 | 1690 | { |
| 1713 | - $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
| 1714 | - if(!isset($found[$index])) |
|
| 1691 | + upd_alter_table('buddy', array( |
|
| 1692 | + "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy table row ID'", |
|
| 1693 | + "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy request status'", |
|
| 1694 | + "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy request text'", // 255 chars |
|
| 1695 | + |
|
| 1696 | + "DROP INDEX `id`", |
|
| 1697 | + |
|
| 1698 | + "DROP FOREIGN KEY `FK_buddy_sender_id`", |
|
| 1699 | + "DROP FOREIGN KEY `FK_buddy_owner_id`", |
|
| 1700 | + "DROP INDEX `I_buddy_sender`", |
|
| 1701 | + "DROP INDEX `I_buddy_owner`", |
|
| 1702 | + ), !$update_tables['buddy']['BUDDY_ID']); |
|
| 1703 | + |
|
| 1704 | + upd_alter_table('buddy', array( |
|
| 1705 | + "CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request sender ID'", |
|
| 1706 | + "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy request recipient ID'", |
|
| 1707 | + ), !$update_tables['buddy']['BUDDY_SENDER']); |
|
| 1708 | + |
|
| 1709 | + $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
|
| 1710 | + $found = $lost = array(); |
|
| 1711 | + while($row = db_fetch($query)) |
|
| 1715 | 1712 | { |
| 1716 | - $found[$index] = $row['BUDDY_ID']; |
|
| 1713 | + $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
| 1714 | + if(!isset($found[$index])) |
|
| 1715 | + { |
|
| 1716 | + $found[$index] = $row['BUDDY_ID']; |
|
| 1717 | + } |
|
| 1718 | + else |
|
| 1719 | + { |
|
| 1720 | + $lost[] = $row['BUDDY_ID']; |
|
| 1721 | + } |
|
| 1717 | 1722 | } |
| 1718 | - else |
|
| 1723 | + $lost = implode(',', $lost); |
|
| 1724 | + if($lost) |
|
| 1719 | 1725 | { |
| 1720 | - $lost[] = $row['BUDDY_ID']; |
|
| 1726 | + upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
|
| 1721 | 1727 | } |
| 1722 | - } |
|
| 1723 | - $lost = implode(',', $lost); |
|
| 1724 | - if($lost) |
|
| 1725 | - { |
|
| 1726 | - upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
|
| 1727 | - } |
|
| 1728 | 1728 | |
| 1729 | - upd_alter_table('buddy', array( |
|
| 1730 | - "ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)", |
|
| 1731 | - "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)", |
|
| 1729 | + upd_alter_table('buddy', array( |
|
| 1730 | + "ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)", |
|
| 1731 | + "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)", |
|
| 1732 | 1732 | |
| 1733 | - "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1734 | - "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1735 | - ), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']); |
|
| 1736 | - } |
|
| 1733 | + "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1734 | + "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 1735 | + ), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']); |
|
| 1736 | + } |
|
| 1737 | 1737 | |
| 1738 | - upd_do_query('COMMIT;', true); |
|
| 1739 | - $new_version = 35; |
|
| 1738 | + upd_do_query('COMMIT;', true); |
|
| 1739 | + $new_version = 35; |
|
| 1740 | 1740 | |
| 1741 | - case 35: |
|
| 1742 | - upd_log_version_update(); |
|
| 1741 | + case 35: |
|
| 1742 | + upd_log_version_update(); |
|
| 1743 | 1743 | |
| 1744 | - upd_do_query("UPDATE {{users}} SET `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL"); |
|
| 1744 | + upd_do_query("UPDATE {{users}} SET `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL"); |
|
| 1745 | 1745 | |
| 1746 | - if(!$update_tables['ube_report']) |
|
| 1747 | - { |
|
| 1748 | - upd_create_table('ube_report', |
|
| 1749 | - "( |
|
| 1746 | + if(!$update_tables['ube_report']) |
|
| 1747 | + { |
|
| 1748 | + upd_create_table('ube_report', |
|
| 1749 | + "( |
|
| 1750 | 1750 | `ube_report_id` SERIAL COMMENT 'Report ID', |
| 1751 | 1751 | |
| 1752 | 1752 | `ube_report_cypher` CHAR(32) NOT NULL DEFAULT '' COMMENT '16 char secret report ID', |
@@ -1782,13 +1782,13 @@ discard block |
||
| 1782 | 1782 | PRIMARY KEY (`ube_report_id`), |
| 1783 | 1783 | KEY `I_ube_report_cypher` (`ube_report_cypher`) |
| 1784 | 1784 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1785 | - ); |
|
| 1786 | - } |
|
| 1785 | + ); |
|
| 1786 | + } |
|
| 1787 | 1787 | |
| 1788 | - if(!$update_tables['ube_report_player']) |
|
| 1789 | - { |
|
| 1790 | - upd_create_table('ube_report_player', |
|
| 1791 | - "( |
|
| 1788 | + if(!$update_tables['ube_report_player']) |
|
| 1789 | + { |
|
| 1790 | + upd_create_table('ube_report_player', |
|
| 1791 | + "( |
|
| 1792 | 1792 | `ube_report_player_id` SERIAL COMMENT 'Record ID', |
| 1793 | 1793 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
| 1794 | 1794 | `ube_report_player_player_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Player ID', |
@@ -1804,13 +1804,13 @@ discard block |
||
| 1804 | 1804 | KEY `I_ube_report_player_player_id` (`ube_report_player_player_id`), |
| 1805 | 1805 | CONSTRAINT `FK_ube_report_player_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 1806 | 1806 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1807 | - ); |
|
| 1808 | - } |
|
| 1807 | + ); |
|
| 1808 | + } |
|
| 1809 | 1809 | |
| 1810 | - if(!$update_tables['ube_report_fleet']) |
|
| 1811 | - { |
|
| 1812 | - upd_create_table('ube_report_fleet', |
|
| 1813 | - "( |
|
| 1810 | + if(!$update_tables['ube_report_fleet']) |
|
| 1811 | + { |
|
| 1812 | + upd_create_table('ube_report_fleet', |
|
| 1813 | + "( |
|
| 1814 | 1814 | `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID', |
| 1815 | 1815 | |
| 1816 | 1816 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1835,17 +1835,17 @@ discard block |
||
| 1835 | 1835 | PRIMARY KEY (`ube_report_fleet_id`), |
| 1836 | 1836 | CONSTRAINT `FK_ube_report_fleet_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 1837 | 1837 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1838 | - ); |
|
| 1839 | - } |
|
| 1838 | + ); |
|
| 1839 | + } |
|
| 1840 | 1840 | |
| 1841 | - if(!$update_tables['ube_report_unit']) |
|
| 1842 | - { |
|
| 1843 | - // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
|
| 1844 | - // Может сохранять имена удаленных кораблей долго? |
|
| 1841 | + if(!$update_tables['ube_report_unit']) |
|
| 1842 | + { |
|
| 1843 | + // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
|
| 1844 | + // Может сохранять имена удаленных кораблей долго? |
|
| 1845 | 1845 | |
| 1846 | - // round SIGNED!!! -1 например - для ауткома |
|
| 1847 | - upd_create_table('ube_report_unit', |
|
| 1848 | - "( |
|
| 1846 | + // round SIGNED!!! -1 например - для ауткома |
|
| 1847 | + upd_create_table('ube_report_unit', |
|
| 1848 | + "( |
|
| 1849 | 1849 | `ube_report_unit_id` SERIAL COMMENT 'Record DB ID', |
| 1850 | 1850 | |
| 1851 | 1851 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1873,13 +1873,13 @@ discard block |
||
| 1873 | 1873 | KEY `I_ube_report_unit_order` (`ube_report_unit_sort_order`), |
| 1874 | 1874 | CONSTRAINT `FK_ube_report_unit_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 1875 | 1875 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1876 | - ); |
|
| 1877 | - } |
|
| 1876 | + ); |
|
| 1877 | + } |
|
| 1878 | 1878 | |
| 1879 | - if(!$update_tables['ube_report_outcome_fleet']) |
|
| 1880 | - { |
|
| 1881 | - upd_create_table('ube_report_outcome_fleet', |
|
| 1882 | - "( |
|
| 1879 | + if(!$update_tables['ube_report_outcome_fleet']) |
|
| 1880 | + { |
|
| 1881 | + upd_create_table('ube_report_outcome_fleet', |
|
| 1882 | + "( |
|
| 1883 | 1883 | `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID', |
| 1884 | 1884 | |
| 1885 | 1885 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1903,13 +1903,13 @@ discard block |
||
| 1903 | 1903 | KEY `I_ube_report_outcome_fleet_report_fleet` (`ube_report_id`, `ube_report_outcome_fleet_fleet_id`), |
| 1904 | 1904 | CONSTRAINT `FK_ube_report_outcome_fleet_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 1905 | 1905 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1906 | - ); |
|
| 1907 | - } |
|
| 1906 | + ); |
|
| 1907 | + } |
|
| 1908 | 1908 | |
| 1909 | - if(!$update_tables['ube_report_outcome_unit']) |
|
| 1910 | - { |
|
| 1911 | - upd_create_table('ube_report_outcome_unit', |
|
| 1912 | - "( |
|
| 1909 | + if(!$update_tables['ube_report_outcome_unit']) |
|
| 1910 | + { |
|
| 1911 | + upd_create_table('ube_report_outcome_unit', |
|
| 1912 | + "( |
|
| 1913 | 1913 | `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID', |
| 1914 | 1914 | |
| 1915 | 1915 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1925,13 +1925,13 @@ discard block |
||
| 1925 | 1925 | KEY `I_ube_report_outcome_unit_report_order` (`ube_report_id`, `ube_report_outcome_unit_sort_order`), |
| 1926 | 1926 | CONSTRAINT `FK_ube_report_outcome_unit_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{$config->db_prefix}ube_report` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 1927 | 1927 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1928 | - ); |
|
| 1929 | - } |
|
| 1928 | + ); |
|
| 1929 | + } |
|
| 1930 | 1930 | |
| 1931 | - if(!$update_tables['unit']) |
|
| 1932 | - { |
|
| 1933 | - upd_create_table('unit', |
|
| 1934 | - "( |
|
| 1931 | + if(!$update_tables['unit']) |
|
| 1932 | + { |
|
| 1933 | + upd_create_table('unit', |
|
| 1934 | + "( |
|
| 1935 | 1935 | `unit_id` SERIAL COMMENT 'Record ID', |
| 1936 | 1936 | |
| 1937 | 1937 | `unit_player_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Unit owner', |
@@ -1945,13 +1945,13 @@ discard block |
||
| 1945 | 1945 | KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`), |
| 1946 | 1946 | CONSTRAINT `FK_unit_player_id` FOREIGN KEY (`unit_player_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 1947 | 1947 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1948 | - ); |
|
| 1949 | - } |
|
| 1948 | + ); |
|
| 1949 | + } |
|
| 1950 | 1950 | |
| 1951 | - if(!$update_tables['captain']) |
|
| 1952 | - { |
|
| 1953 | - upd_create_table('captain', |
|
| 1954 | - "( |
|
| 1951 | + if(!$update_tables['captain']) |
|
| 1952 | + { |
|
| 1953 | + upd_create_table('captain', |
|
| 1954 | + "( |
|
| 1955 | 1955 | `captain_id` SERIAL COMMENT 'Record ID', |
| 1956 | 1956 | `captain_unit_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Link to `unit` record', |
| 1957 | 1957 | |
@@ -1966,36 +1966,36 @@ discard block |
||
| 1966 | 1966 | KEY `I_captain_unit_id` (`captain_unit_id`), |
| 1967 | 1967 | CONSTRAINT `FK_captain_unit_id` FOREIGN KEY (`captain_unit_id`) REFERENCES `{$config->db_prefix}unit` (`unit_id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 1968 | 1968 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 1969 | - ); |
|
| 1970 | - } |
|
| 1969 | + ); |
|
| 1970 | + } |
|
| 1971 | 1971 | |
| 1972 | - if(!$update_tables['fleets']['fleet_start_planet_id']) |
|
| 1973 | - { |
|
| 1974 | - upd_alter_table('fleets', array( |
|
| 1975 | - "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
|
| 1976 | - "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
|
| 1972 | + if(!$update_tables['fleets']['fleet_start_planet_id']) |
|
| 1973 | + { |
|
| 1974 | + upd_alter_table('fleets', array( |
|
| 1975 | + "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
|
| 1976 | + "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
|
| 1977 | 1977 | |
| 1978 | - "ADD KEY `I_fleet_start_planet_id` (`fleet_start_planet_id`)", |
|
| 1979 | - "ADD KEY `I_fleet_end_planet_id` (`fleet_end_planet_id`)", |
|
| 1978 | + "ADD KEY `I_fleet_start_planet_id` (`fleet_start_planet_id`)", |
|
| 1979 | + "ADD KEY `I_fleet_end_planet_id` (`fleet_end_planet_id`)", |
|
| 1980 | 1980 | |
| 1981 | - "ADD CONSTRAINT `FK_fleet_planet_start` FOREIGN KEY (`fleet_start_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 1982 | - "ADD CONSTRAINT `FK_fleet_planet_end` FOREIGN KEY (`fleet_end_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 1983 | - ), !$update_tables['fleets']['fleet_start_planet_id']); |
|
| 1981 | + "ADD CONSTRAINT `FK_fleet_planet_start` FOREIGN KEY (`fleet_start_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 1982 | + "ADD CONSTRAINT `FK_fleet_planet_end` FOREIGN KEY (`fleet_end_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 1983 | + ), !$update_tables['fleets']['fleet_start_planet_id']); |
|
| 1984 | 1984 | |
| 1985 | - upd_do_query(" |
|
| 1985 | + upd_do_query(" |
|
| 1986 | 1986 | UPDATE {{fleets}} AS f |
| 1987 | 1987 | LEFT JOIN {{planets}} AS p_s ON p_s.galaxy = f.fleet_start_galaxy AND p_s.system = f.fleet_start_system AND p_s.planet = f.fleet_start_planet AND p_s.planet_type = f.fleet_start_type |
| 1988 | 1988 | LEFT JOIN {{planets}} AS p_e ON p_e.galaxy = f.fleet_end_galaxy AND p_e.system = f.fleet_end_system AND p_e.planet = f.fleet_end_planet AND p_e.planet_type = f.fleet_end_type |
| 1989 | 1989 | SET f.fleet_start_planet_id = p_s.id, f.fleet_end_planet_id = p_e.id |
| 1990 | 1990 | "); |
| 1991 | - } |
|
| 1991 | + } |
|
| 1992 | 1992 | |
| 1993 | - upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
|
| 1993 | + upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
|
| 1994 | 1994 | |
| 1995 | - if(!$update_tables['chat_player']) |
|
| 1996 | - { |
|
| 1997 | - upd_create_table('chat_player', |
|
| 1998 | - "( |
|
| 1995 | + if(!$update_tables['chat_player']) |
|
| 1996 | + { |
|
| 1997 | + upd_create_table('chat_player', |
|
| 1998 | + "( |
|
| 1999 | 1999 | `chat_player_id` SERIAL COMMENT 'Record ID', |
| 2000 | 2000 | |
| 2001 | 2001 | `chat_player_player_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Chat player record owner', |
@@ -2011,105 +2011,105 @@ discard block |
||
| 2011 | 2011 | CONSTRAINT `FK_chat_player_id` FOREIGN KEY (`chat_player_player_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 2012 | 2012 | |
| 2013 | 2013 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 2014 | - ); |
|
| 2015 | - } |
|
| 2016 | - |
|
| 2017 | - upd_alter_table('chat', array( |
|
| 2018 | - "ADD `chat_message_sender_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message sender ID' AFTER `messageid`", |
|
| 2019 | - "ADD `chat_message_recipient_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message recipient ID' AFTER `user`", |
|
| 2014 | + ); |
|
| 2015 | + } |
|
| 2020 | 2016 | |
| 2021 | - "ADD KEY `I_chat_message_sender_id` (`chat_message_sender_id`)", |
|
| 2022 | - "ADD KEY `I_chat_message_recipient_id` (`chat_message_recipient_id`)", |
|
| 2017 | + upd_alter_table('chat', array( |
|
| 2018 | + "ADD `chat_message_sender_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message sender ID' AFTER `messageid`", |
|
| 2019 | + "ADD `chat_message_recipient_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message recipient ID' AFTER `user`", |
|
| 2023 | 2020 | |
| 2024 | - "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2025 | - "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2026 | - ), !$update_tables['chat']['chat_message_sender_id']); |
|
| 2021 | + "ADD KEY `I_chat_message_sender_id` (`chat_message_sender_id`)", |
|
| 2022 | + "ADD KEY `I_chat_message_recipient_id` (`chat_message_recipient_id`)", |
|
| 2027 | 2023 | |
| 2028 | - upd_alter_table('chat', array( |
|
| 2029 | - "ADD `chat_message_sender_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_sender_id`", |
|
| 2030 | - "ADD `chat_message_recipient_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_recipient_id`", |
|
| 2031 | - ), !$update_tables['chat']['chat_message_sender_name']); |
|
| 2024 | + "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2025 | + "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2026 | + ), !$update_tables['chat']['chat_message_sender_id']); |
|
| 2032 | 2027 | |
| 2033 | - upd_alter_table('users', array( |
|
| 2034 | - "MODIFY COLUMN `banaday` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ban status'", |
|
| 2035 | - ), strtoupper($update_tables['users']['banaday']['Null']) == 'YES'); |
|
| 2028 | + upd_alter_table('chat', array( |
|
| 2029 | + "ADD `chat_message_sender_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_sender_id`", |
|
| 2030 | + "ADD `chat_message_recipient_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_recipient_id`", |
|
| 2031 | + ), !$update_tables['chat']['chat_message_sender_name']); |
|
| 2036 | 2032 | |
| 2037 | - upd_alter_table('banned', array( |
|
| 2038 | - "ADD `ban_user_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banned user ID' AFTER `ban_id`", |
|
| 2039 | - "ADD `ban_issuer_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banner ID' AFTER `ban_until`", |
|
| 2033 | + upd_alter_table('users', array( |
|
| 2034 | + "MODIFY COLUMN `banaday` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ban status'", |
|
| 2035 | + ), strtoupper($update_tables['users']['banaday']['Null']) == 'YES'); |
|
| 2040 | 2036 | |
| 2041 | - "ADD KEY `I_ban_user_id` (`ban_user_id`)", |
|
| 2042 | - "ADD KEY `I_ban_issuer_id` (`ban_issuer_id`)", |
|
| 2037 | + upd_alter_table('banned', array( |
|
| 2038 | + "ADD `ban_user_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banned user ID' AFTER `ban_id`", |
|
| 2039 | + "ADD `ban_issuer_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banner ID' AFTER `ban_until`", |
|
| 2043 | 2040 | |
| 2044 | - "ADD CONSTRAINT `FK_ban_user_id` FOREIGN KEY (`ban_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 2045 | - "ADD CONSTRAINT `FK_ban_issuer_id` FOREIGN KEY (`ban_issuer_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 2046 | - ), !$update_tables['banned']['ban_user_id']); |
|
| 2041 | + "ADD KEY `I_ban_user_id` (`ban_user_id`)", |
|
| 2042 | + "ADD KEY `I_ban_issuer_id` (`ban_issuer_id`)", |
|
| 2047 | 2043 | |
| 2048 | - upd_do_query('COMMIT;', true); |
|
| 2049 | - $new_version = 36; |
|
| 2044 | + "ADD CONSTRAINT `FK_ban_user_id` FOREIGN KEY (`ban_user_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 2045 | + "ADD CONSTRAINT `FK_ban_issuer_id` FOREIGN KEY (`ban_issuer_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 2046 | + ), !$update_tables['banned']['ban_user_id']); |
|
| 2050 | 2047 | |
| 2051 | - case 36: |
|
| 2052 | - upd_log_version_update(); |
|
| 2048 | + upd_do_query('COMMIT;', true); |
|
| 2049 | + $new_version = 36; |
|
| 2053 | 2050 | |
| 2054 | - upd_alter_table('payment', array( |
|
| 2055 | - "DROP FOREIGN KEY `FK_payment_user`", |
|
| 2056 | - ), $update_foreigns['payment']['FK_payment_user']); |
|
| 2051 | + case 36: |
|
| 2052 | + upd_log_version_update(); |
|
| 2057 | 2053 | |
| 2058 | - if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') |
|
| 2059 | - { |
|
| 2060 | - upd_alter_table('chat', array( |
|
| 2061 | - "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
|
| 2062 | - "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
|
| 2063 | - ), true); |
|
| 2054 | + upd_alter_table('payment', array( |
|
| 2055 | + "DROP FOREIGN KEY `FK_payment_user`", |
|
| 2056 | + ), $update_foreigns['payment']['FK_payment_user']); |
|
| 2064 | 2057 | |
| 2065 | - upd_alter_table('chat', array( |
|
| 2066 | - "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2067 | - "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2068 | - ), true); |
|
| 2069 | - } |
|
| 2058 | + if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') |
|
| 2059 | + { |
|
| 2060 | + upd_alter_table('chat', array( |
|
| 2061 | + "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
|
| 2062 | + "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
|
| 2063 | + ), true); |
|
| 2064 | + |
|
| 2065 | + upd_alter_table('chat', array( |
|
| 2066 | + "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2067 | + "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2068 | + ), true); |
|
| 2069 | + } |
|
| 2070 | 2070 | |
| 2071 | - upd_alter_table('users', array( |
|
| 2072 | - "ADD `user_time_diff` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `onlinetime`", |
|
| 2073 | - "ADD `user_time_diff_forced` TINYINT(1) DEFAULT 0 COMMENT 'User time difference forced with time zone selection flag' AFTER `user_time_diff`", |
|
| 2074 | - ), !$update_tables['users']['user_time_diff']); |
|
| 2071 | + upd_alter_table('users', array( |
|
| 2072 | + "ADD `user_time_diff` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `onlinetime`", |
|
| 2073 | + "ADD `user_time_diff_forced` TINYINT(1) DEFAULT 0 COMMENT 'User time difference forced with time zone selection flag' AFTER `user_time_diff`", |
|
| 2074 | + ), !$update_tables['users']['user_time_diff']); |
|
| 2075 | 2075 | |
| 2076 | - upd_alter_table('planets', array( |
|
| 2077 | - "ADD `ship_orbital_heavy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'HOPe - Heavy Orbital Platform'", |
|
| 2078 | - ), !$update_tables['planets']['ship_orbital_heavy']); |
|
| 2076 | + upd_alter_table('planets', array( |
|
| 2077 | + "ADD `ship_orbital_heavy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'HOPe - Heavy Orbital Platform'", |
|
| 2078 | + ), !$update_tables['planets']['ship_orbital_heavy']); |
|
| 2079 | 2079 | |
| 2080 | - upd_check_key('chat_refresh_rate', 5, !isset($config->chat_refresh_rate)); |
|
| 2080 | + upd_check_key('chat_refresh_rate', 5, !isset($config->chat_refresh_rate)); |
|
| 2081 | 2081 | |
| 2082 | - upd_alter_table('chat_player', array( |
|
| 2083 | - "ADD `chat_player_refresh_last` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player last refresh time'", |
|
| 2082 | + upd_alter_table('chat_player', array( |
|
| 2083 | + "ADD `chat_player_refresh_last` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player last refresh time'", |
|
| 2084 | 2084 | |
| 2085 | - "ADD KEY `I_chat_player_refresh_last` (`chat_player_refresh_last`)", |
|
| 2086 | - ), !$update_tables['chat_player']['chat_player_refresh_last']); |
|
| 2085 | + "ADD KEY `I_chat_player_refresh_last` (`chat_player_refresh_last`)", |
|
| 2086 | + ), !$update_tables['chat_player']['chat_player_refresh_last']); |
|
| 2087 | 2087 | |
| 2088 | - upd_alter_table('ube_report', array( |
|
| 2089 | - "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
|
| 2090 | - ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
|
| 2088 | + upd_alter_table('ube_report', array( |
|
| 2089 | + "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
|
| 2090 | + ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
|
| 2091 | 2091 | |
| 2092 | - if(!$update_tables['unit']['unit_time_start']) |
|
| 2093 | - { |
|
| 2094 | - upd_alter_table('unit', array( |
|
| 2095 | - "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
|
| 2096 | - "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
|
| 2097 | - ), !$update_tables['unit']['unit_time_start']); |
|
| 2092 | + if(!$update_tables['unit']['unit_time_start']) |
|
| 2093 | + { |
|
| 2094 | + upd_alter_table('unit', array( |
|
| 2095 | + "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
|
| 2096 | + "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
|
| 2097 | + ), !$update_tables['unit']['unit_time_start']); |
|
| 2098 | 2098 | |
| 2099 | - upd_do_query( |
|
| 2100 | - "INSERT INTO {{unit}} |
|
| 2099 | + upd_do_query( |
|
| 2100 | + "INSERT INTO {{unit}} |
|
| 2101 | 2101 | (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish) |
| 2102 | 2102 | SELECT |
| 2103 | 2103 | `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level` |
| 2104 | 2104 | , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL) |
| 2105 | 2105 | FROM {{powerup}}" |
| 2106 | - ); |
|
| 2107 | - } |
|
| 2106 | + ); |
|
| 2107 | + } |
|
| 2108 | 2108 | |
| 2109 | - if(!$update_tables['que']) |
|
| 2110 | - { |
|
| 2111 | - upd_create_table('que', |
|
| 2112 | - "( |
|
| 2109 | + if(!$update_tables['que']) |
|
| 2110 | + { |
|
| 2111 | + upd_create_table('que', |
|
| 2112 | + "( |
|
| 2113 | 2113 | `que_id` SERIAL COMMENT 'Internal que id', |
| 2114 | 2114 | |
| 2115 | 2115 | `que_player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Que owner ID', |
@@ -2135,175 +2135,175 @@ discard block |
||
| 2135 | 2135 | CONSTRAINT `FK_que_planet_id` FOREIGN KEY (`que_planet_id`) REFERENCES `{$config->db_prefix}planets` (`id`) ON UPDATE CASCADE ON DELETE CASCADE, |
| 2136 | 2136 | CONSTRAINT `FK_que_planet_id_origin` FOREIGN KEY (`que_planet_id_origin`) REFERENCES `{$config->db_prefix}planets` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 2137 | 2137 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 2138 | - ); |
|
| 2139 | - } |
|
| 2138 | + ); |
|
| 2139 | + } |
|
| 2140 | 2140 | |
| 2141 | - // Конвертирум очередь исследований |
|
| 2142 | - if($update_tables['users']['que']) |
|
| 2143 | - { |
|
| 2144 | - $que_lines = array(); |
|
| 2145 | - $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
|
| 2146 | - while($que_row = db_fetch($que_query)) |
|
| 2141 | + // Конвертирум очередь исследований |
|
| 2142 | + if($update_tables['users']['que']) |
|
| 2147 | 2143 | { |
| 2148 | - $que_data = explode(',', $que_row['que']); |
|
| 2149 | - |
|
| 2150 | - if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) |
|
| 2144 | + $que_lines = array(); |
|
| 2145 | + $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
|
| 2146 | + while($que_row = db_fetch($que_query)) |
|
| 2151 | 2147 | { |
| 2152 | - continue; |
|
| 2153 | - } |
|
| 2148 | + $que_data = explode(',', $que_row['que']); |
|
| 2154 | 2149 | |
| 2155 | - $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
|
| 2156 | - // Если планета пустая - ставим главку |
|
| 2157 | - $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
|
| 2158 | - if($que_data[QI_PLANET_ID]) |
|
| 2159 | - { |
|
| 2160 | - $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
|
| 2161 | - if(!$que_planet_check['id']) |
|
| 2150 | + if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) |
|
| 2151 | + { |
|
| 2152 | + continue; |
|
| 2153 | + } |
|
| 2154 | + |
|
| 2155 | + $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
|
| 2156 | + // Если планета пустая - ставим главку |
|
| 2157 | + $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
|
| 2158 | + if($que_data[QI_PLANET_ID]) |
|
| 2162 | 2159 | { |
| 2163 | - $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
|
| 2164 | 2160 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
| 2165 | 2161 | if(!$que_planet_check['id']) |
| 2166 | 2162 | { |
| 2167 | - $que_data[QI_PLANET_ID] = 'NULL'; |
|
| 2163 | + $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
|
| 2164 | + $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
|
| 2165 | + if(!$que_planet_check['id']) |
|
| 2166 | + { |
|
| 2167 | + $que_data[QI_PLANET_ID] = 'NULL'; |
|
| 2168 | + } |
|
| 2168 | 2169 | } |
| 2169 | 2170 | } |
| 2170 | - } |
|
| 2171 | - else |
|
| 2172 | - { |
|
| 2173 | - $que_data[QI_PLANET_ID] = 'NULL'; |
|
| 2174 | - } |
|
| 2171 | + else |
|
| 2172 | + { |
|
| 2173 | + $que_data[QI_PLANET_ID] = 'NULL'; |
|
| 2174 | + } |
|
| 2175 | 2175 | |
| 2176 | - $unit_info = get_unit_param($que_data[QI_UNIT_ID]); |
|
| 2177 | - $unit_level = $que_row[$unit_info[P_NAME]]; |
|
| 2178 | - $unit_factor = $unit_info[P_COST][P_FACTOR] ? $unit_info[P_COST][P_FACTOR] : 1; |
|
| 2179 | - $price_increase = pow($unit_factor, $unit_level); |
|
| 2180 | - $unit_level++; |
|
| 2181 | - $unit_cost = array(); |
|
| 2182 | - foreach($unit_info[P_COST] as $resource_id => $resource_amount) |
|
| 2183 | - { |
|
| 2184 | - if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) |
|
| 2176 | + $unit_info = get_unit_param($que_data[QI_UNIT_ID]); |
|
| 2177 | + $unit_level = $que_row[$unit_info[P_NAME]]; |
|
| 2178 | + $unit_factor = $unit_info[P_COST][P_FACTOR] ? $unit_info[P_COST][P_FACTOR] : 1; |
|
| 2179 | + $price_increase = pow($unit_factor, $unit_level); |
|
| 2180 | + $unit_level++; |
|
| 2181 | + $unit_cost = array(); |
|
| 2182 | + foreach($unit_info[P_COST] as $resource_id => $resource_amount) |
|
| 2185 | 2183 | { |
| 2186 | - continue; |
|
| 2184 | + if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) |
|
| 2185 | + { |
|
| 2186 | + continue; |
|
| 2187 | + } |
|
| 2188 | + $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
|
| 2187 | 2189 | } |
| 2188 | - $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
|
| 2190 | + $unit_cost = implode(';', $unit_cost); |
|
| 2191 | + |
|
| 2192 | + $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," . |
|
| 2193 | + BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
| 2189 | 2194 | } |
| 2190 | - $unit_cost = implode(';', $unit_cost); |
|
| 2191 | 2195 | |
| 2192 | - $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," . |
|
| 2193 | - BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
| 2194 | - } |
|
| 2196 | + if(!empty($que_lines)) |
|
| 2197 | + { |
|
| 2198 | + upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines)); |
|
| 2199 | + } |
|
| 2195 | 2200 | |
| 2196 | - if(!empty($que_lines)) |
|
| 2197 | - { |
|
| 2198 | - upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines)); |
|
| 2201 | + upd_alter_table('users', array( |
|
| 2202 | + "DROP COLUMN `que`", |
|
| 2203 | + ), $update_tables['users']['que']); |
|
| 2199 | 2204 | } |
| 2200 | 2205 | |
| 2201 | - upd_alter_table('users', array( |
|
| 2202 | - "DROP COLUMN `que`", |
|
| 2203 | - ), $update_tables['users']['que']); |
|
| 2204 | - } |
|
| 2205 | - |
|
| 2206 | - |
|
| 2207 | - upd_check_key('server_que_length_research', 1, !isset($config->server_que_length_research)); |
|
| 2208 | 2206 | |
| 2207 | + upd_check_key('server_que_length_research', 1, !isset($config->server_que_length_research)); |
|
| 2209 | 2208 | |
| 2210 | - // Ковертируем технологии в таблицы |
|
| 2211 | - if($update_tables['users']['graviton_tech']) |
|
| 2212 | - { |
|
| 2213 | - upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
|
| 2214 | 2209 | |
| 2215 | - $que_lines = array(); |
|
| 2216 | - $user_query = upd_do_query("SELECT * FROM {{users}}"); |
|
| 2217 | - upd_add_more_time(300); |
|
| 2218 | - $sn_group_tech = sn_get_groups('tech'); |
|
| 2219 | - while($user_row = db_fetch($user_query)) |
|
| 2210 | + // Ковертируем технологии в таблицы |
|
| 2211 | + if($update_tables['users']['graviton_tech']) |
|
| 2220 | 2212 | { |
| 2221 | - foreach($sn_group_tech as $tech_id) |
|
| 2213 | + upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
|
| 2214 | + |
|
| 2215 | + $que_lines = array(); |
|
| 2216 | + $user_query = upd_do_query("SELECT * FROM {{users}}"); |
|
| 2217 | + upd_add_more_time(300); |
|
| 2218 | + $sn_group_tech = sn_get_groups('tech'); |
|
| 2219 | + while($user_row = db_fetch($user_query)) |
|
| 2222 | 2220 | { |
| 2223 | - if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) |
|
| 2221 | + foreach($sn_group_tech as $tech_id) |
|
| 2224 | 2222 | { |
| 2225 | - $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
|
| 2223 | + if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) |
|
| 2224 | + { |
|
| 2225 | + $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
|
| 2226 | + } |
|
| 2226 | 2227 | } |
| 2227 | 2228 | } |
| 2228 | - } |
|
| 2229 | - |
|
| 2230 | - if(!empty($que_lines)) |
|
| 2231 | - { |
|
| 2232 | - upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines)); |
|
| 2233 | - } |
|
| 2234 | - |
|
| 2235 | - upd_alter_table('users', array( |
|
| 2236 | - "DROP COLUMN `graviton_tech`", |
|
| 2237 | - ), $update_tables['users']['graviton_tech']); |
|
| 2238 | - } |
|
| 2239 | 2229 | |
| 2240 | - if(!$update_indexes['unit']['I_unit_record_search']) |
|
| 2241 | - { |
|
| 2242 | - upd_alter_table('unit', array( |
|
| 2243 | - "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
|
| 2244 | - ), !$update_indexes['unit']['I_unit_record_search']); |
|
| 2230 | + if(!empty($que_lines)) |
|
| 2231 | + { |
|
| 2232 | + upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines)); |
|
| 2233 | + } |
|
| 2245 | 2234 | |
| 2246 | - foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) |
|
| 2247 | - { |
|
| 2248 | - $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
|
| 2235 | + upd_alter_table('users', array( |
|
| 2236 | + "DROP COLUMN `graviton_tech`", |
|
| 2237 | + ), $update_tables['users']['graviton_tech']); |
|
| 2249 | 2238 | } |
| 2250 | - $drop_index = array(); |
|
| 2251 | - $create_index = &$drop_index; // array(); |
|
| 2252 | - foreach($planet_units as $unit_name => $unit_create) |
|
| 2239 | + |
|
| 2240 | + if(!$update_indexes['unit']['I_unit_record_search']) |
|
| 2253 | 2241 | { |
| 2254 | - if($update_indexes['planets']['I_' . $unit_name]) |
|
| 2242 | + upd_alter_table('unit', array( |
|
| 2243 | + "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
|
| 2244 | + ), !$update_indexes['unit']['I_unit_record_search']); |
|
| 2245 | + |
|
| 2246 | + foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) |
|
| 2255 | 2247 | { |
| 2256 | - $drop_index[] = "DROP KEY I_{$unit_name}"; |
|
| 2248 | + $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
|
| 2257 | 2249 | } |
| 2258 | - if($update_indexes['planets']['i_' . $unit_name]) |
|
| 2250 | + $drop_index = array(); |
|
| 2251 | + $create_index = &$drop_index; // array(); |
|
| 2252 | + foreach($planet_units as $unit_name => $unit_create) |
|
| 2259 | 2253 | { |
| 2260 | - $drop_index[] = "DROP KEY i_{$unit_name}"; |
|
| 2261 | - } |
|
| 2254 | + if($update_indexes['planets']['I_' . $unit_name]) |
|
| 2255 | + { |
|
| 2256 | + $drop_index[] = "DROP KEY I_{$unit_name}"; |
|
| 2257 | + } |
|
| 2258 | + if($update_indexes['planets']['i_' . $unit_name]) |
|
| 2259 | + { |
|
| 2260 | + $drop_index[] = "DROP KEY i_{$unit_name}"; |
|
| 2261 | + } |
|
| 2262 | 2262 | |
| 2263 | - if($unit_create) |
|
| 2264 | - { |
|
| 2265 | - $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
|
| 2263 | + if($unit_create) |
|
| 2264 | + { |
|
| 2265 | + $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
|
| 2266 | + } |
|
| 2266 | 2267 | } |
| 2268 | + upd_alter_table('planets', $drop_index, true); |
|
| 2267 | 2269 | } |
| 2268 | - upd_alter_table('planets', $drop_index, true); |
|
| 2269 | - } |
|
| 2270 | 2270 | |
| 2271 | - upd_alter_table('users', array( |
|
| 2272 | - "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
|
| 2273 | - ), !$update_tables['users']['user_time_utc_offset']); |
|
| 2271 | + upd_alter_table('users', array( |
|
| 2272 | + "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
|
| 2273 | + ), !$update_tables['users']['user_time_utc_offset']); |
|
| 2274 | 2274 | |
| 2275 | - if(!$update_foreigns['alliance']['FK_alliance_owner']) |
|
| 2276 | - { |
|
| 2277 | - upd_do_query("UPDATE {{alliance}} SET ally_owner = null WHERE ally_owner not in (select id from {{users}})"); |
|
| 2275 | + if(!$update_foreigns['alliance']['FK_alliance_owner']) |
|
| 2276 | + { |
|
| 2277 | + upd_do_query("UPDATE {{alliance}} SET ally_owner = null WHERE ally_owner not in (select id from {{users}})"); |
|
| 2278 | 2278 | |
| 2279 | - upd_alter_table('alliance', array( |
|
| 2280 | - "ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 2281 | - ), !$update_foreigns['alliance']['FK_alliance_owner']); |
|
| 2279 | + upd_alter_table('alliance', array( |
|
| 2280 | + "ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
| 2281 | + ), !$update_foreigns['alliance']['FK_alliance_owner']); |
|
| 2282 | 2282 | |
| 2283 | - upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id not in (select id from {{alliance}}) OR alliance_negotiation_contr_ally_id not in (select id from {{alliance}})"); |
|
| 2283 | + upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id not in (select id from {{alliance}}) OR alliance_negotiation_contr_ally_id not in (select id from {{alliance}})"); |
|
| 2284 | 2284 | |
| 2285 | - upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id"); |
|
| 2286 | - upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id"); |
|
| 2287 | - } |
|
| 2285 | + upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id"); |
|
| 2286 | + upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id"); |
|
| 2287 | + } |
|
| 2288 | 2288 | |
| 2289 | - upd_alter_table('fleets', array( |
|
| 2290 | - 'MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
| 2291 | - "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2292 | - ), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 2289 | + upd_alter_table('fleets', array( |
|
| 2290 | + 'MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
| 2291 | + "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{$config->db_prefix}users` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
| 2292 | + ), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
| 2293 | 2293 | |
| 2294 | - upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !$config->chat_highlight_developer); |
|
| 2294 | + upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !$config->chat_highlight_developer); |
|
| 2295 | 2295 | |
| 2296 | - if(!$update_tables['player_name_history']) |
|
| 2297 | - { |
|
| 2298 | - upd_check_key('game_user_changename_cost', 100000, !$config->game_user_changename_cost); |
|
| 2299 | - upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
|
| 2296 | + if(!$update_tables['player_name_history']) |
|
| 2297 | + { |
|
| 2298 | + upd_check_key('game_user_changename_cost', 100000, !$config->game_user_changename_cost); |
|
| 2299 | + upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
|
| 2300 | 2300 | |
| 2301 | - upd_alter_table('users', array( |
|
| 2302 | - "CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'", |
|
| 2303 | - )); |
|
| 2301 | + upd_alter_table('users', array( |
|
| 2302 | + "CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'", |
|
| 2303 | + )); |
|
| 2304 | 2304 | |
| 2305 | - upd_create_table('player_name_history', |
|
| 2306 | - "( |
|
| 2305 | + upd_create_table('player_name_history', |
|
| 2306 | + "( |
|
| 2307 | 2307 | `player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Player ID', |
| 2308 | 2308 | `player_name` VARCHAR(32) NOT NULL COMMENT 'Historical player name', |
| 2309 | 2309 | `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When player changed name', |
@@ -2313,79 +2313,79 @@ discard block |
||
| 2313 | 2313 | |
| 2314 | 2314 | CONSTRAINT `FK_player_name_history_id` FOREIGN KEY (`player_id`) REFERENCES `{$config->db_prefix}users` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
| 2315 | 2315 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
| 2316 | - ); |
|
| 2316 | + ); |
|
| 2317 | 2317 | |
| 2318 | - upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;"); |
|
| 2319 | - } |
|
| 2318 | + upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;"); |
|
| 2319 | + } |
|
| 2320 | 2320 | |
| 2321 | - upd_alter_table('planets', array( |
|
| 2322 | - "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", |
|
| 2323 | - "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
|
| 2324 | - ), !$update_tables['planets']['density_index']); |
|
| 2321 | + upd_alter_table('planets', array( |
|
| 2322 | + "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", |
|
| 2323 | + "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
|
| 2324 | + ), !$update_tables['planets']['density_index']); |
|
| 2325 | 2325 | |
| 2326 | - if($update_tables['users']['player_artifact_list']) |
|
| 2327 | - { |
|
| 2328 | - upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
|
| 2326 | + if($update_tables['users']['player_artifact_list']) |
|
| 2327 | + { |
|
| 2328 | + upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
|
| 2329 | 2329 | |
| 2330 | - upd_alter_table('unit', "ADD KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`)", !$update_indexes['unit']['I_unit_player_location_snid']); |
|
| 2331 | - upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']); |
|
| 2330 | + upd_alter_table('unit', "ADD KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`)", !$update_indexes['unit']['I_unit_player_location_snid']); |
|
| 2331 | + upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']); |
|
| 2332 | 2332 | |
| 2333 | - $sn_data_artifacts = sn_get_groups('artifacts'); |
|
| 2334 | - $db_changeset = array(); |
|
| 2333 | + $sn_data_artifacts = sn_get_groups('artifacts'); |
|
| 2334 | + $db_changeset = array(); |
|
| 2335 | 2335 | |
| 2336 | - $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
|
| 2337 | - while($row = db_fetch($query)) |
|
| 2338 | - { |
|
| 2339 | - $artifact_list = explode(';', $row['player_artifact_list']); |
|
| 2340 | - if(!$row['player_artifact_list'] || empty($artifact_list)) |
|
| 2341 | - { |
|
| 2342 | - continue; |
|
| 2343 | - } |
|
| 2344 | - foreach($artifact_list as $key => &$value) |
|
| 2336 | + $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
|
| 2337 | + while($row = db_fetch($query)) |
|
| 2345 | 2338 | { |
| 2346 | - $value = explode(',', $value); |
|
| 2347 | - if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) |
|
| 2339 | + $artifact_list = explode(';', $row['player_artifact_list']); |
|
| 2340 | + if(!$row['player_artifact_list'] || empty($artifact_list)) |
|
| 2348 | 2341 | { |
| 2349 | - unset($artifact_list[$key]); |
|
| 2350 | 2342 | continue; |
| 2351 | 2343 | } |
| 2352 | - $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row); |
|
| 2344 | + foreach($artifact_list as $key => &$value) |
|
| 2345 | + { |
|
| 2346 | + $value = explode(',', $value); |
|
| 2347 | + if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) |
|
| 2348 | + { |
|
| 2349 | + unset($artifact_list[$key]); |
|
| 2350 | + continue; |
|
| 2351 | + } |
|
| 2352 | + $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row); |
|
| 2353 | + } |
|
| 2353 | 2354 | } |
| 2354 | - } |
|
| 2355 | - upd_db_changeset_apply($db_changeset); |
|
| 2355 | + upd_db_changeset_apply($db_changeset); |
|
| 2356 | 2356 | |
| 2357 | - upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']); |
|
| 2358 | - } |
|
| 2357 | + upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']); |
|
| 2358 | + } |
|
| 2359 | 2359 | |
| 2360 | - upd_alter_table('users', array( |
|
| 2361 | - "DROP COLUMN `spy_tech`", |
|
| 2362 | - "DROP COLUMN `computer_tech`", |
|
| 2363 | - "DROP COLUMN `military_tech`", |
|
| 2364 | - "DROP COLUMN `defence_tech`", |
|
| 2365 | - "DROP COLUMN `shield_tech`", |
|
| 2366 | - "DROP COLUMN `energy_tech`", |
|
| 2367 | - "DROP COLUMN `hyperspace_tech`", |
|
| 2368 | - "DROP COLUMN `combustion_tech`", |
|
| 2369 | - "DROP COLUMN `impulse_motor_tech`", |
|
| 2370 | - "DROP COLUMN `hyperspace_motor_tech`", |
|
| 2371 | - "DROP COLUMN `laser_tech`", |
|
| 2372 | - "DROP COLUMN `ionic_tech`", |
|
| 2373 | - "DROP COLUMN `buster_tech`", |
|
| 2374 | - "DROP COLUMN `intergalactic_tech`", |
|
| 2375 | - "DROP COLUMN `expedition_tech`", |
|
| 2376 | - "DROP COLUMN `colonisation_tech`", |
|
| 2377 | - ), $update_tables['users']['spy_tech']); |
|
| 2378 | - |
|
| 2379 | - upd_check_key('payment_currency_exchange_dm_', 2500, !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000); |
|
| 2380 | - upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !$config->payment_currency_exchange_eur); |
|
| 2381 | - upd_check_key('payment_currency_exchange_rub', 4.0, !$config->payment_currency_exchange_rub); |
|
| 2382 | - upd_check_key('payment_currency_exchange_usd', 0.125, !$config->payment_currency_exchange_usd); |
|
| 2383 | - upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !$config->payment_currency_exchange_usd); |
|
| 2384 | - upd_check_key('payment_currency_exchange_wmr', 4.1, !$config->payment_currency_exchange_wmr); |
|
| 2385 | - upd_check_key('payment_currency_exchange_wmu', 1.05, !$config->payment_currency_exchange_wmu); |
|
| 2386 | - upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !$config->payment_currency_exchange_wmz); |
|
| 2360 | + upd_alter_table('users', array( |
|
| 2361 | + "DROP COLUMN `spy_tech`", |
|
| 2362 | + "DROP COLUMN `computer_tech`", |
|
| 2363 | + "DROP COLUMN `military_tech`", |
|
| 2364 | + "DROP COLUMN `defence_tech`", |
|
| 2365 | + "DROP COLUMN `shield_tech`", |
|
| 2366 | + "DROP COLUMN `energy_tech`", |
|
| 2367 | + "DROP COLUMN `hyperspace_tech`", |
|
| 2368 | + "DROP COLUMN `combustion_tech`", |
|
| 2369 | + "DROP COLUMN `impulse_motor_tech`", |
|
| 2370 | + "DROP COLUMN `hyperspace_motor_tech`", |
|
| 2371 | + "DROP COLUMN `laser_tech`", |
|
| 2372 | + "DROP COLUMN `ionic_tech`", |
|
| 2373 | + "DROP COLUMN `buster_tech`", |
|
| 2374 | + "DROP COLUMN `intergalactic_tech`", |
|
| 2375 | + "DROP COLUMN `expedition_tech`", |
|
| 2376 | + "DROP COLUMN `colonisation_tech`", |
|
| 2377 | + ), $update_tables['users']['spy_tech']); |
|
| 2378 | + |
|
| 2379 | + upd_check_key('payment_currency_exchange_dm_', 2500, !$config->payment_currency_exchange_dm_ || $config->payment_currency_exchange_dm_ == 1000); |
|
| 2380 | + upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !$config->payment_currency_exchange_eur); |
|
| 2381 | + upd_check_key('payment_currency_exchange_rub', 4.0, !$config->payment_currency_exchange_rub); |
|
| 2382 | + upd_check_key('payment_currency_exchange_usd', 0.125, !$config->payment_currency_exchange_usd); |
|
| 2383 | + upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !$config->payment_currency_exchange_usd); |
|
| 2384 | + upd_check_key('payment_currency_exchange_wmr', 4.1, !$config->payment_currency_exchange_wmr); |
|
| 2385 | + upd_check_key('payment_currency_exchange_wmu', 1.05, !$config->payment_currency_exchange_wmu); |
|
| 2386 | + upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !$config->payment_currency_exchange_wmz); |
|
| 2387 | 2387 | |
| 2388 | - upd_do_query('COMMIT;', true); |
|
| 2389 | - $new_version = 37; |
|
| 2388 | + upd_do_query('COMMIT;', true); |
|
| 2389 | + $new_version = 37; |
|
| 2390 | 2390 | |
| 2391 | 2391 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | // $same_user = false; |
| 54 | 54 | // } |
| 55 | 55 | |
| 56 | - if(!$user_data) { |
|
| 56 | + if (!$user_data) { |
|
| 57 | 57 | message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10); |
| 58 | 58 | die(); |
| 59 | 59 | } |
@@ -64,15 +64,15 @@ discard block |
||
| 64 | 64 | $stat_array = array(); |
| 65 | 65 | $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;"); |
| 66 | 66 | $stat_count = classSupernova::$db->db_affected_rows(); |
| 67 | - while($row = db_fetch($query)) { |
|
| 68 | - foreach($stat_fields as $field_db_name => $field_template_name) { |
|
| 67 | + while ($row = db_fetch($query)) { |
|
| 68 | + foreach ($stat_fields as $field_db_name => $field_template_name) { |
|
| 69 | 69 | // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS |
| 70 | 70 | $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name]; |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | $stat_array_date = $stat_array['STAT_DATE']; |
| 75 | - foreach($stat_array_date['DATA'] as $key => $value) { |
|
| 75 | + foreach ($stat_array_date['DATA'] as $key => $value) { |
|
| 76 | 76 | $template->assign_block_vars('stat_date', array( |
| 77 | 77 | 'ID' => $key, |
| 78 | 78 | 'VALUE' => $value, |
@@ -85,17 +85,17 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | unset($stat_array['STAT_DATE']); |
| 87 | 87 | $template_data = array(); |
| 88 | - foreach($stat_array as $stat_type => &$stat_type_data) { |
|
| 88 | + foreach ($stat_array as $stat_type => &$stat_type_data) { |
|
| 89 | 89 | $reverse_min_max = strpos($stat_type, '_RANK') !== false; |
| 90 | 90 | $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']); |
| 91 | 91 | $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']); |
| 92 | 92 | $stat_type_data['AVG'] = average($stat_type_data['DATA']); |
| 93 | - foreach($stat_type_data['DATA'] as $key => $value) { |
|
| 93 | + foreach ($stat_type_data['DATA'] as $key => $value) { |
|
| 94 | 94 | // $stat_type_data['PERCENT'][$key] = $stat_type_data['MAX'] - $value ? ($stat_type_data['MAX'] - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $value) : 100; |
| 95 | 95 | $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100; |
| 96 | 96 | $template_data[$stat_type][$key]['ID'] = $key; |
| 97 | 97 | $template_data[$stat_type][$key]['VALUE'] = $value; |
| 98 | - $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
| 98 | + $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']); |
|
| 99 | 99 | $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key]; |
| 100 | 100 | |
| 101 | 101 | //$template_data[$stat_type][$key]['PERCENT'] = $key ? $stat_type_data['PERCENT'][$key] : 50; // TODO DEBUG |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | // pdump($stat_array['RES_POINTS']); |
| 105 | 105 | |
| 106 | - foreach($template_data as $stat_type => $stat_type_data) { |
|
| 106 | + foreach ($template_data as $stat_type => $stat_type_data) { |
|
| 107 | 107 | $template->assign_block_vars('stat', array( |
| 108 | 108 | 'TYPE' => $stat_type, |
| 109 | 109 | 'TEXT' => $lang['imp_stat_types'][$stat_type], |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | 'MAX' => $stat_array[$stat_type]['MAX'], |
| 112 | 112 | 'AVG' => $stat_array[$stat_type]['AVG'], |
| 113 | 113 | )); |
| 114 | - foreach($stat_type_data as $stat_entry) { |
|
| 114 | + foreach ($stat_type_data as $stat_entry) { |
|
| 115 | 115 | $template->assign_block_vars('stat.entry', $stat_entry); |
| 116 | 116 | } |
| 117 | 117 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | |
| 120 | 120 | // pdump($template_data); |
| 121 | 121 | |
| 122 | - if($same_user) { |
|
| 122 | + if ($same_user) { |
|
| 123 | 123 | rpg_level_up($user, RPG_STRUCTURE); |
| 124 | 124 | rpg_level_up($user, RPG_RAID); |
| 125 | 125 | rpg_level_up($user, RPG_TECH); |
@@ -153,29 +153,29 @@ discard block |
||
| 153 | 153 | 'builder_xp' => pretty_number($user_data['xpminier']), |
| 154 | 154 | 'builder_lvl' => pretty_number($user_data['lvl_minier']), |
| 155 | 155 | 'builder_lvl_st' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])), |
| 156 | - 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)), |
|
| 156 | + 'builder_lvl_up' => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)), |
|
| 157 | 157 | 'raid_xp' => pretty_number($user_data['xpraid']), |
| 158 | 158 | 'raid_lvl' => pretty_number($user_data['lvl_raid']), |
| 159 | - 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)), |
|
| 159 | + 'raid_lvl_up' => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)), |
|
| 160 | 160 | 'raids' => pretty_number($user_data['raids']), |
| 161 | 161 | 'raidswin' => pretty_number($user_data['raidswin']), |
| 162 | 162 | 'raidsloose' => pretty_number($user_data['raidsloose']), |
| 163 | 163 | 'tech_xp' => pretty_number($user_data['player_rpg_tech_xp']), |
| 164 | 164 | 'tech_lvl' => pretty_number($user_data['player_rpg_tech_level']), |
| 165 | 165 | 'tech_lvl_st' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])), |
| 166 | - 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)), |
|
| 166 | + 'tech_lvl_up' => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)), |
|
| 167 | 167 | |
| 168 | 168 | 'explore_xp' => pretty_number($user_data['player_rpg_explore_xp']), |
| 169 | 169 | 'explore_lvl' => pretty_number($user_data['player_rpg_explore_level']), |
| 170 | 170 | 'explore_lvl_st' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])), |
| 171 | - 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)), |
|
| 172 | - |
|
| 173 | - 'build_points' => pretty_number( $StatRecord['build_points'] ), |
|
| 174 | - 'tech_points' => pretty_number( $StatRecord['tech_points'] ), |
|
| 175 | - 'fleet_points' => pretty_number( $StatRecord['fleet_points'] ), |
|
| 176 | - 'defs_points' => pretty_number( $StatRecord['defs_points'] ), |
|
| 177 | - 'res_points' => pretty_number( $StatRecord['res_points'] ), |
|
| 178 | - 'total_points' => pretty_number( $StatRecord['total_points'] ), |
|
| 171 | + 'explore_lvl_up' => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)), |
|
| 172 | + |
|
| 173 | + 'build_points' => pretty_number($StatRecord['build_points']), |
|
| 174 | + 'tech_points' => pretty_number($StatRecord['tech_points']), |
|
| 175 | + 'fleet_points' => pretty_number($StatRecord['fleet_points']), |
|
| 176 | + 'defs_points' => pretty_number($StatRecord['defs_points']), |
|
| 177 | + 'res_points' => pretty_number($StatRecord['res_points']), |
|
| 178 | + 'total_points' => pretty_number($StatRecord['total_points']), |
|
| 179 | 179 | 'user_rank' => $StatRecord['total_rank'], |
| 180 | 180 | 'RANK_DIFF' => $StatRecord['total_old_rank'] - $StatRecord['total_rank'], |
| 181 | 181 | |
@@ -14,14 +14,14 @@ |
||
| 14 | 14 | global $lang, $user, $planetrow; |
| 15 | 15 | |
| 16 | 16 | $tech_tree = array(); |
| 17 | - foreach(get_unit_param('techtree') as $unit_group_id => $unit_list) |
|
| 17 | + foreach (get_unit_param('techtree') as $unit_group_id => $unit_list) |
|
| 18 | 18 | { |
| 19 | 19 | $tech_tree[] = array( |
| 20 | 20 | 'NAME' => $lang['tech'][$unit_group_id], |
| 21 | 21 | 'GROUP_ID' => $unit_group_id, |
| 22 | 22 | ); |
| 23 | 23 | |
| 24 | - foreach($unit_list as $unit_id) |
|
| 24 | + foreach ($unit_list as $unit_id) |
|
| 25 | 25 | { |
| 26 | 26 | $sn_data_unit = get_unit_param($unit_id); |
| 27 | 27 | $level_basic = $sn_data_unit[P_STACKABLE] ? 0 : mrc_get_level($user, $planetrow, $unit_id, false, true); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | $query = db_user_list("`authlevel` > 0 ORDER BY `authlevel` ASC"); |
| 19 | 19 | |
| 20 | 20 | // while($row = db_fetch($query)) |
| 21 | - foreach($query as $row) |
|
| 21 | + foreach ($query as $row) |
|
| 22 | 22 | { |
| 23 | 23 | $template_result['.']['contact'][] = array( |
| 24 | 24 | 'NAME' => $row['username'], |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | $sn_group_factories = sn_get_groups('factories'); |
| 23 | 23 | $planet_density = sn_get_groups('planet_density'); |
| 24 | 24 | |
| 25 | - if(sys_get_param('save_production')) { |
|
| 25 | + if (sys_get_param('save_production')) { |
|
| 26 | 26 | $production = sys_get_param('percent'); |
| 27 | - if(is_array($production) && !empty($production)) { |
|
| 27 | + if (is_array($production) && !empty($production)) { |
|
| 28 | 28 | // sn_db_transaction_start(); |
| 29 | 29 | $query = array(); |
| 30 | 30 | $planet_row_list = db_planet_list_sorted($user, false, '*'); |
| 31 | 31 | // while($planet = db_fetch($planet_row_list)) |
| 32 | - foreach($planet_row_list as $planet) { |
|
| 33 | - foreach($sn_group_factories as $factory_unit_id) { |
|
| 32 | + foreach ($planet_row_list as $planet) { |
|
| 33 | + foreach ($sn_group_factories as $factory_unit_id) { |
|
| 34 | 34 | $unit_db_name_porcent = pname_factory_production_field_name($factory_unit_id); |
| 35 | - if( |
|
| 35 | + if ( |
|
| 36 | 36 | get_unit_param($factory_unit_id, P_MINING_IS_MANAGED) |
| 37 | 37 | && isset($production[$factory_unit_id][$planet['id']]) |
| 38 | 38 | && ($actual_porcent = intval($production[$factory_unit_id][$planet['id']] / 10)) >= 0 |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - foreach($query as $planet_id => $query_data) { |
|
| 46 | + foreach ($query as $planet_id => $query_data) { |
|
| 47 | 47 | db_planet_set_by_id($planet_id, implode(',', $query_data)); |
| 48 | 48 | } |
| 49 | 49 | // sn_db_transaction_commit(); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $planet_row_list = db_planet_list_sorted($user); |
| 54 | 54 | // while ($planet = db_fetch($planet_row_list)) |
| 55 | - foreach($planet_row_list as $planet) { |
|
| 55 | + foreach ($planet_row_list as $planet) { |
|
| 56 | 56 | sn_db_transaction_start(); |
| 57 | 57 | $global_data = sys_o_get_updated($user, $planet['id'], SN_TIME_NOW, false, true); |
| 58 | 58 | $planets[$planet['id']] = $global_data['planet']; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $template = gettemplate('imperium', $template); |
| 65 | 65 | $template->assign_var('amount', count($planets) + 2); |
| 66 | 66 | |
| 67 | - for($i = 100; $i >= 0; $i -= 10) { |
|
| 67 | + for ($i = 100; $i >= 0; $i -= 10) { |
|
| 68 | 68 | $template->assign_block_vars('percent', array('PERCENT' => $i)); |
| 69 | 69 | } |
| 70 | 70 | |
@@ -79,8 +79,8 @@ discard block |
||
| 79 | 79 | $planet_template = tpl_parse_planet($planet); |
| 80 | 80 | |
| 81 | 81 | $planet_fleet_id = 0; |
| 82 | - $fleet_list = $planet_template['fleet_list'];//flt_get_fleets_to_planet($planet); |
|
| 83 | - if($fleet_list['own']['count']) |
|
| 82 | + $fleet_list = $planet_template['fleet_list']; //flt_get_fleets_to_planet($planet); |
|
| 83 | + if ($fleet_list['own']['count']) |
|
| 84 | 84 | { |
| 85 | 85 | $planet_fleet_id = "p{$fleet_id}"; |
| 86 | 86 | $fleets[] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id); |
@@ -142,19 +142,19 @@ discard block |
||
| 142 | 142 | UNIT_DEFENCE => 'defense', |
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - foreach($show_groups as $unit_group_id => $mode) |
|
| 145 | + foreach ($show_groups as $unit_group_id => $mode) |
|
| 146 | 146 | { |
| 147 | 147 | $template->assign_block_vars('prods', array( |
| 148 | 148 | 'NAME' => $lang['tech'][$unit_group_id], |
| 149 | 149 | )); |
| 150 | 150 | $unit_group = get_unit_param('techtree', $unit_group_id); |
| 151 | - foreach($unit_group as $unit_id) |
|
| 151 | + foreach ($unit_group as $unit_id) |
|
| 152 | 152 | { |
| 153 | 153 | $unit_count = $unit_count_abs = 0; |
| 154 | 154 | $block_vars = array(); |
| 155 | 155 | $unit_is_factory = in_array($unit_id, $sn_group_factories) && get_unit_param($unit_id, P_MINING_IS_MANAGED); |
| 156 | 156 | // $unit_db_name = pname_resource_name($unit_id); |
| 157 | - foreach($planets as $planet) |
|
| 157 | + foreach ($planets as $planet) |
|
| 158 | 158 | { |
| 159 | 159 | $unit_level_plain = mrc_get_level($user, $planet, $unit_id, false, true); |
| 160 | 160 | |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $level_plus['LEVEL_PLUS_GREEN'] = 0; |
| 164 | 164 | |
| 165 | 165 | $level_plus['PERCENT'] = $unit_is_factory ? ($unit_level_plain ? $planet[pname_factory_production_field_name($unit_id)] * 10 : -1) : -1; |
| 166 | - switch($mode) |
|
| 166 | + switch ($mode) |
|
| 167 | 167 | { |
| 168 | 168 | /* |
| 169 | 169 | case 'structures': |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | /** @noinspection PhpMissingBreakStatementInspection */ |
| 180 | 180 | case 'fleet': |
| 181 | - $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id]<=0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}"; |
|
| 181 | + $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id] <= 0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}"; |
|
| 182 | 182 | $total['units'][$unit_id]['LEVEL_PLUS_YELLOW'] += $level_plus['LEVEL_PLUS_YELLOW']; |
| 183 | 183 | |
| 184 | 184 | case 'structures': |
| 185 | 185 | case 'defense': |
| 186 | 186 | $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id]; |
| 187 | - if($level_plus_build) |
|
| 187 | + if ($level_plus_build) |
|
| 188 | 188 | { |
| 189 | 189 | $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build < 0 ? $level_plus_build : "+{$level_plus_build}"; |
| 190 | 190 | // $level_plus['LEVEL_PLUS_GREEN'] = "+{$level_plus_build}"; |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $unit_count_abs += $unit_level_plain + abs($level_plus['LEVEL_PLUS_YELLOW']) + abs($level_plus['LEVEL_PLUS_GREEN']); |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if($unit_count_abs) |
|
| 208 | + if ($unit_count_abs) |
|
| 209 | 209 | { |
| 210 | 210 | $template->assign_block_vars('prods', array( |
| 211 | 211 | 'ID' => $unit_id, |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | 'MODE' => $mode, |
| 215 | 215 | )); |
| 216 | 216 | |
| 217 | - foreach($block_vars as $block_var) |
|
| 217 | + foreach ($block_vars as $block_var) |
|
| 218 | 218 | { |
| 219 | 219 | $template->assign_block_vars('prods.planet', $block_var); |
| 220 | 220 | } |