@@ -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( |
@@ -108,24 +108,24 @@ discard block |
||
108 | 108 | $sql_str = "INSERT INTO `{{ube_report}}` |
109 | 109 | SET |
110 | 110 | `ube_report_cypher` = '{$ube->report_cypher}', |
111 | - `ube_report_time_combat` = '" . date(FMT_DATE_TIME_SQL, $ube->combat_timestamp) . "', |
|
111 | + `ube_report_time_combat` = '".date(FMT_DATE_TIME_SQL, $ube->combat_timestamp)."', |
|
112 | 112 | `ube_report_time_spent` = {$ube->time_spent}, |
113 | 113 | |
114 | - `ube_report_combat_admin` = " . (int)$ube->is_admin_in_combat . ", |
|
114 | + `ube_report_combat_admin` = ".(int) $ube->is_admin_in_combat.", |
|
115 | 115 | `ube_report_mission_type` = {$ube->mission_type_id}, |
116 | 116 | |
117 | 117 | `ube_report_combat_result` = {$ube->combat_result}, |
118 | - `ube_report_combat_sfr` = " . (int)$ube->is_small_fleet_recce . ", |
|
118 | + `ube_report_combat_sfr` = ".(int) $ube->is_small_fleet_recce.", |
|
119 | 119 | |
120 | - `ube_report_planet_id` = " . (int)$ube->ube_planet_info[PLANET_ID] . ", |
|
121 | - `ube_report_planet_name` = '" . db_escape($ube->ube_planet_info[PLANET_NAME]) . "', |
|
122 | - `ube_report_planet_size` = " . (int)$ube->ube_planet_info[PLANET_SIZE] . ", |
|
123 | - `ube_report_planet_galaxy` = " . (int)$ube->ube_planet_info[PLANET_GALAXY] . ", |
|
124 | - `ube_report_planet_system` = " . (int)$ube->ube_planet_info[PLANET_SYSTEM] . ", |
|
125 | - `ube_report_planet_planet` = " . (int)$ube->ube_planet_info[PLANET_PLANET] . ", |
|
126 | - `ube_report_planet_planet_type` = " . (int)$ube->ube_planet_info[PLANET_TYPE] . ", |
|
120 | + `ube_report_planet_id` = " . (int) $ube->ube_planet_info[PLANET_ID].", |
|
121 | + `ube_report_planet_name` = '" . db_escape($ube->ube_planet_info[PLANET_NAME])."', |
|
122 | + `ube_report_planet_size` = " . (int) $ube->ube_planet_info[PLANET_SIZE].", |
|
123 | + `ube_report_planet_galaxy` = " . (int) $ube->ube_planet_info[PLANET_GALAXY].", |
|
124 | + `ube_report_planet_system` = " . (int) $ube->ube_planet_info[PLANET_SYSTEM].", |
|
125 | + `ube_report_planet_planet` = " . (int) $ube->ube_planet_info[PLANET_PLANET].", |
|
126 | + `ube_report_planet_planet_type` = " . (int) $ube->ube_planet_info[PLANET_TYPE].", |
|
127 | 127 | |
128 | - `ube_report_capture_result` = " . (int)$ube->capture_result . ", " |
|
128 | + `ube_report_capture_result` = " . (int) $ube->capture_result.", " |
|
129 | 129 | . $ube->debris->report_generate_sql() |
130 | 130 | . $ube->moon_calculator->report_generate_sql(); |
131 | 131 | |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | |
135 | 135 | // Сохраняем общую информацию по игрокам |
136 | 136 | $player_sides = $ube->players->get_player_sides(); |
137 | - foreach($player_sides as $player_id => $player_side) { |
|
137 | + foreach ($player_sides as $player_id => $player_side) { |
|
138 | 138 | $sql_perform['ube_report_player'][] = array( |
139 | 139 | $ube_report_id, |
140 | 140 | $player_id, |
141 | 141 | |
142 | - "'" . db_escape($ube->players[$player_id]->name) . "'", |
|
142 | + "'".db_escape($ube->players[$player_id]->name)."'", |
|
143 | 143 | $ube->players[$player_id]->getSide() == UBE_PLAYER_IS_ATTACKER ? 1 : 0, |
144 | 144 | |
145 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
146 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
147 | - (float)$ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
145 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ATTACK), |
|
146 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_SHIELD), |
|
147 | + (float) $ube->players[$player_id]->player_bonus->calcBonus(P_ARMOR), |
|
148 | 148 | ); |
149 | 149 | } |
150 | 150 | |
151 | 151 | // Всякая информация по флотам |
152 | - foreach($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
152 | + foreach ($ube->fleet_list->_container as $fleet_id => $UBEFleet) { |
|
153 | 153 | // Сохраняем общую информацию по флотам |
154 | 154 | $sql_perform['ube_report_fleet'][] = $UBEFleet->sql_generate_array($ube_report_id); |
155 | 155 | |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | $ube->rounds->sql_generate_unit_array($sql_perform['ube_report_unit'], $ube_report_id, $ube->fleet_list); |
166 | 166 | |
167 | 167 | // Пакетная вставка данных |
168 | - foreach($sql_perform as $table_name => $table_data) { |
|
169 | - if(count($table_data) < 2) { |
|
168 | + foreach ($sql_perform as $table_name => $table_data) { |
|
169 | + if (count($table_data) < 2) { |
|
170 | 170 | continue; |
171 | 171 | } |
172 | - foreach($table_data as &$record_data) { |
|
173 | - $record_data = '(' . implode(',', $record_data) . ')'; |
|
172 | + foreach ($table_data as &$record_data) { |
|
173 | + $record_data = '('.implode(',', $record_data).')'; |
|
174 | 174 | } |
175 | 175 | $fields = $table_data[0]; |
176 | 176 | unset($table_data[0]); |
177 | - classSupernova::$db->doInsert("INSERT INTO {{{$table_name}}} {$fields} VALUES " . implode(',', $table_data)); |
|
177 | + classSupernova::$db->doInsert("INSERT INTO {{{$table_name}}} {$fields} VALUES ".implode(',', $table_data)); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | return $ube->report_cypher; |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $report_cypher = db_escape($report_cypher); |
193 | 193 | |
194 | 194 | $report_row = classSupernova::$db->doSelectFetch("SELECT * FROM {{ube_report}} WHERE ube_report_cypher = '{$report_cypher}' LIMIT 1"); |
195 | - if(!$report_row) { |
|
195 | + if (!$report_row) { |
|
196 | 196 | return UBE_REPORT_NOT_FOUND; |
197 | 197 | } |
198 | 198 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * @param $template_result |
209 | 209 | */ |
210 | 210 | public function sn_ube_report_generate(UBE $ube, &$template_result) { |
211 | - if(!is_object($ube)) { |
|
211 | + if (!is_object($ube)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
@@ -223,15 +223,15 @@ discard block |
||
223 | 223 | |
224 | 224 | // Координаты, тип и название планеты - если есть |
225 | 225 | //R $planet_owner_id = $combat_data[UBE_FLEETS][0][UBE_OWNER]; |
226 | - if(isset($ube->ube_planet_info)) { |
|
226 | + if (isset($ube->ube_planet_info)) { |
|
227 | 227 | $template_result += $ube->ube_planet_info; |
228 | 228 | $template_result[PLANET_NAME] = str_replace(' ', ' ', htmlentities($template_result[PLANET_NAME], ENT_COMPAT, 'UTF-8')); |
229 | 229 | } |
230 | 230 | |
231 | 231 | // Обломки |
232 | 232 | $debris = array(); |
233 | - foreach(array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
234 | - if($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
233 | + foreach (array(RES_METAL, RES_CRYSTAL) as $resource_id) { |
|
234 | + if ($resource_amount = $ube->debris->debris_get_resource($resource_id)) { |
|
235 | 235 | $debris[] = array( |
236 | 236 | 'NAME' => classLocale::$lang['tech'][$resource_id], |
237 | 237 | 'AMOUNT' => pretty_number($resource_amount), |
@@ -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); |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | */ |
366 | 366 | function db_payment_list_get($flt_payer, $flt_status, $flt_test, $flt_module) { |
367 | 367 | $extra_conditions = |
368 | - ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : '') . |
|
369 | - ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : '') . |
|
370 | - ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : '') . |
|
368 | + ($flt_payer > 0 ? "AND payment_user_id = {$flt_payer} " : ''). |
|
369 | + ($flt_status >= 0 ? "AND payment_status = {$flt_status} " : ''). |
|
370 | + ($flt_test >= 0 ? "AND payment_test = {$flt_test} " : ''). |
|
371 | 371 | ($flt_module ? "AND payment_module_name = '{$flt_module}' " : ''); |
372 | 372 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{payment}}` WHERE 1 {$extra_conditions} ORDER BY payment_id DESC;"); |
373 | 373 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | |
396 | 396 | // Log Online ************************************************************************************************************* |
397 | 397 | function db_log_online_insert() { |
398 | - classSupernova::$db->doInsert("INSERT IGNORE INTO `{{log_users_online}}` SET online_count = " . classSupernova::$config->var_online_user_count); |
|
398 | + classSupernova::$db->doInsert("INSERT IGNORE INTO `{{log_users_online}}` SET online_count = ".classSupernova::$config->var_online_user_count); |
|
399 | 399 | } |
400 | 400 | |
401 | 401 | // Log ************************************************************************************************************* |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | `ban_user_id` = '{$banned['id']}', |
604 | 604 | `ban_user_name` = '{$banned['username']}', |
605 | 605 | `ban_reason` = '{$reason}', |
606 | - `ban_time` = " . SN_TIME_NOW . ", |
|
606 | + `ban_time` = ".SN_TIME_NOW.", |
|
607 | 607 | `ban_until` = {$ban_until}, |
608 | 608 | `ban_issuer_id` = '{$banner['id']}', |
609 | 609 | `ban_issuer_name` = '{$banner['username']}', |
@@ -625,7 +625,7 @@ discard block |
||
625 | 625 | `ban_user_name` = '{$banned['username']}', |
626 | 626 | `ban_reason` = '{$reason}', |
627 | 627 | `ban_time` = 0, |
628 | - `ban_until` = " . SN_TIME_NOW . ", |
|
628 | + `ban_until` = ".SN_TIME_NOW.", |
|
629 | 629 | `ban_issuer_id` = '{$banner['id']}', |
630 | 630 | `ban_issuer_name` = '{$banner['username']}', |
631 | 631 | `ban_issuer_email` = '{$banner['email']}' |
@@ -684,9 +684,9 @@ discard block |
||
684 | 684 | function db_ube_report_get_best_battles() { |
685 | 685 | $query = classSupernova::$db->doSelect("SELECT * |
686 | 686 | FROM `{{ube_report}}` |
687 | - WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS . " DAY)) |
|
687 | + WHERE `ube_report_time_process` < DATE(DATE_SUB(NOW(), INTERVAL " . MODULE_INFO_BEST_BATTLES_LOCK_DAYS." DAY)) |
|
688 | 688 | ORDER BY `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC |
689 | - LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW . ";"); |
|
689 | + LIMIT " . MODULE_INFO_BEST_BATTLES_REPORT_VIEW.";"); |
|
690 | 690 | |
691 | 691 | return $query; |
692 | 692 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | use Vector\Vector; |
8 | 8 | |
9 | 9 | function sys_user_vacation($user) { |
10 | - if(sys_get_param_str('vacation') == 'leave') { |
|
10 | + if (sys_get_param_str('vacation') == 'leave') { |
|
11 | 11 | if ($user['vacation'] < SN_TIME_NOW) { |
12 | 12 | $user['vacation'] = 0; |
13 | 13 | $user['vacation_next'] = SN_TIME_NOW + classSupernova::$config->player_vacation_timeout; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | } |
16 | 16 | } |
17 | 17 | |
18 | - if($user['vacation']) { |
|
18 | + if ($user['vacation']) { |
|
19 | 19 | // sn_sys_logout(false, true); |
20 | 20 | // core_auth::logout(false, true); |
21 | 21 | |
@@ -45,29 +45,29 @@ discard block |
||
45 | 45 | // TODO: Full rewrite |
46 | 46 | sn_db_transaction_start(); |
47 | 47 | $TheUser = DBStaticUser::db_user_by_id($UserID); |
48 | - if ( $TheUser['ally_id'] != 0 ) { |
|
49 | - $TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '" . $TheUser['ally_id'] . "';"); |
|
48 | + if ($TheUser['ally_id'] != 0) { |
|
49 | + $TheAlly = classSupernova::$db->doSelectFetch("SELECT * FROM `{{alliance}}` WHERE `id` = '".$TheUser['ally_id']."';"); |
|
50 | 50 | $TheAlly['ally_members'] -= 1; |
51 | - if ( $TheAlly['ally_members'] > 0 ) { |
|
52 | - classSupernova::$db->doUpdate( "UPDATE `{{alliance}}` SET `ally_members` = '" . $TheAlly['ally_members'] . "' WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
51 | + if ($TheAlly['ally_members'] > 0) { |
|
52 | + classSupernova::$db->doUpdate("UPDATE `{{alliance}}` SET `ally_members` = '".$TheAlly['ally_members']."' WHERE `id` = '".$TheAlly['id']."';"); |
|
53 | 53 | } else { |
54 | - classSupernova::$db->doDelete("DELETE FROM `{{alliance}}` WHERE `id` = '" . $TheAlly['id'] . "';"); |
|
55 | - classSupernova::$db->doDelete("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '" . $TheAlly['id'] . "';"); |
|
54 | + classSupernova::$db->doDelete("DELETE FROM `{{alliance}}` WHERE `id` = '".$TheAlly['id']."';"); |
|
55 | + classSupernova::$db->doDelete("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '2' AND `id_owner` = '".$TheAlly['id']."';"); |
|
56 | 56 | } |
57 | 57 | } |
58 | - classSupernova::$db->doDelete("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '" . $UserID . "';"); |
|
58 | + classSupernova::$db->doDelete("DELETE FROM `{{statpoints}}` WHERE `stat_type` = '1' AND `id_owner` = '".$UserID."';"); |
|
59 | 59 | |
60 | 60 | DBStaticPlanet::db_planet_list_delete_by_owner($UserID); |
61 | 61 | |
62 | - classSupernova::$db->doDelete("DELETE FROM `{{messages}}` WHERE `message_sender` = '" . $UserID . "';"); |
|
63 | - classSupernova::$db->doDelete("DELETE FROM `{{messages}}` WHERE `message_owner` = '" . $UserID . "';"); |
|
64 | - classSupernova::$db->doDelete("DELETE FROM `{{notes}}` WHERE `owner` = '" . $UserID . "';"); |
|
62 | + classSupernova::$db->doDelete("DELETE FROM `{{messages}}` WHERE `message_sender` = '".$UserID."';"); |
|
63 | + classSupernova::$db->doDelete("DELETE FROM `{{messages}}` WHERE `message_owner` = '".$UserID."';"); |
|
64 | + classSupernova::$db->doDelete("DELETE FROM `{{notes}}` WHERE `owner` = '".$UserID."';"); |
|
65 | 65 | FleetList::db_fleet_list_delete_by_owner($UserID); |
66 | 66 | // doDelete("DELETE FROM `{{rw}}` WHERE `id_owner1` = '" . $UserID . "';"); |
67 | 67 | // doDelete("DELETE FROM `{{rw}}` WHERE `id_owner2` = '" . $UserID . "';"); |
68 | - classSupernova::$db->doDelete("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '" . $UserID . "';"); |
|
69 | - classSupernova::$db->doDelete("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '" . $UserID . "';"); |
|
70 | - classSupernova::$db->doDelete("DELETE FROM `{{annonce}}` WHERE `user` = '" . $UserID . "';"); |
|
68 | + classSupernova::$db->doDelete("DELETE FROM `{{buddy}}` WHERE `BUDDY_SENDER_ID` = '".$UserID."';"); |
|
69 | + classSupernova::$db->doDelete("DELETE FROM `{{buddy}}` WHERE `BUDDY_OWNER_ID` = '".$UserID."';"); |
|
70 | + classSupernova::$db->doDelete("DELETE FROM `{{annonce}}` WHERE `user` = '".$UserID."';"); |
|
71 | 71 | |
72 | 72 | |
73 | 73 | classSupernova::db_del_record_by_id(LOC_USER, $UserID); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $ban_current = DBStaticUser::db_user_by_id($banned['id'], false, 'banaday'); |
88 | 88 | $ban_until = ($ban_current['banaday'] ? $ban_current['banaday'] : SN_TIME_NOW) + $term; |
89 | 89 | |
90 | - DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} " . ($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
90 | + DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = {$ban_until} ".($is_vacation ? ", `vacation` = '{$ban_until}' " : '')); |
|
91 | 91 | |
92 | 92 | $banned['username'] = db_escape($banned['username']); |
93 | 93 | $banner['username'] = db_escape($banner['username']); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @param string $reason |
106 | 106 | */ |
107 | 107 | function sys_admin_player_ban_unset($banner, $banned, $reason = '') { |
108 | - DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = " . SN_TIME_NOW . ""); |
|
108 | + DBStaticUser::db_user_set_by_id($banned['id'], "`banaday` = 0, `vacation` = ".SN_TIME_NOW.""); |
|
109 | 109 | |
110 | 110 | $banned['username'] = db_escape($banned['username']); |
111 | 111 | $banner['username'] = db_escape($banner['username']); |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | 'total_points' => $options['total_points'] = empty($options['total_points']) ? 0 : $options['total_points'], |
136 | 136 | |
137 | - 'options' => (empty($options['options']) ? $player_options_string : $options['options']) . (empty($options['options_extra']) ? '' : $options['options_extra']), |
|
137 | + 'options' => (empty($options['options']) ? $player_options_string : $options['options']).(empty($options['options_extra']) ? '' : $options['options_extra']), |
|
138 | 138 | |
139 | 139 | 'galaxy' => $options['galaxy'] = intval($options['galaxy'] ? $options['galaxy'] : 0), |
140 | 140 | 'system' => $options['system'] = intval($options['system'] ? $options['system'] : 0), |
@@ -145,28 +145,28 @@ discard block |
||
145 | 145 | !empty($options['password_encoded_unsafe']) ? $field_set['password'] = $options['password_encoded_unsafe'] : false; |
146 | 146 | |
147 | 147 | $user_new = classSupernova::db_ins_field_set(LOC_USER, $field_set); |
148 | - if(!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
148 | + if (!($options['galaxy'] && $options['system'] && $options['planet'])) { |
|
149 | 149 | $options['galaxy'] = classSupernova::$config->LastSettedGalaxyPos; |
150 | 150 | $options['system'] = classSupernova::$config->LastSettedSystemPos; |
151 | - $segment_size = floor(Vector::$knownPlanets/ 3); |
|
151 | + $segment_size = floor(Vector::$knownPlanets / 3); |
|
152 | 152 | $segment = floor(classSupernova::$config->LastSettedPlanetPos / $segment_size); |
153 | 153 | $segment++; |
154 | 154 | $options['planet'] = mt_rand(1 + $segment * $segment_size, ($segment + 1) * $segment_size); |
155 | 155 | |
156 | 156 | // $new_planet_id = 0; |
157 | - while(true) { |
|
158 | - if($options['planet'] > Vector::$knownPlanets) { |
|
157 | + while (true) { |
|
158 | + if ($options['planet'] > Vector::$knownPlanets) { |
|
159 | 159 | $options['planet'] = mt_rand(0, $segment_size - 1) + 1; |
160 | 160 | $options['system']++; |
161 | 161 | } |
162 | - if($options['system'] > Vector::$knownSystems) { |
|
162 | + if ($options['system'] > Vector::$knownSystems) { |
|
163 | 163 | $options['system'] = 1; |
164 | 164 | $options['galaxy']++; |
165 | 165 | } |
166 | - $options['galaxy'] > Vector::$knownGalaxies? $options['galaxy'] = 1 : false; |
|
166 | + $options['galaxy'] > Vector::$knownGalaxies ? $options['galaxy'] = 1 : false; |
|
167 | 167 | |
168 | 168 | $galaxy_row = DBStaticPlanet::db_planet_by_gspt($options['galaxy'], $options['system'], $options['planet'], PT_PLANET, true, 'id'); |
169 | - if(!$galaxy_row['id']) { |
|
169 | + if (!$galaxy_row['id']) { |
|
170 | 170 | classSupernova::$config->db_saveItem(array( |
171 | 171 | 'LastSettedGalaxyPos' => $options['galaxy'], |
172 | 172 | 'LastSettedSystemPos' => $options['system'], |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | $username_safe = db_escape($username_unsafe); |
190 | 190 | db_player_name_history_replace($user_new, $username_safe); |
191 | 191 | |
192 | - if(!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
192 | + if (!empty($options['partner_id']) && ($referral_row = DBStaticUser::db_user_by_id($options['partner_id'], true))) { |
|
193 | 193 | db_referral_insert($options, $user_new); |
194 | 194 | } |
195 | 195 |
@@ -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,23 +1341,23 @@ 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 | $ally_user_name = db_escape("[{$ally_row['ally_tag']}]"); |
1346 | - classSupernova::$db->doInsert("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = " . SN_TIME_NOW . ", `user_as_ally` = {$ally_row['id']};"); |
|
1346 | + classSupernova::$db->doInsert("INSERT INTO {{users}} SET `username` = '{$ally_user_name}', `register_time` = ".SN_TIME_NOW.", `user_as_ally` = {$ally_row['id']};"); |
|
1347 | 1347 | $ally_user_id = classSupernova::$db->db_insert_id(); |
1348 | 1348 | classSupernova::$db->doUpdate("UPDATE {{alliance}} SET ally_user_id = {$ally_user_id} WHERE id = {$ally_row['id']} LIMIT 1;"); |
1349 | 1349 | } |
1350 | 1350 | // Renaming old ally players TODO: Remove on release |
1351 | 1351 | 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 = '';"); |
1352 | 1352 | // Setting last online time to old ally players TODO: Remove on release |
1353 | - upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;"); |
|
1353 | + upd_do_query("UPDATE {{users}} SET `onlinetime` = ".SN_TIME_NOW." WHERE onlinetime = 0;"); |
|
1354 | 1354 | |
1355 | 1355 | // ------------------------------------------------------------------------ |
1356 | 1356 | // Creating planets for allies |
1357 | 1357 | $ally_user_list = classSupernova::$db->doSelect("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;"); |
1358 | - while($ally_user_row = db_fetch($ally_user_list)) { |
|
1358 | + while ($ally_user_row = db_fetch($ally_user_list)) { |
|
1359 | 1359 | $ally_planet_name = db_escape($ally_user_row['username']); |
1360 | - classSupernova::$db->doInsert("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = " . SN_TIME_NOW . ", `id_owner` = {$ally_user_row['id']};"); |
|
1360 | + classSupernova::$db->doInsert("INSERT INTO {{planets}} SET `name` = '{$ally_planet_name}', `last_update` = ".SN_TIME_NOW.", `id_owner` = {$ally_user_row['id']};"); |
|
1361 | 1361 | $ally_planet_id = classSupernova::$db->db_insert_id(); |
1362 | 1362 | classSupernova::$db->doUpdate("UPDATE {{users}} SET `id_planet` = {$ally_planet_id} WHERE `id` = {$ally_user_row['id']} LIMIT 1;"); |
1363 | 1363 | } |
@@ -1386,10 +1386,10 @@ discard block |
||
1386 | 1386 | // Adding db field |
1387 | 1387 | upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']); |
1388 | 1388 | // Converting old data to new one and dropping old fields |
1389 | - if($update_tables['users']['b_tech_planet']) { |
|
1389 | + if ($update_tables['users']['b_tech_planet']) { |
|
1390 | 1390 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{planets}}` WHERE `b_tech_id` <> 0;"); |
1391 | - while($planet_row = db_fetch($query)) { |
|
1392 | - $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH; |
|
1391 | + while ($planet_row = db_fetch($query)) { |
|
1392 | + $que_item_string = "{$planet_row['b_tech_id']},1,".max(0, $planet_row['b_tech'] - SN_TIME_NOW).",".BUILD_CREATE.",".QUE_RESEARCH; |
|
1393 | 1393 | classSupernova::$db->doUpdate("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;"); |
1394 | 1394 | } |
1395 | 1395 | |
@@ -1401,10 +1401,10 @@ discard block |
||
1401 | 1401 | upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']); |
1402 | 1402 | } |
1403 | 1403 | |
1404 | - if(!$update_tables['powerup']['powerup_category']) { |
|
1404 | + if (!$update_tables['powerup']['powerup_category']) { |
|
1405 | 1405 | upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']); |
1406 | 1406 | |
1407 | - classSupernova::$db->doUpdate("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY); |
|
1407 | + classSupernova::$db->doUpdate("UPDATE {{powerup}} SET powerup_category = ".BONUS_MERCENARY); |
|
1408 | 1408 | } |
1409 | 1409 | |
1410 | 1410 | upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info)); |
@@ -1422,7 +1422,7 @@ discard block |
||
1422 | 1422 | upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets)); |
1423 | 1423 | upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor)); |
1424 | 1424 | |
1425 | - if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1425 | + if (!classSupernova::$config->db_loadItem('rpg_flt_explore')) { |
|
1426 | 1426 | $inflation_rate = 1000; |
1427 | 1427 | |
1428 | 1428 | classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate); |
@@ -1439,17 +1439,17 @@ discard block |
||
1439 | 1439 | classSupernova::$db->doUpdate("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};"); |
1440 | 1440 | |
1441 | 1441 | $query = classSupernova::$db->doSelect("SELECT * FROM `{{quest}}`"); |
1442 | - while($row = db_fetch($query)) { |
|
1442 | + while ($row = db_fetch($query)) { |
|
1443 | 1443 | $query_add = ''; |
1444 | 1444 | $quest_reward_list = explode(';', $row['quest_rewards']); |
1445 | - foreach($quest_reward_list as &$quest_reward) { |
|
1445 | + foreach ($quest_reward_list as &$quest_reward) { |
|
1446 | 1446 | list($reward_resource, $reward_amount) = explode(',', $quest_reward); |
1447 | - if($reward_resource == RES_DARK_MATTER) { |
|
1448 | - $quest_reward = "{$reward_resource}," . $reward_amount * 1000; |
|
1447 | + if ($reward_resource == RES_DARK_MATTER) { |
|
1448 | + $quest_reward = "{$reward_resource},".$reward_amount * 1000; |
|
1449 | 1449 | } |
1450 | 1450 | } |
1451 | 1451 | $new_rewards = implode(';', $quest_reward_list); |
1452 | - if($new_rewards != $row['quest_rewards']) { |
|
1452 | + if ($new_rewards != $row['quest_rewards']) { |
|
1453 | 1453 | classSupernova::$db->doUpdate("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;"); |
1454 | 1454 | } |
1455 | 1455 | } |
@@ -1479,7 +1479,7 @@ discard block |
||
1479 | 1479 | upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range)); |
1480 | 1480 | upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate)); |
1481 | 1481 | |
1482 | - if(!isset($update_tables['payment'])) { |
|
1482 | + if (!isset($update_tables['payment'])) { |
|
1483 | 1483 | upd_alter_table('users', array( |
1484 | 1484 | "ADD KEY `I_user_id_name` (`id`, `username`)", |
1485 | 1485 | ), !$update_indexes['users']['I_user_id_name']); |
@@ -1513,15 +1513,15 @@ discard block |
||
1513 | 1513 | upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price)); |
1514 | 1514 | |
1515 | 1515 | // Updating category for Mercenaries |
1516 | - upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
1516 | + upd_do_query("UPDATE {{powerup}} SET powerup_category = ".UNIT_MERCENARIES." WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;"); |
|
1517 | 1517 | |
1518 | 1518 | // Convert Destructor to Death Star schematic |
1519 | 1519 | upd_do_query("UPDATE {{powerup}} |
1520 | - SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . " |
|
1520 | + SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_DEATH_STAR." |
|
1521 | 1521 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;"); |
1522 | 1522 | // Convert Assasin to SuperNova schematic |
1523 | 1523 | upd_do_query("UPDATE {{powerup}} |
1524 | - SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . " |
|
1524 | + SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_SUPERNOVA." |
|
1525 | 1525 | WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;"); |
1526 | 1526 | |
1527 | 1527 | upd_alter_table('iraks', array( |
@@ -1530,7 +1530,7 @@ discard block |
||
1530 | 1530 | ), !$update_tables['iraks']['fleet_start_type']); |
1531 | 1531 | |
1532 | 1532 | |
1533 | - if(!$update_tables['payment']['payment_status']) { |
|
1533 | + if (!$update_tables['payment']['payment_status']) { |
|
1534 | 1534 | upd_alter_table('payment', array( |
1535 | 1535 | "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`", |
1536 | 1536 | |
@@ -1545,7 +1545,7 @@ discard block |
||
1545 | 1545 | ), !$update_tables['payment']['payment_status']); |
1546 | 1546 | } |
1547 | 1547 | |
1548 | - upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";"); |
|
1548 | + upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = ".UNIT_PLANS.";"); |
|
1549 | 1549 | |
1550 | 1550 | upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date)); |
1551 | 1551 | upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures)); |
@@ -1557,7 +1557,7 @@ discard block |
||
1557 | 1557 | |
1558 | 1558 | upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium)); |
1559 | 1559 | |
1560 | - 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;"); |
|
1560 | + 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;"); |
|
1561 | 1561 | |
1562 | 1562 | |
1563 | 1563 | upd_do_query('COMMIT;', true); |
@@ -1614,7 +1614,7 @@ discard block |
||
1614 | 1614 | "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)", |
1615 | 1615 | ), !$update_indexes['notes']['I_owner_priority_time']); |
1616 | 1616 | |
1617 | - if(!$update_tables['buddy']['BUDDY_ID']) { |
|
1617 | + if (!$update_tables['buddy']['BUDDY_ID']) { |
|
1618 | 1618 | upd_alter_table('buddy', array( |
1619 | 1619 | "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy\Buddy table row ID'", |
1620 | 1620 | "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy\Buddy request status'", |
@@ -1635,16 +1635,16 @@ discard block |
||
1635 | 1635 | |
1636 | 1636 | $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;"); |
1637 | 1637 | $found = $lost = array(); |
1638 | - while($row = db_fetch($query)) { |
|
1639 | - $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
1640 | - if(!isset($found[$index])) { |
|
1638 | + while ($row = db_fetch($query)) { |
|
1639 | + $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']).';'.max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']); |
|
1640 | + if (!isset($found[$index])) { |
|
1641 | 1641 | $found[$index] = $row['BUDDY_ID']; |
1642 | 1642 | } else { |
1643 | 1643 | $lost[] = $row['BUDDY_ID']; |
1644 | 1644 | } |
1645 | 1645 | } |
1646 | 1646 | $lost = implode(',', $lost); |
1647 | - if($lost) { |
|
1647 | + if ($lost) { |
|
1648 | 1648 | upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})"); |
1649 | 1649 | } |
1650 | 1650 | |
@@ -1665,7 +1665,7 @@ discard block |
||
1665 | 1665 | |
1666 | 1666 | 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"); |
1667 | 1667 | |
1668 | - if(!$update_tables['ube_report']) { |
|
1668 | + if (!$update_tables['ube_report']) { |
|
1669 | 1669 | upd_create_table('ube_report', |
1670 | 1670 | "( |
1671 | 1671 | `ube_report_id` SERIAL COMMENT 'Report ID', |
@@ -1706,7 +1706,7 @@ discard block |
||
1706 | 1706 | ); |
1707 | 1707 | } |
1708 | 1708 | |
1709 | - if(!$update_tables['ube_report_player']) { |
|
1709 | + if (!$update_tables['ube_report_player']) { |
|
1710 | 1710 | upd_create_table('ube_report_player', |
1711 | 1711 | "( |
1712 | 1712 | `ube_report_player_id` SERIAL COMMENT 'Record ID', |
@@ -1727,7 +1727,7 @@ discard block |
||
1727 | 1727 | ); |
1728 | 1728 | } |
1729 | 1729 | |
1730 | - if(!$update_tables['ube_report_fleet']) { |
|
1730 | + if (!$update_tables['ube_report_fleet']) { |
|
1731 | 1731 | upd_create_table('ube_report_fleet', |
1732 | 1732 | "( |
1733 | 1733 | `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID', |
@@ -1757,7 +1757,7 @@ discard block |
||
1757 | 1757 | ); |
1758 | 1758 | } |
1759 | 1759 | |
1760 | - if(!$update_tables['ube_report_unit']) { |
|
1760 | + if (!$update_tables['ube_report_unit']) { |
|
1761 | 1761 | // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках |
1762 | 1762 | // Может сохранять имена удаленных кораблей долго? |
1763 | 1763 | |
@@ -1794,7 +1794,7 @@ discard block |
||
1794 | 1794 | ); |
1795 | 1795 | } |
1796 | 1796 | |
1797 | - if(!$update_tables['ube_report_outcome_fleet']) { |
|
1797 | + if (!$update_tables['ube_report_outcome_fleet']) { |
|
1798 | 1798 | upd_create_table('ube_report_outcome_fleet', |
1799 | 1799 | "( |
1800 | 1800 | `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID', |
@@ -1823,7 +1823,7 @@ discard block |
||
1823 | 1823 | ); |
1824 | 1824 | } |
1825 | 1825 | |
1826 | - if(!$update_tables['ube_report_outcome_unit']) { |
|
1826 | + if (!$update_tables['ube_report_outcome_unit']) { |
|
1827 | 1827 | upd_create_table('ube_report_outcome_unit', |
1828 | 1828 | "( |
1829 | 1829 | `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID', |
@@ -1844,7 +1844,7 @@ discard block |
||
1844 | 1844 | ); |
1845 | 1845 | } |
1846 | 1846 | |
1847 | - if(!$update_tables['unit']) { |
|
1847 | + if (!$update_tables['unit']) { |
|
1848 | 1848 | upd_create_table('unit', |
1849 | 1849 | "( |
1850 | 1850 | `unit_id` SERIAL COMMENT 'Record ID', |
@@ -1863,7 +1863,7 @@ discard block |
||
1863 | 1863 | ); |
1864 | 1864 | } |
1865 | 1865 | |
1866 | - if(!$update_tables['captain']) { |
|
1866 | + if (!$update_tables['captain']) { |
|
1867 | 1867 | upd_create_table('captain', |
1868 | 1868 | "( |
1869 | 1869 | `captain_id` SERIAL COMMENT 'Record ID', |
@@ -1883,7 +1883,7 @@ discard block |
||
1883 | 1883 | ); |
1884 | 1884 | } |
1885 | 1885 | |
1886 | - if(!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1886 | + if (!$update_tables['fleets']['fleet_start_planet_id']) { |
|
1887 | 1887 | upd_alter_table('fleets', array( |
1888 | 1888 | "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`", |
1889 | 1889 | "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`", |
@@ -1905,7 +1905,7 @@ discard block |
||
1905 | 1905 | |
1906 | 1906 | upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']); |
1907 | 1907 | |
1908 | - if(!$update_tables['chat_player']) { |
|
1908 | + if (!$update_tables['chat_player']) { |
|
1909 | 1909 | upd_create_table('chat_player', |
1910 | 1910 | "( |
1911 | 1911 | `chat_player_id` SERIAL COMMENT 'Record ID', |
@@ -1967,7 +1967,7 @@ discard block |
||
1967 | 1967 | "DROP FOREIGN KEY `FK_payment_user`", |
1968 | 1968 | ), $update_foreigns['payment']['FK_payment_user']); |
1969 | 1969 | |
1970 | - if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1970 | + if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') { |
|
1971 | 1971 | upd_alter_table('chat', array( |
1972 | 1972 | "DROP FOREIGN KEY `FK_chat_message_sender_user_id`", |
1973 | 1973 | "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`", |
@@ -2000,7 +2000,7 @@ discard block |
||
2000 | 2000 | "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)", |
2001 | 2001 | ), !$update_indexes['ube_report']['I_ube_report_time_combat']); |
2002 | 2002 | |
2003 | - if(!$update_tables['unit']['unit_time_start']) { |
|
2003 | + if (!$update_tables['unit']['unit_time_start']) { |
|
2004 | 2004 | upd_alter_table('unit', array( |
2005 | 2005 | "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'", |
2006 | 2006 | "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'", |
@@ -2010,13 +2010,13 @@ discard block |
||
2010 | 2010 | "INSERT INTO {{unit}} |
2011 | 2011 | (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish) |
2012 | 2012 | SELECT |
2013 | - `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level` |
|
2013 | + `powerup_user_id`, " . LOC_USER.", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level` |
|
2014 | 2014 | , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL) |
2015 | 2015 | FROM {{powerup}}" |
2016 | 2016 | ); |
2017 | 2017 | } |
2018 | 2018 | |
2019 | - if(!$update_tables['que']) { |
|
2019 | + if (!$update_tables['que']) { |
|
2020 | 2020 | upd_create_table('que', |
2021 | 2021 | "( |
2022 | 2022 | `que_id` SERIAL COMMENT 'Internal que id', |
@@ -2048,25 +2048,25 @@ discard block |
||
2048 | 2048 | } |
2049 | 2049 | |
2050 | 2050 | // Конвертирум очередь исследований |
2051 | - if($update_tables['users']['que']) { |
|
2051 | + if ($update_tables['users']['que']) { |
|
2052 | 2052 | $que_lines = array(); |
2053 | 2053 | $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`"); |
2054 | - while($que_row = db_fetch($que_query)) { |
|
2054 | + while ($que_row = db_fetch($que_query)) { |
|
2055 | 2055 | $que_data = explode(',', $que_row['que']); |
2056 | 2056 | |
2057 | - if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2057 | + if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) { |
|
2058 | 2058 | continue; |
2059 | 2059 | } |
2060 | 2060 | |
2061 | 2061 | $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0; |
2062 | 2062 | // Если планета пустая - ставим главку |
2063 | 2063 | $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet']; |
2064 | - if($que_data[QI_PLANET_ID]) { |
|
2064 | + if ($que_data[QI_PLANET_ID]) { |
|
2065 | 2065 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
2066 | - if(!$que_planet_check['id']) { |
|
2066 | + if (!$que_planet_check['id']) { |
|
2067 | 2067 | $que_data[QI_PLANET_ID] = $que_row['id_planet']; |
2068 | 2068 | $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}")); |
2069 | - if(!$que_planet_check['id']) { |
|
2069 | + if (!$que_planet_check['id']) { |
|
2070 | 2070 | $que_data[QI_PLANET_ID] = 'NULL'; |
2071 | 2071 | } |
2072 | 2072 | } |
@@ -2080,20 +2080,20 @@ discard block |
||
2080 | 2080 | $price_increase = pow($unit_factor, $unit_level); |
2081 | 2081 | $unit_level++; |
2082 | 2082 | $unit_cost = array(); |
2083 | - foreach($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2084 | - if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2083 | + foreach ($unit_info[P_COST] as $resource_id => $resource_amount) { |
|
2084 | + if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) { |
|
2085 | 2085 | continue; |
2086 | 2086 | } |
2087 | - $unit_cost[] = $resource_id . ',' . floor($resource_cost); |
|
2087 | + $unit_cost[] = $resource_id.','.floor($resource_cost); |
|
2088 | 2088 | } |
2089 | 2089 | $unit_cost = implode(';', $unit_cost); |
2090 | 2090 | |
2091 | - $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," . |
|
2092 | - BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
2091 | + $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]},".QUE_RESEARCH.",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1,". |
|
2092 | + BUILD_CREATE.",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')"; |
|
2093 | 2093 | } |
2094 | 2094 | |
2095 | - if(!empty($que_lines)) { |
|
2096 | - 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)); |
|
2095 | + if (!empty($que_lines)) { |
|
2096 | + 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)); |
|
2097 | 2097 | } |
2098 | 2098 | |
2099 | 2099 | upd_alter_table('users', array( |
@@ -2106,23 +2106,23 @@ discard block |
||
2106 | 2106 | |
2107 | 2107 | |
2108 | 2108 | // Ковертируем технологии в таблицы |
2109 | - if($update_tables['users']['graviton_tech']) { |
|
2110 | - upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES); |
|
2109 | + if ($update_tables['users']['graviton_tech']) { |
|
2110 | + upd_do_query("DELETE FROM {{unit}} WHERE unit_type = ".UNIT_TECHNOLOGIES); |
|
2111 | 2111 | |
2112 | 2112 | $que_lines = array(); |
2113 | 2113 | $user_query = upd_do_query("SELECT * FROM {{users}}"); |
2114 | 2114 | upd_add_more_time(300); |
2115 | 2115 | $sn_group_tech = sn_get_groups('tech'); |
2116 | - while($user_row = db_fetch($user_query)) { |
|
2117 | - foreach($sn_group_tech as $tech_id) { |
|
2118 | - if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2119 | - $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})"; |
|
2116 | + while ($user_row = db_fetch($user_query)) { |
|
2117 | + foreach ($sn_group_tech as $tech_id) { |
|
2118 | + if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) { |
|
2119 | + $que_lines[] = "({$user_row['id']},".LOC_USER.",{$user_row['id']},".UNIT_TECHNOLOGIES.",{$tech_id},{$tech_level})"; |
|
2120 | 2120 | } |
2121 | 2121 | } |
2122 | 2122 | } |
2123 | 2123 | |
2124 | - if(!empty($que_lines)) { |
|
2125 | - 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)); |
|
2124 | + if (!empty($que_lines)) { |
|
2125 | + 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)); |
|
2126 | 2126 | } |
2127 | 2127 | |
2128 | 2128 | upd_alter_table('users', array( |
@@ -2130,25 +2130,25 @@ discard block |
||
2130 | 2130 | ), $update_tables['users']['graviton_tech']); |
2131 | 2131 | } |
2132 | 2132 | |
2133 | - if(!$update_indexes['unit']['I_unit_record_search']) { |
|
2133 | + if (!$update_indexes['unit']['I_unit_record_search']) { |
|
2134 | 2134 | upd_alter_table('unit', array( |
2135 | 2135 | "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)", |
2136 | 2136 | ), !$update_indexes['unit']['I_unit_record_search']); |
2137 | 2137 | |
2138 | - foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2138 | + foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) { |
|
2139 | 2139 | $planet_units[get_unit_param($unit_id, P_NAME)] = 1; |
2140 | 2140 | } |
2141 | 2141 | $drop_index = array(); |
2142 | 2142 | $create_index = &$drop_index; // array(); |
2143 | - foreach($planet_units as $unit_name => $unit_create) { |
|
2144 | - if($update_indexes['planets']['I_' . $unit_name]) { |
|
2143 | + foreach ($planet_units as $unit_name => $unit_create) { |
|
2144 | + if ($update_indexes['planets']['I_'.$unit_name]) { |
|
2145 | 2145 | $drop_index[] = "DROP KEY I_{$unit_name}"; |
2146 | 2146 | } |
2147 | - if($update_indexes['planets']['i_' . $unit_name]) { |
|
2147 | + if ($update_indexes['planets']['i_'.$unit_name]) { |
|
2148 | 2148 | $drop_index[] = "DROP KEY i_{$unit_name}"; |
2149 | 2149 | } |
2150 | 2150 | |
2151 | - if($unit_create) { |
|
2151 | + if ($unit_create) { |
|
2152 | 2152 | $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)"; |
2153 | 2153 | } |
2154 | 2154 | } |
@@ -2159,7 +2159,7 @@ discard block |
||
2159 | 2159 | "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`", |
2160 | 2160 | ), !$update_tables['users']['user_time_utc_offset']); |
2161 | 2161 | |
2162 | - if(!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2162 | + if (!$update_foreigns['alliance']['FK_alliance_owner']) { |
|
2163 | 2163 | upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})"); |
2164 | 2164 | |
2165 | 2165 | upd_alter_table('alliance', array( |
@@ -2179,7 +2179,7 @@ discard block |
||
2179 | 2179 | |
2180 | 2180 | upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer); |
2181 | 2181 | |
2182 | - if(!$update_tables['player_name_history']) { |
|
2182 | + if (!$update_tables['player_name_history']) { |
|
2183 | 2183 | upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost); |
2184 | 2184 | upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY); |
2185 | 2185 | |
@@ -2205,10 +2205,10 @@ discard block |
||
2205 | 2205 | |
2206 | 2206 | upd_alter_table('planets', array( |
2207 | 2207 | "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'", |
2208 | - "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'", |
|
2208 | + "ADD `density_index` TINYINT NOT NULL DEFAULT ".PLANET_DENSITY_STANDARD." COMMENT 'Planet cached density index'", |
|
2209 | 2209 | ), !$update_tables['planets']['density_index']); |
2210 | 2210 | |
2211 | - if($update_tables['users']['player_artifact_list']) { |
|
2211 | + if ($update_tables['users']['player_artifact_list']) { |
|
2212 | 2212 | upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']); |
2213 | 2213 | |
2214 | 2214 | 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']); |
@@ -2218,14 +2218,14 @@ discard block |
||
2218 | 2218 | $db_changeset = array(); |
2219 | 2219 | |
2220 | 2220 | $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE"); |
2221 | - while($row = db_fetch($query)) { |
|
2221 | + while ($row = db_fetch($query)) { |
|
2222 | 2222 | $artifact_list = explode(';', $row['player_artifact_list']); |
2223 | - if(!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2223 | + if (!$row['player_artifact_list'] || empty($artifact_list)) { |
|
2224 | 2224 | continue; |
2225 | 2225 | } |
2226 | - foreach($artifact_list as $key => &$value) { |
|
2226 | + foreach ($artifact_list as $key => &$value) { |
|
2227 | 2227 | $value = explode(',', $value); |
2228 | - if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2228 | + if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) { |
|
2229 | 2229 | unset($artifact_list[$key]); |
2230 | 2230 | continue; |
2231 | 2231 | } |
@@ -10,34 +10,34 @@ discard block |
||
10 | 10 | * @copyright 2008 By Chlorel for XNova |
11 | 11 | */ |
12 | 12 | |
13 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
13 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
14 | 14 | |
15 | 15 | lng_include('fleet'); |
16 | 16 | |
17 | -if($TargetPlanet = sys_get_param_id('jmpto')) |
|
17 | +if ($TargetPlanet = sys_get_param_id('jmpto')) |
|
18 | 18 | { |
19 | 19 | sn_db_transaction_start(); |
20 | 20 | DBStaticUser::db_user_by_id($user['id'], true, 'id'); |
21 | 21 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
22 | - if(!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
|
22 | + if (!($NextJumpTime = uni_get_time_to_jump($planetrow))) |
|
23 | 23 | { |
24 | 24 | $TargetGate = DBStaticPlanet::db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`'); |
25 | - if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
|
25 | + if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0) |
|
26 | 26 | { |
27 | - $NextDestTime = uni_get_time_to_jump ( $TargetGate ); |
|
28 | - if(!$NextDestTime) |
|
27 | + $NextDestTime = uni_get_time_to_jump($TargetGate); |
|
28 | + if (!$NextDestTime) |
|
29 | 29 | { |
30 | 30 | $ship_list = sys_get_param('ships'); |
31 | 31 | $jumpMade = false; |
32 | - foreach($ship_list as $ship_id => $ship_count) |
|
32 | + foreach ($ship_list as $ship_id => $ship_count) |
|
33 | 33 | { |
34 | - if(!in_array($ship_id, Fleet::$snGroupFleet)) |
|
34 | + if (!in_array($ship_id, Fleet::$snGroupFleet)) |
|
35 | 35 | { |
36 | 36 | continue; |
37 | 37 | } |
38 | 38 | |
39 | 39 | $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id))); |
40 | - if($ship_count) |
|
40 | + if ($ship_count) |
|
41 | 41 | { |
42 | 42 | $jumpMade = true; |
43 | 43 | DBStaticUnit::dbUpdateOrInsertUnit($ship_id, -$ship_count, $user, $planetrow['id']); |
@@ -45,39 +45,39 @@ discard block |
||
45 | 45 | } |
46 | 46 | } |
47 | 47 | // Dit monsieur, y avait quelque chose a envoyer ??? |
48 | - if($jumpMade) |
|
48 | + if ($jumpMade) |
|
49 | 49 | { |
50 | - DBStaticPlanet::db_planet_update_set_by_id($TargetGate['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
|
51 | - DBStaticPlanet::db_planet_update_set_by_id($planetrow['id'], "`last_jump_time` = " . SN_TIME_NOW . ""); |
|
50 | + DBStaticPlanet::db_planet_update_set_by_id($TargetGate['id'], "`last_jump_time` = ".SN_TIME_NOW.""); |
|
51 | + DBStaticPlanet::db_planet_update_set_by_id($planetrow['id'], "`last_jump_time` = ".SN_TIME_NOW.""); |
|
52 | 52 | |
53 | 53 | DBStaticUser::db_user_set_by_id($user['id'], "`current_planet` = '{$TargetGate['id']}'"); |
54 | 54 | |
55 | 55 | $planetrow['last_jump_time'] = SN_TIME_NOW; |
56 | - $RetMessage = classLocale::$lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow)); |
|
56 | + $RetMessage = classLocale::$lang['gate_jump_done']." - ".pretty_time(uni_get_time_to_jump($planetrow)); |
|
57 | 57 | } else { |
58 | 58 | $RetMessage = classLocale::$lang['gate_wait_data']; |
59 | 59 | } |
60 | 60 | } else { |
61 | - $RetMessage = classLocale::$lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime); |
|
61 | + $RetMessage = classLocale::$lang['gate_wait_dest']." - ".pretty_time($NextDestTime); |
|
62 | 62 | } |
63 | 63 | } else { |
64 | 64 | $RetMessage = classLocale::$lang['gate_no_dest_g']; |
65 | 65 | } |
66 | 66 | } else { |
67 | - $RetMessage = classLocale::$lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime); |
|
67 | + $RetMessage = classLocale::$lang['gate_wait_star']." - ".pretty_time($NextJumpTime); |
|
68 | 68 | } |
69 | 69 | sn_db_transaction_commit(); |
70 | 70 | message($RetMessage, classLocale::$lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10); |
71 | 71 | } else { |
72 | 72 | $template = gettemplate('jumpgate', true); |
73 | - if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
|
73 | + if (mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0) |
|
74 | 74 | { |
75 | 75 | $Combo = ''; |
76 | 76 | $MoonList = DBStaticPlanet::db_planet_list_moon_other($user['id'], $planetrow['id']); |
77 | 77 | // while($CurMoon = db_fetch($MoonList)) |
78 | - foreach($MoonList as $CurMoon) |
|
78 | + foreach ($MoonList as $CurMoon) |
|
79 | 79 | { |
80 | - if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
|
80 | + if (mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1) |
|
81 | 81 | { |
82 | 82 | $NextJumpTime = uni_get_time_to_jump($CurMoon); |
83 | 83 | $template->assign_block_vars('moon', array( |
@@ -91,9 +91,9 @@ discard block |
||
91 | 91 | } |
92 | 92 | } |
93 | 93 | |
94 | - foreach(Fleet::$snGroupFleet as $Ship) |
|
94 | + foreach (Fleet::$snGroupFleet as $Ship) |
|
95 | 95 | { |
96 | - if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
|
96 | + if (($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0) |
|
97 | 97 | { |
98 | 98 | continue; |
99 | 99 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $template->assign_vars($quest_templatized); |
180 | 180 | if (!empty($quest_templatized['quest_rewards_list'])) { |
181 | 181 | foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) { |
182 | - $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
|
182 | + $template->assign_block_vars(($block_name ? $block_name.'.' : '').'quest_rewards_list', $quest_reward); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | |
249 | 249 | $comment_reward = array(); |
250 | 250 | foreach ($reward_list as $unit_id => $unit_amount) { |
251 | - $comment_reward[] = $unit_amount . ' ' . classLocale::$lang['tech'][$unit_id]; |
|
251 | + $comment_reward[] = $unit_amount.' '.classLocale::$lang['tech'][$unit_id]; |
|
252 | 252 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
253 | 253 | } |
254 | - $comment .= " {$classLocale['qst_msg_your_reward']} " . implode(',', $comment_reward); |
|
254 | + $comment .= " {$classLocale['qst_msg_your_reward']} ".implode(',', $comment_reward); |
|
255 | 255 | |
256 | 256 | DBStaticMessages::msg_send_simple_message($user['id'], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['msg_from_admin'], classLocale::$lang['qst_msg_complete_subject'], $comment); |
257 | 257 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | if (!empty($resourcesChange)) { |
291 | 291 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
292 | - if($planet_id) { |
|
292 | + if ($planet_id) { |
|
293 | 293 | // update planet |
294 | 294 | DBStaticPlanet::db_planet_update_resources($resourcesChange, $planet_id); |
295 | 295 | } else { |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | |
3 | 3 | function que_get_unit_que($unit_id) { |
4 | 4 | $que_type = false; |
5 | - foreach(sn_get_groups('ques') as $que_id => $que_data) { |
|
6 | - if(in_array($unit_id, $que_data['unit_list'])) { |
|
5 | + foreach (sn_get_groups('ques') as $que_id => $que_data) { |
|
6 | + if (in_array($unit_id, $que_data['unit_list'])) { |
|
7 | 7 | $que_type = $que_id; |
8 | 8 | break; |
9 | 9 | } |
@@ -14,14 +14,14 @@ discard block |
||
14 | 14 | |
15 | 15 | |
16 | 16 | function que_get_max_que_length($user, $planet, $que_id, $que_data = null) { |
17 | - if(empty($que_data)) { |
|
17 | + if (empty($que_data)) { |
|
18 | 18 | $que_data = sn_get_groups('ques'); |
19 | 19 | $que_data = $que_data[$que_id]; |
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | 23 | $que_length = 1; |
24 | - switch($que_id) { |
|
24 | + switch ($que_id) { |
|
25 | 25 | case QUE_RESEARCH: |
26 | 26 | $que_length = classSupernova::$config->server_que_length_research + mrc_get_level($user, null, UNIT_PREMIUM); // TODO - вынести в модуль |
27 | 27 | break; |
@@ -35,8 +35,8 @@ discard block |
||
35 | 35 | |
36 | 36 | function eco_que_str2arr($que_str) { |
37 | 37 | $que_arr = explode(';', $que_str); |
38 | - foreach($que_arr as $que_index => &$que_item) { |
|
39 | - if($que_item) { |
|
38 | + foreach ($que_arr as $que_index => &$que_item) { |
|
39 | + if ($que_item) { |
|
40 | 40 | $que_item = explode(',', $que_item); |
41 | 41 | } else { |
42 | 42 | unset($que_arr[$que_index]); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | function eco_que_arr2str($que_arr) { |
50 | - foreach($que_arr as &$que_item) { |
|
50 | + foreach ($que_arr as &$que_item) { |
|
51 | 51 | $que_item = implode(',', $que_item); |
52 | 52 | } |
53 | 53 | |
@@ -59,14 +59,14 @@ discard block |
||
59 | 59 | $classLocale = classLocale::$lang; |
60 | 60 | |
61 | 61 | $is_autoconvert = false; |
62 | - if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
62 | + if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
63 | 63 | $build_mode = BUILD_CREATE; |
64 | 64 | $is_autoconvert = true; |
65 | 65 | } |
66 | 66 | |
67 | 67 | $unit_amount_qued = 0; |
68 | 68 | try { |
69 | - if(!$user['id']) { |
|
69 | + if (!$user['id']) { |
|
70 | 70 | throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
71 | 71 | } |
72 | 72 | |
@@ -77,16 +77,16 @@ discard block |
||
77 | 77 | foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break; |
78 | 78 | } |
79 | 79 | */ |
80 | - if(!$unit_id) { |
|
80 | + if (!$unit_id) { |
|
81 | 81 | throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
82 | 82 | } |
83 | 83 | |
84 | 84 | $que_id = que_get_unit_que($unit_id); |
85 | - if(!$que_id) { |
|
85 | + if (!$que_id) { |
|
86 | 86 | throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
87 | 87 | } |
88 | 88 | |
89 | - if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
89 | + if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
90 | 90 | throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION |
91 | 91 | } |
92 | 92 | |
@@ -94,12 +94,12 @@ discard block |
||
94 | 94 | $que_data = $que_data[$que_id]; |
95 | 95 | |
96 | 96 | // TODO Переделать под подочереди |
97 | - if($que_id == QUE_STRUCTURES) { |
|
97 | + if ($que_id == QUE_STRUCTURES) { |
|
98 | 98 | $sn_groups_build_allow = sn_get_groups('build_allow'); |
99 | 99 | $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; |
100 | 100 | |
101 | - if(!isset($que_data['unit_list'][$unit_id])) { |
|
102 | - throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
|
101 | + if (!isset($que_data['unit_list'][$unit_id])) { |
|
102 | + throw new exception('{Это здание нельзя строить на '.($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | /* |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | // Это нужно, что бы заблокировать пользователя и работу с очередями |
120 | 120 | $user = DBStaticUser::db_user_by_id($user['id']); |
121 | 121 | // Это нужно, что бы заблокировать планету от списания ресурсов |
122 | - if(isset($planet['id']) && $planet['id']) { |
|
122 | + if (isset($planet['id']) && $planet['id']) { |
|
123 | 123 | $planet = DBStaticPlanet::db_planet_by_id($planet['id'], true); |
124 | 124 | } else { |
125 | 125 | $planet['id'] = 0; |
@@ -131,12 +131,12 @@ discard block |
||
131 | 131 | $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id]; |
132 | 132 | $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); |
133 | 133 | // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей |
134 | - if(count($in_que) >= $que_max_length) { |
|
134 | + if (count($in_que) >= $que_max_length) { |
|
135 | 135 | throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION |
136 | 136 | } |
137 | 137 | |
138 | 138 | // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов |
139 | - switch(eco_can_build_unit($user, $planet, $unit_id)) { |
|
139 | + switch (eco_can_build_unit($user, $planet, $unit_id)) { |
|
140 | 140 | case BUILD_ALLOWED: |
141 | 141 | break; |
142 | 142 | case BUILD_UNIT_BUSY: |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading |
145 | 145 | // case BUILD_REQUIRE_NOT_MEET: |
146 | 146 | default: |
147 | - if($build_mode == BUILD_CREATE) { |
|
147 | + if ($build_mode == BUILD_CREATE) { |
|
148 | 148 | throw new exception('{Требования не удовлетворены}', ERR_ERROR); |
149 | 149 | } |
150 | 150 | break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | $unit_amount_qued = $unit_amount; |
155 | 155 | $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; |
156 | 156 | $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; |
157 | - if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
158 | - if($unit_level >= $unit_max) { |
|
157 | + if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
158 | + if ($unit_level >= $unit_max) { |
|
159 | 159 | throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
160 | 160 | } |
161 | 161 | $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); |
162 | 162 | } |
163 | 163 | |
164 | - if($unit_amount < 1) { |
|
164 | + if ($unit_amount < 1) { |
|
165 | 165 | throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
166 | 166 | } |
167 | 167 | |
@@ -170,21 +170,21 @@ discard block |
||
170 | 170 | // { |
171 | 171 | // die('Unit busy'); // TODO EXCEPTION |
172 | 172 | // } |
173 | - if(get_unit_param($unit_id, P_STACKABLE)) { |
|
173 | + if (get_unit_param($unit_id, P_STACKABLE)) { |
|
174 | 174 | // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь |
175 | - if(in_array($unit_id, $group_missile = sn_get_groups(GROUP_STR_MISSILES))) { |
|
175 | + if (in_array($unit_id, $group_missile = sn_get_groups(GROUP_STR_MISSILES))) { |
|
176 | 176 | // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита |
177 | 177 | $used_silo = 0; |
178 | - foreach($group_missile as $missile_id) { |
|
178 | + foreach ($group_missile as $missile_id) { |
|
179 | 179 | $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; |
180 | 180 | $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); |
181 | 181 | } |
182 | 182 | $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; |
183 | - if($free_silo <= 0) { |
|
183 | + if ($free_silo <= 0) { |
|
184 | 184 | throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
185 | 185 | } |
186 | 186 | $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); |
187 | - if($free_silo < $unit_size) { |
|
187 | + if ($free_silo < $unit_size) { |
|
188 | 188 | throw new exception("{В ракетной шахте нет места для {$classLocale['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION |
189 | 189 | } |
190 | 190 | $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); |
@@ -192,10 +192,10 @@ discard block |
||
192 | 192 | $unit_level = $new_unit_level = 0; |
193 | 193 | } else { |
194 | 194 | $unit_amount = 1; |
195 | - if($que_id == QUE_STRUCTURES) { |
|
195 | + if ($que_id == QUE_STRUCTURES) { |
|
196 | 196 | // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0) |
197 | 197 | $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; |
198 | - if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
198 | + if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) { |
|
199 | 199 | throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION |
200 | 200 | } |
201 | 201 | // И что это я такое написал? Зачем? |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | |
213 | 213 | $exchange = array(); |
214 | 214 | $market_get_autoconvert_cost = market_get_autoconvert_cost(); |
215 | - if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
215 | + if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
216 | 216 | $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
217 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
218 | - throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
|
217 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
218 | + throw new exception("{Нет хватает ".($market_get_autoconvert_cost - $dark_matter)."ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | !get_unit_param($unit_id, P_STACKABLE) ? $unit_amount = 1 : false; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $resource_exchange_rates = array(); |
225 | 225 | $resource_diff = array(); |
226 | 226 | $all_positive = true; |
227 | - foreach($resources_loot as $resource_id) { |
|
227 | + foreach ($resources_loot as $resource_id) { |
|
228 | 228 | $resource_db_name = pname_resource_name($resource_id); |
229 | 229 | $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id)); |
230 | 230 | $resource_exchange_rates[$resource_id] = classSupernova::$config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | $all_positive = $all_positive && ($resource_diff[$resource_id] > 0); |
233 | 233 | } |
234 | 234 | // Нужна автоконвертация |
235 | - if($all_positive) { |
|
235 | + if ($all_positive) { |
|
236 | 236 | $is_autoconvert = false; |
237 | 237 | } else { |
238 | - foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
239 | - if($resource_diff_amount >= 0) { |
|
238 | + foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
239 | + if ($resource_diff_amount >= 0) { |
|
240 | 240 | continue; |
241 | 241 | } |
242 | - foreach($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
243 | - if($resource_got_amount <= 0) { |
|
242 | + foreach ($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
243 | + if ($resource_got_amount <= 0) { |
|
244 | 244 | continue; |
245 | 245 | } |
246 | 246 | $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id]; |
@@ -256,14 +256,14 @@ discard block |
||
256 | 256 | } |
257 | 257 | |
258 | 258 | $is_autoconvert_ok = true; |
259 | - foreach($resource_diff as $resource_diff_amount2) { |
|
260 | - if($resource_diff_amount2 < 0) { |
|
259 | + foreach ($resource_diff as $resource_diff_amount2) { |
|
260 | + if ($resource_diff_amount2 < 0) { |
|
261 | 261 | $is_autoconvert_ok = false; |
262 | 262 | break; |
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | - if($is_autoconvert_ok) { |
|
266 | + if ($is_autoconvert_ok) { |
|
267 | 267 | $build_data['RESULT'][$build_mode] = BUILD_ALLOWED; |
268 | 268 | $build_data['CAN'][$build_mode] = $unit_amount; |
269 | 269 | } else { |
@@ -272,19 +272,19 @@ discard block |
||
272 | 272 | } |
273 | 273 | } |
274 | 274 | $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); |
275 | - if($unit_amount <= 0) { |
|
275 | + if ($unit_amount <= 0) { |
|
276 | 276 | throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION |
277 | 277 | } |
278 | 278 | |
279 | - if($new_unit_level < 0) { |
|
279 | + if ($new_unit_level < 0) { |
|
280 | 280 | throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION |
281 | 281 | } |
282 | 282 | |
283 | - if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
283 | + if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
284 | 284 | throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION |
285 | 285 | } |
286 | 286 | |
287 | - if($is_autoconvert) { |
|
287 | + if ($is_autoconvert) { |
|
288 | 288 | ksort($exchange); |
289 | 289 | ksort($resource_got); |
290 | 290 | db_change_units($user, $planet, array( |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | $unit_amount_qued = 0; |
302 | - while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
302 | + while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
303 | 303 | $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); |
304 | 304 | que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
305 | 305 | $unit_amount -= $place; |
@@ -309,8 +309,8 @@ discard block |
||
309 | 309 | |
310 | 310 | sn_db_transaction_commit(); |
311 | 311 | |
312 | - if($redirect) { |
|
313 | - sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); |
|
312 | + if ($redirect) { |
|
313 | + sys_redirect("{$_SERVER['PHP_SELF']}?mode=".sys_get_param_str('mode')."&ally_id=".sys_get_param_id('ally_id')); |
|
314 | 314 | die(); |
315 | 315 | } |
316 | 316 | |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | 'STATUS' => ERR_NONE, |
319 | 319 | 'MESSAGE' => '{Строительство начато}', |
320 | 320 | ); |
321 | - } catch(exception $e) { |
|
321 | + } catch (exception $e) { |
|
322 | 322 | sn_db_transaction_rollback(); |
323 | 323 | $operation_result = array( |
324 | 324 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -326,8 +326,8 @@ discard block |
||
326 | 326 | ); |
327 | 327 | } |
328 | 328 | |
329 | - if(!empty($operation_result['MESSAGE'])) { |
|
330 | - $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . classLocale::$lang['tech'][$unit_id] . ']'; |
|
329 | + if (!empty($operation_result['MESSAGE'])) { |
|
330 | + $operation_result['MESSAGE'] .= ' '.($unit_amount_qued ? $unit_amount_qued : $unit_amount).'x['.classLocale::$lang['tech'][$unit_id].']'; |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | return $operation_result; |
@@ -337,11 +337,11 @@ discard block |
||
337 | 337 | function que_recalculate($old_que) { |
338 | 338 | $new_que = array(); |
339 | 339 | |
340 | - if(!is_array($old_que['items'])) { |
|
340 | + if (!is_array($old_que['items'])) { |
|
341 | 341 | return $new_que; |
342 | 342 | } |
343 | - foreach($old_que['items'] as $row) { |
|
344 | - if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
343 | + foreach ($old_que['items'] as $row) { |
|
344 | + if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
345 | 345 | continue; |
346 | 346 | } |
347 | 347 | |
@@ -352,9 +352,9 @@ discard block |
||
352 | 352 | |
353 | 353 | $last_id = count($new_que['items']) - 1; |
354 | 354 | |
355 | - if($row['que_planet_id']) { |
|
355 | + if ($row['que_planet_id']) { |
|
356 | 356 | $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
357 | - } elseif($row['que_type'] == QUE_RESEARCH) { |
|
357 | + } elseif ($row['que_type'] == QUE_RESEARCH) { |
|
358 | 358 | $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
359 | 359 | } |
360 | 360 | $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id]; |
@@ -389,9 +389,9 @@ discard block |
||
389 | 389 | $que_type = que_get_unit_que($unit_id); |
390 | 390 | $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL'; |
391 | 391 | $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin; |
392 | - if(is_numeric($planet_id)) { |
|
392 | + if (is_numeric($planet_id)) { |
|
393 | 393 | DBStaticPlanet::db_planet_update_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
394 | - } elseif(is_numeric($user['id'])) { |
|
394 | + } elseif (is_numeric($user['id'])) { |
|
395 | 395 | DBStaticUser::db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
396 | 396 | } |
397 | 397 | |
@@ -421,17 +421,17 @@ discard block |
||
421 | 421 | $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0; |
422 | 422 | $global_que = que_get($user['id'], $planet['id'], $que_type, true); |
423 | 423 | |
424 | - if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
424 | + if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
425 | 425 | $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]); |
426 | 426 | |
427 | - foreach($que as $que_item) { |
|
427 | + foreach ($que as $que_item) { |
|
428 | 428 | DBStaticQue::db_que_delete_by_id($que_item['que_id']); |
429 | 429 | |
430 | - if($que_item['que_planet_id_origin']) { |
|
430 | + if ($que_item['que_planet_id_origin']) { |
|
431 | 431 | $planet['id'] = $que_item['que_planet_id_origin']; |
432 | 432 | } |
433 | 433 | |
434 | - if(!isset($planets_locked[$planet['id']])) { |
|
434 | + if (!isset($planets_locked[$planet['id']])) { |
|
435 | 435 | $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet; |
436 | 436 | } |
437 | 437 | |
@@ -443,14 +443,14 @@ discard block |
||
443 | 443 | RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'], |
444 | 444 | )); |
445 | 445 | |
446 | - if(!$clear) { |
|
446 | + if (!$clear) { |
|
447 | 447 | break; |
448 | 448 | } |
449 | 449 | } |
450 | 450 | |
451 | - if(is_numeric($planet['id'])) { |
|
451 | + if (is_numeric($planet['id'])) { |
|
452 | 452 | DBStaticPlanet::db_planet_update_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
453 | - } elseif(is_numeric($user['id'])) { |
|
453 | + } elseif (is_numeric($user['id'])) { |
|
454 | 454 | DBStaticUser::db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
455 | 455 | } |
456 | 456 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | sn_db_transaction_rollback(); |
460 | 460 | } |
461 | 461 | //die(); |
462 | - header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}" . "&ally_id=" . sys_get_param_id('ally_id')); |
|
462 | + header("Location: {$_SERVER['PHP_SELF']}?mode={$que_type}"."&ally_id=".sys_get_param_id('ally_id')); |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | |
@@ -498,21 +498,21 @@ discard block |
||
498 | 498 | // TODO: Переделать для $que_type === false |
499 | 499 | $planet['id'] = $planet['id'] ? $planet['id'] : 0; |
500 | 500 | |
501 | - if(!is_array($que)) { |
|
501 | + if (!is_array($que)) { |
|
502 | 502 | $que = que_get($user['id'], $planet['id'], $que_type); |
503 | 503 | } |
504 | 504 | |
505 | - if(is_array($que) && isset($que['items'])) { |
|
505 | + if (is_array($que) && isset($que['items'])) { |
|
506 | 506 | $que = $que['ques'][$que_type][$user['id']][$planet['id']]; |
507 | 507 | } |
508 | 508 | |
509 | - if($que) { |
|
510 | - foreach($que as $que_element) { |
|
509 | + if ($que) { |
|
510 | + foreach ($que as $que_element) { |
|
511 | 511 | $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names)); |
512 | 512 | } |
513 | 513 | } |
514 | 514 | |
515 | - if($que_type == QUE_RESEARCH) { |
|
515 | + if ($que_type == QUE_RESEARCH) { |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | $user = DBStaticUser::db_user_by_id($user['id'], true); |
539 | 539 | |
540 | 540 | $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']); |
541 | - if($planet === null && !$time_left[$user['id']][0]) { |
|
541 | + if ($planet === null && !$time_left[$user['id']][0]) { |
|
542 | 542 | // TODO |
543 | 543 | return $que; |
544 | 544 | } |
@@ -547,12 +547,12 @@ discard block |
||
547 | 547 | $que_type_id = $planet === null ? QUE_RESEARCH : false; |
548 | 548 | $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false |
549 | 549 | $que = que_get($user['id'], $planet, $que_type_id, true); |
550 | - if(empty($que['items'])) { |
|
550 | + if (empty($que['items'])) { |
|
551 | 551 | return $que; |
552 | 552 | } |
553 | 553 | |
554 | 554 | $planet_list = array(); |
555 | - if($planet !== null) { |
|
555 | + if ($planet !== null) { |
|
556 | 556 | // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них |
557 | 557 | // TODO - от них не надо ничего, кроме ID и que_processed |
558 | 558 | $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet); |
@@ -561,20 +561,20 @@ discard block |
||
561 | 561 | } |
562 | 562 | |
563 | 563 | // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты |
564 | - if(array_sum($time_left[$user['id']]) == 0) { |
|
564 | + if (array_sum($time_left[$user['id']]) == 0) { |
|
565 | 565 | return $que; |
566 | 566 | } |
567 | 567 | |
568 | 568 | $unit_changes = array(); |
569 | - foreach($que['items'] as &$que_item) { |
|
569 | + foreach ($que['items'] as &$que_item) { |
|
570 | 570 | $que_player_id = &$que_item['que_player_id']; |
571 | 571 | $que_planet_id = intval($que_item['que_planet_id']); |
572 | 572 | |
573 | 573 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
574 | - if(!isset($que_time_left)) { |
|
574 | + if (!isset($que_time_left)) { |
|
575 | 575 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
576 | 576 | } |
577 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
577 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
578 | 578 | continue; |
579 | 579 | } |
580 | 580 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
588 | 588 | |
589 | 589 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
590 | - if($que_time_left >= $que_item['que_time_left']) { |
|
590 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
591 | 591 | // Увеличиваем количество отстроенных юнитов |
592 | 592 | $unit_processed++; |
593 | 593 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -600,12 +600,12 @@ discard block |
||
600 | 600 | $que_item['que_unit_amount'] -= $unit_processed; |
601 | 601 | |
602 | 602 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
603 | - if($que_item['que_unit_amount'] > 0) { |
|
603 | + if ($que_item['que_unit_amount'] > 0) { |
|
604 | 604 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
605 | 605 | $que_time_left = 0; |
606 | 606 | } |
607 | 607 | |
608 | - if($que_item['que_unit_amount'] <= 0) { |
|
608 | + if ($que_item['que_unit_amount'] <= 0) { |
|
609 | 609 | DBStaticQue::db_que_delete_by_id($que_item['que_id']); |
610 | 610 | } else { |
611 | 611 | classSupernova::db_upd_record_list( |
@@ -615,15 +615,15 @@ discard block |
||
615 | 615 | ); |
616 | 616 | } |
617 | 617 | |
618 | - if($unit_processed) { |
|
618 | + if ($unit_processed) { |
|
619 | 619 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
620 | 620 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
621 | 621 | } |
622 | 622 | } |
623 | 623 | |
624 | - foreach($time_left as $player_id => $planet_data) { |
|
625 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
626 | - if($planet_id) { |
|
624 | + foreach ($time_left as $player_id => $planet_data) { |
|
625 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
626 | + if ($planet_id) { |
|
627 | 627 | // update planet |
628 | 628 | classSupernova::db_upd_record_list(LOC_PLANET, "`que_processed` = {$on_time}", "id = {$planet_id}"); |
629 | 629 | } else { |
@@ -631,8 +631,8 @@ discard block |
||
631 | 631 | classSupernova::db_upd_record_list(LOC_USER, "`que_processed` = {$on_time}", "id = {$player_id}"); |
632 | 632 | } |
633 | 633 | |
634 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
635 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
634 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
635 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
636 | 636 | DBStaticUnit::dbUpdateOrInsertUnit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
637 | 637 | } |
638 | 638 | } |
@@ -642,38 +642,38 @@ discard block |
||
642 | 642 | $que = que_recalculate($que); |
643 | 643 | |
644 | 644 | // TODO: Re-enable quests for Alliances |
645 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
645 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
646 | 646 | $quest_list = qst_get_quests($user['id']); |
647 | 647 | $quest_triggers = qst_active_triggers($quest_list); |
648 | 648 | $quest_rewards = array(); |
649 | 649 | |
650 | 650 | |
651 | 651 | $xp_incoming = array(); |
652 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
653 | - foreach($planet_changes as $planet_id => $changes) { |
|
652 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
653 | + foreach ($planet_changes as $planet_id => $changes) { |
|
654 | 654 | $planet_this = $planet_id ? classSupernova::db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
655 | - foreach($changes as $unit_id => $unit_value) { |
|
655 | + foreach ($changes as $unit_id => $unit_value) { |
|
656 | 656 | $que_id = que_get_unit_que($unit_id); |
657 | 657 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
658 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
658 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
659 | 659 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
660 | 660 | $build_data = $build_data[BUILD_CREATE]; |
661 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
661 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
662 | 662 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
663 | 663 | } |
664 | 664 | } |
665 | 665 | |
666 | - if(is_array($quest_triggers)) { |
|
666 | + if (is_array($quest_triggers)) { |
|
667 | 667 | // TODO: Check mutiply condition quests |
668 | 668 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
669 | - if(is_array($quest_trigger_list)) { |
|
670 | - foreach($quest_trigger_list as $quest_id) { |
|
669 | + if (is_array($quest_trigger_list)) { |
|
670 | + foreach ($quest_trigger_list as $quest_id) { |
|
671 | 671 | $quest_unit_level = $unit_level_new; |
672 | - if(get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
672 | + if (get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
673 | 673 | $quest_unit_level = DBStaticUnit::db_unit_count_by_user_and_type_and_snid($user_id, 0, $unit_id); |
674 | 674 | $quest_unit_level = $quest_unit_level[$unit_id]['qty']; |
675 | 675 | } |
676 | - if($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
676 | + if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
677 | 677 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
678 | 678 | $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE; |
679 | 679 | } |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
687 | 687 | qst_reward($user, $quest_rewards, $quest_list); |
688 | 688 | |
689 | - foreach($xp_incoming as $que_id => $xp) { |
|
689 | + foreach ($xp_incoming as $que_id => $xp) { |
|
690 | 690 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
691 | 691 | } |
692 | 692 | } |
@@ -38,7 +38,7 @@ |
||
38 | 38 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
39 | 39 | $query[] = "`que_planet_id` IS NULL"; |
40 | 40 | } elseif ($planet_id) { |
41 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
41 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
42 | 42 | } |
43 | 43 | if ($que_type) { |
44 | 44 | $query[] = "`que_type` = {$que_type}"; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ->where('`user_as_ally` IS NULL') |
24 | 24 | ->orderBy(array('`id` DESC')); |
25 | 25 | |
26 | - return (string)$query->selectValue(); |
|
26 | + return (string) $query->selectValue(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | static::buildDBQ() |
49 | 49 | ->field('id') |
50 | 50 | ->where("`user_as_ally` IS NULL") |
51 | - ->where("`user_bot` = " . USER_BOT_PLAYER) |
|
51 | + ->where("`user_bot` = ".USER_BOT_PLAYER) |
|
52 | 52 | ->setForUpdate(); |
53 | 53 | |
54 | 54 | return $query->selectIterator(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) { |
58 | - $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) . |
|
59 | - (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '') |
|
58 | + $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']). |
|
59 | + (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '') |
|
60 | 60 | . " FOR UPDATE"; |
61 | 61 | |
62 | 62 | static::getDb()->doSelect($query); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | FROM `{{users}}` |
74 | 74 | WHERE |
75 | 75 | `user_as_ally` IS NULL" . |
76 | - ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
76 | + ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
77 | 77 | )); |
78 | 78 | } |
79 | 79 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ->fieldCount('r.id', 'referral_count') |
96 | 96 | ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm') |
97 | 97 | ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id') |
98 | - ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
98 | + ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
99 | 99 | ->groupBy('u.id') |
100 | 100 | ->orderBy("user_as_ally, {$sort} ASC"); |
101 | 101 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)') |
114 | 114 | ->where('`user_as_ally` IS NULL') |
115 | 115 | ->having('`days_after_birthday` >= 0') |
116 | - ->having('`days_after_birthday` < ' . intval($config_user_birthday_range)) |
|
116 | + ->having('`days_after_birthday` < '.intval($config_user_birthday_range)) |
|
117 | 117 | ->setForUpdate(); |
118 | 118 | |
119 | 119 | $result = $query->selectIterator(); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
208 | 208 | |
209 | 209 | $user = classSupernova::$db->doSelectFetch( |
210 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
210 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
211 | 211 | . " FOR UPDATE" |
212 | 212 | ); |
213 | 213 | SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | |
259 | 259 | public static function db_user_list_set_mass_mail(&$owners_list, $set) { |
260 | - return classSupernova::db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : ''); |
|
260 | + return classSupernova::db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : ''); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param array $playerArray |
273 | 273 | */ |
274 | 274 | public static function renderNameAndCoordinates($playerArray) { |
275 | - return "{$playerArray['username']} " . uni_render_coordinates($playerArray); |
|
275 | + return "{$playerArray['username']} ".uni_render_coordinates($playerArray); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $fieldName = pname_resource_name($resourceId); |
304 | 304 | $value = "{$fieldName} = {$fieldName} + ('{$value}')"; |
305 | 305 | } |
306 | - if($query = implode(',', $playerRowFieldChanges)) { |
|
306 | + if ($query = implode(',', $playerRowFieldChanges)) { |
|
307 | 307 | classSupernova::$gc->db->doUpdate("UPDATE `{{users}}` SET {$query} WHERE id = {$userId}"); |
308 | 308 | } |
309 | 309 | } |