@@ -4,13 +4,13 @@ discard block |
||
4 | 4 | |
5 | 5 | function mrc_officer_accessible(&$user, $mercenary_id) { |
6 | 6 | $mercenary_info = get_unit_param($mercenary_id); |
7 | - if(classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) { |
|
7 | + if (classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) { |
|
8 | 8 | return true; |
9 | 9 | } |
10 | 10 | |
11 | - if(isset($mercenary_info[P_REQUIRE])) { |
|
12 | - foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) { |
|
13 | - if(mrc_get_level($user, null, $unit_id) < $unit_level) { |
|
11 | + if (isset($mercenary_info[P_REQUIRE])) { |
|
12 | + foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) { |
|
13 | + if (mrc_get_level($user, null, $unit_id) < $unit_level) { |
|
14 | 14 | return false; |
15 | 15 | } |
16 | 16 | } |
@@ -26,35 +26,35 @@ discard block |
||
26 | 26 | $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary; |
27 | 27 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1); |
28 | 28 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
29 | - if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
29 | + if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) { |
|
30 | 30 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR); |
31 | 31 | } |
32 | 32 | |
33 | - if(!mrc_officer_accessible($user, $mercenary_id)) { |
|
33 | + if (!mrc_officer_accessible($user, $mercenary_id)) { |
|
34 | 34 | throw new Exception(classLocale::$lang['mrc_msg_error_requirements'], ERR_ERROR); |
35 | 35 | } |
36 | 36 | |
37 | 37 | $mercenary_level = sys_get_param_int('mercenary_level'); |
38 | - if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
38 | + if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) { |
|
39 | 39 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_level'], ERR_ERROR); |
40 | 40 | } |
41 | 41 | |
42 | - if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
42 | + if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) { |
|
43 | 43 | throw new Exception(classLocale::$lang['mrc_msg_error_wrong_period'], ERR_ERROR); |
44 | 44 | } |
45 | 45 | |
46 | 46 | sn_db_transaction_start(); |
47 | 47 | |
48 | 48 | $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true); |
49 | - if(classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
49 | + if (classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) { |
|
50 | 50 | throw new Exception(classLocale::$lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first |
51 | - } elseif(classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
51 | + } elseif (classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) { |
|
52 | 52 | throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error |
53 | 53 | } |
54 | 54 | |
55 | - if($mercenary_level) { |
|
55 | + if ($mercenary_level) { |
|
56 | 56 | $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level); |
57 | - if(!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
57 | + if (!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) { |
|
58 | 58 | $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old); |
59 | 59 | $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER]; |
60 | 60 | } |
@@ -64,13 +64,13 @@ discard block |
||
64 | 64 | } |
65 | 65 | $darkmater_cost *= $cost_alliance_multiplyer; |
66 | 66 | |
67 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
67 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) { |
|
68 | 68 | throw new Exception(classLocale::$lang['mrc_msg_error_no_resource'], ERR_ERROR); |
69 | 69 | } |
70 | 70 | |
71 | - if(($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
71 | + if (($darkmater_cost && $mercenary_level) || !$is_permanent) { |
|
72 | 72 | $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id); |
73 | - if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
73 | + if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) { |
|
74 | 74 | $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']); |
75 | 75 | $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER]; |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id); |
84 | 84 | } |
85 | 85 | |
86 | - if($darkmater_cost && $mercenary_level) { |
|
86 | + if ($darkmater_cost && $mercenary_level) { |
|
87 | 87 | db_unit_set_insert( |
88 | 88 | "unit_player_id = {$user['id']}, |
89 | 89 | unit_location_type = " . LOC_USER . ", |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | } |
101 | 101 | sn_db_transaction_commit(); |
102 | 102 | sys_redirect($_SERVER['REQUEST_URI']); |
103 | - } catch(Exception $e) { |
|
103 | + } catch (Exception $e) { |
|
104 | 104 | sn_db_transaction_rollback(); |
105 | 105 | $operation_result = array( |
106 | 106 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES; |
119 | 119 | $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary; |
120 | 120 | |
121 | - if($mercenary_id = sys_get_param_int('mercenary_id')) { |
|
121 | + if ($mercenary_id = sys_get_param_int('mercenary_id')) { |
|
122 | 122 | $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id); |
123 | 123 | } |
124 | 124 | |
@@ -126,11 +126,11 @@ discard block |
||
126 | 126 | |
127 | 127 | $template = gettemplate('mrc_mercenary_hire', true); |
128 | 128 | |
129 | - if(!empty($operation_result)) { |
|
129 | + if (!empty($operation_result)) { |
|
130 | 130 | $template->assign_block_vars('result', $operation_result); |
131 | 131 | } |
132 | 132 | |
133 | - foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) { |
|
133 | + foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) { |
|
134 | 134 | $template->assign_block_vars('period', array( |
135 | 135 | 'LENGTH' => $hire_period, |
136 | 136 | 'TEXT' => classLocale::$lang['mrc_period_list'][$hire_period], |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
143 | 143 | $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1); |
144 | 144 | $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1; |
145 | - foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) { |
|
145 | + foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) { |
|
146 | 146 | { |
147 | 147 | $mercenary = get_unit_param($mercenary_id); |
148 | 148 | $mercenary_bonus = $mercenary['bonus']; |
149 | 149 | $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}"; |
150 | - switch($mercenary['bonus_type']) { |
|
150 | + switch ($mercenary['bonus_type']) { |
|
151 | 151 | case BONUS_PERCENT: |
152 | 152 | $mercenary_bonus = "{$mercenary_bonus}% "; |
153 | 153 | break; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true); |
165 | 165 | $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level); |
166 | 166 | $total_cost_old = 0; |
167 | - if($is_permanent) { |
|
167 | + if ($is_permanent) { |
|
168 | 168 | $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level); |
169 | 169 | $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer; |
170 | 170 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | )); |
194 | 194 | |
195 | 195 | $upgrade_cost = 1; |
196 | - for($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) { |
|
196 | + for ($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) { |
|
197 | 197 | $total_cost = eco_get_total_cost($mercenary_id, $i); |
198 | 198 | $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer; |
199 | 199 | $upgrade_cost = $total_cost[BUILD_CREATE][RES_DARK_MATTER] - $total_cost_old; |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * @param string $query |
161 | 161 | * |
162 | - * @return mixed|string |
|
162 | + * @return string |
|
163 | 163 | */ |
164 | 164 | public function replaceTablePlaceholders($query) { |
165 | 165 | $sql = $query; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
176 | - * @param $query |
|
176 | + * @param string $query |
|
177 | 177 | */ |
178 | 178 | protected function logQuery($query) { |
179 | 179 | if (!classSupernova::$config->debug) { |
@@ -307,6 +307,9 @@ discard block |
||
307 | 307 | } |
308 | 308 | |
309 | 309 | |
310 | + /** |
|
311 | + * @param integer $replace |
|
312 | + */ |
|
310 | 313 | protected function doSet($table, $fieldsAndValues, $replace = DB_INSERT_PLAIN) { |
311 | 314 | $tableSafe = $this->db_escape($table); |
312 | 315 | $safeFieldsAndValues = implode(',', $this->safeFieldsAndValues($fieldsAndValues)); |
@@ -339,6 +342,9 @@ discard block |
||
339 | 342 | return $this->doSet($table, $fieldsAndValues, $replace); |
340 | 343 | } |
341 | 344 | |
345 | + /** |
|
346 | + * @param string $table |
|
347 | + */ |
|
342 | 348 | public function doReplaceSet($table, $fieldsAndValues) { |
343 | 349 | return $this->doSet($table, $fieldsAndValues, DB_INSERT_REPLACE); |
344 | 350 | } |
@@ -373,7 +379,7 @@ discard block |
||
373 | 379 | * Values should be passed as-is |
374 | 380 | * |
375 | 381 | * @param string $table |
376 | - * @param array $fields |
|
382 | + * @param string[] $fields |
|
377 | 383 | * @param string[] $values |
378 | 384 | * |
379 | 385 | * @return array|bool|mysqli_result|null |
@@ -451,7 +457,7 @@ discard block |
||
451 | 457 | * |
452 | 458 | * Usually used for mallformed $where conditions |
453 | 459 | * |
454 | - * @param $table |
|
460 | + * @param string $table |
|
455 | 461 | * @param $where |
456 | 462 | * |
457 | 463 | * @return array|bool|mysqli_result|null |
@@ -589,6 +595,10 @@ discard block |
||
589 | 595 | } |
590 | 596 | |
591 | 597 | // TODO Заменить это на новый логгер |
598 | + |
|
599 | + /** |
|
600 | + * @param string $query |
|
601 | + */ |
|
592 | 602 | protected function security_watch_user_queries($query) { |
593 | 603 | global $user; |
594 | 604 | |
@@ -612,6 +622,9 @@ discard block |
||
612 | 622 | } |
613 | 623 | |
614 | 624 | |
625 | + /** |
|
626 | + * @param string $query |
|
627 | + */ |
|
615 | 628 | public function security_query_check_bad_words($query) { |
616 | 629 | if ($this->skipQueryCheck) { |
617 | 630 | return; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | public function load_db_settings($configFile = '') { |
94 | 94 | $dbsettings = array(); |
95 | 95 | |
96 | - empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false; |
|
96 | + empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false; |
|
97 | 97 | |
98 | 98 | require $configFile; |
99 | 99 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | if (empty($this->dbsettings)) { |
116 | - $this->load_db_settings(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
116 | + $this->load_db_settings(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | $sql = $query; |
166 | 166 | if (strpos($sql, '{{') !== false) { |
167 | 167 | foreach ($this->table_list as $tableName) { |
168 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
168 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
169 | 169 | } |
170 | 170 | } |
171 | 171 | |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | |
239 | 239 | $queryResult = null; |
240 | 240 | try { |
241 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
241 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
242 | 242 | if (!$queryResult) { |
243 | 243 | throw new Exception(); |
244 | 244 | } |
245 | 245 | } catch (Exception $e) { |
246 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
246 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | return $queryResult; |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | $safeFieldsAndValues = implode(',', $this->safeFieldsAndValues($fieldsAndValues)); |
313 | 313 | // $command = $replace == DB_INSERT_REPLACE ? 'REPLACE' : 'INSERT'; |
314 | 314 | // $command .= $replace == DB_INSERT_IGNORE ? ' IGNORE' : ''; |
315 | - switch($replace) { |
|
315 | + switch ($replace) { |
|
316 | 316 | case DB_INSERT_IGNORE: |
317 | 317 | $command = 'INSERT IGNORE'; |
318 | 318 | break; |
@@ -463,7 +463,7 @@ discard block |
||
463 | 463 | |
464 | 464 | |
465 | 465 | protected function castAsDbValue($value) { |
466 | - switch(gettype($value)) { |
|
466 | + switch (gettype($value)) { |
|
467 | 467 | case TYPE_INTEGER: |
468 | 468 | case TYPE_DOUBLE: |
469 | 469 | // do nothing |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | case TYPE_EMPTY: |
487 | 487 | // No-type defaults to string |
488 | 488 | default: |
489 | - $value = "'" . $this->db_escape((string)$value) . "'"; |
|
489 | + $value = "'".$this->db_escape((string) $value)."'"; |
|
490 | 490 | break; |
491 | 491 | } |
492 | 492 | |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | if (is_int($fieldName)) { |
515 | 515 | $result[$fieldName] = $fieldValue; |
516 | 516 | } else { |
517 | - $result[$fieldName] = "`{$fieldName}` = " . $this->castAsDbValue($fieldValue); |
|
517 | + $result[$fieldName] = "`{$fieldName}` = ".$this->castAsDbValue($fieldValue); |
|
518 | 518 | } |
519 | 519 | } |
520 | 520 | |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | } |
546 | 546 | |
547 | 547 | foreach ($fields as $key => $value) { |
548 | - $result[$key] = "`" . $this->db_escape($value) . "`"; |
|
548 | + $result[$key] = "`".$this->db_escape($value)."`"; |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | return $result; |
@@ -601,10 +601,10 @@ discard block |
||
601 | 601 | $this->isWatching = true; |
602 | 602 | $msg = "\$query = \"{$query}\"\n\r"; |
603 | 603 | if (!empty($_POST)) { |
604 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
604 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
605 | 605 | } |
606 | 606 | if (!empty($_GET)) { |
607 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
607 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
608 | 608 | } |
609 | 609 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
610 | 610 | $this->isWatching = false; |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | |
620 | 620 | global $user, $dm_change_legit, $mm_change_legit; |
621 | 621 | |
622 | - switch(true) { |
|
622 | + switch (true) { |
|
623 | 623 | case stripos($query, 'RUNCATE TABL') != false: |
624 | 624 | case stripos($query, 'ROP TABL') != false: |
625 | 625 | case stripos($query, 'ENAME TABL') != false: |
@@ -630,37 +630,37 @@ discard block |
||
630 | 630 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
631 | 631 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
632 | 632 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
633 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
633 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
634 | 634 | $report .= ">Database Inforamation\n"; |
635 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
636 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
637 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
638 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
639 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
640 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
641 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
642 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
643 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
644 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
635 | + $report .= "\tID - ".$user['id']."\n"; |
|
636 | + $report .= "\tUser - ".$user['username']."\n"; |
|
637 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
638 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
639 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
640 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
641 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
642 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
643 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
644 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
645 | 645 | $report .= "\n"; |
646 | 646 | |
647 | 647 | $report .= ">Query Information\n"; |
648 | - $report .= "\tQuery - " . $query . "\n"; |
|
648 | + $report .= "\tQuery - ".$query."\n"; |
|
649 | 649 | $report .= "\n"; |
650 | 650 | |
651 | 651 | $report .= ">\$_SERVER Information\n"; |
652 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
653 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
654 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
655 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
656 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
657 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
658 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
659 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
652 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
653 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
654 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
655 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
656 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
657 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
658 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
659 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
660 | 660 | |
661 | 661 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
662 | 662 | |
663 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
663 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
664 | 664 | fwrite($fp, $report); |
665 | 665 | fclose($fp); |
666 | 666 | |
@@ -681,7 +681,7 @@ discard block |
||
681 | 681 | $prefix_length = strlen($this->db_prefix); |
682 | 682 | |
683 | 683 | $tl = array(); |
684 | - while($row = $this->db_fetch($query)) { |
|
684 | + while ($row = $this->db_fetch($query)) { |
|
685 | 685 | foreach ($row as $table_name) { |
686 | 686 | if (strpos($table_name, $this->db_prefix) === 0) { |
687 | 687 | $table_name = substr($table_name, $prefix_length); |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | if (is_bool($query)) { |
813 | 813 | throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?'); |
814 | 814 | } |
815 | - while($row = db_fetch($query)) { |
|
815 | + while ($row = db_fetch($query)) { |
|
816 | 816 | $result[$row['Variable_name']] = $row['Value']; |
817 | 817 | } |
818 | 818 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @param $user_id |
22 | - * @param $nickUnsafe |
|
22 | + * @param string $nickUnsafe |
|
23 | 23 | * @param $ally_id |
24 | 24 | * @param $message_unsafe |
25 | 25 | * @param $chat_message_sender_name_unsafe |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @param $alliance |
55 | 55 | * @param $where_add |
56 | 56 | * @param $start_row |
57 | - * @param $page_limit |
|
57 | + * @param integer $page_limit |
|
58 | 58 | * |
59 | 59 | * @return array|bool|mysqli_result|null |
60 | 60 | */ |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | JOIN {{users}} AS u ON u.id = cp.chat_player_player_id |
13 | 13 | WHERE |
14 | 14 | `chat_player_refresh_last` >= '{$sql_date}' |
15 | - AND (`banaday` IS NULL OR `banaday` <= " . SN_TIME_NOW . ") |
|
15 | + AND (`banaday` IS NULL OR `banaday` <= ".SN_TIME_NOW.") |
|
16 | 16 | {$ally_add} |
17 | 17 | ORDER BY authlevel DESC, `username`"); |
18 | 18 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @param $user |
141 | 141 | */ |
142 | 142 | public static function db_chat_player_update($user) { |
143 | - classSupernova::$db->doUpdate("UPDATE {{chat_player}} SET `chat_player_refresh_last` = " . SN_TIME_NOW . " WHERE `chat_player_player_id` = {$user['id']} LIMIT 1;"); |
|
143 | + classSupernova::$db->doUpdate("UPDATE {{chat_player}} SET `chat_player_refresh_last` = ".SN_TIME_NOW." WHERE `chat_player_player_id` = {$user['id']} LIMIT 1;"); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @param $user |
212 | 212 | */ |
213 | 213 | public static function db_chat_player_update_activity($user) { |
214 | - classSupernova::$db->doUpdate("UPDATE {{chat_player}} SET `chat_player_activity` = '" . classSupernova::$db->db_escape(SN_TIME_SQL) . "' WHERE `chat_player_player_id` = {$user['id']} LIMIT 1"); |
|
214 | + classSupernova::$db->doUpdate("UPDATE {{chat_player}} SET `chat_player_activity` = '".classSupernova::$db->db_escape(SN_TIME_SQL)."' WHERE `chat_player_player_id` = {$user['id']} LIMIT 1"); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
218 | 218 | \ No newline at end of file |
@@ -5,7 +5,7 @@ |
||
5 | 5 | /** |
6 | 6 | * @param $user |
7 | 7 | * @param $planet_dst |
8 | - * @param $time_limit |
|
8 | + * @param integer $time_limit |
|
9 | 9 | * |
10 | 10 | * @return array|bool|mysqli_result|null |
11 | 11 | */ |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | * Преобразовывает данные симулятора в данные для расчета боя |
460 | 460 | * |
461 | 461 | * @param $side_info |
462 | - * @param $attacker |
|
462 | + * @param boolean $attacker |
|
463 | 463 | * @param int $player_id |
464 | 464 | * |
465 | 465 | */ |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
524 | - * @return int |
|
524 | + * @return double |
|
525 | 525 | */ |
526 | 526 | public function get_time_spent() { |
527 | 527 | return $this->time_spent; |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
567 | - * @param $template |
|
567 | + * @param null|template $template |
|
568 | 568 | * |
569 | 569 | * @return template |
570 | 570 | */ |
@@ -7,7 +7,7 @@ |
||
7 | 7 | /** |
8 | 8 | * @param UBE $ube |
9 | 9 | * |
10 | - * @return bool|string |
|
10 | + * @return false|string |
|
11 | 11 | * |
12 | 12 | * @version 2016-02-25 23:42:45 41a4.68 |
13 | 13 | */ |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function sn_ube_report_save($ube) { |
15 | 15 | // Если уже есть ИД репорта - значит репорт был взят из таблицы. С таким мы не работаем |
16 | - if($ube->get_cypher()) { |
|
16 | + if ($ube->get_cypher()) { |
|
17 | 17 | return false; |
18 | 18 | } |
19 | 19 | |
20 | 20 | // Генерируем уникальный секретный ключ и проверяем наличие в базе |
21 | 21 | do { |
22 | 22 | $ube->report_cypher = sys_random_string(32); |
23 | - } while(classSupernova::$db->doSelectFetch("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE")); |
|
23 | + } while (classSupernova::$db->doSelectFetch("SELECT ube_report_cypher FROM {{ube_report}} WHERE ube_report_cypher = '{$ube->report_cypher}' LIMIT 1 FOR UPDATE")); |
|
24 | 24 | |
25 | 25 | // Инициализация таблицы для пакетной вставки информации |
26 | 26 | $sql_perform = array( |
@@ -106,21 +106,21 @@ discard block |
||
106 | 106 | |
107 | 107 | // Сохраняем общую информацию о бое |
108 | 108 | classSupernova::$db->doInsertSet(TABLE_UBE_REPORT, array( |
109 | - 'ube_report_cypher' => (string)$ube->report_cypher, |
|
110 | - 'ube_report_time_combat' => (string)date(FMT_DATE_TIME_SQL, $ube->combat_timestamp), |
|
111 | - 'ube_report_time_spent' => (float)$ube->time_spent, |
|
112 | - 'ube_report_combat_admin' => (int)$ube->is_admin_in_combat, |
|
113 | - 'ube_report_mission_type' => (int)$ube->mission_type_id, |
|
114 | - 'ube_report_combat_result' => (int)$ube->combat_result, |
|
115 | - 'ube_report_combat_sfr' => (int)$ube->is_small_fleet_recce, |
|
116 | - 'ube_report_planet_id' => (int)$ube->ube_planet_info[PLANET_ID], |
|
117 | - 'ube_report_planet_name' => (string)$ube->ube_planet_info[PLANET_NAME], |
|
118 | - 'ube_report_planet_size' => (int)$ube->ube_planet_info[PLANET_SIZE], |
|
119 | - 'ube_report_planet_galaxy' => (int)$ube->ube_planet_info[PLANET_GALAXY], |
|
120 | - 'ube_report_planet_system' => (int)$ube->ube_planet_info[PLANET_SYSTEM], |
|
121 | - 'ube_report_planet_planet' => (int)$ube->ube_planet_info[PLANET_PLANET], |
|
122 | - 'ube_report_planet_planet_type' => (int)$ube->ube_planet_info[PLANET_TYPE], |
|
123 | - 'ube_report_capture_result' => (int)$ube->capture_result, |
|
109 | + 'ube_report_cypher' => (string) $ube->report_cypher, |
|
110 | + 'ube_report_time_combat' => (string) date(FMT_DATE_TIME_SQL, $ube->combat_timestamp), |
|
111 | + 'ube_report_time_spent' => (float) $ube->time_spent, |
|
112 | + 'ube_report_combat_admin' => (int) $ube->is_admin_in_combat, |
|
113 | + 'ube_report_mission_type' => (int) $ube->mission_type_id, |
|
114 | + 'ube_report_combat_result' => (int) $ube->combat_result, |
|
115 | + 'ube_report_combat_sfr' => (int) $ube->is_small_fleet_recce, |
|
116 | + 'ube_report_planet_id' => (int) $ube->ube_planet_info[PLANET_ID], |
|
117 | + 'ube_report_planet_name' => (string) $ube->ube_planet_info[PLANET_NAME], |
|
118 | + 'ube_report_planet_size' => (int) $ube->ube_planet_info[PLANET_SIZE], |
|
119 | + 'ube_report_planet_galaxy' => (int) $ube->ube_planet_info[PLANET_GALAXY], |
|
120 | + 'ube_report_planet_system' => (int) $ube->ube_planet_info[PLANET_SYSTEM], |
|
121 | + 'ube_report_planet_planet' => (int) $ube->ube_planet_info[PLANET_PLANET], |
|
122 | + 'ube_report_planet_planet_type' => (int) $ube->ube_planet_info[PLANET_TYPE], |
|
123 | + 'ube_report_capture_result' => (int) $ube->capture_result, |
|
124 | 124 | ) |
125 | 125 | + $ube->debris->report_generate_array() |
126 | 126 | + $ube->moon_calculator->report_generate_array() |
@@ -129,22 +129,22 @@ discard block |
||
129 | 129 | |
130 | 130 | // Сохраняем общую информацию по игрокам |
131 | 131 | $player_sides = $ube->players->get_player_sides(); |
132 | - foreach($player_sides as $player_id => $player_side) { |
|
132 | + foreach ($player_sides as $player_id => $player_side) { |
|
133 | 133 | $sql_perform['ube_report_player'][] = array( |
134 | 134 | $ube_report_id, |
135 | 135 | $player_id, |
136 | 136 | |
137 | - "'" . db_escape($ube->players[$player_id]->name) . "'", |
|
137 | + "'".db_escape($ube->players[$player_id]->name)."'", |
|
138 | 138 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
139 | 139 | |
140 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
141 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
142 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
140 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
141 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
142 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
143 | 143 | ); |
144 | 144 | } |
145 | 145 | |
146 | 146 | // Всякая информация по флотам |
147 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
147 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
148 | 148 | // Сохраняем общую информацию по флотам |
149 | 149 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
150 | 150 | |
@@ -159,12 +159,12 @@ discard block |
||
159 | 159 | $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list); |
160 | 160 | |
161 | 161 | // Пакетная вставка данных |
162 | - foreach($sql_perform as $table_name => $table_data) { |
|
163 | - if(count($table_data) < 2) { |
|
162 | + foreach ($sql_perform as $table_name => $table_data) { |
|
163 | + if (count($table_data) < 2) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | - foreach($table_data as &$record_data) { |
|
167 | - $record_data = '(' . implode(',', $record_data) . ')'; |
|
166 | + foreach ($table_data as &$record_data) { |
|
167 | + $record_data = '('.implode(',', $record_data).')'; |
|
168 | 168 | } |
169 | 169 | $fields = $table_data[0]; |
170 | 170 | unset($table_data[0]); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $report_cypher = db_escape($report_cypher); |
187 | 187 | |
188 | 188 | $report_row = classSupernova::$db->doSelectFetch("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1"); |
189 | - if(!$report_row) { |
|
189 | + if (!$report_row) { |
|
190 | 190 | return UBE_REPORT_NOT_FOUND; |
191 | 191 | } |
192 | 192 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | * @param $template_result |
203 | 203 | */ |
204 | 204 | public function sn_ube_report_generate(UBE $ube, &$template_result) { |
205 | - if(!is_object($ube)) { |
|
205 | + if (!is_object($ube)) { |
|
206 | 206 | return; |
207 | 207 | } |
208 | 208 | |
@@ -217,15 +217,15 @@ discard block |
||
217 | 217 | |
218 | 218 | // Координаты, тип и название планеты - если есть |
219 | 219 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
220 | - if(isset($ube->ube_planet_info)) { |
|
220 | + if (isset($ube->ube_planet_info)) { |
|
221 | 221 | $template_result += $ube->ube_planet_info; |
222 | 222 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
223 | 223 | } |
224 | 224 | |
225 | 225 | // Обломки |
226 | 226 | $debris = array(); |
227 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
228 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
227 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
228 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
229 | 229 | $debris[] = array( |
230 | 230 | 'NAME' => classLocale::$lang['tech'][$resource_id], |
231 | 231 | 'AMOUNT' => pretty_number($resource_amount), |
@@ -173,6 +173,11 @@ discard block |
||
173 | 173 | */ |
174 | 174 | // OK v4 |
175 | 175 | // TODO - вынести в отдельный класс |
176 | +/** |
|
177 | + * @param string $db_id_field_name |
|
178 | + * @param string $db_table_name |
|
179 | + * @param string $db_value_field_name |
|
180 | + */ |
|
176 | 181 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
177 | 182 | $current_value_safe = db_escape($current_value_unsafe); |
178 | 183 | $value_id = classSupernova::$db->doSelectFetch("SELECT `{$db_id_field_name}` FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE"); |
@@ -475,8 +480,8 @@ discard block |
||
475 | 480 | |
476 | 481 | |
477 | 482 | /** |
478 | - * @param $user_id |
|
479 | - * @param $change_type |
|
483 | + * @param integer $user_id |
|
484 | + * @param integer $change_type |
|
480 | 485 | * @param $dark_matter |
481 | 486 | * @param $comment_unsafe |
482 | 487 | * @param $rowUserNameUnsafe |
@@ -497,7 +502,7 @@ discard block |
||
497 | 502 | /** |
498 | 503 | * @param $user_id_safe |
499 | 504 | * |
500 | - * @return array|bool|mysqli_result|null |
|
505 | + * @return integer |
|
501 | 506 | */ |
502 | 507 | function db_referral_get_by_id($user_id_safe) { |
503 | 508 | $old_referral = classSupernova::$db->doSelectFetch("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;"); |
@@ -528,9 +533,9 @@ discard block |
||
528 | 533 | |
529 | 534 | // Quests *********************************************************************************************************** |
530 | 535 | /** |
531 | - * @param $query_add_select |
|
536 | + * @param string $query_add_select |
|
532 | 537 | * @param $query_add_from |
533 | - * @param $query_add_where |
|
538 | + * @param string $query_add_where |
|
534 | 539 | * |
535 | 540 | * @return array|bool|mysqli_result|null |
536 | 541 | */ |
@@ -575,10 +580,10 @@ discard block |
||
575 | 580 | |
576 | 581 | /** |
577 | 582 | * @param $quest_name |
578 | - * @param $quest_type |
|
583 | + * @param integer $quest_type |
|
579 | 584 | * @param $quest_description |
580 | 585 | * @param $quest_conditions |
581 | - * @param $quest_rewards |
|
586 | + * @param string $quest_rewards |
|
582 | 587 | * @param $quest_id |
583 | 588 | */ |
584 | 589 | function db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id) { |
@@ -4,11 +4,11 @@ discard block |
||
4 | 4 | |
5 | 5 | function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
6 | 6 | return classSupernova::$db->doSelect( |
7 | - "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
|
7 | + "SELECT p.*, u.username".($table_parent_columns ? ', p1.name AS parent_name' : ''). |
|
8 | 8 | " FROM {{planets}} AS p |
9 | 9 | LEFT JOIN {{users}} AS u ON u.id = p.id_owner" . |
10 | - ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : '') . |
|
11 | - " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
10 | + ($table_parent_columns ? ' LEFT JOIN {{planets}} AS p1 ON p1.id = p.parent_planet' : ''). |
|
11 | + " WHERE ".($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function db_planet_list_search($searchtext) { |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | ORDER BY |
107 | 107 | sp.`{$Rank}_rank`, subject.{$source['id']} |
108 | 108 | LIMIT |
109 | - " . $start . ",100;"; |
|
109 | + ".$start.",100;"; |
|
110 | 110 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
111 | 111 | $query_str = |
112 | 112 | "SELECT |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | ORDER BY |
120 | 120 | subject.{$Rank} DESC, subject.{$source['id']} |
121 | 121 | LIMIT |
122 | - " . $start . ",100;"; |
|
122 | + ".$start.",100;"; |
|
123 | 123 | } |
124 | 124 | } else { |
125 | 125 | // TODO |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | ORDER BY |
137 | 137 | sp.`{$Rank}_rank`, subject.id |
138 | 138 | LIMIT |
139 | - " . $start . ",100;"; |
|
139 | + ".$start.",100;"; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return classSupernova::$db->doSelect($query_str); |
@@ -364,9 +364,9 @@ discard block |
||
364 | 364 | */ |
365 | 365 | function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) { |
366 | 366 | $extra_conditions = |
367 | - ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') . |
|
368 | - ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') . |
|
369 | - ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') . |
|
367 | + ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : ''). |
|
368 | + ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : ''). |
|
369 | + ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : ''). |
|
370 | 370 | ($flt_module ? "AND payment_module_name = '{$flt_module}' " : ''); |
371 | 371 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;"); |
372 | 372 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | // Log Online ************************************************************************************************************* |
396 | 396 | function db_log_online_insert() { |
397 | 397 | classSupernova::$db->doInsertSet(LOG_USERS_ONLINE, array( |
398 | - 'online_count' => (int)classSupernova::$config->var_online_user_count, |
|
398 | + 'online_count' => (int) classSupernova::$config->var_online_user_count, |
|
399 | 399 | ), DB_INSERT_IGNORE); |
400 | 400 | } |
401 | 401 | |
@@ -485,10 +485,10 @@ discard block |
||
485 | 485 | function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment_unsafe, $rowUserNameUnsafe, $page_url_unsafe) { |
486 | 486 | return classSupernova::$db->doInsertSet(TABLE_LOG_DARK_MATTER, array( |
487 | 487 | 'log_dark_matter_username' => $rowUserNameUnsafe, |
488 | - 'log_dark_matter_reason' => (int)$change_type, |
|
489 | - 'log_dark_matter_amount' => (float)$dark_matter, |
|
490 | - 'log_dark_matter_comment' => (string)$comment_unsafe, |
|
491 | - 'log_dark_matter_page' => (string)$page_url_unsafe, |
|
488 | + 'log_dark_matter_reason' => (int) $change_type, |
|
489 | + 'log_dark_matter_amount' => (float) $dark_matter, |
|
490 | + 'log_dark_matter_comment' => (string) $comment_unsafe, |
|
491 | + 'log_dark_matter_page' => (string) $page_url_unsafe, |
|
492 | 492 | 'log_dark_matter_sender' => $user_id, |
493 | 493 | )); |
494 | 494 | } |
@@ -644,9 +644,9 @@ discard block |
||
644 | 644 | function db_ube_report_get_best_battles() { |
645 | 645 | $query = classSupernova::$db->doSelect("SELECT * |
646 | 646 | FROM `{{ube_report}}` |
647 | - WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY)) |
|
647 | + WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY)) |
|
648 | 648 | ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC |
649 | - LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";"); |
|
649 | + LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";"); |
|
650 | 650 | |
651 | 651 | return $query; |
652 | 652 | } |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | // Pretty Safe |
3 | 3 | // TODO: Add ally_tag to usertable |
4 | 4 | |
5 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
5 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
@@ -11,22 +11,22 @@ discard block |
||
11 | 11 | $ally_name_unsafe = sys_get_param_str_unsafe('name'); |
12 | 12 | $ally_name = db_escape($ally_name_unsafe); |
13 | 13 | |
14 | -if($ally_tag) { |
|
15 | - if(!$ally_name_unsafe || !$ally_tag_unsafe) { |
|
14 | +if ($ally_tag) { |
|
15 | + if (!$ally_name_unsafe || !$ally_tag_unsafe) { |
|
16 | 16 | message(classLocale::$lang['have_not_name'], classLocale::$lang['make_alliance']); |
17 | 17 | } |
18 | 18 | |
19 | 19 | $query = DBStaticAlly::db_ally_get_by_name_or_tag($ally_tag, $ally_name); |
20 | - if($query) { |
|
20 | + if ($query) { |
|
21 | 21 | message(str_replace('%s', $query['ally_tag'] == $ally_tag_unsafe ? $ally_tag_unsafe : $ally_name_unsafe, classLocale::$lang['always_exist']), classLocale::$lang['make_alliance']); |
22 | 22 | } |
23 | 23 | |
24 | 24 | DBStaticAlly::db_ally_insert($ally_name_unsafe, $ally_tag_unsafe, $user['id']); |
25 | 25 | $ally_id = classSupernova::$db->db_insert_id(); |
26 | - DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= " . SN_TIME_NOW . ""); |
|
26 | + DBStaticUser::db_user_set_by_id($user['id'], "`ally_tag` = '{$ally_tag}', `ally_id`= {$ally_id}, `ally_name`='{$ally_name}', `ally_register_time`= ".SN_TIME_NOW.""); |
|
27 | 27 | |
28 | 28 | $ally_user = classSupernova::$gc->cacheOperator->db_ins_record(LOC_USER, array( |
29 | - 'username' => "[" . $ally_tag_unsafe . "]", |
|
29 | + 'username' => "[".$ally_tag_unsafe."]", |
|
30 | 30 | 'register_time' => SN_TIME_NOW, |
31 | 31 | 'user_as_ally' => $ally_id, |
32 | 32 | )); |
@@ -5,47 +5,47 @@ discard block |
||
5 | 5 | } |
6 | 6 | |
7 | 7 | switch($new_version) { |
8 | - case 0: |
|
9 | - case 1: |
|
10 | - case 2: |
|
11 | - case 3: |
|
12 | - case 4: |
|
13 | - case 5: |
|
14 | - case 6: |
|
15 | - case 7: |
|
16 | - case 8: |
|
17 | - case 9: |
|
18 | - upd_log_version_update(); |
|
19 | - |
|
20 | - upd_alter_table('planets', "ADD `debris_metal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_metal']); |
|
21 | - upd_alter_table('planets', "ADD `debris_crystal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_crystal']); |
|
22 | - |
|
23 | - upd_alter_table('planets', array( |
|
24 | - "ADD `parent_planet` bigint(11) unsigned DEFAULT '0'", |
|
25 | - "ADD KEY `i_parent_planet` (`parent_planet`)" |
|
26 | - ), !$update_tables['planets']['parent_planet']); |
|
27 | - upd_do_query( |
|
28 | - "UPDATE `{{planets}}` AS lu |
|
8 | + case 0: |
|
9 | + case 1: |
|
10 | + case 2: |
|
11 | + case 3: |
|
12 | + case 4: |
|
13 | + case 5: |
|
14 | + case 6: |
|
15 | + case 7: |
|
16 | + case 8: |
|
17 | + case 9: |
|
18 | + upd_log_version_update(); |
|
19 | + |
|
20 | + upd_alter_table('planets', "ADD `debris_metal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_metal']); |
|
21 | + upd_alter_table('planets', "ADD `debris_crystal` bigint(11) unsigned DEFAULT '0'", !$update_tables['planets']['debris_crystal']); |
|
22 | + |
|
23 | + upd_alter_table('planets', array( |
|
24 | + "ADD `parent_planet` bigint(11) unsigned DEFAULT '0'", |
|
25 | + "ADD KEY `i_parent_planet` (`parent_planet`)" |
|
26 | + ), !$update_tables['planets']['parent_planet']); |
|
27 | + upd_do_query( |
|
28 | + "UPDATE `{{planets}}` AS lu |
|
29 | 29 | LEFT JOIN `{{planets}}` AS pl |
30 | 30 | ON pl.galaxy=lu.galaxy AND pl.system=lu.system AND pl.planet=lu.planet AND pl.planet_type=1 |
31 | 31 | SET lu.parent_planet=pl.id WHERE lu.planet_type=3;" |
32 | - ); |
|
33 | - upd_drop_table('lunas'); |
|
32 | + ); |
|
33 | + upd_drop_table('lunas'); |
|
34 | 34 | |
35 | - if($update_tables['galaxy']) { |
|
36 | - upd_do_query( |
|
37 | - 'UPDATE `{{planets}}` |
|
35 | + if($update_tables['galaxy']) { |
|
36 | + upd_do_query( |
|
37 | + 'UPDATE `{{planets}}` |
|
38 | 38 | LEFT JOIN `{{galaxy}}` ON {{galaxy}}.id_planet = {{planets}}.id |
39 | 39 | SET |
40 | 40 | {{planets}}.debris_metal = {{galaxy}}.metal, |
41 | 41 | {{planets}}.debris_crystal = {{galaxy}}.crystal |
42 | 42 | WHERE {{galaxy}}.metal>0 OR {{galaxy}}.crystal>0;' |
43 | - ); |
|
44 | - } |
|
45 | - upd_drop_table('galaxy'); |
|
43 | + ); |
|
44 | + } |
|
45 | + upd_drop_table('galaxy'); |
|
46 | 46 | |
47 | - upd_create_table('counter', |
|
48 | - "( |
|
47 | + upd_create_table('counter', |
|
48 | + "( |
|
49 | 49 | `id` bigint(11) NOT NULL AUTO_INCREMENT, |
50 | 50 | `time` int(11) NOT NULL DEFAULT '0', |
51 | 51 | `page` varchar(255) CHARACTER SET utf8 DEFAULT '0', |
@@ -55,62 +55,62 @@ discard block |
||
55 | 55 | KEY `i_user_id` (`user_id`), |
56 | 56 | KEY `i_ip` (`ip`) |
57 | 57 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
58 | - ); |
|
59 | - upd_alter_table('counter', "ADD `url` varchar(255) CHARACTER SET utf8 DEFAULT ''", !$update_tables['counter']['url']); |
|
58 | + ); |
|
59 | + upd_alter_table('counter', "ADD `url` varchar(255) CHARACTER SET utf8 DEFAULT ''", !$update_tables['counter']['url']); |
|
60 | 60 | |
61 | - upd_alter_table('fleets', array( |
|
62 | - "ADD KEY `fleet_mess` (`fleet_mess`)", |
|
63 | - "ADD KEY `fleet_group` (`fleet_group`)" |
|
64 | - ), !$update_indexes['fleets']['fleet_mess']); |
|
61 | + upd_alter_table('fleets', array( |
|
62 | + "ADD KEY `fleet_mess` (`fleet_mess`)", |
|
63 | + "ADD KEY `fleet_group` (`fleet_group`)" |
|
64 | + ), !$update_indexes['fleets']['fleet_mess']); |
|
65 | 65 | |
66 | - 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']); |
|
67 | - upd_alter_table('referrals', "ADD KEY `id_partner` (`id_partner`)", !$update_indexes['referrals']['id_partner']); |
|
66 | + 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']); |
|
67 | + upd_alter_table('referrals', "ADD KEY `id_partner` (`id_partner`)", !$update_indexes['referrals']['id_partner']); |
|
68 | 68 | |
69 | - upd_check_key('rpg_bonus_divisor', 10); |
|
69 | + upd_check_key('rpg_bonus_divisor', 10); |
|
70 | 70 | |
71 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('BannerURL', 'banner_source_post', 'BannerOverviewFrame', |
|
71 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('BannerURL', 'banner_source_post', 'BannerOverviewFrame', |
|
72 | 72 | 'close_reason', 'dbVersion', 'ForumUserBarFrame', 'OverviewBanner', 'OverviewClickBanner', 'OverviewExternChat', |
73 | 73 | 'OverviewExternChatCmd', 'OverviewNewsText', 'UserbarURL', 'userbar_source');"); |
74 | 74 | |
75 | - $dm_change_legit = true; |
|
75 | + $dm_change_legit = true; |
|
76 | 76 | |
77 | - upd_do_query( |
|
78 | - "UPDATE {{referrals}} AS r |
|
77 | + upd_do_query( |
|
78 | + "UPDATE {{referrals}} AS r |
|
79 | 79 | LEFT JOIN {{users}} AS u |
80 | 80 | ON u.id = r.id |
81 | 81 | SET r.dark_matter = u.lvl_minier + u.lvl_raid;" |
82 | - ); |
|
83 | - upd_add_more_time(); |
|
82 | + ); |
|
83 | + upd_add_more_time(); |
|
84 | 84 | |
85 | - if($update_tables['users']['rpg_points']) { |
|
86 | - upd_do_query( |
|
87 | - "UPDATE {{users}} AS u |
|
85 | + if($update_tables['users']['rpg_points']) { |
|
86 | + upd_do_query( |
|
87 | + "UPDATE {{users}} AS u |
|
88 | 88 | RIGHT JOIN {{referrals}} AS r |
89 | 89 | ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor . " |
90 | 90 | SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor . ");" |
91 | - ); |
|
92 | - } |
|
91 | + ); |
|
92 | + } |
|
93 | 93 | |
94 | - $dm_change_legit = false; |
|
95 | - upd_do_query('COMMIT;', true); |
|
96 | - $new_version = 10; |
|
97 | - |
|
98 | - case 10: |
|
99 | - case 11: |
|
100 | - case 12: |
|
101 | - case 13: |
|
102 | - case 14: |
|
103 | - case 15: |
|
104 | - case 16: |
|
105 | - case 17: |
|
106 | - case 18: |
|
107 | - case 19: |
|
108 | - case 20: |
|
109 | - case 21: |
|
110 | - upd_log_version_update(); |
|
111 | - |
|
112 | - upd_create_table('alliance_requests', |
|
113 | - "( |
|
94 | + $dm_change_legit = false; |
|
95 | + upd_do_query('COMMIT;', true); |
|
96 | + $new_version = 10; |
|
97 | + |
|
98 | + case 10: |
|
99 | + case 11: |
|
100 | + case 12: |
|
101 | + case 13: |
|
102 | + case 14: |
|
103 | + case 15: |
|
104 | + case 16: |
|
105 | + case 17: |
|
106 | + case 18: |
|
107 | + case 19: |
|
108 | + case 20: |
|
109 | + case 21: |
|
110 | + upd_log_version_update(); |
|
111 | + |
|
112 | + upd_create_table('alliance_requests', |
|
113 | + "( |
|
114 | 114 | `id_user` int(11) NOT NULL, |
115 | 115 | `id_ally` int(11) NOT NULL DEFAULT '0', |
116 | 116 | `request_text` text, |
@@ -118,96 +118,96 @@ discard block |
||
118 | 118 | `request_denied` tinyint(1) unsigned NOT NULL DEFAULT '0', |
119 | 119 | PRIMARY KEY (`id_user`,`id_ally`) |
120 | 120 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8;" |
121 | - ); |
|
122 | - |
|
123 | - upd_alter_table('announce', "ADD `detail_url` varchar(250) NOT NULL DEFAULT '' COMMENT 'Link to more details about update'", !$update_tables['announce']['detail_url']); |
|
124 | - |
|
125 | - 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']); |
|
126 | - |
|
127 | - upd_alter_table('statpoints', array( |
|
128 | - "ADD `res_rank` INT(11) DEFAULT 0 COMMENT 'Rank by resources'", |
|
129 | - "ADD `res_old_rank` INT(11) DEFAULT 0 COMMENT 'Old rank by resources'", |
|
130 | - "ADD `res_points` BIGINT(20) DEFAULT 0 COMMENT 'Resource stat points'", |
|
131 | - "ADD `res_count` BIGINT(20) DEFAULT 0 COMMENT 'Old rank by resources'" |
|
132 | - ), !$update_tables['statpoints']['res_rank']); |
|
133 | - |
|
134 | - upd_alter_table('planets', "ADD `supercargo` bigint(11) NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count'", !$update_tables['planets']['supercargo']); |
|
135 | - |
|
136 | - upd_alter_table('users', "DROP COLUMN `current_luna`", $update_tables['users']['current_luna']); |
|
137 | - upd_alter_table('users', array("DROP COLUMN `aktywnosc`", "DROP COLUMN `time_aktyw`", "DROP COLUMN `kiler`", |
|
138 | - "DROP COLUMN `kod_aktywujacy`", "DROP COLUMN `ataker`", "DROP COLUMN `atakin`"), $update_tables['users']['ataker']); |
|
139 | - upd_alter_table('users', "ADD `options` TEXT COMMENT 'Packed user options'", !$update_tables['users']['options']); |
|
140 | - upd_alter_table('users', "ADD `news_lastread` int(11) NOT NULL DEFAULT '0' COMMENT 'News last read date'", !$update_tables['users']['news_lastread']); |
|
141 | - 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']); |
|
142 | - |
|
143 | - upd_drop_table('update'); |
|
144 | - |
|
145 | - upd_check_key('fleet_speed', classSupernova::$config->fleet_speed / 2500, classSupernova::$config->fleet_speed >= 2500); |
|
146 | - upd_check_key('game_counter', 0); |
|
147 | - upd_check_key('game_default_language', 'ru'); |
|
148 | - upd_check_key('game_default_skin', 'skins/EpicBlue/'); |
|
149 | - upd_check_key('game_default_template', 'OpenGame'); |
|
150 | - upd_check_key('game_news_overview', 3); |
|
151 | - upd_check_key('game_news_actual', 259200); |
|
152 | - upd_check_key('game_noob_factor', 5, !isset(classSupernova::$config->game_noob_factor)); |
|
153 | - upd_check_key('game_noob_points', 5000, !isset(classSupernova::$config->game_noob_points)); |
|
154 | - upd_check_key('game_speed', classSupernova::$config->game_speed / 2500, classSupernova::$config->game_speed >= 2500); |
|
155 | - upd_check_key('int_format_date', 'd.m.Y'); |
|
156 | - upd_check_key('int_format_time', 'H:i:s', true); |
|
157 | - upd_check_key('int_banner_background', 'design/images/banner.png', true); |
|
158 | - upd_check_key('int_userbar_background', 'design/images/userbar.png', true); |
|
159 | - upd_check_key('player_max_colonies', classSupernova::$config->player_max_planets ? (classSupernova::$config->player_max_planets - 1) : 9); |
|
160 | - upd_check_key('url_forum', classSupernova::$config->forum_url, !isset(classSupernova::$config->url_forum)); |
|
161 | - upd_check_key('url_rules', classSupernova::$config->rules_url, !isset(classSupernova::$config->url_rules)); |
|
162 | - upd_check_key('url_dark_matter', '', !isset(classSupernova::$config->url_dark_matter)); |
|
163 | - |
|
164 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ( |
|
121 | + ); |
|
122 | + |
|
123 | + upd_alter_table('announce', "ADD `detail_url` varchar(250) NOT NULL DEFAULT '' COMMENT 'Link to more details about update'", !$update_tables['announce']['detail_url']); |
|
124 | + |
|
125 | + 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']); |
|
126 | + |
|
127 | + upd_alter_table('statpoints', array( |
|
128 | + "ADD `res_rank` INT(11) DEFAULT 0 COMMENT 'Rank by resources'", |
|
129 | + "ADD `res_old_rank` INT(11) DEFAULT 0 COMMENT 'Old rank by resources'", |
|
130 | + "ADD `res_points` BIGINT(20) DEFAULT 0 COMMENT 'Resource stat points'", |
|
131 | + "ADD `res_count` BIGINT(20) DEFAULT 0 COMMENT 'Old rank by resources'" |
|
132 | + ), !$update_tables['statpoints']['res_rank']); |
|
133 | + |
|
134 | + upd_alter_table('planets', "ADD `supercargo` bigint(11) NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count'", !$update_tables['planets']['supercargo']); |
|
135 | + |
|
136 | + upd_alter_table('users', "DROP COLUMN `current_luna`", $update_tables['users']['current_luna']); |
|
137 | + upd_alter_table('users', array("DROP COLUMN `aktywnosc`", "DROP COLUMN `time_aktyw`", "DROP COLUMN `kiler`", |
|
138 | + "DROP COLUMN `kod_aktywujacy`", "DROP COLUMN `ataker`", "DROP COLUMN `atakin`"), $update_tables['users']['ataker']); |
|
139 | + upd_alter_table('users', "ADD `options` TEXT COMMENT 'Packed user options'", !$update_tables['users']['options']); |
|
140 | + upd_alter_table('users', "ADD `news_lastread` int(11) NOT NULL DEFAULT '0' COMMENT 'News last read date'", !$update_tables['users']['news_lastread']); |
|
141 | + 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']); |
|
142 | + |
|
143 | + upd_drop_table('update'); |
|
144 | + |
|
145 | + upd_check_key('fleet_speed', classSupernova::$config->fleet_speed / 2500, classSupernova::$config->fleet_speed >= 2500); |
|
146 | + upd_check_key('game_counter', 0); |
|
147 | + upd_check_key('game_default_language', 'ru'); |
|
148 | + upd_check_key('game_default_skin', 'skins/EpicBlue/'); |
|
149 | + upd_check_key('game_default_template', 'OpenGame'); |
|
150 | + upd_check_key('game_news_overview', 3); |
|
151 | + upd_check_key('game_news_actual', 259200); |
|
152 | + upd_check_key('game_noob_factor', 5, !isset(classSupernova::$config->game_noob_factor)); |
|
153 | + upd_check_key('game_noob_points', 5000, !isset(classSupernova::$config->game_noob_points)); |
|
154 | + upd_check_key('game_speed', classSupernova::$config->game_speed / 2500, classSupernova::$config->game_speed >= 2500); |
|
155 | + upd_check_key('int_format_date', 'd.m.Y'); |
|
156 | + upd_check_key('int_format_time', 'H:i:s', true); |
|
157 | + upd_check_key('int_banner_background', 'design/images/banner.png', true); |
|
158 | + upd_check_key('int_userbar_background', 'design/images/userbar.png', true); |
|
159 | + upd_check_key('player_max_colonies', classSupernova::$config->player_max_planets ? (classSupernova::$config->player_max_planets - 1) : 9); |
|
160 | + upd_check_key('url_forum', classSupernova::$config->forum_url, !isset(classSupernova::$config->url_forum)); |
|
161 | + upd_check_key('url_rules', classSupernova::$config->rules_url, !isset(classSupernova::$config->url_rules)); |
|
162 | + upd_check_key('url_dark_matter', '', !isset(classSupernova::$config->url_dark_matter)); |
|
163 | + |
|
164 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ( |
|
165 | 165 | 'game_date_withTime', 'player_max_planets', 'OverviewNewsFrame', 'forum_url', 'rules_url' |
166 | 166 | );"); |
167 | 167 | |
168 | - upd_do_query('COMMIT;', true); |
|
169 | - $new_version = 22; |
|
170 | - |
|
171 | - case 22: |
|
172 | - upd_log_version_update(); |
|
173 | - |
|
174 | - upd_alter_table('planets', "ADD `governor` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Planet governor'", !$update_tables['planets']['governor']); |
|
175 | - upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
|
176 | - upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
|
177 | - |
|
178 | - if($update_tables['planets']['b_building']) { |
|
179 | - $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
|
180 | - $const_que_structures = QUE_STRUCTURES; |
|
181 | - while($planet_data = db_fetch($planet_query)) { |
|
182 | - $old_que = explode(';', $planet_data['b_building_id']); |
|
183 | - foreach($old_que as $old_que_item_string) { |
|
184 | - if(!$old_que_item_string) { |
|
185 | - continue; |
|
186 | - } |
|
168 | + upd_do_query('COMMIT;', true); |
|
169 | + $new_version = 22; |
|
170 | + |
|
171 | + case 22: |
|
172 | + upd_log_version_update(); |
|
173 | + |
|
174 | + upd_alter_table('planets', "ADD `governor` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Planet governor'", !$update_tables['planets']['governor']); |
|
175 | + upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
|
176 | + upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
|
177 | + |
|
178 | + if($update_tables['planets']['b_building']) { |
|
179 | + $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
|
180 | + $const_que_structures = QUE_STRUCTURES; |
|
181 | + while($planet_data = db_fetch($planet_query)) { |
|
182 | + $old_que = explode(';', $planet_data['b_building_id']); |
|
183 | + foreach($old_que as $old_que_item_string) { |
|
184 | + if(!$old_que_item_string) { |
|
185 | + continue; |
|
186 | + } |
|
187 | 187 | |
188 | - $old_que_item = explode(',', $old_que_item_string); |
|
189 | - if($old_que_item[4] == 'build') { |
|
190 | - $old_que_item[4] = BUILD_CREATE; |
|
191 | - } else { |
|
192 | - $old_que_item[4] = BUILD_DESTROY; |
|
193 | - } |
|
188 | + $old_que_item = explode(',', $old_que_item_string); |
|
189 | + if($old_que_item[4] == 'build') { |
|
190 | + $old_que_item[4] = BUILD_CREATE; |
|
191 | + } else { |
|
192 | + $old_que_item[4] = BUILD_DESTROY; |
|
193 | + } |
|
194 | 194 | |
195 | - $old_que_item[3] = $old_que_item[3] > $planet_data['last_update'] ? $old_que_item[3] - $planet_data['last_update'] : 1; |
|
196 | - $planet_data['que'] = "{$old_que_item[0]},1,{$old_que_item[3]},{$old_que_item[4]},{$const_que_structures};{$planet_data['que']}"; |
|
195 | + $old_que_item[3] = $old_que_item[3] > $planet_data['last_update'] ? $old_que_item[3] - $planet_data['last_update'] : 1; |
|
196 | + $planet_data['que'] = "{$old_que_item[0]},1,{$old_que_item[3]},{$old_que_item[4]},{$const_que_structures};{$planet_data['que']}"; |
|
197 | + } |
|
198 | + 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); |
|
197 | 199 | } |
198 | - 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); |
|
199 | 200 | } |
200 | - } |
|
201 | 201 | |
202 | - upd_do_query('COMMIT;', true); |
|
203 | - $new_version = 23; |
|
202 | + upd_do_query('COMMIT;', true); |
|
203 | + $new_version = 23; |
|
204 | 204 | |
205 | - case 23: |
|
206 | - case 24: |
|
207 | - upd_log_version_update(); |
|
205 | + case 23: |
|
206 | + case 24: |
|
207 | + upd_log_version_update(); |
|
208 | 208 | |
209 | - upd_create_table('confirmations', |
|
210 | - "( |
|
209 | + upd_create_table('confirmations', |
|
210 | + "( |
|
211 | 211 | `id` bigint(11) NOT NULL AUTO_INCREMENT, |
212 | 212 | `id_user` bigint(11) NOT NULL DEFAULT 0, |
213 | 213 | `type` SMALLINT NOT NULL DEFAULT 0, |
@@ -217,124 +217,124 @@ discard block |
||
217 | 217 | PRIMARY KEY (`id`), |
218 | 218 | KEY `i_code_email` (`code`, `email`) |
219 | 219 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
220 | - ); |
|
220 | + ); |
|
221 | 221 | |
222 | - if($update_tables['users']['urlaubs_until']) { |
|
223 | - upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
|
224 | - upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
|
225 | - upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']); |
|
226 | - } |
|
222 | + if($update_tables['users']['urlaubs_until']) { |
|
223 | + upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
|
224 | + upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
|
225 | + upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']); |
|
226 | + } |
|
227 | 227 | |
228 | - upd_check_key('user_vacation_disable', classSupernova::$config->urlaubs_modus_erz, !isset(classSupernova::$config->user_vacation_disable)); |
|
229 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('urlaubs_modus_erz');"); |
|
228 | + upd_check_key('user_vacation_disable', classSupernova::$config->urlaubs_modus_erz, !isset(classSupernova::$config->user_vacation_disable)); |
|
229 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('urlaubs_modus_erz');"); |
|
230 | 230 | |
231 | - upd_do_query('COMMIT;', true); |
|
232 | - $new_version = 25; |
|
233 | - |
|
234 | - case 25: |
|
235 | - upd_log_version_update(); |
|
236 | - |
|
237 | - upd_alter_table('rw', array( |
|
238 | - "DROP COLUMN `a_zestrzelona`", |
|
239 | - "DROP INDEX `rid`", |
|
240 | - "ADD COLUMN `report_id` bigint(11) NOT NULL AUTO_INCREMENT FIRST", |
|
241 | - "ADD PRIMARY KEY (`report_id`)", |
|
242 | - "ADD INDEX `i_rid` (`rid`)" |
|
243 | - ), !$update_tables['rw']['report_id']); |
|
244 | - |
|
245 | - upd_add_more_time(); |
|
246 | - upd_create_table('logs_backup', "AS (SELECT * FROM {{logs}});"); |
|
247 | - |
|
248 | - upd_alter_table('logs', array( |
|
249 | - "MODIFY COLUMN `log_id` INT(1)", |
|
250 | - "DROP PRIMARY KEY" |
|
251 | - ), !$update_tables['logs']['log_timestamp']); |
|
252 | - |
|
253 | - upd_alter_table('logs', array( |
|
254 | - "DROP COLUMN `log_id`", |
|
255 | - "ADD COLUMN `log_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp' FIRST", |
|
256 | - "ADD COLUMN `log_username` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Username' AFTER `log_timestamp`", |
|
257 | - "MODIFY COLUMN `log_title` VARCHAR(64) NOT NULL DEFAULT 'Log entry' COMMENT 'Short description' AFTER `log_username`", |
|
258 | - "MODIFY COLUMN `log_page` VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log' AFTER `log_text`", |
|
259 | - "CHANGE COLUMN `log_type` `log_code` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `log_page`", |
|
260 | - "MODIFY COLUMN `log_sender` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ID which make log record' AFTER `log_code`", |
|
261 | - "MODIFY COLUMN `log_time` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Machine-readable timestamp' AFTER `log_sender`", |
|
262 | - "ADD COLUMN `log_dump` TEXT NOT NULL DEFAULT '' COMMENT 'Machine-readable dump of variables' AFTER `log_time`", |
|
263 | - "ADD INDEX `i_log_username` (`log_username`)", |
|
264 | - "ADD INDEX `i_log_time` (`log_time`)", |
|
265 | - "ADD INDEX `i_log_sender` (`log_sender`)", |
|
266 | - "ADD INDEX `i_log_code` (`log_code`)", |
|
267 | - "ADD INDEX `i_log_page` (`log_page`)", |
|
268 | - "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" |
|
269 | - ), !$update_tables['logs']['log_timestamp']); |
|
270 | - upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
|
271 | - |
|
272 | - if($update_tables['errors']) { |
|
273 | - 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}}`;'); |
|
274 | - if($update_tables['errors_backup']) { |
|
275 | - upd_drop_table('errors_backup'); |
|
276 | - } |
|
277 | - upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup'); |
|
231 | + upd_do_query('COMMIT;', true); |
|
232 | + $new_version = 25; |
|
233 | + |
|
234 | + case 25: |
|
235 | + upd_log_version_update(); |
|
236 | + |
|
237 | + upd_alter_table('rw', array( |
|
238 | + "DROP COLUMN `a_zestrzelona`", |
|
239 | + "DROP INDEX `rid`", |
|
240 | + "ADD COLUMN `report_id` bigint(11) NOT NULL AUTO_INCREMENT FIRST", |
|
241 | + "ADD PRIMARY KEY (`report_id`)", |
|
242 | + "ADD INDEX `i_rid` (`rid`)" |
|
243 | + ), !$update_tables['rw']['report_id']); |
|
244 | + |
|
245 | + upd_add_more_time(); |
|
246 | + upd_create_table('logs_backup', "AS (SELECT * FROM {{logs}});"); |
|
247 | + |
|
248 | + upd_alter_table('logs', array( |
|
249 | + "MODIFY COLUMN `log_id` INT(1)", |
|
250 | + "DROP PRIMARY KEY" |
|
251 | + ), !$update_tables['logs']['log_timestamp']); |
|
252 | + |
|
253 | + upd_alter_table('logs', array( |
|
254 | + "DROP COLUMN `log_id`", |
|
255 | + "ADD COLUMN `log_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp' FIRST", |
|
256 | + "ADD COLUMN `log_username` VARCHAR(64) NOT NULL DEFAULT '' COMMENT 'Username' AFTER `log_timestamp`", |
|
257 | + "MODIFY COLUMN `log_title` VARCHAR(64) NOT NULL DEFAULT 'Log entry' COMMENT 'Short description' AFTER `log_username`", |
|
258 | + "MODIFY COLUMN `log_page` VARCHAR(512) NOT NULL DEFAULT '' COMMENT 'Page that makes entry to log' AFTER `log_text`", |
|
259 | + "CHANGE COLUMN `log_type` `log_code` INT UNSIGNED NOT NULL DEFAULT 0 AFTER `log_page`", |
|
260 | + "MODIFY COLUMN `log_sender` BIGINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ID which make log record' AFTER `log_code`", |
|
261 | + "MODIFY COLUMN `log_time` INT(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Machine-readable timestamp' AFTER `log_sender`", |
|
262 | + "ADD COLUMN `log_dump` TEXT NOT NULL DEFAULT '' COMMENT 'Machine-readable dump of variables' AFTER `log_time`", |
|
263 | + "ADD INDEX `i_log_username` (`log_username`)", |
|
264 | + "ADD INDEX `i_log_time` (`log_time`)", |
|
265 | + "ADD INDEX `i_log_sender` (`log_sender`)", |
|
266 | + "ADD INDEX `i_log_code` (`log_code`)", |
|
267 | + "ADD INDEX `i_log_page` (`log_page`)", |
|
268 | + "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci" |
|
269 | + ), !$update_tables['logs']['log_timestamp']); |
|
270 | + upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
|
271 | + |
|
272 | + if($update_tables['errors']) { |
|
273 | + 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}}`;'); |
|
274 | + if($update_tables['errors_backup']) { |
|
275 | + upd_drop_table('errors_backup'); |
|
276 | + } |
|
277 | + upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup'); |
|
278 | 278 | |
279 | - upd_drop_table('errors'); |
|
280 | - } |
|
279 | + upd_drop_table('errors'); |
|
280 | + } |
|
281 | 281 | |
282 | - upd_alter_table('logs', 'ORDER BY log_time'); |
|
282 | + upd_alter_table('logs', 'ORDER BY log_time'); |
|
283 | 283 | |
284 | - upd_alter_table('logs', array("ADD COLUMN `log_id` SERIAL", "ADD PRIMARY KEY (`log_id`)"), !$update_tables['logs']['log_id']); |
|
284 | + upd_alter_table('logs', array("ADD COLUMN `log_id` SERIAL", "ADD PRIMARY KEY (`log_id`)"), !$update_tables['logs']['log_id']); |
|
285 | 285 | |
286 | - upd_do_query('UPDATE `{{logs}}` SET `log_timestamp` = FROM_UNIXTIME(`log_time`);'); |
|
287 | - 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;'); |
|
286 | + upd_do_query('UPDATE `{{logs}}` SET `log_timestamp` = FROM_UNIXTIME(`log_time`);'); |
|
287 | + 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;'); |
|
288 | 288 | |
289 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 190 WHERE `log_code` = 100 AND `log_title` = 'Stat update';"); |
|
290 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 191 WHERE `log_code` = 101 AND `log_title` = 'Stat update';"); |
|
291 | - upd_do_query("UPDATE `{{logs}}` SET `log_code` = 192 WHERE `log_code` = 102 AND `log_title` = 'Stat update';"); |
|
292 | - $sys_log_disabled = false; |
|
289 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 190 WHERE `log_code` = 100 AND `log_title` = 'Stat update';"); |
|
290 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 191 WHERE `log_code` = 101 AND `log_title` = 'Stat update';"); |
|
291 | + upd_do_query("UPDATE `{{logs}}` SET `log_code` = 192 WHERE `log_code` = 102 AND `log_title` = 'Stat update';"); |
|
292 | + $sys_log_disabled = false; |
|
293 | 293 | |
294 | - upd_do_query('COMMIT;', true); |
|
295 | - $new_version = 26; |
|
294 | + upd_do_query('COMMIT;', true); |
|
295 | + $new_version = 26; |
|
296 | 296 | |
297 | - case 26: |
|
298 | - upd_log_version_update(); |
|
297 | + case 26: |
|
298 | + upd_log_version_update(); |
|
299 | 299 | |
300 | - $sys_log_disabled = false; |
|
300 | + $sys_log_disabled = false; |
|
301 | 301 | |
302 | - upd_alter_table('planets', "ADD INDEX `i_parent_planet` (`parent_planet`)", !$update_indexes['planets']['i_parent_planet']); |
|
303 | - upd_alter_table('messages', "DROP INDEX `owner`", $update_indexes['messages']['owner']); |
|
304 | - upd_alter_table('messages', "DROP INDEX `owner_type`", $update_indexes['messages']['owner_type']); |
|
305 | - upd_alter_table('messages', "DROP INDEX `sender_type`", $update_indexes['messages']['sender_type']); |
|
302 | + upd_alter_table('planets', "ADD INDEX `i_parent_planet` (`parent_planet`)", !$update_indexes['planets']['i_parent_planet']); |
|
303 | + upd_alter_table('messages', "DROP INDEX `owner`", $update_indexes['messages']['owner']); |
|
304 | + upd_alter_table('messages', "DROP INDEX `owner_type`", $update_indexes['messages']['owner_type']); |
|
305 | + upd_alter_table('messages', "DROP INDEX `sender_type`", $update_indexes['messages']['sender_type']); |
|
306 | 306 | |
307 | - upd_alter_table('messages', array( |
|
308 | - "ADD INDEX `i_owner_time` (`message_owner`, `message_time`)", |
|
309 | - "ADD INDEX `i_sender_time` (`message_sender`, `message_time`)", |
|
310 | - "ADD INDEX `i_time` (`message_time`)" |
|
311 | - ), !$update_indexes['messages']['i_owner_time']); |
|
307 | + upd_alter_table('messages', array( |
|
308 | + "ADD INDEX `i_owner_time` (`message_owner`, `message_time`)", |
|
309 | + "ADD INDEX `i_sender_time` (`message_sender`, `message_time`)", |
|
310 | + "ADD INDEX `i_time` (`message_time`)" |
|
311 | + ), !$update_indexes['messages']['i_owner_time']); |
|
312 | 312 | |
313 | - upd_drop_table('fleet_log'); |
|
313 | + upd_drop_table('fleet_log'); |
|
314 | 314 | |
315 | - upd_do_query("UPDATE `{{planets}}` SET `metal` = 0 WHERE `metal` < 0;"); |
|
316 | - upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;"); |
|
317 | - upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;"); |
|
318 | - upd_alter_table('planets', array( |
|
319 | - "DROP COLUMN `b_building`", |
|
320 | - "DROP COLUMN `b_building_id`" |
|
321 | - ), $update_tables['planets']['b_building']); |
|
315 | + upd_do_query("UPDATE `{{planets}}` SET `metal` = 0 WHERE `metal` < 0;"); |
|
316 | + upd_do_query("UPDATE `{{planets}}` SET `crystal` = 0 WHERE `crystal` < 0;"); |
|
317 | + upd_do_query("UPDATE `{{planets}}` SET `deuterium` = 0 WHERE `deuterium` < 0;"); |
|
318 | + upd_alter_table('planets', array( |
|
319 | + "DROP COLUMN `b_building`", |
|
320 | + "DROP COLUMN `b_building_id`" |
|
321 | + ), $update_tables['planets']['b_building']); |
|
322 | 322 | |
323 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');"); |
|
323 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('noobprotection', 'noobprotectionmulti', 'noobprotectiontime', 'chat_admin_msgFormat');"); |
|
324 | 324 | |
325 | - upd_do_query("DELETE FROM `{{logs}}` WHERE `log_code` = 501;"); |
|
326 | - upd_do_query("DELETE FROM `{{logs}}` WHERE `log_title` IN ('Canceling Hangar Que', 'Building Planet Defense');"); |
|
325 | + upd_do_query("DELETE FROM `{{logs}}` WHERE `log_code` = 501;"); |
|
326 | + upd_do_query("DELETE FROM `{{logs}}` WHERE `log_title` IN ('Canceling Hangar Que', 'Building Planet Defense');"); |
|
327 | 327 | |
328 | - upd_check_key('chat_admin_highlight', '<font color=purple>$1</font>', !isset(classSupernova::$config->chat_admin_highlight)); |
|
328 | + upd_check_key('chat_admin_highlight', '<font color=purple>$1</font>', !isset(classSupernova::$config->chat_admin_highlight)); |
|
329 | 329 | |
330 | - upd_check_key('int_banner_URL', 'banner.php?type=banner', classSupernova::$config->int_banner_URL == '/banner.php?type=banner'); |
|
331 | - upd_check_key('int_userbar_URL', 'banner.php?type=userbar', classSupernova::$config->int_userbar_URL == '/banner.php?type=userbar'); |
|
330 | + upd_check_key('int_banner_URL', 'banner.php?type=banner', classSupernova::$config->int_banner_URL == '/banner.php?type=banner'); |
|
331 | + upd_check_key('int_userbar_URL', 'banner.php?type=userbar', classSupernova::$config->int_userbar_URL == '/banner.php?type=userbar'); |
|
332 | 332 | |
333 | - upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
|
333 | + upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
|
334 | 334 | |
335 | - if(!$update_tables['shortcut']) { |
|
336 | - upd_create_table('shortcut', |
|
337 | - "( |
|
335 | + if(!$update_tables['shortcut']) { |
|
336 | + upd_create_table('shortcut', |
|
337 | + "( |
|
338 | 338 | `shortcut_id` SERIAL, |
339 | 339 | `shortcut_user_id` BIGINT(11) UNSIGNED NOT NULL DEFAULT 0, |
340 | 340 | `shortcut_planet_id` bigint(11) NOT NULL DEFAULT 0, |
@@ -351,71 +351,71 @@ discard block |
||
351 | 351 | CONSTRAINT `FK_shortcut_user_id` FOREIGN KEY (`shortcut_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
352 | 352 | |
353 | 353 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
354 | - ); |
|
354 | + ); |
|
355 | 355 | |
356 | - $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
|
356 | + $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
|
357 | 357 | |
358 | - $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
|
359 | - while($user_data = db_fetch($query)) { |
|
360 | - $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
|
361 | - foreach($shortcuts as $shortcut) { |
|
362 | - if(!$shortcut) { |
|
363 | - continue; |
|
364 | - } |
|
358 | + $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
|
359 | + while($user_data = db_fetch($query)) { |
|
360 | + $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
|
361 | + foreach($shortcuts as $shortcut) { |
|
362 | + if(!$shortcut) { |
|
363 | + continue; |
|
364 | + } |
|
365 | 365 | |
366 | - $shortcut = explode(',', $shortcut); |
|
367 | - $shortcut[0] = db_escape($shortcut[0]); |
|
368 | - $shortcut[1] = intval($shortcut[1]); |
|
369 | - $shortcut[2] = intval($shortcut[2]); |
|
370 | - $shortcut[3] = intval($shortcut[3]); |
|
371 | - $shortcut[4] = intval($shortcut[4]); |
|
366 | + $shortcut = explode(',', $shortcut); |
|
367 | + $shortcut[0] = db_escape($shortcut[0]); |
|
368 | + $shortcut[1] = intval($shortcut[1]); |
|
369 | + $shortcut[2] = intval($shortcut[2]); |
|
370 | + $shortcut[3] = intval($shortcut[3]); |
|
371 | + $shortcut[4] = intval($shortcut[4]); |
|
372 | 372 | |
373 | - if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) { |
|
374 | - $db_prefix = classSupernova::$config->db_prefix; |
|
375 | - upd_do_query("INSERT INTO {$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); |
|
373 | + if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) { |
|
374 | + $db_prefix = classSupernova::$config->db_prefix; |
|
375 | + upd_do_query("INSERT INTO {$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); |
|
376 | + } |
|
376 | 377 | } |
377 | 378 | } |
378 | - } |
|
379 | 379 | |
380 | - upd_alter_table('users', 'DROP COLUMN `fleet_shortcut`'); |
|
381 | - }; |
|
380 | + upd_alter_table('users', 'DROP COLUMN `fleet_shortcut`'); |
|
381 | + }; |
|
382 | 382 | |
383 | - upd_check_key('url_faq', '', !isset(classSupernova::$config->url_faq)); |
|
383 | + upd_check_key('url_faq', '', !isset(classSupernova::$config->url_faq)); |
|
384 | 384 | |
385 | - upd_do_query('COMMIT;', true); |
|
386 | - $new_version = 27; |
|
387 | - |
|
388 | - case 27: |
|
389 | - upd_log_version_update(); |
|
390 | - |
|
391 | - upd_check_key('chat_highlight_moderator', '<font color=green>$1</font>', !isset(classSupernova::$config->chat_highlight_moderator)); |
|
392 | - upd_check_key('chat_highlight_operator', '<font color=red>$1</font>', !isset(classSupernova::$config->chat_highlight_operator)); |
|
393 | - upd_check_key('chat_highlight_admin', classSupernova::$config->chat_admin_highlight ? classSupernova::$config->chat_admin_highlight : '<font color=puple>$1</font>', !isset(classSupernova::$config->chat_highlight_admin)); |
|
394 | - |
|
395 | - upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('chat_admin_highlight');"); |
|
396 | - |
|
397 | - upd_alter_table('banned', array( |
|
398 | - "CHANGE COLUMN id ban_id bigint(20) unsigned NOT NULL AUTO_INCREMENT", |
|
399 | - "CHANGE COLUMN `who` `ban_user_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
400 | - "CHANGE COLUMN `theme` `ban_reason` VARCHAR(128) NOT NULL DEFAULT ''", |
|
401 | - "CHANGE COLUMN `time` `ban_time` int(11) NOT NULL DEFAULT 0", |
|
402 | - "CHANGE COLUMN `longer` `ban_until` int(11) NOT NULL DEFAULT 0", |
|
403 | - "CHANGE COLUMN `author` `ban_issuer_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
404 | - "CHANGE COLUMN `email` `ban_issuer_email` VARCHAR(64) NOT NULL DEFAULT ''", |
|
405 | - "DROP COLUMN who2", |
|
406 | - "ADD PRIMARY KEY (`ban_id`)" |
|
407 | - ), !$update_tables['banned']['ban_id']); |
|
408 | - |
|
409 | - upd_alter_table('alliance', array( |
|
410 | - "MODIFY COLUMN `id` SERIAL", |
|
411 | - "ADD CONSTRAINT UNIQUE KEY `i_ally_name` (`ally_name`)", |
|
412 | - "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", |
|
413 | - "ENGINE=InnoDB" |
|
414 | - ), !$update_indexes['alliance']['i_ally_name']); |
|
415 | - |
|
416 | - $upd_relation_types = "'neutral', 'war', 'peace', 'confederation', 'federation', 'union', 'master', 'slave'"; |
|
417 | - upd_create_table('alliance_diplomacy', |
|
418 | - "( |
|
385 | + upd_do_query('COMMIT;', true); |
|
386 | + $new_version = 27; |
|
387 | + |
|
388 | + case 27: |
|
389 | + upd_log_version_update(); |
|
390 | + |
|
391 | + upd_check_key('chat_highlight_moderator', '<font color=green>$1</font>', !isset(classSupernova::$config->chat_highlight_moderator)); |
|
392 | + upd_check_key('chat_highlight_operator', '<font color=red>$1</font>', !isset(classSupernova::$config->chat_highlight_operator)); |
|
393 | + upd_check_key('chat_highlight_admin', classSupernova::$config->chat_admin_highlight ? classSupernova::$config->chat_admin_highlight : '<font color=puple>$1</font>', !isset(classSupernova::$config->chat_highlight_admin)); |
|
394 | + |
|
395 | + upd_do_query("DELETE FROM {{config}} WHERE `config_name` IN ('chat_admin_highlight');"); |
|
396 | + |
|
397 | + upd_alter_table('banned', array( |
|
398 | + "CHANGE COLUMN id ban_id bigint(20) unsigned NOT NULL AUTO_INCREMENT", |
|
399 | + "CHANGE COLUMN `who` `ban_user_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
400 | + "CHANGE COLUMN `theme` `ban_reason` VARCHAR(128) NOT NULL DEFAULT ''", |
|
401 | + "CHANGE COLUMN `time` `ban_time` int(11) NOT NULL DEFAULT 0", |
|
402 | + "CHANGE COLUMN `longer` `ban_until` int(11) NOT NULL DEFAULT 0", |
|
403 | + "CHANGE COLUMN `author` `ban_issuer_name` VARCHAR(64) NOT NULL DEFAULT ''", |
|
404 | + "CHANGE COLUMN `email` `ban_issuer_email` VARCHAR(64) NOT NULL DEFAULT ''", |
|
405 | + "DROP COLUMN who2", |
|
406 | + "ADD PRIMARY KEY (`ban_id`)" |
|
407 | + ), !$update_tables['banned']['ban_id']); |
|
408 | + |
|
409 | + upd_alter_table('alliance', array( |
|
410 | + "MODIFY COLUMN `id` SERIAL", |
|
411 | + "ADD CONSTRAINT UNIQUE KEY `i_ally_name` (`ally_name`)", |
|
412 | + "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci", |
|
413 | + "ENGINE=InnoDB" |
|
414 | + ), !$update_indexes['alliance']['i_ally_name']); |
|
415 | + |
|
416 | + $upd_relation_types = "'neutral', 'war', 'peace', 'confederation', 'federation', 'union', 'master', 'slave'"; |
|
417 | + upd_create_table('alliance_diplomacy', |
|
418 | + "( |
|
419 | 419 | `alliance_diplomacy_id` SERIAL, |
420 | 420 | `alliance_diplomacy_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
421 | 421 | `alliance_diplomacy_contr_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
@@ -432,10 +432,10 @@ discard block |
||
432 | 432 | ,CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
433 | 433 | ,CONSTRAINT `FK_diplomacy_contr_ally_name` FOREIGN KEY (`alliance_diplomacy_contr_ally_name`) REFERENCES `{{alliance}}` (`ally_name`) ON DELETE CASCADE ON UPDATE CASCADE |
434 | 434 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
435 | - ); |
|
435 | + ); |
|
436 | 436 | |
437 | - upd_create_table('alliance_negotiation', |
|
438 | - "( |
|
437 | + upd_create_table('alliance_negotiation', |
|
438 | + "( |
|
439 | 439 | `alliance_negotiation_id` SERIAL, |
440 | 440 | `alliance_negotiation_ally_id` bigint(11) UNSIGNED DEFAULT NULL, |
441 | 441 | `alliance_negotiation_ally_name` varchar(32) DEFAULT '', |
@@ -456,13 +456,13 @@ discard block |
||
456 | 456 | ,CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
457 | 457 | ,CONSTRAINT `FK_negotiation_contr_ally_name` FOREIGN KEY (`alliance_negotiation_contr_ally_name`) REFERENCES `{{alliance}}` (`ally_name`) ON DELETE CASCADE ON UPDATE CASCADE |
458 | 458 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
459 | - ); |
|
459 | + ); |
|
460 | 460 | |
461 | - upd_alter_table('users', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
462 | - upd_alter_table('planets', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
461 | + upd_alter_table('users', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
462 | + upd_alter_table('planets', array("MODIFY COLUMN `id` SERIAL", "CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci"), true); |
|
463 | 463 | |
464 | - upd_create_table('bashing', |
|
465 | - "( |
|
464 | + upd_create_table('bashing', |
|
465 | + "( |
|
466 | 466 | `bashing_id` SERIAL, |
467 | 467 | `bashing_user_id` bigint(11) UNSIGNED DEFAULT NULL, |
468 | 468 | `bashing_planet_id` bigint(11) UNSIGNED DEFAULT NULL, |
@@ -476,23 +476,23 @@ discard block |
||
476 | 476 | CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
477 | 477 | ,CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
478 | 478 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
479 | - ); |
|
479 | + ); |
|
480 | 480 | |
481 | - upd_check_key('fleet_bashing_war_delay', 12 * 60 * 60, !isset(classSupernova::$config->fleet_bashing_war_delay)); |
|
482 | - upd_check_key('fleet_bashing_scope', 24 * 60 * 60, !isset(classSupernova::$config->fleet_bashing_scope)); |
|
483 | - upd_check_key('fleet_bashing_interval', 30 * 60, !isset(classSupernova::$config->fleet_bashing_interval)); |
|
484 | - upd_check_key('fleet_bashing_waves', 3, !isset(classSupernova::$config->fleet_bashing_waves)); |
|
485 | - upd_check_key('fleet_bashing_attacks', 3, !isset(classSupernova::$config->fleet_bashing_attacks)); |
|
481 | + upd_check_key('fleet_bashing_war_delay', 12 * 60 * 60, !isset(classSupernova::$config->fleet_bashing_war_delay)); |
|
482 | + upd_check_key('fleet_bashing_scope', 24 * 60 * 60, !isset(classSupernova::$config->fleet_bashing_scope)); |
|
483 | + upd_check_key('fleet_bashing_interval', 30 * 60, !isset(classSupernova::$config->fleet_bashing_interval)); |
|
484 | + upd_check_key('fleet_bashing_waves', 3, !isset(classSupernova::$config->fleet_bashing_waves)); |
|
485 | + upd_check_key('fleet_bashing_attacks', 3, !isset(classSupernova::$config->fleet_bashing_attacks)); |
|
486 | 486 | |
487 | - upd_do_query('COMMIT;', true); |
|
488 | - $new_version = 28; |
|
487 | + upd_do_query('COMMIT;', true); |
|
488 | + $new_version = 28; |
|
489 | 489 | |
490 | - case 28: |
|
491 | - case 28.1: |
|
492 | - upd_log_version_update(); |
|
490 | + case 28: |
|
491 | + case 28.1: |
|
492 | + upd_log_version_update(); |
|
493 | 493 | |
494 | - upd_create_table('quest', |
|
495 | - "( |
|
494 | + upd_create_table('quest', |
|
495 | + "( |
|
496 | 496 | `quest_id` SERIAL, |
497 | 497 | `quest_name` VARCHAR(255) DEFAULT NULL, |
498 | 498 | `quest_description` TEXT, |
@@ -504,10 +504,10 @@ discard block |
||
504 | 504 | PRIMARY KEY (`quest_id`) |
505 | 505 | ,KEY (`quest_type`, `quest_order`) |
506 | 506 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
507 | - ); |
|
507 | + ); |
|
508 | 508 | |
509 | - upd_create_table('quest_status', |
|
510 | - "( |
|
509 | + upd_create_table('quest_status', |
|
510 | + "( |
|
511 | 511 | `quest_status_id` SERIAL, |
512 | 512 | `quest_status_quest_id` bigint(20) UNSIGNED DEFAULT NULL, |
513 | 513 | `quest_status_user_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0', |
@@ -519,79 +519,79 @@ discard block |
||
519 | 519 | ,CONSTRAINT `FK_quest_status_quest_id` FOREIGN KEY (`quest_status_quest_id`) REFERENCES `{{quest}}` (`quest_id`) ON DELETE CASCADE ON UPDATE CASCADE |
520 | 520 | ,CONSTRAINT `FK_quest_status_user_id` FOREIGN KEY (`quest_status_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
521 | 521 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
522 | - ); |
|
523 | - |
|
524 | - upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total)); |
|
525 | - |
|
526 | - for($i = 0; $i < 25; $i++) { |
|
527 | - upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
|
528 | - upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
|
529 | - upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]); |
|
530 | - } |
|
531 | - |
|
532 | - upd_alter_table('alliance', array('DROP INDEX `id`',), $update_indexes['alliance']['id']); |
|
533 | - upd_alter_table('alliance', array('DROP INDEX `ally_name`',), $update_indexes['alliance']['ally_name']); |
|
534 | - upd_alter_table('alliance', array('ADD UNIQUE INDEX `i_ally_tag` (`ally_tag`)',), !$update_indexes['alliance']['i_ally_tag']); |
|
535 | - upd_alter_table('alliance', array('MODIFY COLUMN `ranklist` TEXT',), true); |
|
522 | + ); |
|
536 | 523 | |
537 | - upd_alter_table('users', array('DROP INDEX `id`',), $update_indexes['users']['id']); |
|
538 | - upd_alter_table('users', "CHANGE COLUMN `rpg_points` `dark_matter` int(11) DEFAULT 0", $update_tables['users']['rpg_points']); |
|
524 | + upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total)); |
|
539 | 525 | |
540 | - upd_alter_table('users', array( |
|
541 | - 'DROP COLUMN `ally_request`', |
|
542 | - 'DROP COLUMN `ally_request_text`', |
|
543 | - ), $update_tables['users']['ally_request_text']); |
|
526 | + for($i = 0; $i < 25; $i++) { |
|
527 | + upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
|
528 | + upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
|
529 | + upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]); |
|
530 | + } |
|
544 | 531 | |
545 | - upd_alter_table('users', array( |
|
546 | - 'ADD INDEX `i_ally_id` (`ally_id`)', |
|
547 | - 'ADD INDEX `i_ally_name` (`ally_name`)', |
|
548 | - ), !$update_indexes['users']['i_ally_id']); |
|
532 | + upd_alter_table('alliance', array('DROP INDEX `id`',), $update_indexes['alliance']['id']); |
|
533 | + upd_alter_table('alliance', array('DROP INDEX `ally_name`',), $update_indexes['alliance']['ally_name']); |
|
534 | + upd_alter_table('alliance', array('ADD UNIQUE INDEX `i_ally_tag` (`ally_tag`)',), !$update_indexes['alliance']['i_ally_tag']); |
|
535 | + upd_alter_table('alliance', array('MODIFY COLUMN `ranklist` TEXT',), true); |
|
549 | 536 | |
550 | - upd_alter_table('users', array( |
|
551 | - "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
|
552 | - ), !$update_tables['users']['msg_admin']); |
|
537 | + upd_alter_table('users', array('DROP INDEX `id`',), $update_indexes['users']['id']); |
|
538 | + upd_alter_table('users', "CHANGE COLUMN `rpg_points` `dark_matter` int(11) DEFAULT 0", $update_tables['users']['rpg_points']); |
|
553 | 539 | |
554 | - if(!$update_foreigns['users']['FK_users_ally_id']) { |
|
555 | 540 | upd_alter_table('users', array( |
556 | - 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
|
557 | - 'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
558 | - ), strtoupper($update_tables['users']['ally_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
541 | + 'DROP COLUMN `ally_request`', |
|
542 | + 'DROP COLUMN `ally_request_text`', |
|
543 | + ), $update_tables['users']['ally_request_text']); |
|
559 | 544 | |
560 | - upd_do_query('DELETE FROM {{alliance}} WHERE id NOT IN (SELECT ally_id FROM {{users}} GROUP BY ally_id);'); |
|
561 | - 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}});"); |
|
562 | - 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;"); |
|
545 | + upd_alter_table('users', array( |
|
546 | + 'ADD INDEX `i_ally_id` (`ally_id`)', |
|
547 | + 'ADD INDEX `i_ally_name` (`ally_name`)', |
|
548 | + ), !$update_indexes['users']['i_ally_id']); |
|
563 | 549 | |
564 | 550 | upd_alter_table('users', array( |
565 | - "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
566 | - "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{{alliance}}` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
567 | - ), !$update_foreigns['users']['FK_users_ally_id']); |
|
568 | - } |
|
551 | + "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
|
552 | + ), !$update_tables['users']['msg_admin']); |
|
553 | + |
|
554 | + if(!$update_foreigns['users']['FK_users_ally_id']) { |
|
555 | + upd_alter_table('users', array( |
|
556 | + 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
|
557 | + 'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
558 | + ), strtoupper($update_tables['users']['ally_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
559 | + |
|
560 | + upd_do_query('DELETE FROM {{alliance}} WHERE id NOT IN (SELECT ally_id FROM {{users}} GROUP BY ally_id);'); |
|
561 | + 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}});"); |
|
562 | + 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;"); |
|
563 | + |
|
564 | + upd_alter_table('users', array( |
|
565 | + "ADD CONSTRAINT `FK_users_ally_id` FOREIGN KEY (`ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
566 | + "ADD CONSTRAINT `FK_users_ally_name` FOREIGN KEY (`ally_name`) REFERENCES `{{alliance}}` (`ally_name`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
567 | + ), !$update_foreigns['users']['FK_users_ally_id']); |
|
568 | + } |
|
569 | 569 | |
570 | - upd_alter_table('planets', array( |
|
571 | - "MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
572 | - "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
573 | - ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
570 | + upd_alter_table('planets', array( |
|
571 | + "MODIFY COLUMN `debris_metal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
572 | + "MODIFY COLUMN `debris_crystal` BIGINT(20) UNSIGNED DEFAULT 0", |
|
573 | + ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
574 | 574 | |
575 | - $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);"); |
|
576 | - while($illegal_moon_row = db_fetch($illegal_moon_query)) { |
|
577 | - upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
|
578 | - } |
|
575 | + $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);"); |
|
576 | + while($illegal_moon_row = db_fetch($illegal_moon_query)) { |
|
577 | + upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
|
578 | + } |
|
579 | 579 | |
580 | - upd_check_key('allow_buffing', isset(classSupernova::$config->fleet_buffing_check) ? !classSupernova::$config->fleet_buffing_check : 0, !isset(classSupernova::$config->allow_buffing)); |
|
581 | - upd_check_key('ally_help_weak', 0, !isset(classSupernova::$config->ally_help_weak)); |
|
580 | + upd_check_key('allow_buffing', isset(classSupernova::$config->fleet_buffing_check) ? !classSupernova::$config->fleet_buffing_check : 0, !isset(classSupernova::$config->allow_buffing)); |
|
581 | + upd_check_key('ally_help_weak', 0, !isset(classSupernova::$config->ally_help_weak)); |
|
582 | 582 | |
583 | - upd_do_query('COMMIT;', true); |
|
584 | - $new_version = 29; |
|
583 | + upd_do_query('COMMIT;', true); |
|
584 | + $new_version = 29; |
|
585 | 585 | |
586 | - case 29: |
|
587 | - upd_log_version_update(); |
|
586 | + case 29: |
|
587 | + upd_log_version_update(); |
|
588 | 588 | |
589 | - upd_check_key('game_email_pm', 0, !isset(classSupernova::$config->game_email_pm)); |
|
590 | - upd_check_key('player_vacation_time', 2 * 24 * 60 * 60, !isset(classSupernova::$config->player_vacation_time)); |
|
591 | - upd_check_key('player_delete_time', 45 * 24 * 60 * 60, !isset(classSupernova::$config->player_delete_time)); |
|
589 | + upd_check_key('game_email_pm', 0, !isset(classSupernova::$config->game_email_pm)); |
|
590 | + upd_check_key('player_vacation_time', 2 * 24 * 60 * 60, !isset(classSupernova::$config->player_vacation_time)); |
|
591 | + upd_check_key('player_delete_time', 45 * 24 * 60 * 60, !isset(classSupernova::$config->player_delete_time)); |
|
592 | 592 | |
593 | - upd_create_table('log_dark_matter', |
|
594 | - "( |
|
593 | + upd_create_table('log_dark_matter', |
|
594 | + "( |
|
595 | 595 | `log_dark_matter_id` SERIAL, |
596 | 596 | `log_dark_matter_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Human-readable record timestamp', |
597 | 597 | `log_dark_matter_username` varchar(64) NOT NULL DEFAULT '' COMMENT 'Username', |
@@ -606,20 +606,20 @@ discard block |
||
606 | 606 | KEY `i_log_dark_matter_reason_sender_id` (`log_dark_matter_reason`, `log_dark_matter_sender`, `log_dark_matter_id`), |
607 | 607 | KEY `i_log_dark_matter_amount` (`log_dark_matter_amount`) |
608 | 608 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE utf8_general_ci;" |
609 | - ); |
|
610 | - upd_do_query('COMMIT;', true); |
|
609 | + ); |
|
610 | + upd_do_query('COMMIT;', true); |
|
611 | 611 | |
612 | - $records = 1; |
|
613 | - while($records) { |
|
614 | - upd_do_query('START TRANSACTION;', true); |
|
615 | - $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;"); |
|
616 | - $records = classSupernova::$db->db_num_rows($query); |
|
617 | - while($row = db_fetch($query)) { |
|
618 | - $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
|
619 | - |
|
620 | - $reason = RPG_NONE; |
|
621 | - $comment = $matches[3]; |
|
622 | - switch($matches[3]) { |
|
612 | + $records = 1; |
|
613 | + while($records) { |
|
614 | + upd_do_query('START TRANSACTION;', true); |
|
615 | + $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;"); |
|
616 | + $records = classSupernova::$db->db_num_rows($query); |
|
617 | + while($row = db_fetch($query)) { |
|
618 | + $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
|
619 | + |
|
620 | + $reason = RPG_NONE; |
|
621 | + $comment = $matches[3]; |
|
622 | + switch($matches[3]) { |
|
623 | 623 | case 'Level Up For Structure Building': |
624 | 624 | $reason = RPG_STRUCTURE; |
625 | 625 | break; |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | $comment = $matches2[1]; |
649 | 649 | } |
650 | 650 | break; |
651 | - } |
|
651 | + } |
|
652 | 652 | |
653 | 653 | if($matches[2]) { |
654 | 654 | $row['log_username'] = db_escape($row['log_username']); |
@@ -682,579 +682,579 @@ discard block |
||
682 | 682 | upd_do_query('COMMIT;', true); |
683 | 683 | $new_version = 30; |
684 | 684 | |
685 | - case 30: |
|
686 | - upd_log_version_update(); |
|
685 | + case 30: |
|
686 | + upd_log_version_update(); |
|
687 | 687 | |
688 | - upd_alter_table('users', array( |
|
689 | - "ADD `player_que` TEXT" |
|
690 | - ), !$update_tables['users']['player_que']); |
|
688 | + upd_alter_table('users', array( |
|
689 | + "ADD `player_que` TEXT" |
|
690 | + ), !$update_tables['users']['player_que']); |
|
691 | 691 | |
692 | - upd_alter_table('planets', array( |
|
693 | - "CHANGE COLUMN `governor` `PLANET_GOVERNOR_ID` SMALLINT(5) NOT NULL DEFAULT 0", |
|
694 | - "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
|
695 | - ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
|
692 | + upd_alter_table('planets', array( |
|
693 | + "CHANGE COLUMN `governor` `PLANET_GOVERNOR_ID` SMALLINT(5) NOT NULL DEFAULT 0", |
|
694 | + "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
|
695 | + ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
|
696 | + |
|
697 | + if($update_tables['users']['rpg_geologue']) { |
|
698 | + classSupernova::$db->doUpdate("UPDATE `{{users}}` SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
|
699 | + |
|
700 | + upd_alter_table('users', array( |
|
701 | + "DROP COLUMN `rpg_geologue`", |
|
702 | + "DROP COLUMN `rpg_ingenieur`", |
|
703 | + "DROP COLUMN `rpg_constructeur`", |
|
704 | + "DROP COLUMN `rpg_technocrate`", |
|
705 | + "DROP COLUMN `rpg_scientifique`", |
|
706 | + "DROP COLUMN `rpg_defenseur`", |
|
707 | + ), $update_tables['users']['rpg_geologue']); |
|
708 | + } |
|
696 | 709 | |
697 | - if($update_tables['users']['rpg_geologue']) { |
|
698 | - classSupernova::$db->doUpdate("UPDATE `{{users}}` SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
|
710 | + if($update_tables['users']['rpg_bunker']) { |
|
711 | + classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
|
699 | 712 | |
700 | - upd_alter_table('users', array( |
|
701 | - "DROP COLUMN `rpg_geologue`", |
|
702 | - "DROP COLUMN `rpg_ingenieur`", |
|
703 | - "DROP COLUMN `rpg_constructeur`", |
|
704 | - "DROP COLUMN `rpg_technocrate`", |
|
705 | - "DROP COLUMN `rpg_scientifique`", |
|
706 | - "DROP COLUMN `rpg_defenseur`", |
|
707 | - ), $update_tables['users']['rpg_geologue']); |
|
708 | - } |
|
709 | - |
|
710 | - if($update_tables['users']['rpg_bunker']) { |
|
711 | - classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
|
713 | + upd_alter_table('users', array( |
|
714 | + "DROP COLUMN `rpg_bunker`", |
|
715 | + ), $update_tables['users']['rpg_bunker']); |
|
716 | + } |
|
712 | 717 | |
713 | 718 | upd_alter_table('users', array( |
714 | - "DROP COLUMN `rpg_bunker`", |
|
715 | - ), $update_tables['users']['rpg_bunker']); |
|
716 | - } |
|
719 | + "DROP COLUMN `p_infligees`", |
|
720 | + "MODIFY COLUMN `dark_matter` BIGINT(20) DEFAULT '0' AFTER `lvl_raid`", |
|
721 | + ), $update_tables['users']['p_infligees']); |
|
717 | 722 | |
718 | - upd_alter_table('users', array( |
|
719 | - "DROP COLUMN `p_infligees`", |
|
720 | - "MODIFY COLUMN `dark_matter` BIGINT(20) DEFAULT '0' AFTER `lvl_raid`", |
|
721 | - ), $update_tables['users']['p_infligees']); |
|
722 | - |
|
723 | - upd_alter_table('users', array( |
|
724 | - "ADD COLUMN `mrc_academic` SMALLINT(3) DEFAULT 0", |
|
725 | - ), !$update_tables['users']['mrc_academic']); |
|
726 | - |
|
727 | - upd_alter_table('users', array( |
|
728 | - "DROP COLUMN `db_deaktjava`", |
|
729 | - "DROP COLUMN `kolorminus`", |
|
730 | - "DROP COLUMN `kolorplus`", |
|
731 | - "DROP COLUMN `kolorpoziom`", |
|
732 | - "DROP COLUMN `deleteme`", |
|
733 | - |
|
734 | - "MODIFY COLUMN `xpraid` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
735 | - "MODIFY COLUMN `xpminier` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
736 | - "MODIFY COLUMN `raids` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
737 | - "MODIFY COLUMN `raidsloose` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
738 | - "MODIFY COLUMN `raidswin` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
739 | - |
|
740 | - "MODIFY COLUMN `register_time` INT(10) UNSIGNED DEFAULT '0'", |
|
741 | - "MODIFY COLUMN `onlinetime` INT(10) UNSIGNED DEFAULT '0'", |
|
742 | - "MODIFY COLUMN `news_lastread` INT(10) UNSIGNED DEFAULT '0'", |
|
743 | - "MODIFY COLUMN `deltime` INT(10) UNSIGNED DEFAULT '0'", |
|
744 | - "MODIFY COLUMN `banaday` INT(10) UNSIGNED DEFAULT '0'", |
|
745 | - "MODIFY COLUMN `vacation` INT(10) UNSIGNED DEFAULT '0'", |
|
746 | - ), strtoupper($update_tables['users']['xpraid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
747 | - |
|
748 | - upd_alter_table('users', array( |
|
749 | - "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
750 | - "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
751 | - ), !isset($update_tables['users']['total_rank'])); |
|
752 | - classSupernova::$db->doUpdate("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;"); |
|
753 | - |
|
754 | - upd_alter_table('alliance', array( |
|
755 | - "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
756 | - "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
757 | - ), !isset($update_tables['alliance']['total_rank'])); |
|
758 | - classSupernova::$db->doUpdate("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;"); |
|
759 | - |
|
760 | - if(!isset($update_tables['users']['ally_tag'])) { |
|
761 | 723 | upd_alter_table('users', array( |
762 | - "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
763 | - ), !isset($update_tables['users']['ally_tag'])); |
|
764 | - classSupernova::$db->doUpdate("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;"); |
|
765 | - classSupernova::$db->doUpdate("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;"); |
|
766 | - upd_alter_table('users', array( |
|
767 | - "ADD CONSTRAINT `FK_users_ally_tag` FOREIGN KEY (`ally_tag`) REFERENCES `{{alliance}}` (`ally_tag`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
768 | - ), !$update_foreigns['users']['FK_users_ally_tag']); |
|
769 | - } |
|
770 | - |
|
771 | - upd_alter_table('users', array( |
|
772 | - "ADD COLUMN `player_artifact_list` TEXT", |
|
773 | - ), !isset($update_tables['users']['player_artifact_list'])); |
|
774 | - |
|
775 | - if(!isset($update_tables['users']['player_rpg_tech_xp'])) { |
|
776 | - upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage)); |
|
724 | + "ADD COLUMN `mrc_academic` SMALLINT(3) DEFAULT 0", |
|
725 | + ), !$update_tables['users']['mrc_academic']); |
|
777 | 726 | |
778 | 727 | upd_alter_table('users', array( |
779 | - "ADD COLUMN `player_rpg_tech_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
780 | - "ADD COLUMN `player_rpg_tech_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
781 | - ), !isset($update_tables['users']['player_rpg_tech_xp'])); |
|
782 | - |
|
783 | - classSupernova::$db->doUpdate("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;"); |
|
784 | - } |
|
728 | + "DROP COLUMN `db_deaktjava`", |
|
729 | + "DROP COLUMN `kolorminus`", |
|
730 | + "DROP COLUMN `kolorplus`", |
|
731 | + "DROP COLUMN `kolorpoziom`", |
|
732 | + "DROP COLUMN `deleteme`", |
|
733 | + |
|
734 | + "MODIFY COLUMN `xpraid` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
735 | + "MODIFY COLUMN `xpminier` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
736 | + "MODIFY COLUMN `raids` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
737 | + "MODIFY COLUMN `raidsloose` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
738 | + "MODIFY COLUMN `raidswin` BIGINT(20) UNSIGNED DEFAULT '0'", |
|
739 | + |
|
740 | + "MODIFY COLUMN `register_time` INT(10) UNSIGNED DEFAULT '0'", |
|
741 | + "MODIFY COLUMN `onlinetime` INT(10) UNSIGNED DEFAULT '0'", |
|
742 | + "MODIFY COLUMN `news_lastread` INT(10) UNSIGNED DEFAULT '0'", |
|
743 | + "MODIFY COLUMN `deltime` INT(10) UNSIGNED DEFAULT '0'", |
|
744 | + "MODIFY COLUMN `banaday` INT(10) UNSIGNED DEFAULT '0'", |
|
745 | + "MODIFY COLUMN `vacation` INT(10) UNSIGNED DEFAULT '0'", |
|
746 | + ), strtoupper($update_tables['users']['xpraid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
785 | 747 | |
786 | - upd_alter_table('planets', array( |
|
787 | - "ADD COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `big_ship_cargo`", |
|
788 | - ), !isset($update_tables['planets']['planet_cargo_hyper'])); |
|
748 | + upd_alter_table('users', array( |
|
749 | + "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
750 | + "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
751 | + ), !isset($update_tables['users']['total_rank'])); |
|
752 | + classSupernova::$db->doUpdate("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;"); |
|
789 | 753 | |
790 | - upd_do_query('COMMIT;', true); |
|
791 | - $new_version = 31; |
|
754 | + upd_alter_table('alliance', array( |
|
755 | + "ADD COLUMN `total_rank` INT(10) UNSIGNED NOT NULL DEFAULT 0", |
|
756 | + "ADD COLUMN `total_points` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0", |
|
757 | + ), !isset($update_tables['alliance']['total_rank'])); |
|
758 | + classSupernova::$db->doUpdate("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;"); |
|
759 | + |
|
760 | + if(!isset($update_tables['users']['ally_tag'])) { |
|
761 | + upd_alter_table('users', array( |
|
762 | + "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
763 | + ), !isset($update_tables['users']['ally_tag'])); |
|
764 | + classSupernova::$db->doUpdate("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;"); |
|
765 | + classSupernova::$db->doUpdate("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;"); |
|
766 | + upd_alter_table('users', array( |
|
767 | + "ADD CONSTRAINT `FK_users_ally_tag` FOREIGN KEY (`ally_tag`) REFERENCES `{{alliance}}` (`ally_tag`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
768 | + ), !$update_foreigns['users']['FK_users_ally_tag']); |
|
769 | + } |
|
792 | 770 | |
793 | - case 31: |
|
794 | - upd_log_version_update(); |
|
771 | + upd_alter_table('users', array( |
|
772 | + "ADD COLUMN `player_artifact_list` TEXT", |
|
773 | + ), !isset($update_tables['users']['player_artifact_list'])); |
|
795 | 774 | |
796 | - upd_alter_table('aks', array( |
|
797 | - "MODIFY COLUMN `planet_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
798 | - ), strtoupper($update_tables['aks']['planet_type']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
775 | + if(!isset($update_tables['users']['player_rpg_tech_xp'])) { |
|
776 | + upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage)); |
|
799 | 777 | |
800 | - upd_alter_table('alliance', array( |
|
801 | - "MODIFY COLUMN `ally_request_notallow` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
802 | - "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
803 | - ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
778 | + upd_alter_table('users', array( |
|
779 | + "ADD COLUMN `player_rpg_tech_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
780 | + "ADD COLUMN `player_rpg_tech_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
|
781 | + ), !isset($update_tables['users']['player_rpg_tech_xp'])); |
|
804 | 782 | |
805 | - if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
806 | - upd_alter_table('alliance_diplomacy', array( |
|
807 | - "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
|
808 | - "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`" |
|
809 | - ), true); |
|
783 | + classSupernova::$db->doUpdate("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;"); |
|
784 | + } |
|
810 | 785 | |
811 | - upd_alter_table('alliance_diplomacy', array( |
|
812 | - "MODIFY COLUMN `alliance_diplomacy_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
813 | - "MODIFY COLUMN `alliance_diplomacy_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
786 | + upd_alter_table('planets', array( |
|
787 | + "ADD COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `big_ship_cargo`", |
|
788 | + ), !isset($update_tables['planets']['planet_cargo_hyper'])); |
|
814 | 789 | |
815 | - "ADD CONSTRAINT `FK_diplomacy_ally_id` FOREIGN KEY (`alliance_diplomacy_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
816 | - "ADD CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
817 | - ), true); |
|
818 | - } |
|
790 | + upd_do_query('COMMIT;', true); |
|
791 | + $new_version = 31; |
|
819 | 792 | |
820 | - if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
821 | - upd_alter_table('alliance_negotiation', array( |
|
822 | - "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
|
823 | - "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`" |
|
824 | - ), true); |
|
793 | + case 31: |
|
794 | + upd_log_version_update(); |
|
825 | 795 | |
826 | - upd_alter_table('alliance_negotiation', array( |
|
827 | - "MODIFY COLUMN `alliance_negotiation_status` TINYINT(1) NOT NULL DEFAULT 0", |
|
828 | - "MODIFY COLUMN `alliance_negotiation_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
829 | - "MODIFY COLUMN `alliance_negotiation_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
796 | + upd_alter_table('aks', array( |
|
797 | + "MODIFY COLUMN `planet_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
798 | + ), strtoupper($update_tables['aks']['planet_type']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
830 | 799 | |
831 | - "ADD CONSTRAINT `FK_negotiation_ally_id` FOREIGN KEY (`alliance_negotiation_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
832 | - "ADD CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
833 | - ), true); |
|
834 | - } |
|
800 | + upd_alter_table('alliance', array( |
|
801 | + "MODIFY COLUMN `ally_request_notallow` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
802 | + "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
803 | + ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
804 | + |
|
805 | + if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
806 | + upd_alter_table('alliance_diplomacy', array( |
|
807 | + "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
|
808 | + "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`" |
|
809 | + ), true); |
|
810 | + |
|
811 | + upd_alter_table('alliance_diplomacy', array( |
|
812 | + "MODIFY COLUMN `alliance_diplomacy_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
813 | + "MODIFY COLUMN `alliance_diplomacy_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
814 | + |
|
815 | + "ADD CONSTRAINT `FK_diplomacy_ally_id` FOREIGN KEY (`alliance_diplomacy_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
816 | + "ADD CONSTRAINT `FK_diplomacy_contr_ally_id` FOREIGN KEY (`alliance_diplomacy_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
817 | + ), true); |
|
818 | + } |
|
835 | 819 | |
836 | - if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
837 | - 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); |
|
820 | + if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
821 | + upd_alter_table('alliance_negotiation', array( |
|
822 | + "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
|
823 | + "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`" |
|
824 | + ), true); |
|
838 | 825 | |
839 | - upd_alter_table('alliance_requests', array( |
|
840 | - "MODIFY COLUMN `id_user` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
841 | - "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
826 | + upd_alter_table('alliance_negotiation', array( |
|
827 | + "MODIFY COLUMN `alliance_negotiation_status` TINYINT(1) NOT NULL DEFAULT 0", |
|
828 | + "MODIFY COLUMN `alliance_negotiation_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
829 | + "MODIFY COLUMN `alliance_negotiation_contr_ally_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
842 | 830 | |
843 | - "ADD KEY `I_alliance_requests_id_ally` (`id_ally`, `id_user`)", |
|
831 | + "ADD CONSTRAINT `FK_negotiation_ally_id` FOREIGN KEY (`alliance_negotiation_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
832 | + "ADD CONSTRAINT `FK_negotiation_contr_ally_id` FOREIGN KEY (`alliance_negotiation_contr_ally_id`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
833 | + ), true); |
|
834 | + } |
|
844 | 835 | |
845 | - "ADD CONSTRAINT `FK_alliance_request_user_id` FOREIGN KEY (`id_user`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
846 | - "ADD CONSTRAINT `FK_alliance_request_ally_id` FOREIGN KEY (`id_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
847 | - ), true); |
|
848 | - } |
|
836 | + if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
837 | + 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); |
|
849 | 838 | |
850 | - if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
851 | - upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true); |
|
839 | + upd_alter_table('alliance_requests', array( |
|
840 | + "MODIFY COLUMN `id_user` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
841 | + "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
852 | 842 | |
853 | - upd_alter_table('annonce', array( |
|
854 | - "MODIFY COLUMN `id` SERIAL", |
|
855 | - "MODIFY COLUMN `user` VARCHAR(64) DEFAULT NULL", |
|
843 | + "ADD KEY `I_alliance_requests_id_ally` (`id_ally`, `id_user`)", |
|
856 | 844 | |
857 | - "ADD KEY `I_annonce_user` (`user`, `id`)", |
|
845 | + "ADD CONSTRAINT `FK_alliance_request_user_id` FOREIGN KEY (`id_user`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
846 | + "ADD CONSTRAINT `FK_alliance_request_ally_id` FOREIGN KEY (`id_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
847 | + ), true); |
|
848 | + } |
|
858 | 849 | |
859 | - "ADD CONSTRAINT `FK_annonce_user` FOREIGN KEY (`user`) REFERENCES `{{users}}` (`username`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
860 | - ), true); |
|
861 | - } |
|
850 | + if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
851 | + upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true); |
|
862 | 852 | |
863 | - if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
864 | - upd_alter_table('bashing', array( |
|
865 | - "DROP FOREIGN KEY `FK_bashing_user_id`", |
|
866 | - "DROP FOREIGN KEY `FK_bashing_planet_id`", |
|
867 | - ), true); |
|
853 | + upd_alter_table('annonce', array( |
|
854 | + "MODIFY COLUMN `id` SERIAL", |
|
855 | + "MODIFY COLUMN `user` VARCHAR(64) DEFAULT NULL", |
|
868 | 856 | |
869 | - upd_alter_table('bashing', array( |
|
870 | - "MODIFY COLUMN `bashing_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
871 | - "MODIFY COLUMN `bashing_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
857 | + "ADD KEY `I_annonce_user` (`user`, `id`)", |
|
872 | 858 | |
873 | - "ADD CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
874 | - "ADD CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
875 | - ), true); |
|
876 | - } |
|
859 | + "ADD CONSTRAINT `FK_annonce_user` FOREIGN KEY (`user`) REFERENCES `{{users}}` (`username`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
860 | + ), true); |
|
861 | + } |
|
877 | 862 | |
878 | - if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
879 | - upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true); |
|
863 | + if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
864 | + upd_alter_table('bashing', array( |
|
865 | + "DROP FOREIGN KEY `FK_bashing_user_id`", |
|
866 | + "DROP FOREIGN KEY `FK_bashing_planet_id`", |
|
867 | + ), true); |
|
880 | 868 | |
881 | - upd_alter_table('buddy', array( |
|
882 | - "MODIFY COLUMN `id` SERIAL", |
|
883 | - "MODIFY COLUMN `sender` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
884 | - "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
885 | - "MODIFY COLUMN `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
869 | + upd_alter_table('bashing', array( |
|
870 | + "MODIFY COLUMN `bashing_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
871 | + "MODIFY COLUMN `bashing_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
886 | 872 | |
887 | - "ADD KEY `I_buddy_sender` (`sender`)", |
|
888 | - "ADD KEY `I_buddy_owner` (`owner`)", |
|
873 | + "ADD CONSTRAINT `FK_bashing_user_id` FOREIGN KEY (`bashing_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
874 | + "ADD CONSTRAINT `FK_bashing_planet_id` FOREIGN KEY (`bashing_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
875 | + ), true); |
|
876 | + } |
|
889 | 877 | |
890 | - "ADD CONSTRAINT `FK_buddy_sender_id` FOREIGN KEY (`sender`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
891 | - "ADD CONSTRAINT `FK_buddy_owner_id` FOREIGN KEY (`owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
892 | - ), true); |
|
893 | - } |
|
878 | + if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
879 | + upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true); |
|
894 | 880 | |
895 | - upd_alter_table('chat', array( |
|
896 | - "MODIFY COLUMN `messageid` SERIAL", |
|
897 | - ), strtoupper($update_tables['chat']['messageid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
881 | + upd_alter_table('buddy', array( |
|
882 | + "MODIFY COLUMN `id` SERIAL", |
|
883 | + "MODIFY COLUMN `sender` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
884 | + "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
885 | + "MODIFY COLUMN `active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", |
|
898 | 886 | |
899 | - upd_alter_table('counter', array( |
|
900 | - "CHANGE COLUMN `id` `counter_id` SERIAL", |
|
887 | + "ADD KEY `I_buddy_sender` (`sender`)", |
|
888 | + "ADD KEY `I_buddy_owner` (`owner`)", |
|
901 | 889 | |
902 | - "MODIFY COLUMN `user_id` BIGINT(20) UNSIGNED DEFAULT 0", |
|
890 | + "ADD CONSTRAINT `FK_buddy_sender_id` FOREIGN KEY (`sender`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
891 | + "ADD CONSTRAINT `FK_buddy_owner_id` FOREIGN KEY (`owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
892 | + ), true); |
|
893 | + } |
|
903 | 894 | |
904 | - "ADD COLUMN `user_name` VARCHAR(64) DEFAULT '' AFTER `user_id`", |
|
895 | + upd_alter_table('chat', array( |
|
896 | + "MODIFY COLUMN `messageid` SERIAL", |
|
897 | + ), strtoupper($update_tables['chat']['messageid']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
905 | 898 | |
906 | - "ADD KEY `I_counter_user_name` (`user_name`)", |
|
907 | - ), strtoupper($update_tables['counter']['counter_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
899 | + upd_alter_table('counter', array( |
|
900 | + "CHANGE COLUMN `id` `counter_id` SERIAL", |
|
908 | 901 | |
909 | - upd_alter_table('fleets', array( |
|
910 | - "MODIFY COLUMN `fleet_id` SERIAL", |
|
911 | - "MODIFY COLUMN `fleet_resource_metal` DECIMAL(65,0) DEFAULT '0'", |
|
912 | - "MODIFY COLUMN `fleet_resource_crystal` DECIMAL(65,0) DEFAULT '0'", |
|
913 | - "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
|
914 | - ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
|
902 | + "MODIFY COLUMN `user_id` BIGINT(20) UNSIGNED DEFAULT 0", |
|
915 | 903 | |
916 | - if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
917 | - upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
|
904 | + "ADD COLUMN `user_name` VARCHAR(64) DEFAULT '' AFTER `user_id`", |
|
918 | 905 | |
919 | - upd_alter_table('iraks', array( |
|
920 | - "CHANGE COLUMN `zeit` `fleet_end_time` INT(11) UNSIGNED NOT NULL DEFAULT 0", |
|
921 | - "CHANGE COLUMN `zielid` `fleet_target_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
922 | - "CHANGE COLUMN `owner` `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
923 | - "CHANGE COLUMN `anzahl` `fleet_amount` BIGINT(20) UNSIGNED DEFAULT 0", |
|
924 | - "CHANGE COLUMN `galaxy_angreifer` `fleet_start_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
925 | - "CHANGE COLUMN `system_angreifer` `fleet_start_system` INT(4) UNSIGNED DEFAULT 0", |
|
926 | - "CHANGE COLUMN `planet_angreifer` `fleet_start_planet` INT(2) UNSIGNED DEFAULT 0", |
|
927 | - |
|
928 | - "CHANGE COLUMN `galaxy` `fleet_end_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
929 | - "CHANGE COLUMN `system` `fleet_end_system` INT(4) UNSIGNED DEFAULT 0", |
|
930 | - "CHANGE COLUMN `planet` `fleet_end_planet` INT(2) UNSIGNED DEFAULT 0", |
|
931 | - |
|
932 | - "ADD KEY `I_iraks_fleet_owner` (`fleet_owner`)", |
|
933 | - "ADD KEY `I_iraks_fleet_target_owner` (`fleet_target_owner`)", |
|
934 | - |
|
935 | - "ADD CONSTRAINT `FK_iraks_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
936 | - "ADD CONSTRAINT `FK_iraks_fleet_target_owner` FOREIGN KEY (`fleet_target_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
937 | - ), true); |
|
938 | - } |
|
906 | + "ADD KEY `I_counter_user_name` (`user_name`)", |
|
907 | + ), strtoupper($update_tables['counter']['counter_id']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
939 | 908 | |
940 | - if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
941 | - upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true); |
|
909 | + upd_alter_table('fleets', array( |
|
910 | + "MODIFY COLUMN `fleet_id` SERIAL", |
|
911 | + "MODIFY COLUMN `fleet_resource_metal` DECIMAL(65,0) DEFAULT '0'", |
|
912 | + "MODIFY COLUMN `fleet_resource_crystal` DECIMAL(65,0) DEFAULT '0'", |
|
913 | + "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
|
914 | + ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
|
915 | + |
|
916 | + if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
917 | + upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
|
918 | + |
|
919 | + upd_alter_table('iraks', array( |
|
920 | + "CHANGE COLUMN `zeit` `fleet_end_time` INT(11) UNSIGNED NOT NULL DEFAULT 0", |
|
921 | + "CHANGE COLUMN `zielid` `fleet_target_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
922 | + "CHANGE COLUMN `owner` `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
923 | + "CHANGE COLUMN `anzahl` `fleet_amount` BIGINT(20) UNSIGNED DEFAULT 0", |
|
924 | + "CHANGE COLUMN `galaxy_angreifer` `fleet_start_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
925 | + "CHANGE COLUMN `system_angreifer` `fleet_start_system` INT(4) UNSIGNED DEFAULT 0", |
|
926 | + "CHANGE COLUMN `planet_angreifer` `fleet_start_planet` INT(2) UNSIGNED DEFAULT 0", |
|
927 | + |
|
928 | + "CHANGE COLUMN `galaxy` `fleet_end_galaxy` INT(2) UNSIGNED DEFAULT 0", |
|
929 | + "CHANGE COLUMN `system` `fleet_end_system` INT(4) UNSIGNED DEFAULT 0", |
|
930 | + "CHANGE COLUMN `planet` `fleet_end_planet` INT(2) UNSIGNED DEFAULT 0", |
|
931 | + |
|
932 | + "ADD KEY `I_iraks_fleet_owner` (`fleet_owner`)", |
|
933 | + "ADD KEY `I_iraks_fleet_target_owner` (`fleet_target_owner`)", |
|
934 | + |
|
935 | + "ADD CONSTRAINT `FK_iraks_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
936 | + "ADD CONSTRAINT `FK_iraks_fleet_target_owner` FOREIGN KEY (`fleet_target_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
937 | + ), true); |
|
938 | + } |
|
942 | 939 | |
943 | - upd_alter_table('notes', array( |
|
944 | - "MODIFY COLUMN id SERIAL", |
|
945 | - "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
940 | + if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
941 | + upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true); |
|
946 | 942 | |
947 | - "ADD KEY `I_notes_owner` (`owner`)", |
|
943 | + upd_alter_table('notes', array( |
|
944 | + "MODIFY COLUMN id SERIAL", |
|
945 | + "MODIFY COLUMN `owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
948 | 946 | |
949 | - "ADD CONSTRAINT `FK_notes_owner` FOREIGN KEY (`owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
950 | - ), true); |
|
951 | - } |
|
947 | + "ADD KEY `I_notes_owner` (`owner`)", |
|
952 | 948 | |
953 | - upd_alter_table('planets', array( |
|
954 | - "MODIFY COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT", |
|
955 | - "MODIFY COLUMN `name` VARCHAR(64) DEFAULT 'Planet' NOT NULL", |
|
956 | - "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
957 | - "MODIFY COLUMN `galaxy` SMALLINT NOT NULL DEFAULT '0'", |
|
958 | - "MODIFY COLUMN `system` SMALLINT NOT NULL DEFAULT '0'", |
|
959 | - "MODIFY COLUMN `planet` SMALLINT NOT NULL DEFAULT '0'", |
|
960 | - "MODIFY COLUMN `planet_type` TINYINT NOT NULL DEFAULT '1'", |
|
961 | - |
|
962 | - "MODIFY COLUMN `metal` DECIMAL(65,5) NOT NULL DEFAULT '0'", |
|
963 | - "MODIFY COLUMN `crystal` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `metal`", |
|
964 | - "MODIFY COLUMN `deuterium` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `crystal`", |
|
965 | - "MODIFY COLUMN `energy_max` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `deuterium`", |
|
966 | - "MODIFY COLUMN `energy_used` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `energy_max`", |
|
967 | - |
|
968 | - "MODIFY COLUMN `metal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
969 | - "MODIFY COLUMN `crystal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
970 | - "MODIFY COLUMN `deuterium_sintetizer` SMALLINT NOT NULL DEFAULT '0'", |
|
971 | - "MODIFY COLUMN `solar_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
972 | - "MODIFY COLUMN `fusion_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
973 | - "MODIFY COLUMN `robot_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
974 | - "MODIFY COLUMN `nano_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
975 | - "MODIFY COLUMN `hangar` SMALLINT NOT NULL DEFAULT '0'", |
|
976 | - "MODIFY COLUMN `metal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
977 | - "MODIFY COLUMN `crystal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
978 | - "MODIFY COLUMN `deuterium_store` SMALLINT NOT NULL DEFAULT '0'", |
|
979 | - "MODIFY COLUMN `laboratory` SMALLINT NOT NULL DEFAULT '0'", |
|
980 | - "MODIFY COLUMN `nano` SMALLINT DEFAULT '0' AFTER `laboratory`", |
|
981 | - "MODIFY COLUMN `terraformer` SMALLINT NOT NULL DEFAULT '0'", |
|
982 | - "MODIFY COLUMN `ally_deposit` SMALLINT NOT NULL DEFAULT '0'", |
|
983 | - "MODIFY COLUMN `silo` SMALLINT NOT NULL DEFAULT '0'", |
|
984 | - "MODIFY COLUMN `mondbasis` SMALLINT NOT NULL DEFAULT '0' AFTER `silo`", |
|
985 | - "MODIFY COLUMN `phalanx` SMALLINT NOT NULL DEFAULT '0' AFTER `mondbasis`", |
|
986 | - "MODIFY COLUMN `sprungtor` SMALLINT NOT NULL DEFAULT '0' AFTER `phalanx`", |
|
987 | - "MODIFY COLUMN `last_jump_time` int(11) NOT NULL DEFAULT '0' AFTER `sprungtor`", |
|
988 | - |
|
989 | - "MODIFY COLUMN `small_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
990 | - "MODIFY COLUMN `big_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
991 | - "MODIFY COLUMN `supercargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count' AFTER `big_ship_cargo`", |
|
992 | - "MODIFY COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `supercargo`", |
|
993 | - "MODIFY COLUMN `recycler` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `planet_cargo_hyper`", |
|
994 | - "MODIFY COLUMN `colonizer` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `recycler`", |
|
995 | - "MODIFY COLUMN `spy_sonde` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `colonizer`", |
|
996 | - "MODIFY COLUMN `solar_satelit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `spy_sonde`", |
|
997 | - |
|
998 | - "MODIFY COLUMN `light_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
999 | - "MODIFY COLUMN `heavy_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1000 | - "MODIFY COLUMN `crusher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1001 | - "MODIFY COLUMN `battle_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1002 | - "MODIFY COLUMN `bomber_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1003 | - "MODIFY COLUMN `battleship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `bomber_ship`", |
|
1004 | - "MODIFY COLUMN `destructor` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1005 | - "MODIFY COLUMN `dearth_star` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1006 | - "MODIFY COLUMN `supernova` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1007 | - |
|
1008 | - "MODIFY COLUMN `misil_launcher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1009 | - "MODIFY COLUMN `small_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1010 | - "MODIFY COLUMN `big_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1011 | - "MODIFY COLUMN `gauss_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1012 | - "MODIFY COLUMN `ionic_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1013 | - "MODIFY COLUMN `buster_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1014 | - |
|
1015 | - "MODIFY COLUMN `small_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
1016 | - "MODIFY COLUMN `big_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
1017 | - "MODIFY COLUMN `planet_protector` tinyint(1) NOT NULL DEFAULT '0'", |
|
1018 | - |
|
1019 | - "MODIFY COLUMN `interceptor_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1020 | - "MODIFY COLUMN `interplanetary_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1021 | - |
|
1022 | - "MODIFY COLUMN `metal_perhour` INT NOT NULL DEFAULT '0' AFTER `interplanetary_misil`", |
|
1023 | - "MODIFY COLUMN `crystal_perhour` INT NOT NULL DEFAULT '0' AFTER `metal_perhour`", |
|
1024 | - "MODIFY COLUMN `deuterium_perhour` INT NOT NULL DEFAULT '0' AFTER `crystal_perhour`", |
|
1025 | - |
|
1026 | - "MODIFY COLUMN `metal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1027 | - "MODIFY COLUMN `crystal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1028 | - "MODIFY COLUMN `deuterium_sintetizer_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1029 | - "MODIFY COLUMN `solar_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1030 | - "MODIFY COLUMN `fusion_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1031 | - "MODIFY COLUMN `solar_satelit_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1032 | - |
|
1033 | - "MODIFY COLUMN `que` TEXT COMMENT 'Planet que' AFTER `solar_satelit_porcent`", |
|
1034 | -// "MODIFY COLUMN `b_tech` INT(11) NOT NULL DEFAULT 0 AFTER `que`", |
|
1035 | -// "MODIFY COLUMN `b_tech_id` SMALLINT NOT NULL DEFAULT 0 AFTER `b_tech`", |
|
1036 | - "MODIFY COLUMN `b_hangar` INT(11) NOT NULL DEFAULT '0' AFTER `que`", |
|
1037 | - "MODIFY COLUMN `b_hangar_id` TEXT AFTER `b_hangar`", |
|
1038 | - "MODIFY COLUMN `last_update` INT(11) DEFAULT NULL AFTER `b_hangar_id`", |
|
1039 | - |
|
1040 | - "MODIFY COLUMN `image` varchar(64) NOT NULL DEFAULT 'normaltempplanet01' AFTER `last_update`", |
|
1041 | - "MODIFY COLUMN `points` bigint(20) DEFAULT '0' AFTER `image`", |
|
1042 | - "MODIFY COLUMN `ranks` bigint(20) DEFAULT '0' AFTER `points`", |
|
1043 | - "MODIFY COLUMN `id_level` TINYINT NOT NULL DEFAULT '0' AFTER `ranks`", |
|
1044 | - "MODIFY COLUMN `destruyed` int(11) NOT NULL DEFAULT '0' AFTER `id_level`", |
|
1045 | - "MODIFY COLUMN `diameter` int(11) NOT NULL DEFAULT '12800' AFTER `destruyed`", |
|
1046 | - "MODIFY COLUMN `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT '163' AFTER `diameter`", |
|
1047 | - "MODIFY COLUMN `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT '0' AFTER `field_max`", |
|
1048 | - "MODIFY COLUMN `temp_min` SMALLINT NOT NULL DEFAULT '0' AFTER `field_current`", |
|
1049 | - "MODIFY COLUMN `temp_max` SMALLINT NOT NULL DEFAULT '40' AFTER `temp_min`", |
|
1050 | - |
|
1051 | - "MODIFY COLUMN `metal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `temp_max`", |
|
1052 | - "MODIFY COLUMN `crystal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `metal_max`", |
|
1053 | - "MODIFY COLUMN `deuterium_max` DECIMAL(65,0) DEFAULT '100000' AFTER `crystal_max`", |
|
1054 | - |
|
1055 | - "MODIFY COLUMN `debris_metal` bigint(20) unsigned DEFAULT '0'", |
|
1056 | - "MODIFY COLUMN `debris_crystal` bigint(20) unsigned DEFAULT '0'", |
|
1057 | - "MODIFY COLUMN `PLANET_GOVERNOR_ID` SMALLINT NOT NULL DEFAULT '0'", |
|
1058 | - "MODIFY COLUMN `PLANET_GOVERNOR_LEVEL` SMALLINT NOT NULL DEFAULT '0'", |
|
1059 | - |
|
1060 | - "MODIFY COLUMN `parent_planet` BIGINT(20) unsigned DEFAULT '0'", |
|
1061 | - |
|
1062 | - "DROP COLUMN `b_hangar_plus`", |
|
1063 | - ), isset($update_tables['planets']['b_hangar_plus'])); |
|
1064 | - |
|
1065 | - if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1066 | - upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
|
1067 | - |
|
1068 | - upd_alter_table('referrals', array( |
|
1069 | - "MODIFY COLUMN `id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1070 | - "MODIFY COLUMN `id_partner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1071 | - "MODIFY COLUMN `dark_matter` DECIMAL(65,0) NOT NULL DEFAULT '0'", |
|
1072 | - |
|
1073 | - "ADD CONSTRAINT `FK_referrals_id` FOREIGN KEY (`id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1074 | - "ADD CONSTRAINT `FK_referrals_id_partner` FOREIGN KEY (`id_partner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1075 | - ), true); |
|
1076 | - } |
|
949 | + "ADD CONSTRAINT `FK_notes_owner` FOREIGN KEY (`owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
950 | + ), true); |
|
951 | + } |
|
1077 | 952 | |
1078 | - upd_alter_table('rw', array( |
|
1079 | - "MODIFY COLUMN `report_id` SERIAL", |
|
1080 | - "MODIFY COLUMN `id_owner1` BIGINT(20) UNSIGNED", |
|
1081 | - "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
|
1082 | - ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
1083 | - |
|
1084 | - if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1085 | - 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); |
|
1086 | - |
|
1087 | - upd_alter_table('shortcut', array( |
|
1088 | - "MODIFY COLUMN `shortcut_id` SERIAL", |
|
1089 | - "MODIFY COLUMN `shortcut_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1090 | - "MODIFY COLUMN `shortcut_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1091 | - "MODIFY COLUMN `shortcut_galaxy` TINYINT UNSIGNED DEFAULT 0", |
|
1092 | - "MODIFY COLUMN `shortcut_system` SMALLINT UNSIGNED DEFAULT 0", |
|
1093 | - "MODIFY COLUMN `shortcut_planet` TINYINT UNSIGNED DEFAULT 0", |
|
1094 | - |
|
1095 | - "ADD CONSTRAINT `FK_shortcut_planet_id` FOREIGN KEY (`shortcut_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1096 | - ), true); |
|
1097 | - } |
|
953 | + upd_alter_table('planets', array( |
|
954 | + "MODIFY COLUMN `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT", |
|
955 | + "MODIFY COLUMN `name` VARCHAR(64) DEFAULT 'Planet' NOT NULL", |
|
956 | + "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
957 | + "MODIFY COLUMN `galaxy` SMALLINT NOT NULL DEFAULT '0'", |
|
958 | + "MODIFY COLUMN `system` SMALLINT NOT NULL DEFAULT '0'", |
|
959 | + "MODIFY COLUMN `planet` SMALLINT NOT NULL DEFAULT '0'", |
|
960 | + "MODIFY COLUMN `planet_type` TINYINT NOT NULL DEFAULT '1'", |
|
961 | + |
|
962 | + "MODIFY COLUMN `metal` DECIMAL(65,5) NOT NULL DEFAULT '0'", |
|
963 | + "MODIFY COLUMN `crystal` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `metal`", |
|
964 | + "MODIFY COLUMN `deuterium` DECIMAL(65,5) NOT NULL DEFAULT '0' AFTER `crystal`", |
|
965 | + "MODIFY COLUMN `energy_max` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `deuterium`", |
|
966 | + "MODIFY COLUMN `energy_used` DECIMAL(65,0) NOT NULL DEFAULT '0' AFTER `energy_max`", |
|
967 | + |
|
968 | + "MODIFY COLUMN `metal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
969 | + "MODIFY COLUMN `crystal_mine` SMALLINT NOT NULL DEFAULT '0'", |
|
970 | + "MODIFY COLUMN `deuterium_sintetizer` SMALLINT NOT NULL DEFAULT '0'", |
|
971 | + "MODIFY COLUMN `solar_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
972 | + "MODIFY COLUMN `fusion_plant` SMALLINT NOT NULL DEFAULT '0'", |
|
973 | + "MODIFY COLUMN `robot_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
974 | + "MODIFY COLUMN `nano_factory` SMALLINT NOT NULL DEFAULT '0'", |
|
975 | + "MODIFY COLUMN `hangar` SMALLINT NOT NULL DEFAULT '0'", |
|
976 | + "MODIFY COLUMN `metal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
977 | + "MODIFY COLUMN `crystal_store` SMALLINT NOT NULL DEFAULT '0'", |
|
978 | + "MODIFY COLUMN `deuterium_store` SMALLINT NOT NULL DEFAULT '0'", |
|
979 | + "MODIFY COLUMN `laboratory` SMALLINT NOT NULL DEFAULT '0'", |
|
980 | + "MODIFY COLUMN `nano` SMALLINT DEFAULT '0' AFTER `laboratory`", |
|
981 | + "MODIFY COLUMN `terraformer` SMALLINT NOT NULL DEFAULT '0'", |
|
982 | + "MODIFY COLUMN `ally_deposit` SMALLINT NOT NULL DEFAULT '0'", |
|
983 | + "MODIFY COLUMN `silo` SMALLINT NOT NULL DEFAULT '0'", |
|
984 | + "MODIFY COLUMN `mondbasis` SMALLINT NOT NULL DEFAULT '0' AFTER `silo`", |
|
985 | + "MODIFY COLUMN `phalanx` SMALLINT NOT NULL DEFAULT '0' AFTER `mondbasis`", |
|
986 | + "MODIFY COLUMN `sprungtor` SMALLINT NOT NULL DEFAULT '0' AFTER `phalanx`", |
|
987 | + "MODIFY COLUMN `last_jump_time` int(11) NOT NULL DEFAULT '0' AFTER `sprungtor`", |
|
988 | + |
|
989 | + "MODIFY COLUMN `small_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
990 | + "MODIFY COLUMN `big_ship_cargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
991 | + "MODIFY COLUMN `supercargo` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT 'Supercargo ship count' AFTER `big_ship_cargo`", |
|
992 | + "MODIFY COLUMN `planet_cargo_hyper` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `supercargo`", |
|
993 | + "MODIFY COLUMN `recycler` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `planet_cargo_hyper`", |
|
994 | + "MODIFY COLUMN `colonizer` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `recycler`", |
|
995 | + "MODIFY COLUMN `spy_sonde` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `colonizer`", |
|
996 | + "MODIFY COLUMN `solar_satelit` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `spy_sonde`", |
|
997 | + |
|
998 | + "MODIFY COLUMN `light_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
999 | + "MODIFY COLUMN `heavy_hunter` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1000 | + "MODIFY COLUMN `crusher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1001 | + "MODIFY COLUMN `battle_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1002 | + "MODIFY COLUMN `bomber_ship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1003 | + "MODIFY COLUMN `battleship` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' AFTER `bomber_ship`", |
|
1004 | + "MODIFY COLUMN `destructor` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1005 | + "MODIFY COLUMN `dearth_star` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1006 | + "MODIFY COLUMN `supernova` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1007 | + |
|
1008 | + "MODIFY COLUMN `misil_launcher` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1009 | + "MODIFY COLUMN `small_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1010 | + "MODIFY COLUMN `big_laser` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1011 | + "MODIFY COLUMN `gauss_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1012 | + "MODIFY COLUMN `ionic_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1013 | + "MODIFY COLUMN `buster_canyon` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1014 | + |
|
1015 | + "MODIFY COLUMN `small_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
1016 | + "MODIFY COLUMN `big_protection_shield` tinyint(1) NOT NULL DEFAULT '0'", |
|
1017 | + "MODIFY COLUMN `planet_protector` tinyint(1) NOT NULL DEFAULT '0'", |
|
1018 | + |
|
1019 | + "MODIFY COLUMN `interceptor_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1020 | + "MODIFY COLUMN `interplanetary_misil` BIGINT(20) UNSIGNED NOT NULL DEFAULT '0'", |
|
1021 | + |
|
1022 | + "MODIFY COLUMN `metal_perhour` INT NOT NULL DEFAULT '0' AFTER `interplanetary_misil`", |
|
1023 | + "MODIFY COLUMN `crystal_perhour` INT NOT NULL DEFAULT '0' AFTER `metal_perhour`", |
|
1024 | + "MODIFY COLUMN `deuterium_perhour` INT NOT NULL DEFAULT '0' AFTER `crystal_perhour`", |
|
1025 | + |
|
1026 | + "MODIFY COLUMN `metal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1027 | + "MODIFY COLUMN `crystal_mine_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1028 | + "MODIFY COLUMN `deuterium_sintetizer_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1029 | + "MODIFY COLUMN `solar_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1030 | + "MODIFY COLUMN `fusion_plant_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1031 | + "MODIFY COLUMN `solar_satelit_porcent` TINYINT UNSIGNED NOT NULL DEFAULT '10'", |
|
1032 | + |
|
1033 | + "MODIFY COLUMN `que` TEXT COMMENT 'Planet que' AFTER `solar_satelit_porcent`", |
|
1034 | + // "MODIFY COLUMN `b_tech` INT(11) NOT NULL DEFAULT 0 AFTER `que`", |
|
1035 | + // "MODIFY COLUMN `b_tech_id` SMALLINT NOT NULL DEFAULT 0 AFTER `b_tech`", |
|
1036 | + "MODIFY COLUMN `b_hangar` INT(11) NOT NULL DEFAULT '0' AFTER `que`", |
|
1037 | + "MODIFY COLUMN `b_hangar_id` TEXT AFTER `b_hangar`", |
|
1038 | + "MODIFY COLUMN `last_update` INT(11) DEFAULT NULL AFTER `b_hangar_id`", |
|
1039 | + |
|
1040 | + "MODIFY COLUMN `image` varchar(64) NOT NULL DEFAULT 'normaltempplanet01' AFTER `last_update`", |
|
1041 | + "MODIFY COLUMN `points` bigint(20) DEFAULT '0' AFTER `image`", |
|
1042 | + "MODIFY COLUMN `ranks` bigint(20) DEFAULT '0' AFTER `points`", |
|
1043 | + "MODIFY COLUMN `id_level` TINYINT NOT NULL DEFAULT '0' AFTER `ranks`", |
|
1044 | + "MODIFY COLUMN `destruyed` int(11) NOT NULL DEFAULT '0' AFTER `id_level`", |
|
1045 | + "MODIFY COLUMN `diameter` int(11) NOT NULL DEFAULT '12800' AFTER `destruyed`", |
|
1046 | + "MODIFY COLUMN `field_max` SMALLINT UNSIGNED NOT NULL DEFAULT '163' AFTER `diameter`", |
|
1047 | + "MODIFY COLUMN `field_current` SMALLINT UNSIGNED NOT NULL DEFAULT '0' AFTER `field_max`", |
|
1048 | + "MODIFY COLUMN `temp_min` SMALLINT NOT NULL DEFAULT '0' AFTER `field_current`", |
|
1049 | + "MODIFY COLUMN `temp_max` SMALLINT NOT NULL DEFAULT '40' AFTER `temp_min`", |
|
1050 | + |
|
1051 | + "MODIFY COLUMN `metal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `temp_max`", |
|
1052 | + "MODIFY COLUMN `crystal_max` DECIMAL(65,0) DEFAULT '100000' AFTER `metal_max`", |
|
1053 | + "MODIFY COLUMN `deuterium_max` DECIMAL(65,0) DEFAULT '100000' AFTER `crystal_max`", |
|
1054 | + |
|
1055 | + "MODIFY COLUMN `debris_metal` bigint(20) unsigned DEFAULT '0'", |
|
1056 | + "MODIFY COLUMN `debris_crystal` bigint(20) unsigned DEFAULT '0'", |
|
1057 | + "MODIFY COLUMN `PLANET_GOVERNOR_ID` SMALLINT NOT NULL DEFAULT '0'", |
|
1058 | + "MODIFY COLUMN `PLANET_GOVERNOR_LEVEL` SMALLINT NOT NULL DEFAULT '0'", |
|
1059 | + |
|
1060 | + "MODIFY COLUMN `parent_planet` BIGINT(20) unsigned DEFAULT '0'", |
|
1061 | + |
|
1062 | + "DROP COLUMN `b_hangar_plus`", |
|
1063 | + ), isset($update_tables['planets']['b_hangar_plus'])); |
|
1064 | + |
|
1065 | + if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1066 | + upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
|
1067 | + |
|
1068 | + upd_alter_table('referrals', array( |
|
1069 | + "MODIFY COLUMN `id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1070 | + "MODIFY COLUMN `id_partner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1071 | + "MODIFY COLUMN `dark_matter` DECIMAL(65,0) NOT NULL DEFAULT '0'", |
|
1072 | + |
|
1073 | + "ADD CONSTRAINT `FK_referrals_id` FOREIGN KEY (`id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1074 | + "ADD CONSTRAINT `FK_referrals_id_partner` FOREIGN KEY (`id_partner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1075 | + ), true); |
|
1076 | + } |
|
1098 | 1077 | |
1099 | - if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1100 | - 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); |
|
1078 | + upd_alter_table('rw', array( |
|
1079 | + "MODIFY COLUMN `report_id` SERIAL", |
|
1080 | + "MODIFY COLUMN `id_owner1` BIGINT(20) UNSIGNED", |
|
1081 | + "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
|
1082 | + ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
1083 | + |
|
1084 | + if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1085 | + 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); |
|
1086 | + |
|
1087 | + upd_alter_table('shortcut', array( |
|
1088 | + "MODIFY COLUMN `shortcut_id` SERIAL", |
|
1089 | + "MODIFY COLUMN `shortcut_user_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1090 | + "MODIFY COLUMN `shortcut_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1091 | + "MODIFY COLUMN `shortcut_galaxy` TINYINT UNSIGNED DEFAULT 0", |
|
1092 | + "MODIFY COLUMN `shortcut_system` SMALLINT UNSIGNED DEFAULT 0", |
|
1093 | + "MODIFY COLUMN `shortcut_planet` TINYINT UNSIGNED DEFAULT 0", |
|
1094 | + |
|
1095 | + "ADD CONSTRAINT `FK_shortcut_planet_id` FOREIGN KEY (`shortcut_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1096 | + ), true); |
|
1097 | + } |
|
1101 | 1098 | |
1102 | - upd_alter_table('statpoints', array( |
|
1103 | - "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST", |
|
1104 | - "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1105 | - "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1106 | - "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0", |
|
1107 | - "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1108 | - |
|
1109 | - "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1110 | - "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1111 | - "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1112 | - "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'", |
|
1113 | - |
|
1114 | - "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1115 | - "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1116 | - "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1117 | - "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1118 | - |
|
1119 | - "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1120 | - "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1121 | - "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1122 | - "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1123 | - |
|
1124 | - "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1125 | - "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1126 | - "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1127 | - "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1128 | - |
|
1129 | - "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`", |
|
1130 | - "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`", |
|
1131 | - "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`", |
|
1132 | - "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`", |
|
1133 | - |
|
1134 | - "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1135 | - "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1136 | - "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1137 | - "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1138 | - |
|
1139 | - "ADD KEY `I_stats_id_ally` (`id_ally`)", |
|
1140 | - |
|
1141 | - "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1142 | - "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1143 | - ), true); |
|
1144 | - } |
|
1099 | + if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1100 | + 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); |
|
1101 | + |
|
1102 | + upd_alter_table('statpoints', array( |
|
1103 | + "MODIFY COLUMN `stat_date` int(11) NOT NULL DEFAULT '0' FIRST", |
|
1104 | + "MODIFY COLUMN `id_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1105 | + "MODIFY COLUMN `id_ally` BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1106 | + "MODIFY COLUMN `stat_type` TINYINT UNSIGNED DEFAULT 0", |
|
1107 | + "MODIFY COLUMN `stat_code` TINYINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1108 | + |
|
1109 | + "MODIFY COLUMN `tech_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1110 | + "MODIFY COLUMN `tech_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1111 | + "MODIFY COLUMN `tech_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1112 | + "MODIFY COLUMN `tech_count` DECIMAL(65,0) UNSIGNED UNSIGNED NOT NULL DEFAULT '0'", |
|
1113 | + |
|
1114 | + "MODIFY COLUMN `build_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1115 | + "MODIFY COLUMN `build_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1116 | + "MODIFY COLUMN `build_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1117 | + "MODIFY COLUMN `build_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1118 | + |
|
1119 | + "MODIFY COLUMN `defs_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1120 | + "MODIFY COLUMN `defs_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1121 | + "MODIFY COLUMN `defs_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1122 | + "MODIFY COLUMN `defs_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1123 | + |
|
1124 | + "MODIFY COLUMN `fleet_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1125 | + "MODIFY COLUMN `fleet_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1126 | + "MODIFY COLUMN `fleet_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1127 | + "MODIFY COLUMN `fleet_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1128 | + |
|
1129 | + "MODIFY COLUMN `res_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Rank by resources' AFTER `fleet_count`", |
|
1130 | + "MODIFY COLUMN `res_old_rank` INT(11) UNSIGNED DEFAULT '0' COMMENT 'Old rank by resources'AFTER `res_rank`", |
|
1131 | + "MODIFY COLUMN `res_points` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource stat points' AFTER `res_old_rank`", |
|
1132 | + "MODIFY COLUMN `res_count` DECIMAL(65,0) UNSIGNED DEFAULT '0' COMMENT 'Resource count' AFTER `res_points`", |
|
1133 | + |
|
1134 | + "MODIFY COLUMN `total_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1135 | + "MODIFY COLUMN `total_old_rank` INT(11) UNSIGNED NOT NULL DEFAULT '0'", |
|
1136 | + "MODIFY COLUMN `total_points` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1137 | + "MODIFY COLUMN `total_count` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT '0'", |
|
1138 | + |
|
1139 | + "ADD KEY `I_stats_id_ally` (`id_ally`)", |
|
1140 | + |
|
1141 | + "ADD CONSTRAINT `FK_stats_id_owner` FOREIGN KEY (`id_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1142 | + "ADD CONSTRAINT `FK_stats_id_ally` FOREIGN KEY (`id_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1143 | + ), true); |
|
1144 | + } |
|
1145 | 1145 | |
1146 | - upd_alter_table('users', array( |
|
1147 | - "MODIFY COLUMN `authlevel` tinyint unsigned NOT NULL DEFAULT '0' AFTER `username`", |
|
1148 | - "MODIFY COLUMN `vacation` int(11) unsigned DEFAULT '0' AFTER `authlevel`", |
|
1149 | - "MODIFY COLUMN `banaday` int(11) unsigned DEFAULT '0' AFTER `vacation`", |
|
1150 | - "MODIFY COLUMN `dark_matter` bigint(20) DEFAULT '0' AFTER `banaday`", |
|
1151 | - "MODIFY COLUMN `spy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1152 | - "MODIFY COLUMN `computer_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1153 | - "MODIFY COLUMN `military_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1154 | - "MODIFY COLUMN `defence_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1155 | - "MODIFY COLUMN `shield_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1156 | - "MODIFY COLUMN `energy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1157 | - "MODIFY COLUMN `hyperspace_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1158 | - "MODIFY COLUMN `combustion_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1159 | - "MODIFY COLUMN `impulse_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1160 | - "MODIFY COLUMN `hyperspace_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1161 | - "MODIFY COLUMN `laser_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1162 | - "MODIFY COLUMN `ionic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1163 | - "MODIFY COLUMN `buster_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1164 | - "MODIFY COLUMN `intergalactic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1165 | - "MODIFY COLUMN `expedition_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1166 | - "MODIFY COLUMN `colonisation_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1167 | - "MODIFY COLUMN `graviton_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1168 | - "MODIFY COLUMN `player_artifact_list` text AFTER `graviton_tech`", |
|
1169 | - "MODIFY COLUMN `ally_id` bigint(20) unsigned DEFAULT NULL AFTER `player_artifact_list`", |
|
1170 | - "MODIFY COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
1171 | - "MODIFY COLUMN `ally_name` varchar(32) DEFAULT NULL AFTER `ally_tag`", |
|
1172 | - "MODIFY COLUMN `ally_register_time` int(11) NOT NULL DEFAULT '0' AFTER `ally_name`", |
|
1173 | - "MODIFY COLUMN `ally_rank_id` int(11) NOT NULL DEFAULT '0' AFTER `ally_register_time`", |
|
1174 | - "MODIFY COLUMN `player_que` text AFTER `ally_rank_id`", |
|
1175 | - "MODIFY COLUMN `lvl_minier` bigint(20) unsigned NOT NULL DEFAULT '1'", |
|
1176 | - "MODIFY COLUMN `xpminier` bigint(20) unsigned DEFAULT '0' AFTER `lvl_minier`", |
|
1177 | - "MODIFY COLUMN `player_rpg_tech_xp` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1178 | - "MODIFY COLUMN `player_rpg_tech_level` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1179 | - "MODIFY COLUMN `lvl_raid` bigint(20) unsigned NOT NULL DEFAULT '1' AFTER `player_rpg_tech_level`", |
|
1180 | - "MODIFY COLUMN `xpraid` bigint(20) unsigned DEFAULT '0'", |
|
1181 | - "MODIFY COLUMN `raids` bigint(20) unsigned DEFAULT '0'", |
|
1182 | - "MODIFY COLUMN `raidsloose` bigint(20) unsigned DEFAULT '0'", |
|
1183 | - "MODIFY COLUMN `raidswin` bigint(20) unsigned DEFAULT '0'", |
|
1184 | - "MODIFY COLUMN `new_message` int(11) NOT NULL DEFAULT '0' AFTER `raidswin`", |
|
1185 | - "MODIFY COLUMN `mnl_alliance` int(11) NOT NULL DEFAULT '0'", |
|
1186 | - "MODIFY COLUMN `mnl_joueur` int(11) NOT NULL DEFAULT '0'", |
|
1187 | - "MODIFY COLUMN `mnl_attaque` int(11) NOT NULL DEFAULT '0'", |
|
1188 | - "MODIFY COLUMN `mnl_spy` int(11) NOT NULL DEFAULT '0'", |
|
1189 | - "MODIFY COLUMN `mnl_exploit` int(11) NOT NULL DEFAULT '0'", |
|
1190 | - "MODIFY COLUMN `mnl_transport` int(11) NOT NULL DEFAULT '0'", |
|
1191 | - "MODIFY COLUMN `mnl_expedition` int(11) NOT NULL DEFAULT '0'", |
|
1192 | - "MODIFY COLUMN `mnl_buildlist` int(11) NOT NULL DEFAULT '0'", |
|
1193 | - "MODIFY COLUMN `msg_admin` bigint(11) unsigned DEFAULT '0'", |
|
1194 | -// "MODIFY COLUMN `b_tech_planet` int(11) NOT NULL DEFAULT '0' AFTER `msg_admin`", |
|
1195 | - "MODIFY COLUMN `deltime` int(10) unsigned DEFAULT '0'", |
|
1196 | - "MODIFY COLUMN `news_lastread` int(10) unsigned DEFAULT '0'", |
|
1197 | - "MODIFY COLUMN `total_rank` int(10) unsigned NOT NULL DEFAULT '0'", |
|
1198 | - "MODIFY COLUMN `total_points` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1199 | - "MODIFY COLUMN `password` varchar(64) NOT NULL DEFAULT '' AFTER `total_points`", |
|
1200 | - "MODIFY COLUMN `email` varchar(64) NOT NULL DEFAULT '' AFTER `password`", |
|
1201 | - "MODIFY COLUMN `email_2` varchar(64) NOT NULL DEFAULT '' AFTER `email`", |
|
1202 | - "MODIFY COLUMN `lang` varchar(8) NOT NULL DEFAULT 'ru' AFTER `email_2`", |
|
1203 | - "MODIFY COLUMN `sex` char(1) DEFAULT NULL AFTER `lang`", |
|
1204 | - "MODIFY COLUMN `avatar` varchar(255) NOT NULL DEFAULT '' AFTER `sex`", |
|
1205 | - "MODIFY COLUMN `sign` mediumtext AFTER `avatar`", |
|
1206 | - "MODIFY COLUMN `id_planet` int(11) NOT NULL DEFAULT '0' AFTER `sign`", |
|
1207 | - "MODIFY COLUMN `galaxy` int(11) NOT NULL DEFAULT '0' AFTER `id_planet`", |
|
1208 | - "MODIFY COLUMN `system` int(11) NOT NULL DEFAULT '0' AFTER `galaxy`", |
|
1209 | - "MODIFY COLUMN `planet` int(11) NOT NULL DEFAULT '0' AFTER `system`", |
|
1210 | - "MODIFY COLUMN `current_planet` int(11) NOT NULL DEFAULT '0' AFTER `planet`", |
|
1211 | - "MODIFY COLUMN `user_agent` mediumtext NOT NULL AFTER `current_planet`", |
|
1212 | - "MODIFY COLUMN `user_lastip` varchar(250) DEFAULT NULL COMMENT 'User last IP' AFTER `user_agent`", |
|
1213 | - "MODIFY COLUMN `user_proxy` varchar(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)' AFTER `user_lastip`", |
|
1214 | - "MODIFY COLUMN `register_time` int(10) unsigned DEFAULT '0' AFTER `user_proxy`", |
|
1215 | - "MODIFY COLUMN `onlinetime` int(10) unsigned DEFAULT '0' AFTER `register_time`", |
|
1216 | - "MODIFY COLUMN `dpath` varchar(255) NOT NULL DEFAULT '' AFTER `onlinetime`", |
|
1217 | - "MODIFY COLUMN `design` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `dpath`", |
|
1218 | - "MODIFY COLUMN `noipcheck` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `design`", |
|
1219 | - "MODIFY COLUMN `options` mediumtext COMMENT 'Packed user options' AFTER `noipcheck`", |
|
1220 | - "MODIFY COLUMN `planet_sort` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `options`", |
|
1221 | - "MODIFY COLUMN `planet_sort_order` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `planet_sort`", |
|
1222 | - "MODIFY COLUMN `spio_anz` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `planet_sort_order`", |
|
1223 | - "MODIFY COLUMN `settings_tooltiptime` tinyint(1) unsigned NOT NULL DEFAULT '5' AFTER `spio_anz`", |
|
1224 | - "MODIFY COLUMN `settings_fleetactions` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_tooltiptime`", |
|
1225 | - "MODIFY COLUMN `settings_esp` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_allylogo`", |
|
1226 | - "MODIFY COLUMN `settings_wri` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_esp`", |
|
1227 | - "MODIFY COLUMN `settings_bud` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_wri`", |
|
1228 | - "MODIFY COLUMN `settings_mis` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_bud`", |
|
1229 | - "MODIFY COLUMN `settings_rep` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_mis`", |
|
1230 | - ), strtoupper($update_tables['users']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
1146 | + upd_alter_table('users', array( |
|
1147 | + "MODIFY COLUMN `authlevel` tinyint unsigned NOT NULL DEFAULT '0' AFTER `username`", |
|
1148 | + "MODIFY COLUMN `vacation` int(11) unsigned DEFAULT '0' AFTER `authlevel`", |
|
1149 | + "MODIFY COLUMN `banaday` int(11) unsigned DEFAULT '0' AFTER `vacation`", |
|
1150 | + "MODIFY COLUMN `dark_matter` bigint(20) DEFAULT '0' AFTER `banaday`", |
|
1151 | + "MODIFY COLUMN `spy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1152 | + "MODIFY COLUMN `computer_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1153 | + "MODIFY COLUMN `military_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1154 | + "MODIFY COLUMN `defence_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1155 | + "MODIFY COLUMN `shield_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1156 | + "MODIFY COLUMN `energy_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1157 | + "MODIFY COLUMN `hyperspace_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1158 | + "MODIFY COLUMN `combustion_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1159 | + "MODIFY COLUMN `impulse_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1160 | + "MODIFY COLUMN `hyperspace_motor_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1161 | + "MODIFY COLUMN `laser_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1162 | + "MODIFY COLUMN `ionic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1163 | + "MODIFY COLUMN `buster_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1164 | + "MODIFY COLUMN `intergalactic_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1165 | + "MODIFY COLUMN `expedition_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1166 | + "MODIFY COLUMN `colonisation_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1167 | + "MODIFY COLUMN `graviton_tech` SMALLINT UNSIGNED NOT NULL DEFAULT '0'", |
|
1168 | + "MODIFY COLUMN `player_artifact_list` text AFTER `graviton_tech`", |
|
1169 | + "MODIFY COLUMN `ally_id` bigint(20) unsigned DEFAULT NULL AFTER `player_artifact_list`", |
|
1170 | + "MODIFY COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
|
1171 | + "MODIFY COLUMN `ally_name` varchar(32) DEFAULT NULL AFTER `ally_tag`", |
|
1172 | + "MODIFY COLUMN `ally_register_time` int(11) NOT NULL DEFAULT '0' AFTER `ally_name`", |
|
1173 | + "MODIFY COLUMN `ally_rank_id` int(11) NOT NULL DEFAULT '0' AFTER `ally_register_time`", |
|
1174 | + "MODIFY COLUMN `player_que` text AFTER `ally_rank_id`", |
|
1175 | + "MODIFY COLUMN `lvl_minier` bigint(20) unsigned NOT NULL DEFAULT '1'", |
|
1176 | + "MODIFY COLUMN `xpminier` bigint(20) unsigned DEFAULT '0' AFTER `lvl_minier`", |
|
1177 | + "MODIFY COLUMN `player_rpg_tech_xp` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1178 | + "MODIFY COLUMN `player_rpg_tech_level` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1179 | + "MODIFY COLUMN `lvl_raid` bigint(20) unsigned NOT NULL DEFAULT '1' AFTER `player_rpg_tech_level`", |
|
1180 | + "MODIFY COLUMN `xpraid` bigint(20) unsigned DEFAULT '0'", |
|
1181 | + "MODIFY COLUMN `raids` bigint(20) unsigned DEFAULT '0'", |
|
1182 | + "MODIFY COLUMN `raidsloose` bigint(20) unsigned DEFAULT '0'", |
|
1183 | + "MODIFY COLUMN `raidswin` bigint(20) unsigned DEFAULT '0'", |
|
1184 | + "MODIFY COLUMN `new_message` int(11) NOT NULL DEFAULT '0' AFTER `raidswin`", |
|
1185 | + "MODIFY COLUMN `mnl_alliance` int(11) NOT NULL DEFAULT '0'", |
|
1186 | + "MODIFY COLUMN `mnl_joueur` int(11) NOT NULL DEFAULT '0'", |
|
1187 | + "MODIFY COLUMN `mnl_attaque` int(11) NOT NULL DEFAULT '0'", |
|
1188 | + "MODIFY COLUMN `mnl_spy` int(11) NOT NULL DEFAULT '0'", |
|
1189 | + "MODIFY COLUMN `mnl_exploit` int(11) NOT NULL DEFAULT '0'", |
|
1190 | + "MODIFY COLUMN `mnl_transport` int(11) NOT NULL DEFAULT '0'", |
|
1191 | + "MODIFY COLUMN `mnl_expedition` int(11) NOT NULL DEFAULT '0'", |
|
1192 | + "MODIFY COLUMN `mnl_buildlist` int(11) NOT NULL DEFAULT '0'", |
|
1193 | + "MODIFY COLUMN `msg_admin` bigint(11) unsigned DEFAULT '0'", |
|
1194 | + // "MODIFY COLUMN `b_tech_planet` int(11) NOT NULL DEFAULT '0' AFTER `msg_admin`", |
|
1195 | + "MODIFY COLUMN `deltime` int(10) unsigned DEFAULT '0'", |
|
1196 | + "MODIFY COLUMN `news_lastread` int(10) unsigned DEFAULT '0'", |
|
1197 | + "MODIFY COLUMN `total_rank` int(10) unsigned NOT NULL DEFAULT '0'", |
|
1198 | + "MODIFY COLUMN `total_points` bigint(20) unsigned NOT NULL DEFAULT '0'", |
|
1199 | + "MODIFY COLUMN `password` varchar(64) NOT NULL DEFAULT '' AFTER `total_points`", |
|
1200 | + "MODIFY COLUMN `email` varchar(64) NOT NULL DEFAULT '' AFTER `password`", |
|
1201 | + "MODIFY COLUMN `email_2` varchar(64) NOT NULL DEFAULT '' AFTER `email`", |
|
1202 | + "MODIFY COLUMN `lang` varchar(8) NOT NULL DEFAULT 'ru' AFTER `email_2`", |
|
1203 | + "MODIFY COLUMN `sex` char(1) DEFAULT NULL AFTER `lang`", |
|
1204 | + "MODIFY COLUMN `avatar` varchar(255) NOT NULL DEFAULT '' AFTER `sex`", |
|
1205 | + "MODIFY COLUMN `sign` mediumtext AFTER `avatar`", |
|
1206 | + "MODIFY COLUMN `id_planet` int(11) NOT NULL DEFAULT '0' AFTER `sign`", |
|
1207 | + "MODIFY COLUMN `galaxy` int(11) NOT NULL DEFAULT '0' AFTER `id_planet`", |
|
1208 | + "MODIFY COLUMN `system` int(11) NOT NULL DEFAULT '0' AFTER `galaxy`", |
|
1209 | + "MODIFY COLUMN `planet` int(11) NOT NULL DEFAULT '0' AFTER `system`", |
|
1210 | + "MODIFY COLUMN `current_planet` int(11) NOT NULL DEFAULT '0' AFTER `planet`", |
|
1211 | + "MODIFY COLUMN `user_agent` mediumtext NOT NULL AFTER `current_planet`", |
|
1212 | + "MODIFY COLUMN `user_lastip` varchar(250) DEFAULT NULL COMMENT 'User last IP' AFTER `user_agent`", |
|
1213 | + "MODIFY COLUMN `user_proxy` varchar(250) NOT NULL DEFAULT '' COMMENT 'User proxy (if any)' AFTER `user_lastip`", |
|
1214 | + "MODIFY COLUMN `register_time` int(10) unsigned DEFAULT '0' AFTER `user_proxy`", |
|
1215 | + "MODIFY COLUMN `onlinetime` int(10) unsigned DEFAULT '0' AFTER `register_time`", |
|
1216 | + "MODIFY COLUMN `dpath` varchar(255) NOT NULL DEFAULT '' AFTER `onlinetime`", |
|
1217 | + "MODIFY COLUMN `design` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `dpath`", |
|
1218 | + "MODIFY COLUMN `noipcheck` tinyint(4) unsigned NOT NULL DEFAULT '1' AFTER `design`", |
|
1219 | + "MODIFY COLUMN `options` mediumtext COMMENT 'Packed user options' AFTER `noipcheck`", |
|
1220 | + "MODIFY COLUMN `planet_sort` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `options`", |
|
1221 | + "MODIFY COLUMN `planet_sort_order` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `planet_sort`", |
|
1222 | + "MODIFY COLUMN `spio_anz` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `planet_sort_order`", |
|
1223 | + "MODIFY COLUMN `settings_tooltiptime` tinyint(1) unsigned NOT NULL DEFAULT '5' AFTER `spio_anz`", |
|
1224 | + "MODIFY COLUMN `settings_fleetactions` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_tooltiptime`", |
|
1225 | + "MODIFY COLUMN `settings_esp` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_allylogo`", |
|
1226 | + "MODIFY COLUMN `settings_wri` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_esp`", |
|
1227 | + "MODIFY COLUMN `settings_bud` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_wri`", |
|
1228 | + "MODIFY COLUMN `settings_mis` tinyint(1) unsigned NOT NULL DEFAULT '1' AFTER `settings_bud`", |
|
1229 | + "MODIFY COLUMN `settings_rep` tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER `settings_mis`", |
|
1230 | + ), strtoupper($update_tables['users']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
1231 | 1231 | |
1232 | - upd_do_query('COMMIT;', true); |
|
1233 | - $new_version = 32; |
|
1232 | + upd_do_query('COMMIT;', true); |
|
1233 | + $new_version = 32; |
|
1234 | 1234 | |
1235 | - case 32: |
|
1236 | - upd_log_version_update(); |
|
1235 | + case 32: |
|
1236 | + upd_log_version_update(); |
|
1237 | 1237 | |
1238 | - upd_check_key('avatar_max_width', 128, !isset(classSupernova::$config->avatar_max_width)); |
|
1239 | - upd_check_key('avatar_max_height', 128, !isset(classSupernova::$config->avatar_max_height)); |
|
1238 | + upd_check_key('avatar_max_width', 128, !isset(classSupernova::$config->avatar_max_width)); |
|
1239 | + upd_check_key('avatar_max_height', 128, !isset(classSupernova::$config->avatar_max_height)); |
|
1240 | 1240 | |
1241 | - upd_alter_table('users', array( |
|
1242 | - "MODIFY COLUMN `avatar` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
1243 | - ), strtoupper($update_tables['users']['avatar']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
1241 | + upd_alter_table('users', array( |
|
1242 | + "MODIFY COLUMN `avatar` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
1243 | + ), strtoupper($update_tables['users']['avatar']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
1244 | 1244 | |
1245 | - upd_alter_table('alliance', array( |
|
1246 | - "MODIFY COLUMN `ally_image` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
1247 | - ), strtoupper($update_tables['alliance']['ally_image']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
1245 | + upd_alter_table('alliance', array( |
|
1246 | + "MODIFY COLUMN `ally_image` tinyint(1) unsigned NOT NULL DEFAULT '0'", |
|
1247 | + ), strtoupper($update_tables['alliance']['ally_image']['Type']) != 'TINYINT(1) UNSIGNED'); |
|
1248 | 1248 | |
1249 | - upd_alter_table('users', array( |
|
1250 | - "DROP COLUMN `settings_allylogo`", |
|
1251 | - ), isset($update_tables['users']['settings_allylogo'])); |
|
1249 | + upd_alter_table('users', array( |
|
1250 | + "DROP COLUMN `settings_allylogo`", |
|
1251 | + ), isset($update_tables['users']['settings_allylogo'])); |
|
1252 | 1252 | |
1253 | - if(!isset($update_tables['powerup'])) { |
|
1254 | - upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};"); |
|
1253 | + if(!isset($update_tables['powerup'])) { |
|
1254 | + upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};"); |
|
1255 | 1255 | |
1256 | - upd_create_table('powerup', |
|
1257 | - "( |
|
1256 | + upd_create_table('powerup', |
|
1257 | + "( |
|
1258 | 1258 | `powerup_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
1259 | 1259 | `powerup_user_id` bigint(20) UNSIGNED NULL DEFAULT NULL, |
1260 | 1260 | `powerup_planet_id` bigint(20) UNSIGNED NULL DEFAULT NULL, |
@@ -1273,33 +1273,33 @@ discard block |
||
1273 | 1273 | CONSTRAINT `FK_powerup_user_id` FOREIGN KEY (`powerup_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, |
1274 | 1274 | CONSTRAINT `FK_powerup_planet_id` FOREIGN KEY (`powerup_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
1275 | 1275 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1276 | - ); |
|
1277 | - |
|
1278 | - upd_check_key('empire_mercenary_temporary', 0, !isset(classSupernova::$config->empire_mercenary_temporary)); |
|
1279 | - upd_check_key('empire_mercenary_base_period', PERIOD_MONTH, !isset(classSupernova::$config->empire_mercenary_base_period)); |
|
1280 | - |
|
1281 | - $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
|
1282 | - $user_list = upd_do_query("SELECT * FROM {{users}};"); |
|
1283 | - while($user_row = db_fetch($user_list)) { |
|
1284 | - $update_query_str = ''; |
|
1285 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) { |
|
1286 | - $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
|
1287 | - if($mercenary_level = $user_row[$mercenary_data_name]) { |
|
1288 | - $update_query_str = ", `{$mercenary_data_name}` = 0"; |
|
1289 | - upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
|
1290 | - upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};"); |
|
1276 | + ); |
|
1277 | + |
|
1278 | + upd_check_key('empire_mercenary_temporary', 0, !isset(classSupernova::$config->empire_mercenary_temporary)); |
|
1279 | + upd_check_key('empire_mercenary_base_period', PERIOD_MONTH, !isset(classSupernova::$config->empire_mercenary_base_period)); |
|
1280 | + |
|
1281 | + $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
|
1282 | + $user_list = upd_do_query("SELECT * FROM {{users}};"); |
|
1283 | + while($user_row = db_fetch($user_list)) { |
|
1284 | + $update_query_str = ''; |
|
1285 | + foreach(sn_get_groups('mercenaries') as $mercenary_id) { |
|
1286 | + $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
|
1287 | + if($mercenary_level = $user_row[$mercenary_data_name]) { |
|
1288 | + $update_query_str = ", `{$mercenary_data_name}` = 0"; |
|
1289 | + upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
|
1290 | + upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};"); |
|
1291 | + } |
|
1291 | 1292 | } |
1292 | - } |
|
1293 | 1293 | |
1294 | - if($update_query_str) { |
|
1295 | - upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
|
1294 | + if($update_query_str) { |
|
1295 | + upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
|
1296 | + } |
|
1296 | 1297 | } |
1297 | 1298 | } |
1298 | - } |
|
1299 | 1299 | |
1300 | - if(!isset($update_tables['universe'])) { |
|
1301 | - upd_create_table('universe', |
|
1302 | - "( |
|
1300 | + if(!isset($update_tables['universe'])) { |
|
1301 | + upd_create_table('universe', |
|
1302 | + "( |
|
1303 | 1303 | `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0', |
1304 | 1304 | `universe_system` SMALLINT UNSIGNED NOT NULL DEFAULT '0', |
1305 | 1305 | `universe_name` varchar(32) NOT NULL DEFAULT '', |
@@ -1307,193 +1307,193 @@ discard block |
||
1307 | 1307 | |
1308 | 1308 | PRIMARY KEY (`universe_galaxy`, `universe_system`) |
1309 | 1309 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1310 | - ); |
|
1310 | + ); |
|
1311 | 1311 | |
1312 | - upd_check_key('uni_price_galaxy', 10000, !isset(classSupernova::$config->uni_price_galaxy)); |
|
1313 | - upd_check_key('uni_price_system', 1000, !isset(classSupernova::$config->uni_price_system)); |
|
1314 | - } |
|
1312 | + upd_check_key('uni_price_galaxy', 10000, !isset(classSupernova::$config->uni_price_galaxy)); |
|
1313 | + upd_check_key('uni_price_system', 1000, !isset(classSupernova::$config->uni_price_system)); |
|
1314 | + } |
|
1315 | 1315 | |
1316 | - // ======================================================================== |
|
1317 | - // Ally player |
|
1318 | - // Adding config variable |
|
1319 | - upd_check_key('ali_bonus_members', 10, !isset(classSupernova::$config->ali_bonus_members)); |
|
1316 | + // ======================================================================== |
|
1317 | + // Ally player |
|
1318 | + // Adding config variable |
|
1319 | + upd_check_key('ali_bonus_members', 10, !isset(classSupernova::$config->ali_bonus_members)); |
|
1320 | 1320 | |
1321 | - // ------------------------------------------------------------------------ |
|
1322 | - // Modifying tables |
|
1323 | - if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1324 | - upd_alter_table('users', array( |
|
1325 | - "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1321 | + // ------------------------------------------------------------------------ |
|
1322 | + // Modifying tables |
|
1323 | + if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1324 | + upd_alter_table('users', array( |
|
1325 | + "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1326 | 1326 | |
1327 | - "ADD KEY `I_user_user_as_ally` (`user_as_ally`)", |
|
1327 | + "ADD KEY `I_user_user_as_ally` (`user_as_ally`)", |
|
1328 | 1328 | |
1329 | - "ADD CONSTRAINT `FK_user_user_as_ally` FOREIGN KEY (`user_as_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1330 | - ), true); |
|
1329 | + "ADD CONSTRAINT `FK_user_user_as_ally` FOREIGN KEY (`user_as_ally`) REFERENCES `{{alliance}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1330 | + ), true); |
|
1331 | 1331 | |
1332 | - upd_alter_table('alliance', array( |
|
1333 | - "ADD COLUMN ally_user_id BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1332 | + upd_alter_table('alliance', array( |
|
1333 | + "ADD COLUMN ally_user_id BIGINT(20) UNSIGNED DEFAULT NULL", |
|
1334 | 1334 | |
1335 | - "ADD KEY `I_ally_user_id` (`ally_user_id`)", |
|
1335 | + "ADD KEY `I_ally_user_id` (`ally_user_id`)", |
|
1336 | 1336 | |
1337 | - "ADD CONSTRAINT `FK_ally_ally_user_id` FOREIGN KEY (`ally_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1338 | - ), true); |
|
1339 | - } |
|
1340 | - |
|
1341 | - // ------------------------------------------------------------------------ |
|
1342 | - // Creating players for allies |
|
1343 | - $ally_row_list = classSupernova::$db->doSelect("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
|
1344 | - while($ally_row = db_fetch($ally_row_list)) { |
|
1345 | - classSupernova::$db->doInsertSet(TABLE_USERS, array( |
|
1346 | - 'username' => "[{$ally_row['ally_tag']}]", |
|
1347 | - 'register_time' => SN_TIME_NOW, |
|
1348 | - 'user_as_ally' => $ally_row['id'], |
|
1349 | - )); |
|
1350 | - |
|
1351 | - $ally_user_id = classSupernova::$db->db_insert_id(); |
|
1352 | - classSupernova::$db->doUpdate("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;"); |
|
1353 | - } |
|
1354 | - // Renaming old ally players TODO: Remove on release |
|
1355 | - 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 = '';"); |
|
1356 | - // Setting last online time to old ally players TODO: Remove on release |
|
1357 | - upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;"); |
|
1358 | - |
|
1359 | - // ------------------------------------------------------------------------ |
|
1360 | - // Creating planets for allies |
|
1361 | - $ally_user_list = classSupernova::$db->doSelect("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
|
1362 | - while($ally_user_row = db_fetch($ally_user_list)) { |
|
1363 | - classSupernova::$db->doInsertSet(TABLE_PLANETS, array( |
|
1364 | - 'name' => $ally_user_row['username'], |
|
1365 | - 'last_update' => SN_TIME_NOW, |
|
1366 | - 'id_owner' => $ally_user_row['id'], |
|
1367 | - )); |
|
1368 | - |
|
1369 | - $ally_planet_id = classSupernova::$db->db_insert_id(); |
|
1370 | - classSupernova::$db->doUpdate("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;"); |
|
1371 | - } |
|
1337 | + "ADD CONSTRAINT `FK_ally_ally_user_id` FOREIGN KEY (`ally_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1338 | + ), true); |
|
1339 | + } |
|
1372 | 1340 | |
1373 | - 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;"); |
|
1374 | - |
|
1375 | - upd_alter_table('users', array( |
|
1376 | - "DROP COLUMN `rpg_amiral`", |
|
1377 | - "DROP COLUMN `mrc_academic`", |
|
1378 | - "DROP COLUMN `rpg_espion`", |
|
1379 | - "DROP COLUMN `rpg_commandant`", |
|
1380 | - "DROP COLUMN `rpg_stockeur`", |
|
1381 | - "DROP COLUMN `rpg_destructeur`", |
|
1382 | - "DROP COLUMN `rpg_general`", |
|
1383 | - "DROP COLUMN `rpg_raideur`", |
|
1384 | - "DROP COLUMN `rpg_empereur`", |
|
1385 | - |
|
1386 | - "ADD COLUMN `metal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1387 | - "ADD COLUMN `crystal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1388 | - "ADD COLUMN `deuterium` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1389 | - ), $update_tables['users']['rpg_amiral']); |
|
1390 | - |
|
1391 | - |
|
1392 | - // ======================================================================== |
|
1393 | - // User que |
|
1394 | - // Adding db field |
|
1395 | - upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
|
1396 | - // Converting old data to new one and dropping old fields |
|
1397 | - if($update_tables['users']['b_tech_planet']) { |
|
1398 | - $query = classSupernova::$db->doSelect("SELECT * FROM `{{planets}}` WHERE `b_tech_id` <> 0;"); |
|
1399 | - while($planet_row = db_fetch($query)) { |
|
1400 | - $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
|
1401 | - classSupernova::$db->doUpdate("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
|
1341 | + // ------------------------------------------------------------------------ |
|
1342 | + // Creating players for allies |
|
1343 | + $ally_row_list = classSupernova::$db->doSelect("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
|
1344 | + while($ally_row = db_fetch($ally_row_list)) { |
|
1345 | + classSupernova::$db->doInsertSet(TABLE_USERS, array( |
|
1346 | + 'username' => "[{$ally_row['ally_tag']}]", |
|
1347 | + 'register_time' => SN_TIME_NOW, |
|
1348 | + 'user_as_ally' => $ally_row['id'], |
|
1349 | + )); |
|
1350 | + |
|
1351 | + $ally_user_id = classSupernova::$db->db_insert_id(); |
|
1352 | + classSupernova::$db->doUpdate("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;"); |
|
1353 | + } |
|
1354 | + // Renaming old ally players TODO: Remove on release |
|
1355 | + 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 = '';"); |
|
1356 | + // Setting last online time to old ally players TODO: Remove on release |
|
1357 | + upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;"); |
|
1358 | + |
|
1359 | + // ------------------------------------------------------------------------ |
|
1360 | + // Creating planets for allies |
|
1361 | + $ally_user_list = classSupernova::$db->doSelect("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
|
1362 | + while($ally_user_row = db_fetch($ally_user_list)) { |
|
1363 | + classSupernova::$db->doInsertSet(TABLE_PLANETS, array( |
|
1364 | + 'name' => $ally_user_row['username'], |
|
1365 | + 'last_update' => SN_TIME_NOW, |
|
1366 | + 'id_owner' => $ally_user_row['id'], |
|
1367 | + )); |
|
1368 | + |
|
1369 | + $ally_planet_id = classSupernova::$db->db_insert_id(); |
|
1370 | + classSupernova::$db->doUpdate("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;"); |
|
1402 | 1371 | } |
1403 | 1372 | |
1404 | - upd_alter_table('planets', array( |
|
1405 | - "DROP COLUMN `b_tech`", |
|
1406 | - "DROP COLUMN `b_tech_id`", |
|
1407 | - ), $update_tables['planets']['b_tech']); |
|
1373 | + 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;"); |
|
1408 | 1374 | |
1409 | - upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
|
1410 | - } |
|
1375 | + upd_alter_table('users', array( |
|
1376 | + "DROP COLUMN `rpg_amiral`", |
|
1377 | + "DROP COLUMN `mrc_academic`", |
|
1378 | + "DROP COLUMN `rpg_espion`", |
|
1379 | + "DROP COLUMN `rpg_commandant`", |
|
1380 | + "DROP COLUMN `rpg_stockeur`", |
|
1381 | + "DROP COLUMN `rpg_destructeur`", |
|
1382 | + "DROP COLUMN `rpg_general`", |
|
1383 | + "DROP COLUMN `rpg_raideur`", |
|
1384 | + "DROP COLUMN `rpg_empereur`", |
|
1385 | + |
|
1386 | + "ADD COLUMN `metal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1387 | + "ADD COLUMN `crystal` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1388 | + "ADD COLUMN `deuterium` decimal(65,5) NOT NULL DEFAULT '0.00000'", |
|
1389 | + ), $update_tables['users']['rpg_amiral']); |
|
1390 | + |
|
1391 | + |
|
1392 | + // ======================================================================== |
|
1393 | + // User que |
|
1394 | + // Adding db field |
|
1395 | + upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
|
1396 | + // Converting old data to new one and dropping old fields |
|
1397 | + if($update_tables['users']['b_tech_planet']) { |
|
1398 | + $query = classSupernova::$db->doSelect("SELECT * FROM `{{planets}}` WHERE `b_tech_id` <> 0;"); |
|
1399 | + while($planet_row = db_fetch($query)) { |
|
1400 | + $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
|
1401 | + classSupernova::$db->doUpdate("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
|
1402 | + } |
|
1411 | 1403 | |
1412 | - if(!$update_tables['powerup']['powerup_category']) { |
|
1413 | - upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
|
1404 | + upd_alter_table('planets', array( |
|
1405 | + "DROP COLUMN `b_tech`", |
|
1406 | + "DROP COLUMN `b_tech_id`", |
|
1407 | + ), $update_tables['planets']['b_tech']); |
|
1414 | 1408 | |
1415 | - classSupernova::$db->doUpdate("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
|
1416 | - } |
|
1409 | + upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
|
1410 | + } |
|
1411 | + |
|
1412 | + if(!$update_tables['powerup']['powerup_category']) { |
|
1413 | + upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
|
1417 | 1414 | |
1418 | - upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info)); |
|
1419 | - upd_check_key('tpl_minifier', 0, !isset(classSupernova::$config->tpl_minifier)); |
|
1420 | - |
|
1421 | - upd_check_key('server_updater_check_auto', 0, !isset(classSupernova::$config->server_updater_check_auto)); |
|
1422 | - upd_check_key('server_updater_check_period', PERIOD_DAY, !isset(classSupernova::$config->server_updater_check_period)); |
|
1423 | - upd_check_key('server_updater_check_last', 0, !isset(classSupernova::$config->server_updater_check_last)); |
|
1424 | - upd_check_key('server_updater_check_result', SNC_VER_NEVER, !isset(classSupernova::$config->server_updater_check_result)); |
|
1425 | - upd_check_key('server_updater_key', '', !isset(classSupernova::$config->server_updater_key)); |
|
1426 | - upd_check_key('server_updater_id', 0, !isset(classSupernova::$config->server_updater_id)); |
|
1427 | - |
|
1428 | - upd_check_key('ali_bonus_algorithm', 0, !isset(classSupernova::$config->ali_bonus_algorithm)); |
|
1429 | - upd_check_key('ali_bonus_divisor', 10000000, !isset(classSupernova::$config->ali_bonus_divisor)); |
|
1430 | - upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets)); |
|
1431 | - upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor)); |
|
1432 | - |
|
1433 | - if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1434 | - $inflation_rate = 1000; |
|
1435 | - |
|
1436 | - classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate); |
|
1437 | - classSupernova::$config->db_saveItem('rpg_cost_exchange', classSupernova::$config->rpg_cost_exchange * $inflation_rate); |
|
1438 | - classSupernova::$config->db_saveItem('rpg_cost_pawnshop', classSupernova::$config->rpg_cost_pawnshop * $inflation_rate); |
|
1439 | - classSupernova::$config->db_saveItem('rpg_cost_scraper', classSupernova::$config->rpg_cost_scraper * $inflation_rate); |
|
1440 | - classSupernova::$config->db_saveItem('rpg_cost_stockman', classSupernova::$config->rpg_cost_stockman * $inflation_rate); |
|
1441 | - classSupernova::$config->db_saveItem('rpg_cost_trader', classSupernova::$config->rpg_cost_trader * $inflation_rate); |
|
1442 | - |
|
1443 | - classSupernova::$config->db_saveItem('rpg_exchange_darkMatter', classSupernova::$config->rpg_exchange_darkMatter / $inflation_rate * 4); |
|
1444 | - |
|
1445 | - classSupernova::$config->db_saveItem('rpg_flt_explore', $inflation_rate); |
|
1446 | - |
|
1447 | - classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
|
1448 | - |
|
1449 | - $query = classSupernova::$db->doSelect("SELECT * FROM `{{quest}}`"); |
|
1450 | - while($row = db_fetch($query)) { |
|
1451 | - $query_add = ''; |
|
1452 | - $quest_reward_list = explode(';', $row['quest_rewards']); |
|
1453 | - foreach($quest_reward_list as &$quest_reward) { |
|
1454 | - list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
|
1455 | - if($reward_resource == RES_DARK_MATTER) { |
|
1456 | - $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
|
1415 | + classSupernova::$db->doUpdate("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
|
1416 | + } |
|
1417 | + |
|
1418 | + upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info)); |
|
1419 | + upd_check_key('tpl_minifier', 0, !isset(classSupernova::$config->tpl_minifier)); |
|
1420 | + |
|
1421 | + upd_check_key('server_updater_check_auto', 0, !isset(classSupernova::$config->server_updater_check_auto)); |
|
1422 | + upd_check_key('server_updater_check_period', PERIOD_DAY, !isset(classSupernova::$config->server_updater_check_period)); |
|
1423 | + upd_check_key('server_updater_check_last', 0, !isset(classSupernova::$config->server_updater_check_last)); |
|
1424 | + upd_check_key('server_updater_check_result', SNC_VER_NEVER, !isset(classSupernova::$config->server_updater_check_result)); |
|
1425 | + upd_check_key('server_updater_key', '', !isset(classSupernova::$config->server_updater_key)); |
|
1426 | + upd_check_key('server_updater_id', 0, !isset(classSupernova::$config->server_updater_id)); |
|
1427 | + |
|
1428 | + upd_check_key('ali_bonus_algorithm', 0, !isset(classSupernova::$config->ali_bonus_algorithm)); |
|
1429 | + upd_check_key('ali_bonus_divisor', 10000000, !isset(classSupernova::$config->ali_bonus_divisor)); |
|
1430 | + upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets)); |
|
1431 | + upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor)); |
|
1432 | + |
|
1433 | + if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1434 | + $inflation_rate = 1000; |
|
1435 | + |
|
1436 | + classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate); |
|
1437 | + classSupernova::$config->db_saveItem('rpg_cost_exchange', classSupernova::$config->rpg_cost_exchange * $inflation_rate); |
|
1438 | + classSupernova::$config->db_saveItem('rpg_cost_pawnshop', classSupernova::$config->rpg_cost_pawnshop * $inflation_rate); |
|
1439 | + classSupernova::$config->db_saveItem('rpg_cost_scraper', classSupernova::$config->rpg_cost_scraper * $inflation_rate); |
|
1440 | + classSupernova::$config->db_saveItem('rpg_cost_stockman', classSupernova::$config->rpg_cost_stockman * $inflation_rate); |
|
1441 | + classSupernova::$config->db_saveItem('rpg_cost_trader', classSupernova::$config->rpg_cost_trader * $inflation_rate); |
|
1442 | + |
|
1443 | + classSupernova::$config->db_saveItem('rpg_exchange_darkMatter', classSupernova::$config->rpg_exchange_darkMatter / $inflation_rate * 4); |
|
1444 | + |
|
1445 | + classSupernova::$config->db_saveItem('rpg_flt_explore', $inflation_rate); |
|
1446 | + |
|
1447 | + classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
|
1448 | + |
|
1449 | + $query = classSupernova::$db->doSelect("SELECT * FROM `{{quest}}`"); |
|
1450 | + while($row = db_fetch($query)) { |
|
1451 | + $query_add = ''; |
|
1452 | + $quest_reward_list = explode(';', $row['quest_rewards']); |
|
1453 | + foreach($quest_reward_list as &$quest_reward) { |
|
1454 | + list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
|
1455 | + if($reward_resource == RES_DARK_MATTER) { |
|
1456 | + $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
|
1457 | + } |
|
1458 | + } |
|
1459 | + $new_rewards = implode(';', $quest_reward_list); |
|
1460 | + if($new_rewards != $row['quest_rewards']) { |
|
1461 | + classSupernova::$db->doUpdate("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
|
1457 | 1462 | } |
1458 | - } |
|
1459 | - $new_rewards = implode(';', $quest_reward_list); |
|
1460 | - if($new_rewards != $row['quest_rewards']) { |
|
1461 | - classSupernova::$db->doUpdate("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
|
1462 | 1463 | } |
1463 | 1464 | } |
1464 | - } |
|
1465 | 1465 | |
1466 | - upd_check_key('rpg_bonus_minimum', 10000, !isset(classSupernova::$config->rpg_bonus_minimum)); |
|
1467 | - upd_check_key('rpg_bonus_divisor', |
|
1468 | - !isset(classSupernova::$config->rpg_bonus_divisor) ? 10 : (classSupernova::$config->rpg_bonus_divisor >= 1000 ? floor(classSupernova::$config->rpg_bonus_divisor / 1000) : classSupernova::$config->rpg_bonus_divisor), |
|
1469 | - !isset(classSupernova::$config->rpg_bonus_divisor) || classSupernova::$config->rpg_bonus_divisor >= 1000); |
|
1466 | + upd_check_key('rpg_bonus_minimum', 10000, !isset(classSupernova::$config->rpg_bonus_minimum)); |
|
1467 | + upd_check_key('rpg_bonus_divisor', |
|
1468 | + !isset(classSupernova::$config->rpg_bonus_divisor) ? 10 : (classSupernova::$config->rpg_bonus_divisor >= 1000 ? floor(classSupernova::$config->rpg_bonus_divisor / 1000) : classSupernova::$config->rpg_bonus_divisor), |
|
1469 | + !isset(classSupernova::$config->rpg_bonus_divisor) || classSupernova::$config->rpg_bonus_divisor >= 1000); |
|
1470 | 1470 | |
1471 | - upd_check_key('var_news_last', 0, !isset(classSupernova::$config->var_news_last)); |
|
1471 | + upd_check_key('var_news_last', 0, !isset(classSupernova::$config->var_news_last)); |
|
1472 | 1472 | |
1473 | - upd_do_query('COMMIT;', true); |
|
1474 | - $new_version = 33; |
|
1473 | + upd_do_query('COMMIT;', true); |
|
1474 | + $new_version = 33; |
|
1475 | 1475 | |
1476 | - case 33: |
|
1477 | - upd_log_version_update(); |
|
1476 | + case 33: |
|
1477 | + upd_log_version_update(); |
|
1478 | 1478 | |
1479 | - upd_alter_table('users', array( |
|
1480 | - "ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'", |
|
1481 | - "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'", |
|
1479 | + upd_alter_table('users', array( |
|
1480 | + "ADD `user_birthday` DATE DEFAULT NULL COMMENT 'User birthday'", |
|
1481 | + "ADD `user_birthday_celebrated` DATE DEFAULT NULL COMMENT 'Last time where user got birthday gift'", |
|
1482 | 1482 | |
1483 | - "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)", |
|
1484 | - ), !$update_tables['users']['user_birthday']); |
|
1483 | + "ADD KEY `I_user_birthday` (`user_birthday`, `user_birthday_celebrated`)", |
|
1484 | + ), !$update_tables['users']['user_birthday']); |
|
1485 | 1485 | |
1486 | - upd_check_key('user_birthday_gift', 0, !isset(classSupernova::$config->user_birthday_gift)); |
|
1487 | - upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range)); |
|
1488 | - upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate)); |
|
1486 | + upd_check_key('user_birthday_gift', 0, !isset(classSupernova::$config->user_birthday_gift)); |
|
1487 | + upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range)); |
|
1488 | + upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate)); |
|
1489 | 1489 | |
1490 | - if(!isset($update_tables['payment'])) { |
|
1491 | - upd_alter_table('users', array( |
|
1492 | - "ADD KEY `I_user_id_name` (`id`, `username`)", |
|
1493 | - ), !$update_indexes['users']['I_user_id_name']); |
|
1490 | + if(!isset($update_tables['payment'])) { |
|
1491 | + upd_alter_table('users', array( |
|
1492 | + "ADD KEY `I_user_id_name` (`id`, `username`)", |
|
1493 | + ), !$update_indexes['users']['I_user_id_name']); |
|
1494 | 1494 | |
1495 | - upd_create_table('payment', |
|
1496 | - "( |
|
1495 | + upd_create_table('payment', |
|
1496 | + "( |
|
1497 | 1497 | `payment_id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Internal payment ID', |
1498 | 1498 | `payment_user_id` BIGINT(20) UNSIGNED DEFAULT NULL, |
1499 | 1499 | `payment_user_name` VARCHAR(64) DEFAULT NULL, |
@@ -1513,169 +1513,169 @@ discard block |
||
1513 | 1513 | |
1514 | 1514 | CONSTRAINT `FK_payment_user` FOREIGN KEY (`payment_user_id`, `payment_user_name`) REFERENCES `{{users}}` (`id`, `username`) ON UPDATE CASCADE ON DELETE NO ACTION |
1515 | 1515 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1516 | - ); |
|
1516 | + ); |
|
1517 | 1517 | |
1518 | - upd_check_key('payment_currency_default', 'UAH', !isset(classSupernova::$config->payment_currency_default)); |
|
1519 | - } |
|
1520 | - upd_check_key('payment_lot_size', 1000, !isset(classSupernova::$config->payment_lot_size)); |
|
1521 | - upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price)); |
|
1518 | + upd_check_key('payment_currency_default', 'UAH', !isset(classSupernova::$config->payment_currency_default)); |
|
1519 | + } |
|
1520 | + upd_check_key('payment_lot_size', 1000, !isset(classSupernova::$config->payment_lot_size)); |
|
1521 | + upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price)); |
|
1522 | 1522 | |
1523 | - // Updating category for Mercenaries |
|
1524 | - upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
1523 | + // Updating category for Mercenaries |
|
1524 | + upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
1525 | 1525 | |
1526 | - // Convert Destructor to Death Star schematic |
|
1527 | - upd_do_query("UPDATE {{powerup}} |
|
1526 | + // Convert Destructor to Death Star schematic |
|
1527 | + upd_do_query("UPDATE {{powerup}} |
|
1528 | 1528 | SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . " |
1529 | 1529 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;"); |
1530 | - // Convert Assasin to SuperNova schematic |
|
1531 | - upd_do_query("UPDATE {{powerup}} |
|
1530 | + // Convert Assasin to SuperNova schematic |
|
1531 | + upd_do_query("UPDATE {{powerup}} |
|
1532 | 1532 | SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . " |
1533 | 1533 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;"); |
1534 | 1534 | |
1535 | - upd_alter_table('iraks', array( |
|
1536 | - "ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1", |
|
1537 | - "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1", |
|
1538 | - ), !$update_tables['iraks']['fleet_start_type']); |
|
1535 | + upd_alter_table('iraks', array( |
|
1536 | + "ADD `fleet_start_type` SMALLINT NOT NULL DEFAULT 1", |
|
1537 | + "ADD `fleet_end_type` SMALLINT NOT NULL DEFAULT 1", |
|
1538 | + ), !$update_tables['iraks']['fleet_start_type']); |
|
1539 | 1539 | |
1540 | 1540 | |
1541 | - if(!$update_tables['payment']['payment_status']) { |
|
1542 | - upd_alter_table('payment', array( |
|
1543 | - "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
|
1541 | + if(!$update_tables['payment']['payment_status']) { |
|
1542 | + upd_alter_table('payment', array( |
|
1543 | + "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
|
1544 | 1544 | |
1545 | - "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'", |
|
1546 | - "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`", |
|
1545 | + "CHANGE COLUMN `payment_dm` `payment_dark_matter_paid` DECIMAL(65,0) DEFAULT 0 COMMENT 'Real DM paid for'", |
|
1546 | + "ADD COLUMN `payment_dark_matter_gained` DECIMAL(65,0) DEFAULT 0 COMMENT 'DM gained by player (with bonuses)' AFTER `payment_dark_matter_paid`", |
|
1547 | 1547 | |
1548 | - "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'", |
|
1549 | - "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'", |
|
1550 | - "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'", |
|
1551 | - "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'", |
|
1552 | - "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'", |
|
1553 | - ), !$update_tables['payment']['payment_status']); |
|
1554 | - } |
|
1548 | + "CHANGE COLUMN `payment_internal_id` `payment_external_id` VARCHAR(255) DEFAULT '' COMMENT 'External payment ID in payment system'", |
|
1549 | + "CHANGE COLUMN `payment_internal_date` `payment_external_date` DATETIME COMMENT 'External payment timestamp in payment system'", |
|
1550 | + "ADD COLUMN `payment_external_lots` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Payment system lot amount'", |
|
1551 | + "ADD COLUMN `payment_external_amount` decimal(65,5) NOT NULL DEFAULT '0.00000' COMMENT 'Money incoming from payment system'", |
|
1552 | + "ADD COLUMN `payment_external_currency` VARCHAR(3) NOT NULL DEFAULT '' COMMENT 'Payment system currency'", |
|
1553 | + ), !$update_tables['payment']['payment_status']); |
|
1554 | + } |
|
1555 | 1555 | |
1556 | - upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";"); |
|
1556 | + upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";"); |
|
1557 | 1557 | |
1558 | - upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date)); |
|
1559 | - upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures)); |
|
1560 | - upd_check_key('server_que_length_hangar', 5, !isset(classSupernova::$config->server_que_length_hangar)); |
|
1558 | + upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date)); |
|
1559 | + upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures)); |
|
1560 | + upd_check_key('server_que_length_hangar', 5, !isset(classSupernova::$config->server_que_length_hangar)); |
|
1561 | 1561 | |
1562 | - upd_check_key('chat_highlight_moderator', '<span class="nick_moderator">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=green>$1</font>'); |
|
1563 | - upd_check_key('chat_highlight_operator', '<span class="nick_operator">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=red>$1</font>'); |
|
1564 | - upd_check_key('chat_highlight_admin', '<span class="nick_admin">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=purple>$1</font>'); |
|
1562 | + upd_check_key('chat_highlight_moderator', '<span class="nick_moderator">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=green>$1</font>'); |
|
1563 | + upd_check_key('chat_highlight_operator', '<span class="nick_operator">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=red>$1</font>'); |
|
1564 | + upd_check_key('chat_highlight_admin', '<span class="nick_admin">$1</span>', classSupernova::$config->chat_highlight_admin == '<font color=purple>$1</font>'); |
|
1565 | 1565 | |
1566 | - upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium)); |
|
1566 | + upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium)); |
|
1567 | 1567 | |
1568 | - 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;"); |
|
1568 | + 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;"); |
|
1569 | 1569 | |
1570 | 1570 | |
1571 | - upd_do_query('COMMIT;', true); |
|
1572 | - $new_version = 34; |
|
1573 | - |
|
1574 | - case 34: |
|
1575 | - upd_log_version_update(); |
|
1576 | - |
|
1577 | - upd_alter_table('planets', array( |
|
1578 | - "ADD COLUMN `planet_teleport_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next teleport time'", |
|
1579 | - ), !$update_tables['planets']['planet_teleport_next']); |
|
1580 | - |
|
1581 | - upd_check_key('planet_teleport_cost', 50000, !isset(classSupernova::$config->planet_teleport_cost)); |
|
1582 | - upd_check_key('planet_teleport_timeout', PERIOD_DAY * 1, !isset(classSupernova::$config->planet_teleport_timeout)); |
|
1583 | - |
|
1584 | - upd_check_key('planet_capital_cost', 25000, !isset(classSupernova::$config->planet_capital_cost)); |
|
1585 | - |
|
1586 | - upd_alter_table('users', array( |
|
1587 | - "ADD COLUMN `player_race` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player\'s race'", |
|
1588 | - ), !$update_tables['users']['player_race']); |
|
1589 | - |
|
1590 | - upd_alter_table('chat', array( |
|
1591 | - "MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'", |
|
1592 | - ), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT'); |
|
1593 | - |
|
1594 | - upd_alter_table('planets', array( |
|
1595 | - "ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'", |
|
1596 | - "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'", |
|
1597 | - "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'", |
|
1598 | - "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'", |
|
1599 | - "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'", |
|
1600 | - "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'", |
|
1601 | - ), !$update_tables['planets']['ship_sattelite_sloth']); |
|
1602 | - |
|
1603 | - upd_alter_table('planets', array( |
|
1604 | - "ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'", |
|
1605 | - "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)", |
|
1606 | - "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)", |
|
1607 | - "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)", |
|
1608 | - "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)", |
|
1609 | - "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)", |
|
1610 | - "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)", |
|
1611 | - ), !$update_tables['planets']['ship_sattelite_sloth_porcent']); |
|
1612 | - |
|
1613 | - upd_check_key('stats_hide_admins', 1, !isset(classSupernova::$config->stats_hide_admins)); |
|
1614 | - upd_check_key('stats_hide_player_list', '', !isset(classSupernova::$config->stats_hide_player_list)); |
|
1615 | - |
|
1616 | - upd_check_key('adv_seo_meta_description', '', !isset(classSupernova::$config->adv_seo_meta_description)); |
|
1617 | - upd_check_key('adv_seo_meta_keywords', '', !isset(classSupernova::$config->adv_seo_meta_keywords)); |
|
1618 | - |
|
1619 | - upd_check_key('stats_hide_pm_link', '0', !isset(classSupernova::$config->stats_hide_pm_link)); |
|
1620 | - |
|
1621 | - upd_alter_table('notes', array( |
|
1622 | - "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
|
1623 | - ), !$update_indexes['notes']['I_owner_priority_time']); |
|
1624 | - |
|
1625 | - if(!$update_tables['buddy']['BUDDY_ID']) { |
|
1626 | - upd_alter_table('buddy', array( |
|
1627 | - "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy\Buddy table row ID'", |
|
1628 | - "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy\Buddy request status'", |
|
1629 | - "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy\Buddy request text'", // 255 chars |
|
1630 | - |
|
1631 | - "DROP INDEX `id`", |
|
1632 | - |
|
1633 | - "DROP FOREIGN KEY `FK_buddy_sender_id`", |
|
1634 | - "DROP FOREIGN KEY `FK_buddy_owner_id`", |
|
1635 | - "DROP INDEX `I_buddy_sender`", |
|
1636 | - "DROP INDEX `I_buddy_owner`", |
|
1637 | - ), !$update_tables['buddy']['BUDDY_ID']); |
|
1638 | - |
|
1639 | - upd_alter_table('buddy', array( |
|
1640 | - "CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy\Buddy request sender ID'", |
|
1641 | - "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy\Buddy request recipient ID'", |
|
1642 | - ), !$update_tables['buddy']['BUDDY_SENDER']); |
|
1643 | - |
|
1644 | - $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
|
1645 | - $found = $lost = array(); |
|
1646 | - while($row = db_fetch($query)) { |
|
1647 | - $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
1648 | - if(!isset($found[$index])) { |
|
1649 | - $found[$index] = $row['BUDDY_ID']; |
|
1650 | - } else { |
|
1651 | - $lost[] = $row['BUDDY_ID']; |
|
1571 | + upd_do_query('COMMIT;', true); |
|
1572 | + $new_version = 34; |
|
1573 | + |
|
1574 | + case 34: |
|
1575 | + upd_log_version_update(); |
|
1576 | + |
|
1577 | + upd_alter_table('planets', array( |
|
1578 | + "ADD COLUMN `planet_teleport_next` INT(11) NOT NULL DEFAULT 0 COMMENT 'Next teleport time'", |
|
1579 | + ), !$update_tables['planets']['planet_teleport_next']); |
|
1580 | + |
|
1581 | + upd_check_key('planet_teleport_cost', 50000, !isset(classSupernova::$config->planet_teleport_cost)); |
|
1582 | + upd_check_key('planet_teleport_timeout', PERIOD_DAY * 1, !isset(classSupernova::$config->planet_teleport_timeout)); |
|
1583 | + |
|
1584 | + upd_check_key('planet_capital_cost', 25000, !isset(classSupernova::$config->planet_capital_cost)); |
|
1585 | + |
|
1586 | + upd_alter_table('users', array( |
|
1587 | + "ADD COLUMN `player_race` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player\'s race'", |
|
1588 | + ), !$update_tables['users']['player_race']); |
|
1589 | + |
|
1590 | + upd_alter_table('chat', array( |
|
1591 | + "MODIFY COLUMN `user` TEXT COMMENT 'Chat message user name'", |
|
1592 | + ), strtoupper($update_tables['chat']['user']['Type']) != 'TEXT'); |
|
1593 | + |
|
1594 | + upd_alter_table('planets', array( |
|
1595 | + "ADD `ship_sattelite_sloth` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Terran Sloth'", |
|
1596 | + "ADD `ship_bomber_envy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Lunar Envy'", |
|
1597 | + "ADD `ship_recycler_gluttony` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Mercurian Gluttony'", |
|
1598 | + "ADD `ship_fighter_wrath` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Venerian Wrath'", |
|
1599 | + "ADD `ship_battleship_pride` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Martian Pride'", |
|
1600 | + "ADD `ship_cargo_greed` bigint(20) NOT NULL DEFAULT '0' COMMENT 'Republican Greed'", |
|
1601 | + ), !$update_tables['planets']['ship_sattelite_sloth']); |
|
1602 | + |
|
1603 | + upd_alter_table('planets', array( |
|
1604 | + "ADD `ship_sattelite_sloth_porcent` TINYINT(3) UNSIGNED NOT NULL DEFAULT '10' COMMENT 'Terran Sloth production'", |
|
1605 | + "ADD KEY `I_ship_sattelite_sloth` (`ship_sattelite_sloth`, `id_level`)", |
|
1606 | + "ADD KEY `I_ship_bomber_envy` (`ship_bomber_envy`, `id_level`)", |
|
1607 | + "ADD KEY `I_ship_recycler_gluttony` (`ship_recycler_gluttony`, `id_level`)", |
|
1608 | + "ADD KEY `I_ship_fighter_wrath` (`ship_fighter_wrath`, `id_level`)", |
|
1609 | + "ADD KEY `I_ship_battleship_pride` (`ship_battleship_pride`, `id_level`)", |
|
1610 | + "ADD KEY `I_ship_cargo_greed` (`ship_cargo_greed`, `id_level`)", |
|
1611 | + ), !$update_tables['planets']['ship_sattelite_sloth_porcent']); |
|
1612 | + |
|
1613 | + upd_check_key('stats_hide_admins', 1, !isset(classSupernova::$config->stats_hide_admins)); |
|
1614 | + upd_check_key('stats_hide_player_list', '', !isset(classSupernova::$config->stats_hide_player_list)); |
|
1615 | + |
|
1616 | + upd_check_key('adv_seo_meta_description', '', !isset(classSupernova::$config->adv_seo_meta_description)); |
|
1617 | + upd_check_key('adv_seo_meta_keywords', '', !isset(classSupernova::$config->adv_seo_meta_keywords)); |
|
1618 | + |
|
1619 | + upd_check_key('stats_hide_pm_link', '0', !isset(classSupernova::$config->stats_hide_pm_link)); |
|
1620 | + |
|
1621 | + upd_alter_table('notes', array( |
|
1622 | + "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
|
1623 | + ), !$update_indexes['notes']['I_owner_priority_time']); |
|
1624 | + |
|
1625 | + if(!$update_tables['buddy']['BUDDY_ID']) { |
|
1626 | + upd_alter_table('buddy', array( |
|
1627 | + "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy\Buddy table row ID'", |
|
1628 | + "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy\Buddy request status'", |
|
1629 | + "CHANGE COLUMN `text` `BUDDY_REQUEST` TINYTEXT DEFAULT '' COMMENT 'Buddy\Buddy request text'", // 255 chars |
|
1630 | + |
|
1631 | + "DROP INDEX `id`", |
|
1632 | + |
|
1633 | + "DROP FOREIGN KEY `FK_buddy_sender_id`", |
|
1634 | + "DROP FOREIGN KEY `FK_buddy_owner_id`", |
|
1635 | + "DROP INDEX `I_buddy_sender`", |
|
1636 | + "DROP INDEX `I_buddy_owner`", |
|
1637 | + ), !$update_tables['buddy']['BUDDY_ID']); |
|
1638 | + |
|
1639 | + upd_alter_table('buddy', array( |
|
1640 | + "CHANGE COLUMN `sender` `BUDDY_SENDER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy\Buddy request sender ID'", |
|
1641 | + "CHANGE COLUMN `owner` `BUDDY_OWNER_ID` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Buddy\Buddy request recipient ID'", |
|
1642 | + ), !$update_tables['buddy']['BUDDY_SENDER']); |
|
1643 | + |
|
1644 | + $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
|
1645 | + $found = $lost = array(); |
|
1646 | + while($row = db_fetch($query)) { |
|
1647 | + $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
1648 | + if(!isset($found[$index])) { |
|
1649 | + $found[$index] = $row['BUDDY_ID']; |
|
1650 | + } else { |
|
1651 | + $lost[] = $row['BUDDY_ID']; |
|
1652 | + } |
|
1653 | + } |
|
1654 | + $lost = implode(',', $lost); |
|
1655 | + if($lost) { |
|
1656 | + upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
|
1652 | 1657 | } |
1653 | - } |
|
1654 | - $lost = implode(',', $lost); |
|
1655 | - if($lost) { |
|
1656 | - upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
|
1657 | - } |
|
1658 | 1658 | |
1659 | - upd_alter_table('buddy', array( |
|
1660 | - "ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)", |
|
1661 | - "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)", |
|
1659 | + upd_alter_table('buddy', array( |
|
1660 | + "ADD KEY `I_BUDDY_SENDER_ID` (`BUDDY_SENDER_ID`, `BUDDY_OWNER_ID`)", |
|
1661 | + "ADD KEY `I_BUDDY_OWNER_ID` (`BUDDY_OWNER_ID`, `BUDDY_SENDER_ID`)", |
|
1662 | 1662 | |
1663 | - "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1664 | - "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1665 | - ), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']); |
|
1666 | - } |
|
1663 | + "ADD CONSTRAINT `FK_BUDDY_SENDER_ID` FOREIGN KEY (`BUDDY_SENDER_ID`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1664 | + "ADD CONSTRAINT `FK_BUDDY_OWNER_ID` FOREIGN KEY (`BUDDY_OWNER_ID`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1665 | + ), !$update_indexes['buddy']['I_BUDDY_SENDER_ID']); |
|
1666 | + } |
|
1667 | 1667 | |
1668 | - upd_do_query('COMMIT;', true); |
|
1669 | - $new_version = 35; |
|
1668 | + upd_do_query('COMMIT;', true); |
|
1669 | + $new_version = 35; |
|
1670 | 1670 | |
1671 | - case 35: |
|
1672 | - upd_log_version_update(); |
|
1671 | + case 35: |
|
1672 | + upd_log_version_update(); |
|
1673 | 1673 | |
1674 | - 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"); |
|
1674 | + 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"); |
|
1675 | 1675 | |
1676 | - if(!$update_tables['ube_report']) { |
|
1677 | - upd_create_table('ube_report', |
|
1678 | - "( |
|
1676 | + if(!$update_tables['ube_report']) { |
|
1677 | + upd_create_table('ube_report', |
|
1678 | + "( |
|
1679 | 1679 | `ube_report_id` SERIAL COMMENT 'Report ID', |
1680 | 1680 | |
1681 | 1681 | `ube_report_cypher` CHAR(32) NOT NULL DEFAULT '' COMMENT '16 char secret report ID', |
@@ -1711,12 +1711,12 @@ discard block |
||
1711 | 1711 | PRIMARY KEY (`ube_report_id`), |
1712 | 1712 | KEY `I_ube_report_cypher` (`ube_report_cypher`) |
1713 | 1713 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1714 | - ); |
|
1715 | - } |
|
1714 | + ); |
|
1715 | + } |
|
1716 | 1716 | |
1717 | - if(!$update_tables['ube_report_player']) { |
|
1718 | - upd_create_table('ube_report_player', |
|
1719 | - "( |
|
1717 | + if(!$update_tables['ube_report_player']) { |
|
1718 | + upd_create_table('ube_report_player', |
|
1719 | + "( |
|
1720 | 1720 | `ube_report_player_id` SERIAL COMMENT 'Record ID', |
1721 | 1721 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
1722 | 1722 | `ube_report_player_player_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Player ID', |
@@ -1732,12 +1732,12 @@ discard block |
||
1732 | 1732 | KEY `I_ube_report_player_player_id` (`ube_report_player_player_id`), |
1733 | 1733 | CONSTRAINT `FK_ube_report_player_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1734 | 1734 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1735 | - ); |
|
1736 | - } |
|
1735 | + ); |
|
1736 | + } |
|
1737 | 1737 | |
1738 | - if(!$update_tables['ube_report_fleet']) { |
|
1739 | - upd_create_table('ube_report_fleet', |
|
1740 | - "( |
|
1738 | + if(!$update_tables['ube_report_fleet']) { |
|
1739 | + upd_create_table('ube_report_fleet', |
|
1740 | + "( |
|
1741 | 1741 | `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID', |
1742 | 1742 | |
1743 | 1743 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1762,16 +1762,16 @@ discard block |
||
1762 | 1762 | PRIMARY KEY (`ube_report_fleet_id`), |
1763 | 1763 | CONSTRAINT `FK_ube_report_fleet_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1764 | 1764 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1765 | - ); |
|
1766 | - } |
|
1765 | + ); |
|
1766 | + } |
|
1767 | 1767 | |
1768 | - if(!$update_tables['ube_report_unit']) { |
|
1769 | - // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
|
1770 | - // Может сохранять имена удаленных кораблей долго? |
|
1768 | + if(!$update_tables['ube_report_unit']) { |
|
1769 | + // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
|
1770 | + // Может сохранять имена удаленных кораблей долго? |
|
1771 | 1771 | |
1772 | - // round SIGNED!!! -1 например - для ауткома |
|
1773 | - upd_create_table('ube_report_unit', |
|
1774 | - "( |
|
1772 | + // round SIGNED!!! -1 например - для ауткома |
|
1773 | + upd_create_table('ube_report_unit', |
|
1774 | + "( |
|
1775 | 1775 | `ube_report_unit_id` SERIAL COMMENT 'Record DB ID', |
1776 | 1776 | |
1777 | 1777 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1799,12 +1799,12 @@ discard block |
||
1799 | 1799 | KEY `I_ube_report_unit_order` (`ube_report_unit_sort_order`), |
1800 | 1800 | CONSTRAINT `FK_ube_report_unit_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1801 | 1801 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1802 | - ); |
|
1803 | - } |
|
1802 | + ); |
|
1803 | + } |
|
1804 | 1804 | |
1805 | - if(!$update_tables['ube_report_outcome_fleet']) { |
|
1806 | - upd_create_table('ube_report_outcome_fleet', |
|
1807 | - "( |
|
1805 | + if(!$update_tables['ube_report_outcome_fleet']) { |
|
1806 | + upd_create_table('ube_report_outcome_fleet', |
|
1807 | + "( |
|
1808 | 1808 | `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID', |
1809 | 1809 | |
1810 | 1810 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1828,12 +1828,12 @@ discard block |
||
1828 | 1828 | KEY `I_ube_report_outcome_fleet_report_fleet` (`ube_report_id`, `ube_report_outcome_fleet_fleet_id`), |
1829 | 1829 | CONSTRAINT `FK_ube_report_outcome_fleet_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1830 | 1830 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1831 | - ); |
|
1832 | - } |
|
1831 | + ); |
|
1832 | + } |
|
1833 | 1833 | |
1834 | - if(!$update_tables['ube_report_outcome_unit']) { |
|
1835 | - upd_create_table('ube_report_outcome_unit', |
|
1836 | - "( |
|
1834 | + if(!$update_tables['ube_report_outcome_unit']) { |
|
1835 | + upd_create_table('ube_report_outcome_unit', |
|
1836 | + "( |
|
1837 | 1837 | `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID', |
1838 | 1838 | |
1839 | 1839 | `ube_report_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Report ID', |
@@ -1849,12 +1849,12 @@ discard block |
||
1849 | 1849 | KEY `I_ube_report_outcome_unit_report_order` (`ube_report_id`, `ube_report_outcome_unit_sort_order`), |
1850 | 1850 | CONSTRAINT `FK_ube_report_outcome_unit_ube_report` FOREIGN KEY (`ube_report_id`) REFERENCES `{{ube_report}}` (`ube_report_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1851 | 1851 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1852 | - ); |
|
1853 | - } |
|
1852 | + ); |
|
1853 | + } |
|
1854 | 1854 | |
1855 | - if(!$update_tables['unit']) { |
|
1856 | - upd_create_table('unit', |
|
1857 | - "( |
|
1855 | + if(!$update_tables['unit']) { |
|
1856 | + upd_create_table('unit', |
|
1857 | + "( |
|
1858 | 1858 | `unit_id` SERIAL COMMENT 'Record ID', |
1859 | 1859 | |
1860 | 1860 | `unit_player_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Unit owner', |
@@ -1868,12 +1868,12 @@ discard block |
||
1868 | 1868 | KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`), |
1869 | 1869 | CONSTRAINT `FK_unit_player_id` FOREIGN KEY (`unit_player_id`) REFERENCES `{{users}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
1870 | 1870 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1871 | - ); |
|
1872 | - } |
|
1871 | + ); |
|
1872 | + } |
|
1873 | 1873 | |
1874 | - if(!$update_tables['captain']) { |
|
1875 | - upd_create_table('captain', |
|
1876 | - "( |
|
1874 | + if(!$update_tables['captain']) { |
|
1875 | + upd_create_table('captain', |
|
1876 | + "( |
|
1877 | 1877 | `captain_id` SERIAL COMMENT 'Record ID', |
1878 | 1878 | `captain_unit_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Link to `unit` record', |
1879 | 1879 | |
@@ -1888,34 +1888,34 @@ discard block |
||
1888 | 1888 | KEY `I_captain_unit_id` (`captain_unit_id`), |
1889 | 1889 | CONSTRAINT `FK_captain_unit_id` FOREIGN KEY (`captain_unit_id`) REFERENCES `{{unit}}` (`unit_id`) ON UPDATE CASCADE ON DELETE CASCADE |
1890 | 1890 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1891 | - ); |
|
1892 | - } |
|
1891 | + ); |
|
1892 | + } |
|
1893 | 1893 | |
1894 | - if(!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1895 | - upd_alter_table('fleets', array( |
|
1896 | - "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
|
1897 | - "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
|
1894 | + if(!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1895 | + upd_alter_table('fleets', array( |
|
1896 | + "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
|
1897 | + "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
|
1898 | 1898 | |
1899 | - "ADD KEY `I_fleet_start_planet_id` (`fleet_start_planet_id`)", |
|
1900 | - "ADD KEY `I_fleet_end_planet_id` (`fleet_end_planet_id`)", |
|
1899 | + "ADD KEY `I_fleet_start_planet_id` (`fleet_start_planet_id`)", |
|
1900 | + "ADD KEY `I_fleet_end_planet_id` (`fleet_end_planet_id`)", |
|
1901 | 1901 | |
1902 | - "ADD CONSTRAINT `FK_fleet_planet_start` FOREIGN KEY (`fleet_start_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1903 | - "ADD CONSTRAINT `FK_fleet_planet_end` FOREIGN KEY (`fleet_end_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1904 | - ), !$update_tables['fleets']['fleet_start_planet_id']); |
|
1902 | + "ADD CONSTRAINT `FK_fleet_planet_start` FOREIGN KEY (`fleet_start_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1903 | + "ADD CONSTRAINT `FK_fleet_planet_end` FOREIGN KEY (`fleet_end_planet_id`) REFERENCES `{{planets}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1904 | + ), !$update_tables['fleets']['fleet_start_planet_id']); |
|
1905 | 1905 | |
1906 | - upd_do_query(" |
|
1906 | + upd_do_query(" |
|
1907 | 1907 | UPDATE {{fleets}} AS f |
1908 | 1908 | 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 |
1909 | 1909 | 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 |
1910 | 1910 | SET f.fleet_start_planet_id = p_s.id, f.fleet_end_planet_id = p_e.id |
1911 | 1911 | "); |
1912 | - } |
|
1912 | + } |
|
1913 | 1913 | |
1914 | - upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
|
1914 | + upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
|
1915 | 1915 | |
1916 | - if(!$update_tables['chat_player']) { |
|
1917 | - upd_create_table('chat_player', |
|
1918 | - "( |
|
1916 | + if(!$update_tables['chat_player']) { |
|
1917 | + upd_create_table('chat_player', |
|
1918 | + "( |
|
1919 | 1919 | `chat_player_id` SERIAL COMMENT 'Record ID', |
1920 | 1920 | |
1921 | 1921 | `chat_player_player_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Chat player record owner', |
@@ -1931,102 +1931,102 @@ discard block |
||
1931 | 1931 | CONSTRAINT `FK_chat_player_id` FOREIGN KEY (`chat_player_player_id`) REFERENCES `{{users}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
1932 | 1932 | |
1933 | 1933 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
1934 | - ); |
|
1935 | - } |
|
1936 | - |
|
1937 | - upd_alter_table('chat', array( |
|
1938 | - "ADD `chat_message_sender_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message sender ID' AFTER `messageid`", |
|
1939 | - "ADD `chat_message_recipient_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message recipient ID' AFTER `user`", |
|
1940 | - |
|
1941 | - "ADD KEY `I_chat_message_sender_id` (`chat_message_sender_id`)", |
|
1942 | - "ADD KEY `I_chat_message_recipient_id` (`chat_message_recipient_id`)", |
|
1934 | + ); |
|
1935 | + } |
|
1943 | 1936 | |
1944 | - "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1945 | - "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1946 | - ), !$update_tables['chat']['chat_message_sender_id']); |
|
1937 | + upd_alter_table('chat', array( |
|
1938 | + "ADD `chat_message_sender_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message sender ID' AFTER `messageid`", |
|
1939 | + "ADD `chat_message_recipient_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Message recipient ID' AFTER `user`", |
|
1947 | 1940 | |
1948 | - upd_alter_table('chat', array( |
|
1949 | - "ADD `chat_message_sender_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_sender_id`", |
|
1950 | - "ADD `chat_message_recipient_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_recipient_id`", |
|
1951 | - ), !$update_tables['chat']['chat_message_sender_name']); |
|
1941 | + "ADD KEY `I_chat_message_sender_id` (`chat_message_sender_id`)", |
|
1942 | + "ADD KEY `I_chat_message_recipient_id` (`chat_message_recipient_id`)", |
|
1952 | 1943 | |
1953 | - upd_alter_table('users', array( |
|
1954 | - "MODIFY COLUMN `banaday` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ban status'", |
|
1955 | - ), strtoupper($update_tables['users']['banaday']['Null']) == 'YES'); |
|
1944 | + "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1945 | + "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1946 | + ), !$update_tables['chat']['chat_message_sender_id']); |
|
1956 | 1947 | |
1957 | - upd_alter_table('banned', array( |
|
1958 | - "ADD `ban_user_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banned user ID' AFTER `ban_id`", |
|
1959 | - "ADD `ban_issuer_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banner ID' AFTER `ban_until`", |
|
1948 | + upd_alter_table('chat', array( |
|
1949 | + "ADD `chat_message_sender_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_sender_id`", |
|
1950 | + "ADD `chat_message_recipient_name` VARCHAR(64) DEFAULT '' COMMENT 'Message sender name' AFTER `chat_message_recipient_id`", |
|
1951 | + ), !$update_tables['chat']['chat_message_sender_name']); |
|
1960 | 1952 | |
1961 | - "ADD KEY `I_ban_user_id` (`ban_user_id`)", |
|
1962 | - "ADD KEY `I_ban_issuer_id` (`ban_issuer_id`)", |
|
1953 | + upd_alter_table('users', array( |
|
1954 | + "MODIFY COLUMN `banaday` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'User ban status'", |
|
1955 | + ), strtoupper($update_tables['users']['banaday']['Null']) == 'YES'); |
|
1963 | 1956 | |
1964 | - "ADD CONSTRAINT `FK_ban_user_id` FOREIGN KEY (`ban_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1965 | - "ADD CONSTRAINT `FK_ban_issuer_id` FOREIGN KEY (`ban_issuer_id`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1966 | - ), !$update_tables['banned']['ban_user_id']); |
|
1957 | + upd_alter_table('banned', array( |
|
1958 | + "ADD `ban_user_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banned user ID' AFTER `ban_id`", |
|
1959 | + "ADD `ban_issuer_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Banner ID' AFTER `ban_until`", |
|
1967 | 1960 | |
1968 | - upd_do_query('COMMIT;', true); |
|
1969 | - $new_version = 36; |
|
1961 | + "ADD KEY `I_ban_user_id` (`ban_user_id`)", |
|
1962 | + "ADD KEY `I_ban_issuer_id` (`ban_issuer_id`)", |
|
1970 | 1963 | |
1971 | - case 36: |
|
1972 | - upd_log_version_update(); |
|
1964 | + "ADD CONSTRAINT `FK_ban_user_id` FOREIGN KEY (`ban_user_id`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1965 | + "ADD CONSTRAINT `FK_ban_issuer_id` FOREIGN KEY (`ban_issuer_id`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
1966 | + ), !$update_tables['banned']['ban_user_id']); |
|
1973 | 1967 | |
1974 | - upd_alter_table('payment', array( |
|
1975 | - "DROP FOREIGN KEY `FK_payment_user`", |
|
1976 | - ), $update_foreigns['payment']['FK_payment_user']); |
|
1968 | + upd_do_query('COMMIT;', true); |
|
1969 | + $new_version = 36; |
|
1977 | 1970 | |
1978 | - if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1979 | - upd_alter_table('chat', array( |
|
1980 | - "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
|
1981 | - "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
|
1982 | - ), true); |
|
1971 | + case 36: |
|
1972 | + upd_log_version_update(); |
|
1983 | 1973 | |
1984 | - upd_alter_table('chat', array( |
|
1985 | - "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1986 | - "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1987 | - ), true); |
|
1988 | - } |
|
1974 | + upd_alter_table('payment', array( |
|
1975 | + "DROP FOREIGN KEY `FK_payment_user`", |
|
1976 | + ), $update_foreigns['payment']['FK_payment_user']); |
|
1977 | + |
|
1978 | + if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1979 | + upd_alter_table('chat', array( |
|
1980 | + "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
|
1981 | + "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
|
1982 | + ), true); |
|
1983 | + |
|
1984 | + upd_alter_table('chat', array( |
|
1985 | + "ADD CONSTRAINT `FK_chat_message_sender_user_id` FOREIGN KEY (`chat_message_sender_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1986 | + "ADD CONSTRAINT `FK_chat_message_sender_recipient_id` FOREIGN KEY (`chat_message_recipient_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
1987 | + ), true); |
|
1988 | + } |
|
1989 | 1989 | |
1990 | - upd_alter_table('users', array( |
|
1991 | - "ADD `user_time_diff` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `onlinetime`", |
|
1992 | - "ADD `user_time_diff_forced` TINYINT(1) DEFAULT 0 COMMENT 'User time difference forced with time zone selection flag' AFTER `user_time_diff`", |
|
1993 | - ), !$update_tables['users']['user_time_diff']); |
|
1990 | + upd_alter_table('users', array( |
|
1991 | + "ADD `user_time_diff` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `onlinetime`", |
|
1992 | + "ADD `user_time_diff_forced` TINYINT(1) DEFAULT 0 COMMENT 'User time difference forced with time zone selection flag' AFTER `user_time_diff`", |
|
1993 | + ), !$update_tables['users']['user_time_diff']); |
|
1994 | 1994 | |
1995 | - upd_alter_table('planets', array( |
|
1996 | - "ADD `ship_orbital_heavy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'HOPe - Heavy Orbital Platform'", |
|
1997 | - ), !$update_tables['planets']['ship_orbital_heavy']); |
|
1995 | + upd_alter_table('planets', array( |
|
1996 | + "ADD `ship_orbital_heavy` bigint(20) NOT NULL DEFAULT '0' COMMENT 'HOPe - Heavy Orbital Platform'", |
|
1997 | + ), !$update_tables['planets']['ship_orbital_heavy']); |
|
1998 | 1998 | |
1999 | - upd_check_key('chat_refresh_rate', 5, !isset(classSupernova::$config->chat_refresh_rate)); |
|
1999 | + upd_check_key('chat_refresh_rate', 5, !isset(classSupernova::$config->chat_refresh_rate)); |
|
2000 | 2000 | |
2001 | - upd_alter_table('chat_player', array( |
|
2002 | - "ADD `chat_player_refresh_last` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player last refresh time'", |
|
2001 | + upd_alter_table('chat_player', array( |
|
2002 | + "ADD `chat_player_refresh_last` INT(11) NOT NULL DEFAULT 0 COMMENT 'Player last refresh time'", |
|
2003 | 2003 | |
2004 | - "ADD KEY `I_chat_player_refresh_last` (`chat_player_refresh_last`)", |
|
2005 | - ), !$update_tables['chat_player']['chat_player_refresh_last']); |
|
2004 | + "ADD KEY `I_chat_player_refresh_last` (`chat_player_refresh_last`)", |
|
2005 | + ), !$update_tables['chat_player']['chat_player_refresh_last']); |
|
2006 | 2006 | |
2007 | - upd_alter_table('ube_report', array( |
|
2008 | - "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
|
2009 | - ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
|
2007 | + upd_alter_table('ube_report', array( |
|
2008 | + "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
|
2009 | + ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
|
2010 | 2010 | |
2011 | - if(!$update_tables['unit']['unit_time_start']) { |
|
2012 | - upd_alter_table('unit', array( |
|
2013 | - "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
|
2014 | - "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
|
2015 | - ), !$update_tables['unit']['unit_time_start']); |
|
2011 | + if(!$update_tables['unit']['unit_time_start']) { |
|
2012 | + upd_alter_table('unit', array( |
|
2013 | + "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
|
2014 | + "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
|
2015 | + ), !$update_tables['unit']['unit_time_start']); |
|
2016 | 2016 | |
2017 | - upd_do_query( |
|
2018 | - "INSERT INTO {{unit}} |
|
2017 | + upd_do_query( |
|
2018 | + "INSERT INTO {{unit}} |
|
2019 | 2019 | (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish) |
2020 | 2020 | SELECT |
2021 | 2021 | `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level` |
2022 | 2022 | , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL) |
2023 | 2023 | FROM {{powerup}}" |
2024 | - ); |
|
2025 | - } |
|
2024 | + ); |
|
2025 | + } |
|
2026 | 2026 | |
2027 | - if(!$update_tables['que']) { |
|
2028 | - upd_create_table('que', |
|
2029 | - "( |
|
2027 | + if(!$update_tables['que']) { |
|
2028 | + upd_create_table('que', |
|
2029 | + "( |
|
2030 | 2030 | `que_id` SERIAL COMMENT 'Internal que id', |
2031 | 2031 | |
2032 | 2032 | `que_player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Que owner ID', |
@@ -2052,151 +2052,151 @@ discard block |
||
2052 | 2052 | CONSTRAINT `FK_que_planet_id` FOREIGN KEY (`que_planet_id`) REFERENCES `{{planets}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE, |
2053 | 2053 | CONSTRAINT `FK_que_planet_id_origin` FOREIGN KEY (`que_planet_id_origin`) REFERENCES `{{planets}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
2054 | 2054 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
2055 | - ); |
|
2056 | - } |
|
2055 | + ); |
|
2056 | + } |
|
2057 | 2057 | |
2058 | - // Конвертирум очередь исследований |
|
2059 | - if($update_tables['users']['que']) { |
|
2060 | - $que_lines = array(); |
|
2061 | - $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
|
2062 | - while($que_row = db_fetch($que_query)) { |
|
2063 | - $que_data = explode(',', $que_row['que']); |
|
2058 | + // Конвертирум очередь исследований |
|
2059 | + if($update_tables['users']['que']) { |
|
2060 | + $que_lines = array(); |
|
2061 | + $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
|
2062 | + while($que_row = db_fetch($que_query)) { |
|
2063 | + $que_data = explode(',', $que_row['que']); |
|
2064 | 2064 | |
2065 | - if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2066 | - continue; |
|
2067 | - } |
|
2065 | + if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2066 | + continue; |
|
2067 | + } |
|
2068 | 2068 | |
2069 | - $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
|
2070 | - // Если планета пустая - ставим главку |
|
2071 | - $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
|
2072 | - if($que_data[QI_PLANET_ID]) { |
|
2073 | - $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
|
2074 | - if(!$que_planet_check['id']) { |
|
2075 | - $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
|
2069 | + $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
|
2070 | + // Если планета пустая - ставим главку |
|
2071 | + $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
|
2072 | + if($que_data[QI_PLANET_ID]) { |
|
2076 | 2073 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
2077 | 2074 | if(!$que_planet_check['id']) { |
2078 | - $que_data[QI_PLANET_ID] = 'NULL'; |
|
2075 | + $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
|
2076 | + $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
|
2077 | + if(!$que_planet_check['id']) { |
|
2078 | + $que_data[QI_PLANET_ID] = 'NULL'; |
|
2079 | + } |
|
2079 | 2080 | } |
2081 | + } else { |
|
2082 | + $que_data[QI_PLANET_ID] = 'NULL'; |
|
2080 | 2083 | } |
2081 | - } else { |
|
2082 | - $que_data[QI_PLANET_ID] = 'NULL'; |
|
2083 | - } |
|
2084 | 2084 | |
2085 | - $unit_info = get_unit_param($que_data[QI_UNIT_ID]); |
|
2086 | - $unit_level = $que_row[$unit_info[P_NAME]]; |
|
2087 | - $unit_factor = $unit_info[P_COST][P_FACTOR] ? $unit_info[P_COST][P_FACTOR] : 1; |
|
2088 | - $price_increase = pow($unit_factor, $unit_level); |
|
2089 | - $unit_level++; |
|
2090 | - $unit_cost = array(); |
|
2091 | - foreach($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2092 | - if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2093 | - continue; |
|
2085 | + $unit_info = get_unit_param($que_data[QI_UNIT_ID]); |
|
2086 | + $unit_level = $que_row[$unit_info[P_NAME]]; |
|
2087 | + $unit_factor = $unit_info[P_COST][P_FACTOR] ? $unit_info[P_COST][P_FACTOR] : 1; |
|
2088 | + $price_increase = pow($unit_factor, $unit_level); |
|
2089 | + $unit_level++; |
|
2090 | + $unit_cost = array(); |
|
2091 | + foreach($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2092 | + if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2093 | + continue; |
|
2094 | + } |
|
2095 | + $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
|
2094 | 2096 | } |
2095 | - $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
|
2097 | + $unit_cost = implode(';', $unit_cost); |
|
2098 | + |
|
2099 | + $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," . |
|
2100 | + BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
2096 | 2101 | } |
2097 | - $unit_cost = implode(';', $unit_cost); |
|
2098 | 2102 | |
2099 | - $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," . |
|
2100 | - BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
2101 | - } |
|
2103 | + if(!empty($que_lines)) { |
|
2104 | + 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)); |
|
2105 | + } |
|
2102 | 2106 | |
2103 | - if(!empty($que_lines)) { |
|
2104 | - 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)); |
|
2107 | + upd_alter_table('users', array( |
|
2108 | + "DROP COLUMN `que`", |
|
2109 | + ), $update_tables['users']['que']); |
|
2105 | 2110 | } |
2106 | 2111 | |
2107 | - upd_alter_table('users', array( |
|
2108 | - "DROP COLUMN `que`", |
|
2109 | - ), $update_tables['users']['que']); |
|
2110 | - } |
|
2111 | 2112 | |
2113 | + upd_check_key('server_que_length_research', 1, !isset(classSupernova::$config->server_que_length_research)); |
|
2112 | 2114 | |
2113 | - upd_check_key('server_que_length_research', 1, !isset(classSupernova::$config->server_que_length_research)); |
|
2114 | 2115 | |
2116 | + // Ковертируем технологии в таблицы |
|
2117 | + if($update_tables['users']['graviton_tech']) { |
|
2118 | + upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
|
2115 | 2119 | |
2116 | - // Ковертируем технологии в таблицы |
|
2117 | - if($update_tables['users']['graviton_tech']) { |
|
2118 | - upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
|
2119 | - |
|
2120 | - $que_lines = array(); |
|
2121 | - $user_query = upd_do_query("SELECT * FROM {{users}}"); |
|
2122 | - upd_add_more_time(300); |
|
2123 | - $sn_group_tech = sn_get_groups('tech'); |
|
2124 | - while($user_row = db_fetch($user_query)) { |
|
2125 | - foreach($sn_group_tech as $tech_id) { |
|
2126 | - if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2127 | - $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
|
2120 | + $que_lines = array(); |
|
2121 | + $user_query = upd_do_query("SELECT * FROM {{users}}"); |
|
2122 | + upd_add_more_time(300); |
|
2123 | + $sn_group_tech = sn_get_groups('tech'); |
|
2124 | + while($user_row = db_fetch($user_query)) { |
|
2125 | + foreach($sn_group_tech as $tech_id) { |
|
2126 | + if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2127 | + $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
|
2128 | + } |
|
2128 | 2129 | } |
2129 | 2130 | } |
2130 | - } |
|
2131 | 2131 | |
2132 | - if(!empty($que_lines)) { |
|
2133 | - 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)); |
|
2134 | - } |
|
2132 | + if(!empty($que_lines)) { |
|
2133 | + 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)); |
|
2134 | + } |
|
2135 | 2135 | |
2136 | - upd_alter_table('users', array( |
|
2137 | - "DROP COLUMN `graviton_tech`", |
|
2138 | - ), $update_tables['users']['graviton_tech']); |
|
2139 | - } |
|
2136 | + upd_alter_table('users', array( |
|
2137 | + "DROP COLUMN `graviton_tech`", |
|
2138 | + ), $update_tables['users']['graviton_tech']); |
|
2139 | + } |
|
2140 | 2140 | |
2141 | - if(!$update_indexes['unit']['I_unit_record_search']) { |
|
2142 | - upd_alter_table('unit', array( |
|
2143 | - "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
|
2144 | - ), !$update_indexes['unit']['I_unit_record_search']); |
|
2141 | + if(!$update_indexes['unit']['I_unit_record_search']) { |
|
2142 | + upd_alter_table('unit', array( |
|
2143 | + "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
|
2144 | + ), !$update_indexes['unit']['I_unit_record_search']); |
|
2145 | 2145 | |
2146 | - foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2147 | - $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
|
2148 | - } |
|
2149 | - $drop_index = array(); |
|
2150 | - $create_index = &$drop_index; // array(); |
|
2151 | - foreach($planet_units as $unit_name => $unit_create) { |
|
2152 | - if($update_indexes['planets']['I_' . $unit_name]) { |
|
2153 | - $drop_index[] = "DROP KEY I_{$unit_name}"; |
|
2154 | - } |
|
2155 | - if($update_indexes['planets']['i_' . $unit_name]) { |
|
2156 | - $drop_index[] = "DROP KEY i_{$unit_name}"; |
|
2146 | + foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2147 | + $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
|
2157 | 2148 | } |
2149 | + $drop_index = array(); |
|
2150 | + $create_index = &$drop_index; // array(); |
|
2151 | + foreach($planet_units as $unit_name => $unit_create) { |
|
2152 | + if($update_indexes['planets']['I_' . $unit_name]) { |
|
2153 | + $drop_index[] = "DROP KEY I_{$unit_name}"; |
|
2154 | + } |
|
2155 | + if($update_indexes['planets']['i_' . $unit_name]) { |
|
2156 | + $drop_index[] = "DROP KEY i_{$unit_name}"; |
|
2157 | + } |
|
2158 | 2158 | |
2159 | - if($unit_create) { |
|
2160 | - $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
|
2159 | + if($unit_create) { |
|
2160 | + $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
|
2161 | + } |
|
2161 | 2162 | } |
2163 | + upd_alter_table('planets', $drop_index, true); |
|
2162 | 2164 | } |
2163 | - upd_alter_table('planets', $drop_index, true); |
|
2164 | - } |
|
2165 | 2165 | |
2166 | - upd_alter_table('users', array( |
|
2167 | - "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
|
2168 | - ), !$update_tables['users']['user_time_utc_offset']); |
|
2166 | + upd_alter_table('users', array( |
|
2167 | + "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
|
2168 | + ), !$update_tables['users']['user_time_utc_offset']); |
|
2169 | 2169 | |
2170 | - if(!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2171 | - upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})"); |
|
2170 | + if(!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2171 | + upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})"); |
|
2172 | 2172 | |
2173 | - upd_alter_table('alliance', array( |
|
2174 | - "ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
2175 | - ), !$update_foreigns['alliance']['FK_alliance_owner']); |
|
2173 | + upd_alter_table('alliance', array( |
|
2174 | + "ADD CONSTRAINT `FK_alliance_owner` FOREIGN KEY (`ally_owner`) REFERENCES `{{users}}` (`id`) ON DELETE SET NULL ON UPDATE CASCADE", |
|
2175 | + ), !$update_foreigns['alliance']['FK_alliance_owner']); |
|
2176 | 2176 | |
2177 | - 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}})"); |
|
2177 | + 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}})"); |
|
2178 | 2178 | |
2179 | - upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id"); |
|
2180 | - upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id"); |
|
2181 | - } |
|
2179 | + upd_do_query("DELETE FROM {{alliance_negotiation}} WHERE alliance_negotiation_ally_id = alliance_negotiation_contr_ally_id"); |
|
2180 | + upd_do_query("DELETE FROM {{alliance_diplomacy}} WHERE alliance_diplomacy_ally_id = alliance_diplomacy_contr_ally_id"); |
|
2181 | + } |
|
2182 | 2182 | |
2183 | - upd_alter_table('fleets', array( |
|
2184 | - 'MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
2185 | - "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
2186 | - ), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
2183 | + upd_alter_table('fleets', array( |
|
2184 | + 'MODIFY COLUMN `fleet_owner` BIGINT(20) UNSIGNED DEFAULT NULL', |
|
2185 | + "ADD CONSTRAINT `FK_fleet_owner` FOREIGN KEY (`fleet_owner`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE", |
|
2186 | + ), strtoupper($update_tables['fleets']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
|
2187 | 2187 | |
2188 | - upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer); |
|
2188 | + upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer); |
|
2189 | 2189 | |
2190 | - if(!$update_tables['player_name_history']) { |
|
2191 | - upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost); |
|
2192 | - upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
|
2190 | + if(!$update_tables['player_name_history']) { |
|
2191 | + upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost); |
|
2192 | + upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
|
2193 | 2193 | |
2194 | - upd_alter_table('users', array( |
|
2195 | - "CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'", |
|
2196 | - )); |
|
2194 | + upd_alter_table('users', array( |
|
2195 | + "CHANGE COLUMN `username` `username` VARCHAR(32) NOT NULL DEFAULT '' COMMENT 'Player name'", |
|
2196 | + )); |
|
2197 | 2197 | |
2198 | - upd_create_table('player_name_history', |
|
2199 | - "( |
|
2198 | + upd_create_table('player_name_history', |
|
2199 | + "( |
|
2200 | 2200 | `player_id` BIGINT(20) UNSIGNED NULL DEFAULT NULL COMMENT 'Player ID', |
2201 | 2201 | `player_name` VARCHAR(32) NOT NULL COMMENT 'Historical player name', |
2202 | 2202 | `timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'When player changed name', |
@@ -2206,74 +2206,74 @@ discard block |
||
2206 | 2206 | |
2207 | 2207 | CONSTRAINT `FK_player_name_history_id` FOREIGN KEY (`player_id`) REFERENCES `{{users}}` (`id`) ON UPDATE CASCADE ON DELETE CASCADE |
2208 | 2208 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
2209 | - ); |
|
2209 | + ); |
|
2210 | 2210 | |
2211 | - upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;"); |
|
2212 | - } |
|
2211 | + upd_do_query("REPLACE INTO {{player_name_history}} (`player_id`, `player_name`) SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NULL;"); |
|
2212 | + } |
|
2213 | 2213 | |
2214 | - upd_alter_table('planets', array( |
|
2215 | - "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", |
|
2216 | - "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
|
2217 | - ), !$update_tables['planets']['density_index']); |
|
2214 | + upd_alter_table('planets', array( |
|
2215 | + "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", |
|
2216 | + "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
|
2217 | + ), !$update_tables['planets']['density_index']); |
|
2218 | 2218 | |
2219 | - if($update_tables['users']['player_artifact_list']) { |
|
2220 | - upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
|
2219 | + if($update_tables['users']['player_artifact_list']) { |
|
2220 | + upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
|
2221 | 2221 | |
2222 | - 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']); |
|
2223 | - upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']); |
|
2222 | + 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']); |
|
2223 | + upd_alter_table('unit', "DROP KEY `I_unit_player_id_temporary`", $update_indexes['unit']['I_unit_player_id_temporary']); |
|
2224 | 2224 | |
2225 | - $sn_data_artifacts = sn_get_groups('artifacts'); |
|
2226 | - $db_changeset = array(); |
|
2225 | + $sn_data_artifacts = sn_get_groups('artifacts'); |
|
2226 | + $db_changeset = array(); |
|
2227 | 2227 | |
2228 | - $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
|
2229 | - while($row = db_fetch($query)) { |
|
2230 | - $artifact_list = explode(';', $row['player_artifact_list']); |
|
2231 | - if(!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2232 | - continue; |
|
2233 | - } |
|
2234 | - foreach($artifact_list as $key => &$value) { |
|
2235 | - $value = explode(',', $value); |
|
2236 | - if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2237 | - unset($artifact_list[$key]); |
|
2228 | + $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
|
2229 | + while($row = db_fetch($query)) { |
|
2230 | + $artifact_list = explode(';', $row['player_artifact_list']); |
|
2231 | + if(!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2238 | 2232 | continue; |
2239 | 2233 | } |
2240 | - $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row); |
|
2234 | + foreach($artifact_list as $key => &$value) { |
|
2235 | + $value = explode(',', $value); |
|
2236 | + if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2237 | + unset($artifact_list[$key]); |
|
2238 | + continue; |
|
2239 | + } |
|
2240 | + $db_changeset['unit'][] = upd_db_unit_changeset_prepare($value[0], $value[1], $row); |
|
2241 | + } |
|
2241 | 2242 | } |
2242 | - } |
|
2243 | - upd_db_changeset_apply($db_changeset); |
|
2243 | + upd_db_changeset_apply($db_changeset); |
|
2244 | 2244 | |
2245 | - upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']); |
|
2246 | - } |
|
2245 | + upd_alter_table('users', "DROP COLUMN `player_artifact_list`", $update_tables['users']['player_artifact_list']); |
|
2246 | + } |
|
2247 | 2247 | |
2248 | - upd_alter_table('users', array( |
|
2249 | - "DROP COLUMN `spy_tech`", |
|
2250 | - "DROP COLUMN `computer_tech`", |
|
2251 | - "DROP COLUMN `military_tech`", |
|
2252 | - "DROP COLUMN `defence_tech`", |
|
2253 | - "DROP COLUMN `shield_tech`", |
|
2254 | - "DROP COLUMN `energy_tech`", |
|
2255 | - "DROP COLUMN `hyperspace_tech`", |
|
2256 | - "DROP COLUMN `combustion_tech`", |
|
2257 | - "DROP COLUMN `impulse_motor_tech`", |
|
2258 | - "DROP COLUMN `hyperspace_motor_tech`", |
|
2259 | - "DROP COLUMN `laser_tech`", |
|
2260 | - "DROP COLUMN `ionic_tech`", |
|
2261 | - "DROP COLUMN `buster_tech`", |
|
2262 | - "DROP COLUMN `intergalactic_tech`", |
|
2263 | - "DROP COLUMN `expedition_tech`", |
|
2264 | - "DROP COLUMN `colonisation_tech`", |
|
2265 | - ), $update_tables['users']['spy_tech']); |
|
2266 | - |
|
2267 | - upd_check_key('payment_currency_exchange_dm_', 2500, !classSupernova::$config->payment_currency_exchange_dm_ || classSupernova::$config->payment_currency_exchange_dm_ == 1000); |
|
2268 | - upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !classSupernova::$config->payment_currency_exchange_eur); |
|
2269 | - upd_check_key('payment_currency_exchange_rub', 4.0, !classSupernova::$config->payment_currency_exchange_rub); |
|
2270 | - upd_check_key('payment_currency_exchange_usd', 0.125, !classSupernova::$config->payment_currency_exchange_usd); |
|
2271 | - upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !classSupernova::$config->payment_currency_exchange_usd); |
|
2272 | - upd_check_key('payment_currency_exchange_wmr', 4.1, !classSupernova::$config->payment_currency_exchange_wmr); |
|
2273 | - upd_check_key('payment_currency_exchange_wmu', 1.05, !classSupernova::$config->payment_currency_exchange_wmu); |
|
2274 | - upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !classSupernova::$config->payment_currency_exchange_wmz); |
|
2248 | + upd_alter_table('users', array( |
|
2249 | + "DROP COLUMN `spy_tech`", |
|
2250 | + "DROP COLUMN `computer_tech`", |
|
2251 | + "DROP COLUMN `military_tech`", |
|
2252 | + "DROP COLUMN `defence_tech`", |
|
2253 | + "DROP COLUMN `shield_tech`", |
|
2254 | + "DROP COLUMN `energy_tech`", |
|
2255 | + "DROP COLUMN `hyperspace_tech`", |
|
2256 | + "DROP COLUMN `combustion_tech`", |
|
2257 | + "DROP COLUMN `impulse_motor_tech`", |
|
2258 | + "DROP COLUMN `hyperspace_motor_tech`", |
|
2259 | + "DROP COLUMN `laser_tech`", |
|
2260 | + "DROP COLUMN `ionic_tech`", |
|
2261 | + "DROP COLUMN `buster_tech`", |
|
2262 | + "DROP COLUMN `intergalactic_tech`", |
|
2263 | + "DROP COLUMN `expedition_tech`", |
|
2264 | + "DROP COLUMN `colonisation_tech`", |
|
2265 | + ), $update_tables['users']['spy_tech']); |
|
2266 | + |
|
2267 | + upd_check_key('payment_currency_exchange_dm_', 2500, !classSupernova::$config->payment_currency_exchange_dm_ || classSupernova::$config->payment_currency_exchange_dm_ == 1000); |
|
2268 | + upd_check_key('payment_currency_exchange_eur', 0.09259259259259, !classSupernova::$config->payment_currency_exchange_eur); |
|
2269 | + upd_check_key('payment_currency_exchange_rub', 4.0, !classSupernova::$config->payment_currency_exchange_rub); |
|
2270 | + upd_check_key('payment_currency_exchange_usd', 0.125, !classSupernova::$config->payment_currency_exchange_usd); |
|
2271 | + upd_check_key('payment_currency_exchange_wme', 0.0952380952381, !classSupernova::$config->payment_currency_exchange_usd); |
|
2272 | + upd_check_key('payment_currency_exchange_wmr', 4.1, !classSupernova::$config->payment_currency_exchange_wmr); |
|
2273 | + upd_check_key('payment_currency_exchange_wmu', 1.05, !classSupernova::$config->payment_currency_exchange_wmu); |
|
2274 | + upd_check_key('payment_currency_exchange_wmz', 0.126582278481, !classSupernova::$config->payment_currency_exchange_wmz); |
|
2275 | 2275 | |
2276 | - upd_do_query('COMMIT;', true); |
|
2277 | - $new_version = 37; |
|
2276 | + upd_do_query('COMMIT;', true); |
|
2277 | + $new_version = 37; |
|
2278 | 2278 | |
2279 | 2279 | } |
@@ -1,10 +1,10 @@ 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 | die('Hack attempt'); |
5 | 5 | } |
6 | 6 | |
7 | -switch($new_version) { |
|
7 | +switch ($new_version) { |
|
8 | 8 | case 0: |
9 | 9 | case 1: |
10 | 10 | case 2: |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | ); |
33 | 33 | upd_drop_table('lunas'); |
34 | 34 | |
35 | - if($update_tables['galaxy']) { |
|
35 | + if ($update_tables['galaxy']) { |
|
36 | 36 | upd_do_query( |
37 | 37 | 'UPDATE `{{planets}}` |
38 | 38 | LEFT JOIN `{{galaxy}}` ON {{galaxy}}.id_planet = {{planets}}.id |
@@ -82,12 +82,12 @@ discard block |
||
82 | 82 | ); |
83 | 83 | upd_add_more_time(); |
84 | 84 | |
85 | - if($update_tables['users']['rpg_points']) { |
|
85 | + if ($update_tables['users']['rpg_points']) { |
|
86 | 86 | upd_do_query( |
87 | 87 | "UPDATE {{users}} AS u |
88 | 88 | RIGHT JOIN {{referrals}} AS r |
89 | - ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor . " |
|
90 | - SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor . ");" |
|
89 | + ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor." |
|
90 | + SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor.");" |
|
91 | 91 | ); |
92 | 92 | } |
93 | 93 | |
@@ -175,18 +175,18 @@ discard block |
||
175 | 175 | upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']); |
176 | 176 | upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']); |
177 | 177 | |
178 | - if($update_tables['planets']['b_building']) { |
|
178 | + if ($update_tables['planets']['b_building']) { |
|
179 | 179 | $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;'); |
180 | 180 | $const_que_structures = QUE_STRUCTURES; |
181 | - while($planet_data = db_fetch($planet_query)) { |
|
181 | + while ($planet_data = db_fetch($planet_query)) { |
|
182 | 182 | $old_que = explode(';', $planet_data['b_building_id']); |
183 | - foreach($old_que as $old_que_item_string) { |
|
184 | - if(!$old_que_item_string) { |
|
183 | + foreach ($old_que as $old_que_item_string) { |
|
184 | + if (!$old_que_item_string) { |
|
185 | 185 | continue; |
186 | 186 | } |
187 | 187 | |
188 | 188 | $old_que_item = explode(',', $old_que_item_string); |
189 | - if($old_que_item[4] == 'build') { |
|
189 | + if ($old_que_item[4] == 'build') { |
|
190 | 190 | $old_que_item[4] = BUILD_CREATE; |
191 | 191 | } else { |
192 | 192 | $old_que_item[4] = BUILD_DESTROY; |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;" |
220 | 220 | ); |
221 | 221 | |
222 | - if($update_tables['users']['urlaubs_until']) { |
|
222 | + if ($update_tables['users']['urlaubs_until']) { |
|
223 | 223 | upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']); |
224 | 224 | upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;'); |
225 | 225 | upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']); |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | ), !$update_tables['logs']['log_timestamp']); |
270 | 270 | upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;'); |
271 | 271 | |
272 | - if($update_tables['errors']) { |
|
272 | + if ($update_tables['errors']) { |
|
273 | 273 | 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}}`;'); |
274 | - if($update_tables['errors_backup']) { |
|
274 | + if ($update_tables['errors_backup']) { |
|
275 | 275 | upd_drop_table('errors_backup'); |
276 | 276 | } |
277 | - upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup'); |
|
277 | + upd_alter_table('errors', ' RENAME TO '.classSupernova::$config->db_prefix.'errors_backup'); |
|
278 | 278 | |
279 | 279 | upd_drop_table('errors'); |
280 | 280 | } |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | |
333 | 333 | upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci'); |
334 | 334 | |
335 | - if(!$update_tables['shortcut']) { |
|
335 | + if (!$update_tables['shortcut']) { |
|
336 | 336 | upd_create_table('shortcut', |
337 | 337 | "( |
338 | 338 | `shortcut_id` SERIAL, |
@@ -356,10 +356,10 @@ discard block |
||
356 | 356 | $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON); |
357 | 357 | |
358 | 358 | $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';"); |
359 | - while($user_data = db_fetch($query)) { |
|
359 | + while ($user_data = db_fetch($query)) { |
|
360 | 360 | $shortcuts = explode("\r\n", $user_data['fleet_shortcut']); |
361 | - foreach($shortcuts as $shortcut) { |
|
362 | - if(!$shortcut) { |
|
361 | + foreach ($shortcuts as $shortcut) { |
|
362 | + if (!$shortcut) { |
|
363 | 363 | continue; |
364 | 364 | } |
365 | 365 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | $shortcut[3] = intval($shortcut[3]); |
371 | 371 | $shortcut[4] = intval($shortcut[4]); |
372 | 372 | |
373 | - if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) { |
|
373 | + if ($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) { |
|
374 | 374 | $db_prefix = classSupernova::$config->db_prefix; |
375 | 375 | upd_do_query("INSERT INTO {$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); |
376 | 376 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | |
524 | 524 | upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total)); |
525 | 525 | |
526 | - for($i = 0; $i < 25; $i++) { |
|
526 | + for ($i = 0; $i < 25; $i++) { |
|
527 | 527 | upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]); |
528 | 528 | upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]); |
529 | 529 | upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]); |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist" |
552 | 552 | ), !$update_tables['users']['msg_admin']); |
553 | 553 | |
554 | - if(!$update_foreigns['users']['FK_users_ally_id']) { |
|
554 | + if (!$update_foreigns['users']['FK_users_ally_id']) { |
|
555 | 555 | upd_alter_table('users', array( |
556 | 556 | 'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL', |
557 | 557 | 'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL', |
@@ -573,7 +573,7 @@ discard block |
||
573 | 573 | ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED'); |
574 | 574 | |
575 | 575 | $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);"); |
576 | - while($illegal_moon_row = db_fetch($illegal_moon_query)) { |
|
576 | + while ($illegal_moon_row = db_fetch($illegal_moon_query)) { |
|
577 | 577 | upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true); |
578 | 578 | } |
579 | 579 | |
@@ -610,16 +610,16 @@ discard block |
||
610 | 610 | upd_do_query('COMMIT;', true); |
611 | 611 | |
612 | 612 | $records = 1; |
613 | - while($records) { |
|
613 | + while ($records) { |
|
614 | 614 | upd_do_query('START TRANSACTION;', true); |
615 | 615 | $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;"); |
616 | 616 | $records = classSupernova::$db->db_num_rows($query); |
617 | - while($row = db_fetch($query)) { |
|
617 | + while ($row = db_fetch($query)) { |
|
618 | 618 | $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches); |
619 | 619 | |
620 | 620 | $reason = RPG_NONE; |
621 | 621 | $comment = $matches[3]; |
622 | - switch($matches[3]) { |
|
622 | + switch ($matches[3]) { |
|
623 | 623 | case 'Level Up For Structure Building': |
624 | 624 | $reason = RPG_STRUCTURE; |
625 | 625 | break; |
@@ -635,22 +635,22 @@ discard block |
||
635 | 635 | break; |
636 | 636 | |
637 | 637 | default: |
638 | - if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) { |
|
638 | + if (preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) { |
|
639 | 639 | $reason = RPG_MARKET; |
640 | - } elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) { |
|
640 | + } elseif (preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) { |
|
641 | 641 | $reason = RPG_MERCENARY; |
642 | 642 | $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}"; |
643 | - } elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) { |
|
643 | + } elseif (preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) { |
|
644 | 644 | $reason = RPG_REFERRAL; |
645 | 645 | $comment = "Incoming from referral ID {$matches[1]}"; |
646 | - } elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) { |
|
646 | + } elseif (preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) { |
|
647 | 647 | $reason = RPG_ADMIN; |
648 | 648 | $comment = $matches2[1]; |
649 | 649 | } |
650 | 650 | break; |
651 | 651 | } |
652 | 652 | |
653 | - if($matches[2]) { |
|
653 | + if ($matches[2]) { |
|
654 | 654 | $row['log_username'] = db_escape($row['log_username']); |
655 | 655 | $row['log_page'] = db_escape($row['log_page']); |
656 | 656 | $comment = db_escape($comment); |
@@ -669,12 +669,12 @@ discard block |
||
669 | 669 | upd_do_query('COMMIT;', true); |
670 | 670 | } |
671 | 671 | |
672 | - foreach($update_tables as $table_name => $cork) { |
|
673 | - $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '" . classSupernova::$config->db_prefix . "{$table_name}';", true)); |
|
674 | - if($row['ENGINE'] != 'InnoDB') { |
|
672 | + foreach ($update_tables as $table_name => $cork) { |
|
673 | + $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '".classSupernova::$config->db_prefix."{$table_name}';", true)); |
|
674 | + if ($row['ENGINE'] != 'InnoDB') { |
|
675 | 675 | upd_alter_table($table_name, 'ENGINE=InnoDB', true); |
676 | 676 | } |
677 | - if($row['TABLE_COLLATION'] != 'utf8_general_ci') { |
|
677 | + if ($row['TABLE_COLLATION'] != 'utf8_general_ci') { |
|
678 | 678 | upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true); |
679 | 679 | } |
680 | 680 | } |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0", |
695 | 695 | ), !$update_tables['planets']['PLANET_GOVERNOR_ID']); |
696 | 696 | |
697 | - if($update_tables['users']['rpg_geologue']) { |
|
697 | + if ($update_tables['users']['rpg_geologue']) { |
|
698 | 698 | classSupernova::$db->doUpdate("UPDATE `{{users}}` SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;"); |
699 | 699 | |
700 | 700 | upd_alter_table('users', array( |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | ), $update_tables['users']['rpg_geologue']); |
708 | 708 | } |
709 | 709 | |
710 | - if($update_tables['users']['rpg_bunker']) { |
|
710 | + if ($update_tables['users']['rpg_bunker']) { |
|
711 | 711 | classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;"); |
712 | 712 | |
713 | 713 | upd_alter_table('users', array( |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | ), !isset($update_tables['alliance']['total_rank'])); |
758 | 758 | classSupernova::$db->doUpdate("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;"); |
759 | 759 | |
760 | - if(!isset($update_tables['users']['ally_tag'])) { |
|
760 | + if (!isset($update_tables['users']['ally_tag'])) { |
|
761 | 761 | upd_alter_table('users', array( |
762 | 762 | "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`", |
763 | 763 | ), !isset($update_tables['users']['ally_tag'])); |
@@ -772,7 +772,7 @@ discard block |
||
772 | 772 | "ADD COLUMN `player_artifact_list` TEXT", |
773 | 773 | ), !isset($update_tables['users']['player_artifact_list'])); |
774 | 774 | |
775 | - if(!isset($update_tables['users']['player_rpg_tech_xp'])) { |
|
775 | + if (!isset($update_tables['users']['player_rpg_tech_xp'])) { |
|
776 | 776 | upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage)); |
777 | 777 | |
778 | 778 | upd_alter_table('users', array( |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL", |
803 | 803 | ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED'); |
804 | 804 | |
805 | - if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
805 | + if (strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
806 | 806 | upd_alter_table('alliance_diplomacy', array( |
807 | 807 | "DROP FOREIGN KEY `FK_diplomacy_ally_id`", |
808 | 808 | "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`" |
@@ -817,7 +817,7 @@ discard block |
||
817 | 817 | ), true); |
818 | 818 | } |
819 | 819 | |
820 | - if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
820 | + if (strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
821 | 821 | upd_alter_table('alliance_negotiation', array( |
822 | 822 | "DROP FOREIGN KEY `FK_negotiation_ally_id`", |
823 | 823 | "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`" |
@@ -833,7 +833,7 @@ discard block |
||
833 | 833 | ), true); |
834 | 834 | } |
835 | 835 | |
836 | - if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
836 | + if (strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
837 | 837 | 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); |
838 | 838 | |
839 | 839 | upd_alter_table('alliance_requests', array( |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | ), true); |
848 | 848 | } |
849 | 849 | |
850 | - if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
850 | + if (strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
851 | 851 | upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true); |
852 | 852 | |
853 | 853 | upd_alter_table('annonce', array( |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | ), true); |
861 | 861 | } |
862 | 862 | |
863 | - if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
863 | + if (strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
864 | 864 | upd_alter_table('bashing', array( |
865 | 865 | "DROP FOREIGN KEY `FK_bashing_user_id`", |
866 | 866 | "DROP FOREIGN KEY `FK_bashing_planet_id`", |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | ), true); |
876 | 876 | } |
877 | 877 | |
878 | - if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
878 | + if (strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
879 | 879 | upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true); |
880 | 880 | |
881 | 881 | upd_alter_table('buddy', array( |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'", |
914 | 914 | ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)'); |
915 | 915 | |
916 | - if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
916 | + if (strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
917 | 917 | upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true); |
918 | 918 | |
919 | 919 | upd_alter_table('iraks', array( |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | ), true); |
938 | 938 | } |
939 | 939 | |
940 | - if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
940 | + if (strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
941 | 941 | upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true); |
942 | 942 | |
943 | 943 | upd_alter_table('notes', array( |
@@ -1062,7 +1062,7 @@ discard block |
||
1062 | 1062 | "DROP COLUMN `b_hangar_plus`", |
1063 | 1063 | ), isset($update_tables['planets']['b_hangar_plus'])); |
1064 | 1064 | |
1065 | - if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1065 | + if (strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1066 | 1066 | upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true); |
1067 | 1067 | |
1068 | 1068 | upd_alter_table('referrals', array( |
@@ -1081,7 +1081,7 @@ discard block |
||
1081 | 1081 | "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED", |
1082 | 1082 | ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED'); |
1083 | 1083 | |
1084 | - if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1084 | + if (strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1085 | 1085 | 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); |
1086 | 1086 | |
1087 | 1087 | upd_alter_table('shortcut', array( |
@@ -1096,7 +1096,7 @@ discard block |
||
1096 | 1096 | ), true); |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1099 | + if (strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1100 | 1100 | 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); |
1101 | 1101 | |
1102 | 1102 | upd_alter_table('statpoints', array( |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | "DROP COLUMN `settings_allylogo`", |
1251 | 1251 | ), isset($update_tables['users']['settings_allylogo'])); |
1252 | 1252 | |
1253 | - if(!isset($update_tables['powerup'])) { |
|
1253 | + if (!isset($update_tables['powerup'])) { |
|
1254 | 1254 | upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};"); |
1255 | 1255 | |
1256 | 1256 | upd_create_table('powerup', |
@@ -1280,24 +1280,24 @@ discard block |
||
1280 | 1280 | |
1281 | 1281 | $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;"; |
1282 | 1282 | $user_list = upd_do_query("SELECT * FROM {{users}};"); |
1283 | - while($user_row = db_fetch($user_list)) { |
|
1283 | + while ($user_row = db_fetch($user_list)) { |
|
1284 | 1284 | $update_query_str = ''; |
1285 | - foreach(sn_get_groups('mercenaries') as $mercenary_id) { |
|
1285 | + foreach (sn_get_groups('mercenaries') as $mercenary_id) { |
|
1286 | 1286 | $mercenary_data_name = get_unit_param($mercenary_id, P_NAME); |
1287 | - if($mercenary_level = $user_row[$mercenary_data_name]) { |
|
1287 | + if ($mercenary_level = $user_row[$mercenary_data_name]) { |
|
1288 | 1288 | $update_query_str = ", `{$mercenary_data_name}` = 0"; |
1289 | 1289 | upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;"); |
1290 | 1290 | upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};"); |
1291 | 1291 | } |
1292 | 1292 | } |
1293 | 1293 | |
1294 | - if($update_query_str) { |
|
1294 | + if ($update_query_str) { |
|
1295 | 1295 | upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id'])); |
1296 | 1296 | } |
1297 | 1297 | } |
1298 | 1298 | } |
1299 | 1299 | |
1300 | - if(!isset($update_tables['universe'])) { |
|
1300 | + if (!isset($update_tables['universe'])) { |
|
1301 | 1301 | upd_create_table('universe', |
1302 | 1302 | "( |
1303 | 1303 | `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0', |
@@ -1320,7 +1320,7 @@ discard block |
||
1320 | 1320 | |
1321 | 1321 | // ------------------------------------------------------------------------ |
1322 | 1322 | // Modifying tables |
1323 | - if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1323 | + if (strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') { |
|
1324 | 1324 | upd_alter_table('users', array( |
1325 | 1325 | "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL", |
1326 | 1326 | |
@@ -1341,7 +1341,7 @@ discard block |
||
1341 | 1341 | // ------------------------------------------------------------------------ |
1342 | 1342 | // Creating players for allies |
1343 | 1343 | $ally_row_list = classSupernova::$db->doSelect("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;"); |
1344 | - while($ally_row = db_fetch($ally_row_list)) { |
|
1344 | + while ($ally_row = db_fetch($ally_row_list)) { |
|
1345 | 1345 | classSupernova::$db->doInsertSet(TABLE_USERS, array( |
1346 | 1346 | 'username' => "[{$ally_row['ally_tag']}]", |
1347 | 1347 | 'register_time' => SN_TIME_NOW, |
@@ -1354,12 +1354,12 @@ discard block |
||
1354 | 1354 | // Renaming old ally players TODO: Remove on release |
1355 | 1355 | 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 = '';"); |
1356 | 1356 | // Setting last online time to old ally players TODO: Remove on release |
1357 | - upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;"); |
|
1357 | + upd_do_query("UPDATE {{users}} SET `onlinetime` = ".SN_TIME_NOW." WHERE onlinetime = 0;"); |
|
1358 | 1358 | |
1359 | 1359 | // ------------------------------------------------------------------------ |
1360 | 1360 | // Creating planets for allies |
1361 | 1361 | $ally_user_list = classSupernova::$db->doSelect("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
1362 | - while($ally_user_row = db_fetch($ally_user_list)) { |
|
1362 | + while ($ally_user_row = db_fetch($ally_user_list)) { |
|
1363 | 1363 | classSupernova::$db->doInsertSet(TABLE_PLANETS, array( |
1364 | 1364 | 'name' => $ally_user_row['username'], |
1365 | 1365 | 'last_update' => SN_TIME_NOW, |
@@ -1394,10 +1394,10 @@ discard block |
||
1394 | 1394 | // Adding db field |
1395 | 1395 | upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
1396 | 1396 | // Converting old data to new one and dropping old fields |
1397 | - if($update_tables['users']['b_tech_planet']) { |
|
1397 | + if ($update_tables['users']['b_tech_planet']) { |
|
1398 | 1398 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{planets}}` WHERE `b_tech_id` <> 0;"); |
1399 | - while($planet_row = db_fetch($query)) { |
|
1400 | - $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
|
1399 | + while ($planet_row = db_fetch($query)) { |
|
1400 | + $que_item_string = "{$planet_row['b_tech_id']},1,".max(0, $planet_row['b_tech'] - SN_TIME_NOW).",".BUILD_CREATE.",".QUE_RESEARCH; |
|
1401 | 1401 | classSupernova::$db->doUpdate("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
1402 | 1402 | } |
1403 | 1403 | |
@@ -1409,10 +1409,10 @@ discard block |
||
1409 | 1409 | upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
1410 | 1410 | } |
1411 | 1411 | |
1412 | - if(!$update_tables['powerup']['powerup_category']) { |
|
1412 | + if (!$update_tables['powerup']['powerup_category']) { |
|
1413 | 1413 | upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
1414 | 1414 | |
1415 | - classSupernova::$db->doUpdate("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
|
1415 | + classSupernova::$db->doUpdate("UPDATE {{powerup}} SET powerup_category = ".BONUS_MERCENARY); |
|
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info)); |
@@ -1430,7 +1430,7 @@ discard block |
||
1430 | 1430 | upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets)); |
1431 | 1431 | upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor)); |
1432 | 1432 | |
1433 | - if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1433 | + if (!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1434 | 1434 | $inflation_rate = 1000; |
1435 | 1435 | |
1436 | 1436 | classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate); |
@@ -1447,17 +1447,17 @@ discard block |
||
1447 | 1447 | classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
1448 | 1448 | |
1449 | 1449 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{quest}}`"); |
1450 | - while($row = db_fetch($query)) { |
|
1450 | + while ($row = db_fetch($query)) { |
|
1451 | 1451 | $query_add = ''; |
1452 | 1452 | $quest_reward_list = explode(';', $row['quest_rewards']); |
1453 | - foreach($quest_reward_list as &$quest_reward) { |
|
1453 | + foreach ($quest_reward_list as &$quest_reward) { |
|
1454 | 1454 | list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
1455 | - if($reward_resource == RES_DARK_MATTER) { |
|
1456 | - $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
|
1455 | + if ($reward_resource == RES_DARK_MATTER) { |
|
1456 | + $quest_reward = "{$reward_resource},".$reward_amount * 1000; |
|
1457 | 1457 | } |
1458 | 1458 | } |
1459 | 1459 | $new_rewards = implode(';', $quest_reward_list); |
1460 | - if($new_rewards != $row['quest_rewards']) { |
|
1460 | + if ($new_rewards != $row['quest_rewards']) { |
|
1461 | 1461 | classSupernova::$db->doUpdate("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
1462 | 1462 | } |
1463 | 1463 | } |
@@ -1487,7 +1487,7 @@ discard block |
||
1487 | 1487 | upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range)); |
1488 | 1488 | upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate)); |
1489 | 1489 | |
1490 | - if(!isset($update_tables['payment'])) { |
|
1490 | + if (!isset($update_tables['payment'])) { |
|
1491 | 1491 | upd_alter_table('users', array( |
1492 | 1492 | "ADD KEY `I_user_id_name` (`id`, `username`)", |
1493 | 1493 | ), !$update_indexes['users']['I_user_id_name']); |
@@ -1521,15 +1521,15 @@ discard block |
||
1521 | 1521 | upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price)); |
1522 | 1522 | |
1523 | 1523 | // Updating category for Mercenaries |
1524 | - upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
1524 | + upd_do_query("UPDATE {{powerup}} SET powerup_category = ".UNIT_MERCENARIES." WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
1525 | 1525 | |
1526 | 1526 | // Convert Destructor to Death Star schematic |
1527 | 1527 | upd_do_query("UPDATE {{powerup}} |
1528 | - SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . " |
|
1528 | + SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_DEATH_STAR." |
|
1529 | 1529 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;"); |
1530 | 1530 | // Convert Assasin to SuperNova schematic |
1531 | 1531 | upd_do_query("UPDATE {{powerup}} |
1532 | - SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . " |
|
1532 | + SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_SUPERNOVA." |
|
1533 | 1533 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;"); |
1534 | 1534 | |
1535 | 1535 | upd_alter_table('iraks', array( |
@@ -1538,7 +1538,7 @@ discard block |
||
1538 | 1538 | ), !$update_tables['iraks']['fleet_start_type']); |
1539 | 1539 | |
1540 | 1540 | |
1541 | - if(!$update_tables['payment']['payment_status']) { |
|
1541 | + if (!$update_tables['payment']['payment_status']) { |
|
1542 | 1542 | upd_alter_table('payment', array( |
1543 | 1543 | "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
1544 | 1544 | |
@@ -1553,7 +1553,7 @@ discard block |
||
1553 | 1553 | ), !$update_tables['payment']['payment_status']); |
1554 | 1554 | } |
1555 | 1555 | |
1556 | - upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";"); |
|
1556 | + upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = ".UNIT_PLANS.";"); |
|
1557 | 1557 | |
1558 | 1558 | upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date)); |
1559 | 1559 | upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures)); |
@@ -1565,7 +1565,7 @@ discard block |
||
1565 | 1565 | |
1566 | 1566 | upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium)); |
1567 | 1567 | |
1568 | - 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;"); |
|
1568 | + 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;"); |
|
1569 | 1569 | |
1570 | 1570 | |
1571 | 1571 | upd_do_query('COMMIT;', true); |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
1623 | 1623 | ), !$update_indexes['notes']['I_owner_priority_time']); |
1624 | 1624 | |
1625 | - if(!$update_tables['buddy']['BUDDY_ID']) { |
|
1625 | + if (!$update_tables['buddy']['BUDDY_ID']) { |
|
1626 | 1626 | upd_alter_table('buddy', array( |
1627 | 1627 | "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy\Buddy table row ID'", |
1628 | 1628 | "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy\Buddy request status'", |
@@ -1643,16 +1643,16 @@ discard block |
||
1643 | 1643 | |
1644 | 1644 | $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
1645 | 1645 | $found = $lost = array(); |
1646 | - while($row = db_fetch($query)) { |
|
1647 | - $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
1648 | - if(!isset($found[$index])) { |
|
1646 | + while ($row = db_fetch($query)) { |
|
1647 | + $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']).';'.max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
1648 | + if (!isset($found[$index])) { |
|
1649 | 1649 | $found[$index] = $row['BUDDY_ID']; |
1650 | 1650 | } else { |
1651 | 1651 | $lost[] = $row['BUDDY_ID']; |
1652 | 1652 | } |
1653 | 1653 | } |
1654 | 1654 | $lost = implode(',', $lost); |
1655 | - if($lost) { |
|
1655 | + if ($lost) { |
|
1656 | 1656 | upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
1657 | 1657 | } |
1658 | 1658 | |
@@ -1673,7 +1673,7 @@ discard block |
||
1673 | 1673 | |
1674 | 1674 | 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"); |
1675 | 1675 | |
1676 | - if(!$update_tables['ube_report']) { |
|
1676 | + if (!$update_tables['ube_report']) { |
|
1677 | 1677 | upd_create_table('ube_report', |
1678 | 1678 | "( |
1679 | 1679 | `ube_report_id` SERIAL COMMENT 'Report ID', |
@@ -1714,7 +1714,7 @@ discard block |
||
1714 | 1714 | ); |
1715 | 1715 | } |
1716 | 1716 | |
1717 | - if(!$update_tables['ube_report_player']) { |
|
1717 | + if (!$update_tables['ube_report_player']) { |
|
1718 | 1718 | upd_create_table('ube_report_player', |
1719 | 1719 | "( |
1720 | 1720 | `ube_report_player_id` SERIAL COMMENT 'Record ID', |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | ); |
1736 | 1736 | } |
1737 | 1737 | |
1738 | - if(!$update_tables['ube_report_fleet']) { |
|
1738 | + if (!$update_tables['ube_report_fleet']) { |
|
1739 | 1739 | upd_create_table('ube_report_fleet', |
1740 | 1740 | "( |
1741 | 1741 | `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID', |
@@ -1765,7 +1765,7 @@ discard block |
||
1765 | 1765 | ); |
1766 | 1766 | } |
1767 | 1767 | |
1768 | - if(!$update_tables['ube_report_unit']) { |
|
1768 | + if (!$update_tables['ube_report_unit']) { |
|
1769 | 1769 | // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
1770 | 1770 | // Может сохранять имена удаленных кораблей долго? |
1771 | 1771 | |
@@ -1802,7 +1802,7 @@ discard block |
||
1802 | 1802 | ); |
1803 | 1803 | } |
1804 | 1804 | |
1805 | - if(!$update_tables['ube_report_outcome_fleet']) { |
|
1805 | + if (!$update_tables['ube_report_outcome_fleet']) { |
|
1806 | 1806 | upd_create_table('ube_report_outcome_fleet', |
1807 | 1807 | "( |
1808 | 1808 | `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID', |
@@ -1831,7 +1831,7 @@ discard block |
||
1831 | 1831 | ); |
1832 | 1832 | } |
1833 | 1833 | |
1834 | - if(!$update_tables['ube_report_outcome_unit']) { |
|
1834 | + if (!$update_tables['ube_report_outcome_unit']) { |
|
1835 | 1835 | upd_create_table('ube_report_outcome_unit', |
1836 | 1836 | "( |
1837 | 1837 | `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID', |
@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | ); |
1853 | 1853 | } |
1854 | 1854 | |
1855 | - if(!$update_tables['unit']) { |
|
1855 | + if (!$update_tables['unit']) { |
|
1856 | 1856 | upd_create_table('unit', |
1857 | 1857 | "( |
1858 | 1858 | `unit_id` SERIAL COMMENT 'Record ID', |
@@ -1871,7 +1871,7 @@ discard block |
||
1871 | 1871 | ); |
1872 | 1872 | } |
1873 | 1873 | |
1874 | - if(!$update_tables['captain']) { |
|
1874 | + if (!$update_tables['captain']) { |
|
1875 | 1875 | upd_create_table('captain', |
1876 | 1876 | "( |
1877 | 1877 | `captain_id` SERIAL COMMENT 'Record ID', |
@@ -1891,7 +1891,7 @@ discard block |
||
1891 | 1891 | ); |
1892 | 1892 | } |
1893 | 1893 | |
1894 | - if(!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1894 | + if (!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1895 | 1895 | upd_alter_table('fleets', array( |
1896 | 1896 | "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
1897 | 1897 | "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
@@ -1913,7 +1913,7 @@ discard block |
||
1913 | 1913 | |
1914 | 1914 | upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
1915 | 1915 | |
1916 | - if(!$update_tables['chat_player']) { |
|
1916 | + if (!$update_tables['chat_player']) { |
|
1917 | 1917 | upd_create_table('chat_player', |
1918 | 1918 | "( |
1919 | 1919 | `chat_player_id` SERIAL COMMENT 'Record ID', |
@@ -1975,7 +1975,7 @@ discard block |
||
1975 | 1975 | "DROP FOREIGN KEY `FK_payment_user`", |
1976 | 1976 | ), $update_foreigns['payment']['FK_payment_user']); |
1977 | 1977 | |
1978 | - if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1978 | + if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1979 | 1979 | upd_alter_table('chat', array( |
1980 | 1980 | "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
1981 | 1981 | "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
@@ -2008,7 +2008,7 @@ discard block |
||
2008 | 2008 | "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
2009 | 2009 | ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
2010 | 2010 | |
2011 | - if(!$update_tables['unit']['unit_time_start']) { |
|
2011 | + if (!$update_tables['unit']['unit_time_start']) { |
|
2012 | 2012 | upd_alter_table('unit', array( |
2013 | 2013 | "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
2014 | 2014 | "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
@@ -2018,13 +2018,13 @@ discard block |
||
2018 | 2018 | "INSERT INTO {{unit}} |
2019 | 2019 | (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish) |
2020 | 2020 | SELECT |
2021 | - `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level` |
|
2021 | + `powerup_user_id`, " . LOC_USER.", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level` |
|
2022 | 2022 | , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL) |
2023 | 2023 | FROM {{powerup}}" |
2024 | 2024 | ); |
2025 | 2025 | } |
2026 | 2026 | |
2027 | - if(!$update_tables['que']) { |
|
2027 | + if (!$update_tables['que']) { |
|
2028 | 2028 | upd_create_table('que', |
2029 | 2029 | "( |
2030 | 2030 | `que_id` SERIAL COMMENT 'Internal que id', |
@@ -2056,25 +2056,25 @@ discard block |
||
2056 | 2056 | } |
2057 | 2057 | |
2058 | 2058 | // Конвертирум очередь исследований |
2059 | - if($update_tables['users']['que']) { |
|
2059 | + if ($update_tables['users']['que']) { |
|
2060 | 2060 | $que_lines = array(); |
2061 | 2061 | $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
2062 | - while($que_row = db_fetch($que_query)) { |
|
2062 | + while ($que_row = db_fetch($que_query)) { |
|
2063 | 2063 | $que_data = explode(',', $que_row['que']); |
2064 | 2064 | |
2065 | - if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2065 | + if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2066 | 2066 | continue; |
2067 | 2067 | } |
2068 | 2068 | |
2069 | 2069 | $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
2070 | 2070 | // Если планета пустая - ставим главку |
2071 | 2071 | $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
2072 | - if($que_data[QI_PLANET_ID]) { |
|
2072 | + if ($que_data[QI_PLANET_ID]) { |
|
2073 | 2073 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
2074 | - if(!$que_planet_check['id']) { |
|
2074 | + if (!$que_planet_check['id']) { |
|
2075 | 2075 | $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
2076 | 2076 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
2077 | - if(!$que_planet_check['id']) { |
|
2077 | + if (!$que_planet_check['id']) { |
|
2078 | 2078 | $que_data[QI_PLANET_ID] = 'NULL'; |
2079 | 2079 | } |
2080 | 2080 | } |
@@ -2088,20 +2088,20 @@ discard block |
||
2088 | 2088 | $price_increase = pow($unit_factor, $unit_level); |
2089 | 2089 | $unit_level++; |
2090 | 2090 | $unit_cost = array(); |
2091 | - foreach($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2092 | - if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2091 | + foreach ($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2092 | + if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2093 | 2093 | continue; |
2094 | 2094 | } |
2095 | - $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
|
2095 | + $unit_cost[] = $resource_id.','.floor($resource_cost); |
|
2096 | 2096 | } |
2097 | 2097 | $unit_cost = implode(';', $unit_cost); |
2098 | 2098 | |
2099 | - $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," . |
|
2100 | - BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
2099 | + $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]},".QUE_RESEARCH.",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1,". |
|
2100 | + BUILD_CREATE.",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
2101 | 2101 | } |
2102 | 2102 | |
2103 | - if(!empty($que_lines)) { |
|
2104 | - 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)); |
|
2103 | + if (!empty($que_lines)) { |
|
2104 | + 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)); |
|
2105 | 2105 | } |
2106 | 2106 | |
2107 | 2107 | upd_alter_table('users', array( |
@@ -2114,23 +2114,23 @@ discard block |
||
2114 | 2114 | |
2115 | 2115 | |
2116 | 2116 | // Ковертируем технологии в таблицы |
2117 | - if($update_tables['users']['graviton_tech']) { |
|
2118 | - upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
|
2117 | + if ($update_tables['users']['graviton_tech']) { |
|
2118 | + upd_do_query("DELETE FROM {{unit}} WHERE unit_type = ".UNIT_TECHNOLOGIES); |
|
2119 | 2119 | |
2120 | 2120 | $que_lines = array(); |
2121 | 2121 | $user_query = upd_do_query("SELECT * FROM {{users}}"); |
2122 | 2122 | upd_add_more_time(300); |
2123 | 2123 | $sn_group_tech = sn_get_groups('tech'); |
2124 | - while($user_row = db_fetch($user_query)) { |
|
2125 | - foreach($sn_group_tech as $tech_id) { |
|
2126 | - if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2127 | - $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
|
2124 | + while ($user_row = db_fetch($user_query)) { |
|
2125 | + foreach ($sn_group_tech as $tech_id) { |
|
2126 | + if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2127 | + $que_lines[] = "({$user_row['id']},".LOC_USER.",{$user_row['id']},".UNIT_TECHNOLOGIES.",{$tech_id},{$tech_level})"; |
|
2128 | 2128 | } |
2129 | 2129 | } |
2130 | 2130 | } |
2131 | 2131 | |
2132 | - if(!empty($que_lines)) { |
|
2133 | - 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)); |
|
2132 | + if (!empty($que_lines)) { |
|
2133 | + 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)); |
|
2134 | 2134 | } |
2135 | 2135 | |
2136 | 2136 | upd_alter_table('users', array( |
@@ -2138,25 +2138,25 @@ discard block |
||
2138 | 2138 | ), $update_tables['users']['graviton_tech']); |
2139 | 2139 | } |
2140 | 2140 | |
2141 | - if(!$update_indexes['unit']['I_unit_record_search']) { |
|
2141 | + if (!$update_indexes['unit']['I_unit_record_search']) { |
|
2142 | 2142 | upd_alter_table('unit', array( |
2143 | 2143 | "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
2144 | 2144 | ), !$update_indexes['unit']['I_unit_record_search']); |
2145 | 2145 | |
2146 | - foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2146 | + foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2147 | 2147 | $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
2148 | 2148 | } |
2149 | 2149 | $drop_index = array(); |
2150 | 2150 | $create_index = &$drop_index; // array(); |
2151 | - foreach($planet_units as $unit_name => $unit_create) { |
|
2152 | - if($update_indexes['planets']['I_' . $unit_name]) { |
|
2151 | + foreach ($planet_units as $unit_name => $unit_create) { |
|
2152 | + if ($update_indexes['planets']['I_'.$unit_name]) { |
|
2153 | 2153 | $drop_index[] = "DROP KEY I_{$unit_name}"; |
2154 | 2154 | } |
2155 | - if($update_indexes['planets']['i_' . $unit_name]) { |
|
2155 | + if ($update_indexes['planets']['i_'.$unit_name]) { |
|
2156 | 2156 | $drop_index[] = "DROP KEY i_{$unit_name}"; |
2157 | 2157 | } |
2158 | 2158 | |
2159 | - if($unit_create) { |
|
2159 | + if ($unit_create) { |
|
2160 | 2160 | $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
2161 | 2161 | } |
2162 | 2162 | } |
@@ -2167,7 +2167,7 @@ discard block |
||
2167 | 2167 | "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
2168 | 2168 | ), !$update_tables['users']['user_time_utc_offset']); |
2169 | 2169 | |
2170 | - if(!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2170 | + if (!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2171 | 2171 | upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})"); |
2172 | 2172 | |
2173 | 2173 | upd_alter_table('alliance', array( |
@@ -2187,7 +2187,7 @@ discard block |
||
2187 | 2187 | |
2188 | 2188 | upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer); |
2189 | 2189 | |
2190 | - if(!$update_tables['player_name_history']) { |
|
2190 | + if (!$update_tables['player_name_history']) { |
|
2191 | 2191 | upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost); |
2192 | 2192 | upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
2193 | 2193 | |
@@ -2213,10 +2213,10 @@ discard block |
||
2213 | 2213 | |
2214 | 2214 | upd_alter_table('planets', array( |
2215 | 2215 | "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", |
2216 | - "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
|
2216 | + "ADD `density_index` TINYINT NOT NULL DEFAULT ".PLANET_DENSITY_STANDARD." COMMENT 'Planet cached density index'", |
|
2217 | 2217 | ), !$update_tables['planets']['density_index']); |
2218 | 2218 | |
2219 | - if($update_tables['users']['player_artifact_list']) { |
|
2219 | + if ($update_tables['users']['player_artifact_list']) { |
|
2220 | 2220 | upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
2221 | 2221 | |
2222 | 2222 | 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']); |
@@ -2226,14 +2226,14 @@ discard block |
||
2226 | 2226 | $db_changeset = array(); |
2227 | 2227 | |
2228 | 2228 | $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
2229 | - while($row = db_fetch($query)) { |
|
2229 | + while ($row = db_fetch($query)) { |
|
2230 | 2230 | $artifact_list = explode(';', $row['player_artifact_list']); |
2231 | - if(!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2231 | + if (!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2232 | 2232 | continue; |
2233 | 2233 | } |
2234 | - foreach($artifact_list as $key => &$value) { |
|
2234 | + foreach ($artifact_list as $key => &$value) { |
|
2235 | 2235 | $value = explode(',', $value); |
2236 | - if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2236 | + if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2237 | 2237 | unset($artifact_list[$key]); |
2238 | 2238 | continue; |
2239 | 2239 | } |