@@ -15,10 +15,10 @@ discard block |
||
15 | 15 | // classSupernova::$db->sn_db_connect(); |
16 | 16 | if (!(strpos($query, '{{') === false)) { |
17 | 17 | foreach ($update_tables as $tableName => $cork) { |
18 | - $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query); |
|
18 | + $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix.$tableName, $query); |
|
19 | 19 | } |
20 | 20 | } |
21 | - !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for ' . $query . ': ' . classSupernova::$db->db_error()) : false; |
|
21 | + !($result = classSupernova::$db->db_sql_query($query)) ? die('Query error for '.$query.': '.classSupernova::$db->db_error()) : false; |
|
22 | 22 | |
23 | 23 | return $result; |
24 | 24 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | global $update_tables, $update_indexes, $update_indexes_full, $update_foreigns; |
86 | 86 | |
87 | 87 | $tableName = $prefixed ? str_replace(classSupernova::$config->db_prefix, '', $prefix_table_name) : $prefix_table_name; |
88 | - $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix . $prefix_table_name; |
|
88 | + $prefix_table_name = $prefixed ? $prefix_table_name : classSupernova::$config->db_prefix.$prefix_table_name; |
|
89 | 89 | |
90 | 90 | upd_unset_table_info($tableName); |
91 | 91 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1; |
101 | 101 | } |
102 | 102 | |
103 | - $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
103 | + $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true); |
|
104 | 104 | while ($r1 = db_fetch($q1)) { |
105 | 105 | $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']); |
106 | 106 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}"); |
161 | 161 | $error = classSupernova::$db->db_error(); |
162 | 162 | if ($error) { |
163 | - die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration)); |
|
163 | + die("Creating error for table `{$table_name}`: {$error}<br />".dump($declaration)); |
|
164 | 164 | } |
165 | 165 | upd_do_query('set foreign_key_checks = 1;', true); |
166 | 166 | upd_load_table_info($table_name, false); |
@@ -175,10 +175,10 @@ discard block |
||
175 | 175 | "SELECT {$fields} |
176 | 176 | FROM {{unit}} |
177 | 177 | WHERE |
178 | - `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions() . |
|
179 | - ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') . |
|
180 | - ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : '') . |
|
181 | - " LIMIT 1" . |
|
178 | + `unit_location_type` = {$location_type} AND `unit_location_id` = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions(). |
|
179 | + ($user_id = intval($user_id) ? " AND `unit_player_id` = {$user_id}" : ''). |
|
180 | + ($unit_snid = intval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : ''). |
|
181 | + " LIMIT 1". |
|
182 | 182 | ($for_update ? ' FOR UPDATE' : '') |
183 | 183 | )); |
184 | 184 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | foreach ($table_data as $record_id => $conditions) { |
260 | 260 | $where = ''; |
261 | 261 | if (!empty($conditions['where'])) { |
262 | - $where = 'WHERE ' . implode(' AND ', $conditions['where']); |
|
262 | + $where = 'WHERE '.implode(' AND ', $conditions['where']); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | $fields = array(); |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | $condition = "`{$field_name}` = "; |
269 | 269 | $value = ''; |
270 | 270 | if ($field_data['delta']) { |
271 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
271 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
272 | 272 | } elseif ($field_data['set']) { |
273 | 273 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
274 | 274 | } |
275 | 275 | if ($value) { |
276 | - $fields[] = $condition . $value; |
|
276 | + $fields[] = $condition.$value; |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | 'checkSpeedPercentOld' => FLIGHT_FLEET_SPEED_WRONG, |
15 | 15 | 'checkTargetInUniverse' => FLIGHT_VECTOR_BEYOND_UNIVERSE, |
16 | 16 | 'checkTargetNotSource' => FLIGHT_VECTOR_SAME_SOURCE, |
17 | - 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
17 | + 'checkSenderNoVacation' => FLIGHT_PLAYER_VACATION_OWN, // tODO |
|
18 | 18 | 'checkTargetNoVacation' => FLIGHT_PLAYER_VACATION, |
19 | 19 | 'checkFleetNotEmpty' => FLIGHT_SHIPS_NO_SHIPS, |
20 | 20 | // 'checkUnitsPositive' => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $checkResult = call_user_func(array($this, $condition)); |
135 | 135 | defined('DEBUG_FLEET_MISSION_VALIDATE_DUMP_STEPS') |
136 | - ? pdump($action, $condition . ' ' . ($checkResult ? 'TRUE' : 'FALSE')) : false; |
|
136 | + ? pdump($action, $condition.' '.($checkResult ? 'TRUE' : 'FALSE')) : false; |
|
137 | 137 | |
138 | 138 | // If check failed and there no alternative actions - throw exception |
139 | 139 | // Shortcut ACTION => FAIL_STATUS instead of ACTION => array(false => FAIL_STATUS) |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | $this->checkMissionRestrictions($action); |
157 | 157 | } else { |
158 | 158 | // No - then just performing action |
159 | - if($exception) { |
|
159 | + if ($exception) { |
|
160 | 160 | throw new ExceptionFleetInvalid($action, $action); |
161 | 161 | } else { |
162 | 162 | return $action; |
@@ -598,10 +598,10 @@ discard block |
||
598 | 598 | protected function checkMissionPrefix($name, $prefix) { |
599 | 599 | $result = false; |
600 | 600 | if (strpos($name, $prefix) === 0) { |
601 | - $mission = 'MT_' . strtoupper(substr($name, strlen($prefix))); |
|
601 | + $mission = 'MT_'.strtoupper(substr($name, strlen($prefix))); |
|
602 | 602 | if (!defined($mission)) { |
603 | 603 | // TODO - Ну, как-то получше это обделать |
604 | - throw new Exception('Mission type "' . $mission . '" is not defined', FLIGHT_MISSION_UNKNOWN); |
|
604 | + throw new Exception('Mission type "'.$mission.'" is not defined', FLIGHT_MISSION_UNKNOWN); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | $result = constant($mission); |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * @throws ExceptionFleetInvalid |
35 | 35 | */ |
36 | 36 | public static function build($missionType, $fleet) { |
37 | - if (!empty(self::$missions[$missionType]) && class_exists($className = __NAMESPACE__ . '\\' . self::$missions[$missionType])) { |
|
37 | + if (!empty(self::$missions[$missionType]) && class_exists($className = __NAMESPACE__.'\\'.self::$missions[$missionType])) { |
|
38 | 38 | $result = new $className($fleet); |
39 | 39 | } else { |
40 | 40 | throw new ExceptionFleetInvalid("Mission type {$missionType} unknown", FLIGHT_MISSION_UNKNOWN); |
@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | |
31 | 31 | defined('INSIDE') || die(); |
32 | 32 | |
33 | -if(php_sapi_name() == "cli") { |
|
33 | +if (php_sapi_name() == "cli") { |
|
34 | 34 | // In cli-mode |
35 | 35 | define('__DEBUG_CRLF', "\r\n"); |
36 | - define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF); |
|
36 | + define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF); |
|
37 | 37 | } else { |
38 | 38 | // Not in cli-mode |
39 | 39 | define('__DEBUG_CRLF', '<br />'); |
@@ -50,17 +50,17 @@ discard block |
||
50 | 50 | function log_file($message, $ident_change = 0) { |
51 | 51 | static $ident = 0; |
52 | 52 | |
53 | - if(!defined('SN_DEBUG_LOG')) { |
|
53 | + if (!defined('SN_DEBUG_LOG')) { |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | |
57 | - if($this->log_file_handler === null) { |
|
58 | - $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
|
57 | + if ($this->log_file_handler === null) { |
|
58 | + $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+'); |
|
59 | 59 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
60 | 60 | } |
61 | 61 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
62 | - if($this->log_file_handler) { |
|
63 | - @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
|
62 | + if ($this->log_file_handler) { |
|
63 | + @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n"); |
|
64 | 64 | } |
65 | 65 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
66 | 66 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | } |
81 | 81 | |
82 | 82 | function echo_log() { |
83 | - echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
83 | + echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>"; |
|
84 | 84 | die(); |
85 | 85 | } |
86 | 86 | |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | $result = array(); |
91 | 91 | $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++; |
92 | 92 | $result[] = "tID {$transaction_id}"; |
93 | - foreach($backtrace as $a_trace) { |
|
94 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
93 | + foreach ($backtrace as $a_trace) { |
|
94 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
95 | 95 | continue; |
96 | 96 | } |
97 | 97 | $function = |
98 | 98 | ($a_trace['type'] |
99 | 99 | ? ($a_trace['type'] == '->' |
100 | - ? "({$a_trace['class']})" . get_class($a_trace['object']) |
|
100 | + ? "({$a_trace['class']})".get_class($a_trace['object']) |
|
101 | 101 | : $a_trace['class'] |
102 | - ) . $a_trace['type'] |
|
102 | + ).$a_trace['type'] |
|
103 | 103 | : '' |
104 | - ) . $a_trace['function'] . '()'; |
|
104 | + ).$a_trace['function'].'()'; |
|
105 | 105 | |
106 | 106 | $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file'])); |
107 | 107 | |
108 | 108 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
109 | 109 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
110 | 110 | |
111 | - if(!$long_comment) { |
|
111 | + if (!$long_comment) { |
|
112 | 112 | break; |
113 | 113 | } |
114 | 114 | } |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | function dump($dump = false, $force_base = false, $deadlock = false) { |
123 | 123 | global $user, $planetrow; |
124 | 124 | |
125 | - if($dump === false) { |
|
125 | + if ($dump === false) { |
|
126 | 126 | return; |
127 | 127 | } |
128 | 128 | |
129 | 129 | $error_backtrace = array(); |
130 | 130 | $base_dump = false; |
131 | 131 | |
132 | - if($force_base === true) { |
|
132 | + if ($force_base === true) { |
|
133 | 133 | $base_dump = true; |
134 | 134 | } |
135 | 135 | |
136 | - if($dump === true) { |
|
136 | + if ($dump === true) { |
|
137 | 137 | $base_dump = true; |
138 | 138 | } else { |
139 | - if(!is_array($dump)) { |
|
139 | + if (!is_array($dump)) { |
|
140 | 140 | $dump = array('var' => $dump); |
141 | 141 | } |
142 | 142 | |
143 | - foreach($dump as $dump_var_name => $dump_var) { |
|
144 | - if($dump_var_name == 'base_dump') { |
|
143 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
144 | + if ($dump_var_name == 'base_dump') { |
|
145 | 145 | $base_dump = $dump_var; |
146 | 146 | } else { |
147 | 147 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -149,22 +149,21 @@ discard block |
||
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
152 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
153 | 153 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
154 | 154 | $error_backtrace['locks'] = SnCache::getLocks(); |
155 | 155 | $error_backtrace['cSN_data'] = SnCache::getData(); |
156 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
157 | - foreach($location as $location_id => &$location_data) { |
|
158 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
159 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
156 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
157 | + foreach ($location as $location_id => &$location_data) { |
|
158 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
160 | 159 | } |
161 | 160 | } |
162 | 161 | $error_backtrace['cSN_queries'] = SnCache::getQueries(); |
163 | 162 | } |
164 | 163 | |
165 | - if($base_dump) { |
|
166 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
167 | - foreach($this->log_array as $log) { |
|
164 | + if ($base_dump) { |
|
165 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
166 | + foreach ($this->log_array as $log) { |
|
168 | 167 | $error_backtrace['queries'][] = $log; |
169 | 168 | } |
170 | 169 | } |
@@ -193,14 +192,14 @@ discard block |
||
193 | 192 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
194 | 193 | global $sys_stop_log_hit, $sys_log_disabled, $user; |
195 | 194 | |
196 | - if(empty(classSupernova::$db->connected)) { |
|
195 | + if (empty(classSupernova::$db->connected)) { |
|
197 | 196 | // TODO - писать ошибку в файл |
198 | 197 | die('SQL server currently unavailable. Please contact Administration...'); |
199 | 198 | } |
200 | 199 | |
201 | 200 | sn_db_transaction_rollback(); |
202 | 201 | |
203 | - if(classSupernova::$config->debug == 1) { |
|
202 | + if (classSupernova::$config->debug == 1) { |
|
204 | 203 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
205 | 204 | echo "<table>{$this->log}</table>"; |
206 | 205 | } |
@@ -212,16 +211,16 @@ discard block |
||
212 | 211 | |
213 | 212 | $userId = empty($user['id']) ? 0 : $user['id']; |
214 | 213 | |
215 | - if(!$sys_log_disabled) { |
|
214 | + if (!$sys_log_disabled) { |
|
216 | 215 | $query = "INSERT INTO `{{logs}}` SET |
217 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
218 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
219 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
216 | + `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."', |
|
217 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
218 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
220 | 219 | // ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";"; |
221 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
222 | - doquery($query, '', false, true) or die($fatal_error . classSupernova::$db->db_error()); |
|
220 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
221 | + doquery($query, '', false, true) or die($fatal_error.classSupernova::$db->db_error()); |
|
223 | 222 | |
224 | - $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>"; |
|
223 | + $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>"; |
|
225 | 224 | |
226 | 225 | $sys_stop_log_hit = true; |
227 | 226 | $sys_log_disabled = true; |
@@ -231,7 +230,7 @@ discard block |
||
231 | 230 | ob_start(); |
232 | 231 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
233 | 232 | |
234 | - foreach($error_backtrace as $name => $value) { |
|
233 | + foreach ($error_backtrace as $name => $value) { |
|
235 | 234 | print(__DEBUG_LINE); |
236 | 235 | pdump($value, $name); |
237 | 236 | } |
@@ -243,7 +242,7 @@ discard block |
||
243 | 242 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
244 | 243 | global $user, $sys_log_disabled; |
245 | 244 | |
246 | - if(empty(classSupernova::$db->connected)) { |
|
245 | + if (empty(classSupernova::$db->connected)) { |
|
247 | 246 | // TODO - писать ошибку в файл |
248 | 247 | die('SQL server currently unavailable. Please contact Administration...'); |
249 | 248 | } |
@@ -252,12 +251,12 @@ discard block |
||
252 | 251 | |
253 | 252 | $userId = empty($user['id']) ? 0 : $user['id']; |
254 | 253 | |
255 | - if(!$sys_log_disabled) { |
|
254 | + if (!$sys_log_disabled) { |
|
256 | 255 | $query = "INSERT INTO `{{logs}}` SET |
257 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
258 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
259 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
260 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
256 | + `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."', |
|
257 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
258 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
259 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
261 | 260 | doquery($query, '', false, true); |
262 | 261 | } else { |
263 | 262 | // // TODO Здесь надо писать в файло |
@@ -270,11 +269,11 @@ discard block |
||
270 | 269 | // Dump variables nicer then var_dump() |
271 | 270 | |
272 | 271 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
273 | - if(isset($varname)) { |
|
272 | + if (isset($varname)) { |
|
274 | 273 | $varname .= " = "; |
275 | 274 | } |
276 | 275 | |
277 | - if($level == -1) { |
|
276 | + if ($level == -1) { |
|
278 | 277 | $trans[' '] = '∴'; |
279 | 278 | $trans["\t"] = '⇒'; |
280 | 279 | $trans["\n"] = '¶;'; |
@@ -283,31 +282,31 @@ discard block |
||
283 | 282 | |
284 | 283 | return strtr(htmlspecialchars($value), $trans); |
285 | 284 | } |
286 | - if($level == 0) { |
|
285 | + if ($level == 0) { |
|
287 | 286 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
288 | - $dumper = mt_rand(10, 99) . '|' . $varname; |
|
287 | + $dumper = mt_rand(10, 99).'|'.$varname; |
|
289 | 288 | } |
290 | 289 | |
291 | 290 | $type = gettype($value); |
292 | 291 | $dumper .= $type; |
293 | 292 | |
294 | - if($type == 'string') { |
|
295 | - $dumper .= '(' . strlen($value) . ')'; |
|
293 | + if ($type == 'string') { |
|
294 | + $dumper .= '('.strlen($value).')'; |
|
296 | 295 | $value = dump($value, '', -1); |
297 | - } elseif($type == 'boolean') { |
|
296 | + } elseif ($type == 'boolean') { |
|
298 | 297 | $value = ($value ? 'true' : 'false'); |
299 | - } elseif($type == 'object') { |
|
298 | + } elseif ($type == 'object') { |
|
300 | 299 | $props = get_class_vars(get_class($value)); |
301 | - $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
302 | - foreach($props as $key => $val) { |
|
303 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
300 | + $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
301 | + foreach ($props as $key => $val) { |
|
302 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
304 | 303 | $dumper .= dump($value->$key, '', $level + 1); |
305 | 304 | } |
306 | 305 | $value = ''; |
307 | - } elseif($type == 'array') { |
|
308 | - $dumper .= '(' . count($value) . ')'; |
|
309 | - foreach($value as $key => $val) { |
|
310 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
|
306 | + } elseif ($type == 'array') { |
|
307 | + $dumper .= '('.count($value).')'; |
|
308 | + foreach ($value as $key => $val) { |
|
309 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => '; |
|
311 | 310 | $dumper .= dump($val, '', $level + 1); |
312 | 311 | } |
313 | 312 | $value = ''; |
@@ -326,24 +325,24 @@ discard block |
||
326 | 325 | // $backtrace = $backtrace[1]; |
327 | 326 | |
328 | 327 | $caller = ''; |
329 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
330 | - $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
|
331 | - (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
|
332 | - $backtrace[1]['function'] . |
|
328 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
329 | + $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : ''). |
|
330 | + (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : ''). |
|
331 | + $backtrace[1]['function']. |
|
333 | 332 | (!empty($backtrace[0]['file']) |
334 | 333 | ? ( |
335 | - ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) . |
|
336 | - (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') . |
|
334 | + ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN). |
|
335 | + (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : ''). |
|
337 | 336 | ')' |
338 | 337 | ) |
339 | 338 | : '' |
340 | 339 | ); |
341 | - $caller = "\r\n" . $caller; |
|
340 | + $caller = "\r\n".$caller; |
|
342 | 341 | } |
343 | 342 | |
344 | - print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' . |
|
345 | - dump($value, $varname) . |
|
346 | - $caller . |
|
343 | + print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'. |
|
344 | + dump($value, $varname). |
|
345 | + $caller. |
|
347 | 346 | '</pre>' |
348 | 347 | ); |
349 | 348 | } |
@@ -353,24 +352,24 @@ discard block |
||
353 | 352 | } |
354 | 353 | |
355 | 354 | function pr($prePrint = false) { |
356 | - if($prePrint) { |
|
355 | + if ($prePrint) { |
|
357 | 356 | print(__DEBUG_CRLF); |
358 | 357 | } |
359 | - print(mt_rand() . __DEBUG_CRLF); |
|
358 | + print(mt_rand().__DEBUG_CRLF); |
|
360 | 359 | } |
361 | 360 | |
362 | 361 | function pc($prePrint = false) { |
363 | 362 | global $_PRINT_COUNT_VALUE; |
364 | 363 | $_PRINT_COUNT_VALUE++; |
365 | 364 | |
366 | - if($prePrint) { |
|
365 | + if ($prePrint) { |
|
367 | 366 | print(__DEBUG_CRLF); |
368 | 367 | } |
369 | - print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
|
368 | + print($_PRINT_COUNT_VALUE.__DEBUG_CRLF); |
|
370 | 369 | } |
371 | 370 | |
372 | 371 | function prep($message) { |
373 | - print('<pre>' . $message . '</pre>'); |
|
372 | + print('<pre>'.$message.'</pre>'); |
|
374 | 373 | } |
375 | 374 | |
376 | 375 | function backtrace_no_arg() { |
@@ -393,5 +392,5 @@ discard block |
||
393 | 392 | */ |
394 | 393 | function pdie($message = '') { |
395 | 394 | $backtrace = debug_backtrace(); |
396 | - die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']); |
|
395 | + die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']); |
|
397 | 396 | } |
@@ -414,31 +414,31 @@ discard block |
||
414 | 414 | |
415 | 415 | return doquery( |
416 | 416 | // Блокировка самого флота |
417 | - "SELECT 1 FROM {{fleets}} AS f " . |
|
417 | + "SELECT 1 FROM {{fleets}} AS f ". |
|
418 | 418 | |
419 | 419 | // Блокировка всех юнитов, принадлежащих этому флоту |
420 | - "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " . |
|
420 | + "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ". |
|
421 | 421 | |
422 | 422 | // Блокировка всех прилетающих и улетающих флотов, если нужно |
423 | 423 | // TODO - lock fleets by COORDINATES |
424 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') . |
|
424 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : ''). |
|
425 | 425 | // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination |
426 | - ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') . |
|
426 | + ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : ''). |
|
427 | 427 | |
428 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') . |
|
428 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : ''). |
|
429 | 429 | // Блокировка всех юнитов, принадлежащих владельцу планеты-цели |
430 | - ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') . |
|
430 | + ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : ''). |
|
431 | 431 | // Блокировка планеты-цели |
432 | - ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') . |
|
432 | + ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : ''). |
|
433 | 433 | // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели |
434 | 434 | // ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') . |
435 | 435 | |
436 | 436 | |
437 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') . |
|
437 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : ''). |
|
438 | 438 | // Блокировка всех юнитов, принадлежащих владельцу флота |
439 | - ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') . |
|
439 | + ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : ''). |
|
440 | 440 | // Блокировка планеты отправления |
441 | - ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') . |
|
441 | + ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : ''). |
|
442 | 442 | // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота |
443 | 443 | // ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') . |
444 | 444 | |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | public function dbGetLockById($dbId) { |
456 | 456 | doquery( |
457 | 457 | // Блокировка самого флота |
458 | - "SELECT 1 FROM {{fleets}} AS FLEET0 " . |
|
458 | + "SELECT 1 FROM {{fleets}} AS FLEET0 ". |
|
459 | 459 | // Lock fleet owner |
460 | - "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " . |
|
460 | + "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ". |
|
461 | 461 | // Блокировка всех юнитов, принадлежащих этому флоту |
462 | - "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " . |
|
462 | + "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ". |
|
463 | 463 | |
464 | 464 | // Без предварительной выборки неизвестно - куда летит этот флот. |
465 | 465 | // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота. |
@@ -475,9 +475,9 @@ discard block |
||
475 | 475 | FLEET1.fleet_end_planet = FLEET0.fleet_end_planet |
476 | 476 | " . |
477 | 477 | // Блокировка всех юнитов, принадлежащих этим флотам |
478 | - "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " . |
|
478 | + "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ". |
|
479 | 479 | // Lock fleet owner |
480 | - "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " . |
|
480 | + "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ". |
|
481 | 481 | |
482 | 482 | "LEFT JOIN {{fleets}} AS FLEET2 ON |
483 | 483 | FLEET2.fleet_mess = 1 AND FLEET0.fleet_mess = 0 AND |
@@ -487,7 +487,7 @@ discard block |
||
487 | 487 | " . |
488 | 488 | // Блокировка всех юнитов, принадлежащих этим флотам |
489 | 489 | "LEFT JOIN {{unit}} as UNIT2 ON |
490 | - UNIT2.unit_location_type = " . LOC_FLEET . " AND |
|
490 | + UNIT2.unit_location_type = " . LOC_FLEET." AND |
|
491 | 491 | UNIT2.unit_location_id = FLEET2.fleet_id |
492 | 492 | " . |
493 | 493 | // Lock fleet owner |
@@ -504,11 +504,11 @@ discard block |
||
504 | 504 | " . |
505 | 505 | // Блокировка всех юнитов, принадлежащих этим флотам |
506 | 506 | "LEFT JOIN {{unit}} as UNIT3 ON |
507 | - UNIT3.unit_location_type = " . LOC_FLEET . " AND |
|
507 | + UNIT3.unit_location_type = " . LOC_FLEET." AND |
|
508 | 508 | UNIT3.unit_location_id = FLEET3.fleet_id |
509 | 509 | " . |
510 | 510 | // Lock fleet owner |
511 | - "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " . |
|
511 | + "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ". |
|
512 | 512 | |
513 | 513 | "LEFT JOIN {{fleets}} AS FLEET4 ON |
514 | 514 | FLEET4.fleet_mess = 1 AND FLEET0.fleet_mess = 1 AND |
@@ -518,7 +518,7 @@ discard block |
||
518 | 518 | " . |
519 | 519 | // Блокировка всех юнитов, принадлежащих этим флотам |
520 | 520 | "LEFT JOIN {{unit}} as UNIT4 ON |
521 | - UNIT4.unit_location_type = " . LOC_FLEET . " AND |
|
521 | + UNIT4.unit_location_type = " . LOC_FLEET." AND |
|
522 | 522 | UNIT4.unit_location_id = FLEET4.fleet_id |
523 | 523 | " . |
524 | 524 | // Lock fleet owner |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | " . |
541 | 541 | // Блокировка всех юнитов, принадлежащих этой планете |
542 | 542 | "LEFT JOIN {{unit}} as UNIT5 ON |
543 | - UNIT5.unit_location_type = " . LOC_PLANET . " AND |
|
543 | + UNIT5.unit_location_type = " . LOC_PLANET." AND |
|
544 | 544 | UNIT5.unit_location_id = PLANETS5.id |
545 | 545 | " . |
546 | 546 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | " . |
559 | 559 | // Блокировка всех юнитов, принадлежащих этой планете |
560 | 560 | "LEFT JOIN {{unit}} as UNIT6 ON |
561 | - UNIT6.unit_location_type = " . LOC_PLANET . " AND |
|
561 | + UNIT6.unit_location_type = " . LOC_PLANET." AND |
|
562 | 562 | UNIT6.unit_location_id = PLANETS6.id |
563 | 563 | " . |
564 | 564 | "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE" |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | } elseif ($this->isResource($unit_id)) { |
678 | 678 | $this->resource_list[$unit_id] = $unit_count; |
679 | 679 | } else { |
680 | - throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG); |
|
680 | + throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG); |
|
681 | 681 | } |
682 | 682 | } |
683 | 683 | } |
@@ -811,7 +811,7 @@ discard block |
||
811 | 811 | * @param int $unit_count |
812 | 812 | */ |
813 | 813 | public function shipSetCount($unit_id, $unit_count = 0) { |
814 | - pdump(__CLASS__ . '->' . __FUNCTION__); |
|
814 | + pdump(__CLASS__.'->'.__FUNCTION__); |
|
815 | 815 | $this->shipAdjustCount($unit_id, $unit_count, true); |
816 | 816 | } |
817 | 817 | |
@@ -1019,7 +1019,7 @@ discard block |
||
1019 | 1019 | */ |
1020 | 1020 | public function resourcesSet($resource_list) { |
1021 | 1021 | if (!empty($this->propertiesAdjusted['resource_list'])) { |
1022 | - throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR); |
|
1022 | + throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR); |
|
1023 | 1023 | } |
1024 | 1024 | $this->resourcesAdjust($resource_list, true); |
1025 | 1025 | } |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | // Check for negative unit value |
1054 | 1054 | if ($this->resource_list[$resource_id] < 0) { |
1055 | 1055 | // TODO |
1056 | - throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR); |
|
1056 | + throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR); |
|
1057 | 1057 | } |
1058 | 1058 | } |
1059 | 1059 | } |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | |
1235 | 1235 | protected function printErrorIfNoShips() { |
1236 | 1236 | if ($this->unitList->unitsCount() <= 0) { |
1237 | - message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5); |
|
1237 | + message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5); |
|
1238 | 1238 | } |
1239 | 1239 | } |
1240 | 1240 | |
@@ -1622,7 +1622,7 @@ discard block |
||
1622 | 1622 | if (FLIGHT_ALLOWED == $validateResult[$missionType]) { |
1623 | 1623 | $this->allowed_missions[$missionType] = $mission; |
1624 | 1624 | } else { |
1625 | - if($missionType == $this->mission_type) { |
|
1625 | + if ($missionType == $this->mission_type) { |
|
1626 | 1626 | } |
1627 | 1627 | unset($this->allowed_missions[$missionType]); |
1628 | 1628 | } |
@@ -1630,8 +1630,8 @@ discard block |
||
1630 | 1630 | // print('asd'); |
1631 | 1631 | //var_dump($this->allowed_missions); |
1632 | 1632 | // print('выф'); |
1633 | - if(empty($this->allowed_missions)) { |
|
1634 | - if($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) { |
|
1633 | + if (empty($this->allowed_missions)) { |
|
1634 | + if ($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) { |
|
1635 | 1635 | throw new ExceptionFleetInvalid($validateResult[$this->mission_type], $validateResult[$this->mission_type]); |
1636 | 1636 | } else { |
1637 | 1637 | throw new ExceptionFleetInvalid(FLIGHT_MISSION_IMPOSSIBLE, FLIGHT_MISSION_IMPOSSIBLE); |
@@ -1844,7 +1844,7 @@ discard block |
||
1844 | 1844 | |
1845 | 1845 | |
1846 | 1846 | if (!empty($this->captain['unit_id'])) { |
1847 | - DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}"); |
|
1847 | + DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}"); |
|
1848 | 1848 | } |
1849 | 1849 | |
1850 | 1850 | // return $this->fleet->acs['ankunft'] - $this->fleet->time_launch >= $this->fleet->travelData['duration']; |
@@ -1856,7 +1856,7 @@ discard block |
||
1856 | 1856 | $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob); |
1857 | 1857 | |
1858 | 1858 | $template_result += array( |
1859 | - 'mission' => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''), |
|
1859 | + 'mission' => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''), |
|
1860 | 1860 | 'dist' => pretty_number($this->travelData['distance']), |
1861 | 1861 | 'speed' => pretty_number($this->travelData['fleet_speed']), |
1862 | 1862 | 'deute_need' => pretty_number($this->travelData['consumption']), |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | function loadModuleRootConfig() { |
75 | - require SN_ROOT_PHYSICAL . 'config.php'; |
|
75 | + require SN_ROOT_PHYSICAL.'config.php'; |
|
76 | 76 | |
77 | - $module_config_array = get_class($this) . '_config'; |
|
78 | - if(!empty($$module_config_array) && is_array($$module_config_array)) { |
|
77 | + $module_config_array = get_class($this).'_config'; |
|
78 | + if (!empty($$module_config_array) && is_array($$module_config_array)) { |
|
79 | 79 | $this->config = $$module_config_array; |
80 | 80 | |
81 | 81 | return true; |
@@ -93,17 +93,17 @@ discard block |
||
93 | 93 | |
94 | 94 | // TODO: Load configuration from DB. Manifest setting |
95 | 95 | // Trying to load configuration from file |
96 | - if(!$config_exists = $this->loadModuleRootConfig()) { |
|
96 | + if (!$config_exists = $this->loadModuleRootConfig()) { |
|
97 | 97 | // Конфигурация может лежать в config_path в манифеста или в корне модуля |
98 | - if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) { |
|
98 | + if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'].'/config.php')) { |
|
99 | 99 | $config_exists = true; |
100 | - } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) { |
|
100 | + } elseif (file_exists($config_filename = dirname($filename).'/config.php')) { |
|
101 | 101 | $config_exists = true; |
102 | 102 | } |
103 | 103 | |
104 | - if($config_exists) { |
|
104 | + if ($config_exists) { |
|
105 | 105 | include($config_filename); |
106 | - $module_config_array = $class_module_name . '_config'; |
|
106 | + $module_config_array = $class_module_name.'_config'; |
|
107 | 107 | $this->config = $$module_config_array; |
108 | 108 | } |
109 | 109 | } |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | // Checking module status - is it installed and active |
120 | 120 | $this->check_status(); |
121 | - if(!$this->manifest['active']) { |
|
121 | + if (!$this->manifest['active']) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
@@ -138,11 +138,11 @@ discard block |
||
138 | 138 | |
139 | 139 | protected function setSystemConstants() { |
140 | 140 | // Setting constants - if any |
141 | - if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
141 | + if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - foreach($this->manifest['constants'] as $constant_name => $constant_value) { |
|
145 | + foreach ($this->manifest['constants'] as $constant_name => $constant_value) { |
|
146 | 146 | !defined($constant_name) ? define($constant_name, $constant_value) : false; |
147 | 147 | } |
148 | 148 | } |
@@ -154,48 +154,48 @@ discard block |
||
154 | 154 | // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays) |
155 | 155 | // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]' |
156 | 156 | $this->manifest['vars'] = $this->__assign_vars(); |
157 | - if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
157 | + if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | 161 | $vars_assigned = array(); |
162 | - foreach($this->manifest['vars'] as $var_name => $var_value) { |
|
162 | + foreach ($this->manifest['vars'] as $var_name => $var_value) { |
|
163 | 163 | $sub_vars = explode('[', str_replace(']', '', $var_name)); |
164 | 164 | $var_name = $sub_vars[0]; |
165 | 165 | |
166 | - if(!isset($vars_assigned[$var_name])) { |
|
166 | + if (!isset($vars_assigned[$var_name])) { |
|
167 | 167 | $vars_assigned[$var_name] = true; |
168 | 168 | global $$var_name; |
169 | 169 | } |
170 | 170 | |
171 | 171 | $pointer = &$$var_name; |
172 | - if(($n = count($sub_vars)) > 1) { |
|
173 | - for($i = 1; $i < $n; $i++) { |
|
174 | - if(defined($sub_vars[$i])) { |
|
172 | + if (($n = count($sub_vars)) > 1) { |
|
173 | + for ($i = 1; $i < $n; $i++) { |
|
174 | + if (defined($sub_vars[$i])) { |
|
175 | 175 | $sub_vars[$i] = constant($sub_vars[$i]); |
176 | 176 | } |
177 | 177 | |
178 | - if(!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
178 | + if (!isset($pointer[$sub_vars[$i]]) && $i != $n) { |
|
179 | 179 | $pointer[$sub_vars[$i]] = array(); |
180 | 180 | } |
181 | 181 | $pointer = &$pointer[$sub_vars[$i]]; |
182 | 182 | } |
183 | 183 | } |
184 | 184 | |
185 | - if(!isset($pointer) || !is_array($pointer)) { |
|
185 | + if (!isset($pointer) || !is_array($pointer)) { |
|
186 | 186 | $pointer = $var_value; |
187 | - } elseif(is_array($$var_name)) { |
|
187 | + } elseif (is_array($$var_name)) { |
|
188 | 188 | $pointer = array_merge_recursive_numeric($pointer, $var_value); |
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
192 | 192 | |
193 | 193 | protected function mergeMenu(&$sn_menu_extra, &$menu_patch) { |
194 | - if(!is_array($menu_patch)) { |
|
194 | + if (!is_array($menu_patch)) { |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | - foreach($menu_patch as $menu_item_name => $menu_item_data) { |
|
198 | + foreach ($menu_patch as $menu_item_name => $menu_item_data) { |
|
199 | 199 | $sn_menu_extra[$menu_item_name] = $menu_item_data; |
200 | 200 | } |
201 | 201 | } |
@@ -204,34 +204,34 @@ discard block |
||
204 | 204 | // Overriding function if any |
205 | 205 | sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this); |
206 | 206 | |
207 | - foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
207 | + foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) { |
|
208 | 208 | sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type); |
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
212 | 212 | protected function mergeNavbarButton() { |
213 | - if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
213 | + if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) { |
|
214 | 214 | return; |
215 | 215 | } |
216 | 216 | |
217 | - foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
217 | + foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) { |
|
218 | 218 | classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | protected function mergeI18N() { |
223 | 223 | $arrayName = 'i18n'; |
224 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
224 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | |
228 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
229 | - foreach($contentList as &$i18n_file_data) { |
|
230 | - if(is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
228 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
229 | + foreach ($contentList as &$i18n_file_data) { |
|
230 | + if (is_array($i18n_file_data) && !$i18n_file_data['path']) { |
|
231 | 231 | $i18n_file_data['path'] = $this->manifest['root_relative']; |
232 | 232 | } |
233 | 233 | } |
234 | - if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
234 | + if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) { |
|
235 | 235 | classSupernova::$sn_mvc[$arrayName][$pageName] = array(); |
236 | 236 | } |
237 | 237 | classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList; |
@@ -239,13 +239,13 @@ discard block |
||
239 | 239 | } |
240 | 240 | |
241 | 241 | protected function mergeArraySpecial($arrayName) { |
242 | - if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
242 | + if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) { |
|
243 | 243 | return; |
244 | 244 | } |
245 | 245 | |
246 | - foreach($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
246 | + foreach ($this->manifest[$arrayName] as $pageName => &$contentList) { |
|
247 | 247 | !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false; |
248 | - foreach($contentList as $contentName => &$content) { |
|
248 | + foreach ($contentList as $contentName => &$content) { |
|
249 | 249 | classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content; |
250 | 250 | } |
251 | 251 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | $load_order[$loaded_module_name] = $level; |
300 | 300 | } |
301 | 301 | } |
302 | - } while($prev_order != $load_order); |
|
302 | + } while ($prev_order != $load_order); |
|
303 | 303 | |
304 | 304 | asort($load_order); |
305 | 305 |
@@ -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_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_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,21 +561,21 @@ 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 | $db_changeset = array(); |
569 | 569 | $unit_changes = array(); |
570 | - foreach($que['items'] as &$que_item) { |
|
570 | + foreach ($que['items'] as &$que_item) { |
|
571 | 571 | $que_player_id = &$que_item['que_player_id']; |
572 | 572 | $que_planet_id = intval($que_item['que_planet_id']); |
573 | 573 | |
574 | 574 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
575 | - if(!isset($que_time_left)) { |
|
575 | + if (!isset($que_time_left)) { |
|
576 | 576 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
577 | 577 | } |
578 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
578 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
579 | 579 | continue; |
580 | 580 | } |
581 | 581 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
589 | 589 | |
590 | 590 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
591 | - if($que_time_left >= $que_item['que_time_left']) { |
|
591 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
592 | 592 | // Увеличиваем количество отстроенных юнитов |
593 | 593 | $unit_processed++; |
594 | 594 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -601,12 +601,12 @@ discard block |
||
601 | 601 | $que_item['que_unit_amount'] -= $unit_processed; |
602 | 602 | |
603 | 603 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
604 | - if($que_item['que_unit_amount'] > 0) { |
|
604 | + if ($que_item['que_unit_amount'] > 0) { |
|
605 | 605 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
606 | 606 | $que_time_left = 0; |
607 | 607 | } |
608 | 608 | |
609 | - if($que_item['que_unit_amount'] <= 0) { |
|
609 | + if ($que_item['que_unit_amount'] <= 0) { |
|
610 | 610 | $db_changeset['que'][] = array( |
611 | 611 | 'action' => SQL_OP_DELETE, |
612 | 612 | P_VERSION => 1, |
@@ -632,14 +632,14 @@ discard block |
||
632 | 632 | ); |
633 | 633 | } |
634 | 634 | |
635 | - if($unit_processed) { |
|
635 | + if ($unit_processed) { |
|
636 | 636 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
637 | 637 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
638 | 638 | } |
639 | 639 | } |
640 | 640 | |
641 | - foreach($time_left as $player_id => $planet_data) { |
|
642 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
641 | + foreach ($time_left as $player_id => $planet_data) { |
|
642 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
643 | 643 | $table = $planet_id ? 'planets' : 'users'; |
644 | 644 | $id = $planet_id ? $planet_id : $player_id; |
645 | 645 | $db_changeset[$table][] = array( |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | ), |
656 | 656 | ); |
657 | 657 | |
658 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
659 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
658 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
659 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
660 | 660 | $db_changeset['unit'][] = sn_db_unit_changeset_prepare($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
661 | 661 | } |
662 | 662 | } |
@@ -666,38 +666,38 @@ discard block |
||
666 | 666 | $que = que_recalculate($que); |
667 | 667 | |
668 | 668 | // TODO: Re-enable quests for Alliances |
669 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
669 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
670 | 670 | $quest_list = qst_get_quests($user['id']); |
671 | 671 | $quest_triggers = qst_active_triggers($quest_list); |
672 | 672 | $quest_rewards = array(); |
673 | 673 | |
674 | 674 | |
675 | 675 | $xp_incoming = array(); |
676 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
677 | - foreach($planet_changes as $planet_id => $changes) { |
|
676 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
677 | + foreach ($planet_changes as $planet_id => $changes) { |
|
678 | 678 | $planet_this = $planet_id ? classSupernova::db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
679 | - foreach($changes as $unit_id => $unit_value) { |
|
679 | + foreach ($changes as $unit_id => $unit_value) { |
|
680 | 680 | $que_id = que_get_unit_que($unit_id); |
681 | 681 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
682 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
682 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
683 | 683 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
684 | 684 | $build_data = $build_data[BUILD_CREATE]; |
685 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
685 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
686 | 686 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
690 | - if(is_array($quest_triggers)) { |
|
690 | + if (is_array($quest_triggers)) { |
|
691 | 691 | // TODO: Check mutiply condition quests |
692 | 692 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
693 | - if(is_array($quest_trigger_list)) { |
|
694 | - foreach($quest_trigger_list as $quest_id) { |
|
693 | + if (is_array($quest_trigger_list)) { |
|
694 | + foreach ($quest_trigger_list as $quest_id) { |
|
695 | 695 | $quest_unit_level = $unit_level_new; |
696 | - if(get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
696 | + if (get_unit_param($unit_id, P_UNIT_TYPE) == UNIT_SHIPS) { |
|
697 | 697 | $quest_unit_level = DBStaticUnit::db_unit_count_by_user_and_type_and_snid($user_id, 0, $unit_id); |
698 | 698 | $quest_unit_level = $quest_unit_level[$unit_id]['qty']; |
699 | 699 | } |
700 | - if($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
700 | + if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE && $quest_list[$quest_id]['quest_unit_amount'] <= $quest_unit_level) { |
|
701 | 701 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
702 | 702 | $quest_list[$quest_id]['quest_status_status'] = QUEST_STATUS_COMPLETE; |
703 | 703 | } |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
711 | 711 | qst_reward($user, $quest_rewards, $quest_list); |
712 | 712 | |
713 | - foreach($xp_incoming as $que_id => $xp) { |
|
713 | + foreach ($xp_incoming as $que_id => $xp) { |
|
714 | 714 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
715 | 715 | } |
716 | 716 | } |
@@ -1,18 +1,18 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
4 | 4 | classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
5 | 5 | } |
6 | 6 | |
7 | 7 | $template = gettemplate('ali_search', true); |
8 | 8 | |
9 | 9 | $ali_search_text = sys_get_param_str('searchtext'); |
10 | -if($ali_search_text) { |
|
10 | +if ($ali_search_text) { |
|
11 | 11 | $template->assign_var('SEARCH_TEXT', $ali_search_text); |
12 | 12 | |
13 | 13 | $search = DBStaticAlly::db_ally_search_by_name_or_tag($ali_search_text); |
14 | - if(classSupernova::$db->db_num_rows($search)) { |
|
15 | - while($ally_row = db_fetch($search)) { |
|
14 | + if (classSupernova::$db->db_num_rows($search)) { |
|
15 | + while ($ally_row = db_fetch($search)) { |
|
16 | 16 | $template->assign_block_vars('alliances', array( |
17 | 17 | 'ID' => $ally_row['id'], |
18 | 18 | 'TAG' => $ally_row['ally_tag'], |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | use Vector\Vector; |
25 | 25 | |
26 | -if(!defined('INIT')) { |
|
26 | +if (!defined('INIT')) { |
|
27 | 27 | // include_once('init.php'); |
28 | 28 | die('Unauthorized access'); |
29 | 29 | } |
@@ -41,8 +41,8 @@ discard block |
||
41 | 41 | classSupernova::$config->debug = 0; |
42 | 42 | |
43 | 43 | |
44 | -if(classSupernova::$config->db_version == DB_VERSION) { |
|
45 | -} elseif(classSupernova::$config->db_version > DB_VERSION) { |
|
44 | +if (classSupernova::$config->db_version == DB_VERSION) { |
|
45 | +} elseif (classSupernova::$config->db_version > DB_VERSION) { |
|
46 | 46 | classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW); |
47 | 47 | die( |
48 | 48 | 'Internal error! Auotupdater detects DB version greater then can be handled!<br /> |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
54 | -if(classSupernova::$config->db_version < 26) { |
|
54 | +if (classSupernova::$config->db_version < 26) { |
|
55 | 55 | $sys_log_disabled = true; |
56 | 56 | } |
57 | 57 | |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | $update_tables = array(); |
71 | 71 | $update_indexes = array(); |
72 | 72 | $query = upd_do_query('SHOW TABLES;', true); |
73 | -while($row = classSupernova::$db->db_fetch_row($query)) { |
|
73 | +while ($row = classSupernova::$db->db_fetch_row($query)) { |
|
74 | 74 | upd_load_table_info($row[0]); |
75 | 75 | } |
76 | 76 | upd_log_message('Table info loaded. Now looking DB for upgrades...'); |
77 | 77 | |
78 | 78 | upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true); |
79 | 79 | |
80 | -if($new_version < 37) { |
|
80 | +if ($new_version < 37) { |
|
81 | 81 | require_once('update_old.php'); |
82 | 82 | } |
83 | 83 | |
84 | 84 | ini_set('memory_limit', '1024M'); |
85 | 85 | |
86 | -switch($new_version) { |
|
86 | +switch ($new_version) { |
|
87 | 87 | case 37: |
88 | 88 | upd_log_version_update(); |
89 | 89 | |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_); |
100 | 100 | |
101 | - if(!$update_tables['log_metamatter']) { |
|
101 | + if (!$update_tables['log_metamatter']) { |
|
102 | 102 | upd_create_table('log_metamatter', |
103 | 103 | "( |
104 | 104 | `id` SERIAL, |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
124 | 124 | ), !$update_tables['payment']['payment_test']); |
125 | 125 | |
126 | - if($update_tables['payment']['payment_test']['Default'] == 1) { |
|
126 | + if ($update_tables['payment']['payment_test']['Default'] == 1) { |
|
127 | 127 | upd_alter_table('payment', array( |
128 | 128 | "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'", |
129 | 129 | )); |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | "MODIFY COLUMN `metamatter` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Metamatter amount'", |
140 | 140 | ), $update_tables['users']['metamatter']['Type'] == 'int(20)'); |
141 | 141 | |
142 | - $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE"); |
|
143 | - while($row = db_fetch($query)) { |
|
142 | + $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = ".QUE_RESEARCH." AND que_unit_id IN (".TECH_EXPEDITION.",".TECH_COLONIZATION.") FOR UPDATE"); |
|
143 | + while ($row = db_fetch($query)) { |
|
144 | 144 | $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']); |
145 | 145 | upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE"); |
146 | 146 | $price = sys_unit_str2arr($row['que_unit_price']); |
147 | - upd_do_query("UPDATE {{planets}} SET " . |
|
148 | - "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," . |
|
149 | - "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," . |
|
150 | - "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) . |
|
147 | + upd_do_query("UPDATE {{planets}} SET ". |
|
148 | + "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",". |
|
149 | + "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",". |
|
150 | + "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0). |
|
151 | 151 | " WHERE id = {$planet_id}" |
152 | 152 | ); |
153 | 153 | upd_do_query("DELETE FROM {{que}} WHERE que_id = {$row['que_id']}"); |
@@ -156,10 +156,10 @@ discard block |
||
156 | 156 | $query = upd_do_query("SELECT unit_id, unit_snid, unit_level, id_planet FROM {{unit}} AS un |
157 | 157 | LEFT JOIN {{users}} AS u ON u.id = un.unit_player_id |
158 | 158 | LEFT JOIN {{planets}} AS p ON p.id = u.id_planet |
159 | - WHERE unit_snid IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") |
|
159 | + WHERE unit_snid IN (" . TECH_EXPEDITION.",".TECH_COLONIZATION.") |
|
160 | 160 | FOR UPDATE"); |
161 | - while($row = db_fetch($query)) { |
|
162 | - if(!$row['id_planet']) { |
|
161 | + while ($row = db_fetch($query)) { |
|
162 | + if (!$row['id_planet']) { |
|
163 | 163 | continue; |
164 | 164 | } |
165 | 165 | |
@@ -167,14 +167,14 @@ discard block |
||
167 | 167 | $unit_level = $row['unit_level']; |
168 | 168 | $price = get_unit_param($unit_id, P_COST); |
169 | 169 | $factor = $price['factor']; |
170 | - foreach($price as $resource_id => &$resource_amount) { |
|
170 | + foreach ($price as $resource_id => &$resource_amount) { |
|
171 | 171 | $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1); |
172 | 172 | } |
173 | 173 | // upd_do_query |
174 | - upd_do_query($q = "UPDATE {{planets}} SET " . |
|
175 | - "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," . |
|
176 | - "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," . |
|
177 | - "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) . |
|
174 | + upd_do_query($q = "UPDATE {{planets}} SET ". |
|
175 | + "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",". |
|
176 | + "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",". |
|
177 | + "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0). |
|
178 | 178 | " WHERE id = {$row['id_planet']}" |
179 | 179 | ); |
180 | 180 | upd_do_query("DELETE FROM {{unit}} WHERE unit_id = {$row['unit_id']}"); |
@@ -186,14 +186,14 @@ discard block |
||
186 | 186 | // Вернуть ресы за уже исследованную Экспедиционную технологию |
187 | 187 | upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0); |
188 | 188 | |
189 | - if(!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
189 | + if (!isset($update_tables['users']['player_rpg_explore_xp'])) { |
|
190 | 190 | upd_alter_table('users', array( |
191 | 191 | "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
192 | 192 | "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`", |
193 | 193 | ), !isset($update_tables['users']['player_rpg_explore_xp'])); |
194 | 194 | } |
195 | 195 | |
196 | - if(!$update_tables['log_users_online']) { |
|
196 | + if (!$update_tables['log_users_online']) { |
|
197 | 197 | upd_create_table('log_users_online', "( |
198 | 198 | `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time', |
199 | 199 | `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online', |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`", |
209 | 209 | ), !$update_tables['users']['user_time_measured']); |
210 | 210 | |
211 | - if($update_tables['rw']) { |
|
211 | + if ($update_tables['rw']) { |
|
212 | 212 | upd_do_query("DROP TABLE IF EXISTS {{rw}};"); |
213 | 213 | } |
214 | 214 | |
215 | - if(!$update_tables['player_award']) { |
|
215 | + if (!$update_tables['player_award']) { |
|
216 | 216 | upd_create_table('player_award', "( |
217 | 217 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
218 | 218 | `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc', |
@@ -254,14 +254,14 @@ discard block |
||
254 | 254 | upd_log_version_update(); |
255 | 255 | |
256 | 256 | |
257 | - if(!isset($update_tables['planets']['que_processed'])) { |
|
257 | + if (!isset($update_tables['planets']['que_processed'])) { |
|
258 | 258 | upd_alter_table('planets', array( |
259 | 259 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`", |
260 | 260 | ), true); |
261 | 261 | upd_do_query("UPDATE {{planets}} SET que_processed = last_update;"); |
262 | 262 | } |
263 | 263 | |
264 | - if(!isset($update_tables['users']['que_processed'])) { |
|
264 | + if (!isset($update_tables['users']['que_processed'])) { |
|
265 | 265 | upd_alter_table('users', array( |
266 | 266 | "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`", |
267 | 267 | ), true); |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | |
271 | 271 | |
272 | - if(isset($update_tables['planets']['que'])) { |
|
272 | + if (isset($update_tables['planets']['que'])) { |
|
273 | 273 | $sn_data_aux = array( |
274 | 274 | SHIP_SMALL_FIGHTER_WRATH => array( |
275 | 275 | 'name' => 'ship_fighter_wrath', |
@@ -354,20 +354,20 @@ discard block |
||
354 | 354 | $unit_data = array(); |
355 | 355 | $planets = array(); |
356 | 356 | |
357 | - foreach($planet_unit_list as $unit_id) { |
|
358 | - if(!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
357 | + foreach ($planet_unit_list as $unit_id) { |
|
358 | + if (!($unit_name = get_unit_param($unit_id, P_NAME))) { |
|
359 | 359 | $unit_name = $sn_data_aux[$unit_id][P_NAME]; |
360 | 360 | } |
361 | - if(isset($update_tables['planets'][$unit_name])) { |
|
361 | + if (isset($update_tables['planets'][$unit_name])) { |
|
362 | 362 | $drop[] = "DROP COLUMN `{$unit_name}`"; |
363 | 363 | |
364 | - if(isset($aux_group[$unit_id])) { |
|
364 | + if (isset($aux_group[$unit_id])) { |
|
365 | 365 | $units_info[$unit_id] = $sn_data_aux[$unit_id]; |
366 | 366 | $units_info[$unit_id]['que'] = QUE_HANGAR; |
367 | 367 | } else { |
368 | 368 | $units_info[$unit_id] = get_unit_param($unit_id); |
369 | - foreach($ques_info as $que_id => $que_data1) { |
|
370 | - if(in_array($unit_id, $que_data1['unit_list'])) { |
|
369 | + foreach ($ques_info as $que_id => $que_data1) { |
|
370 | + if (in_array($unit_id, $que_data1['unit_list'])) { |
|
371 | 371 | $units_info[$unit_id]['que'] = $que_id; |
372 | 372 | break; |
373 | 373 | } |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } |
378 | 378 | |
379 | 379 | $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE"); |
380 | - while($row = db_fetch($query)) { |
|
380 | + while ($row = db_fetch($query)) { |
|
381 | 381 | $user_id = $row['id_owner']; |
382 | 382 | $planet_id = $row['id']; |
383 | 383 | |
@@ -385,25 +385,25 @@ discard block |
||
385 | 385 | |
386 | 386 | // Конвертируем юниты |
387 | 387 | $units_levels = array(); |
388 | - foreach($planet_unit_list as $unit_id) { |
|
388 | + foreach ($planet_unit_list as $unit_id) { |
|
389 | 389 | $unit_name = &$units_info[$unit_id][P_NAME]; |
390 | - if(!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
390 | + if (!isset($row[$unit_name]) || !$row[$unit_name]) { |
|
391 | 391 | continue; |
392 | 392 | } |
393 | 393 | $units_levels[$unit_id] = $row[$unit_name]; |
394 | - $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
|
395 | - if(count($unit_data) > 30) { |
|
394 | + $unit_data[] = "({$user_id},".LOC_PLANET.",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})"; |
|
395 | + if (count($unit_data) > 30) { |
|
396 | 396 | $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max; |
397 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
397 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES '.implode(',', $unit_data).';'); |
|
398 | 398 | $unit_data = array(); |
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | 402 | // Конвертируем очередь построек |
403 | - if($row['que']) { |
|
403 | + if ($row['que']) { |
|
404 | 404 | $que = explode(';', $row['que']); |
405 | - foreach($que as $que_item) { |
|
406 | - if(!$que_item) { |
|
405 | + foreach ($que as $que_item) { |
|
406 | + if (!$que_item) { |
|
407 | 407 | continue; |
408 | 408 | } |
409 | 409 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1; |
419 | 419 | $price_increase = pow($unit_factor, $unit_level); |
420 | 420 | // $unit_time = 0; |
421 | - foreach($unit_cost as $resource_id => &$resource_amount) { |
|
422 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
421 | + foreach ($unit_cost as $resource_id => &$resource_amount) { |
|
422 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
423 | 423 | unset($unit_cost[$resource_id]); |
424 | 424 | continue; |
425 | 425 | } |
@@ -433,39 +433,39 @@ discard block |
||
433 | 433 | } |
434 | 434 | |
435 | 435 | // Конвертируем очередь верфи |
436 | - if($row['b_hangar_id']) { |
|
436 | + if ($row['b_hangar_id']) { |
|
437 | 437 | $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,); |
438 | 438 | $hangar_units = sys_unit_str2arr($row['b_hangar_id']); |
439 | - foreach($hangar_units as $unit_id => $unit_count) { |
|
440 | - if($unit_count <= 0) { |
|
439 | + foreach ($hangar_units as $unit_id => $unit_count) { |
|
440 | + if ($unit_count <= 0) { |
|
441 | 441 | continue; |
442 | 442 | } |
443 | - foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
444 | - if(!in_array($resource_id, $group_resource_loot)) { |
|
443 | + foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) { |
|
444 | + if (!in_array($resource_id, $group_resource_loot)) { |
|
445 | 445 | continue; |
446 | 446 | } |
447 | 447 | $return_resources[$resource_id] += $unit_count * $resource_amount; |
448 | 448 | } |
449 | 449 | } |
450 | - if(array_sum($return_resources) > 0) { |
|
450 | + if (array_sum($return_resources) > 0) { |
|
451 | 451 | upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1"); |
452 | 452 | } |
453 | 453 | } |
454 | 454 | |
455 | 455 | |
456 | - if(count($que_data) > 10) { |
|
456 | + if (count($que_data) > 10) { |
|
457 | 457 | $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max; |
458 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_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_data) . ';'); |
|
458 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_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_data).';'); |
|
459 | 459 | $que_data = array(); |
460 | 460 | } |
461 | 461 | } |
462 | 462 | |
463 | - if(!empty($unit_data)) { |
|
464 | - upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';'); |
|
463 | + if (!empty($unit_data)) { |
|
464 | + upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES '.implode(',', $unit_data).';'); |
|
465 | 465 | } |
466 | 466 | |
467 | - if(!empty($que_data)) { |
|
468 | - upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_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_data) . ';'); |
|
467 | + if (!empty($que_data)) { |
|
468 | + upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_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_data).';'); |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | upd_alter_table('planets', $drop, true); |
@@ -475,7 +475,7 @@ discard block |
||
475 | 475 | JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = '' |
476 | 476 | SET u.`username` = CONCAT('[', a.`ally_tag`, ']');"); |
477 | 477 | |
478 | - if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
478 | + if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') { |
|
479 | 479 | upd_do_query("SET FOREIGN_KEY_CHECKS=0;"); |
480 | 480 | upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']); |
481 | 481 | upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']); |
@@ -571,7 +571,7 @@ discard block |
||
571 | 571 | "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{security_browser}}` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE", |
572 | 572 | ), !isset($update_tables['users']['user_last_proxy'])); |
573 | 573 | |
574 | - if(!isset($update_tables['notes']['planet_type'])) { |
|
574 | + if (!isset($update_tables['notes']['planet_type'])) { |
|
575 | 575 | upd_alter_table('notes', array( |
576 | 576 | "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`", |
577 | 577 | "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`", |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot'])); |
590 | 590 | upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']); |
591 | 591 | |
592 | - if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
592 | + if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') { |
|
593 | 593 | upd_alter_table('users', array( |
594 | 594 | "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'", |
595 | 595 | ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint'); |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;"); |
598 | 598 | } |
599 | 599 | |
600 | - if(!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
600 | + if (!isset($update_tables['log_users_online']['online_aggregated'])) { |
|
601 | 601 | upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated'])); |
602 | 602 | upd_alter_table('log_users_online', array( |
603 | 603 | "DROP PRIMARY KEY", |
@@ -605,13 +605,13 @@ discard block |
||
605 | 605 | ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,'); |
606 | 606 | } |
607 | 607 | |
608 | - if(!isset($update_tables['users']['gender'])) { |
|
609 | - upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
|
610 | - upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));"); |
|
608 | + if (!isset($update_tables['users']['gender'])) { |
|
609 | + upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT ".GENDER_UNKNOWN, !isset($update_tables['users']['gender'])); |
|
610 | + upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', ".GENDER_FEMALE.", IF(UPPER(`sex`) = 'M', ".GENDER_MALE.", ".GENDER_UNKNOWN."));"); |
|
611 | 611 | } |
612 | 612 | upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex'])); |
613 | 613 | |
614 | - if(!$update_tables['users']['dark_matter_total']) { |
|
614 | + if (!$update_tables['users']['dark_matter_total']) { |
|
615 | 615 | upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']); |
616 | 616 | upd_do_query( |
617 | 617 | "UPDATE `{{users}}` AS u |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | } |
625 | 625 | |
626 | 626 | upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal)); |
627 | - if(!$update_tables['users']['metamatter_total']) { |
|
627 | + if (!$update_tables['users']['metamatter_total']) { |
|
628 | 628 | upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']); |
629 | 629 | |
630 | 630 | upd_do_query( |
@@ -636,11 +636,11 @@ discard block |
||
636 | 636 | (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0) |
637 | 637 | );"); |
638 | 638 | } |
639 | - if(!isset($update_tables['users']['immortal'])) { |
|
639 | + if (!isset($update_tables['users']['immortal'])) { |
|
640 | 640 | upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal'])); |
641 | 641 | upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;"); |
642 | 642 | } |
643 | - if(isset($update_tables['player_award'])) { |
|
643 | + if (isset($update_tables['player_award'])) { |
|
644 | 644 | upd_do_query( |
645 | 645 | "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id |
646 | 646 | SET metamatter_total = 1, immortal = NOW() |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE |
668 | 668 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"); |
669 | 669 | |
670 | - if(empty($update_tables['blitz_statpoints'])) { |
|
670 | + if (empty($update_tables['blitz_statpoints'])) { |
|
671 | 671 | upd_create_table('blitz_statpoints', " ( |
672 | 672 | `stat_date` int(11) NOT NULL DEFAULT '0', |
673 | 673 | `id_owner` bigint(20) unsigned DEFAULT NULL, |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE |
736 | 736 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
737 | 737 | |
738 | - if(empty($update_tables['security_url'])) { |
|
738 | + if (empty($update_tables['security_url'])) { |
|
739 | 739 | upd_create_table('security_url', " ( |
740 | 740 | `url_id` int unsigned NOT NULL AUTO_INCREMENT, |
741 | 741 | `url_string` VARCHAR(250) NOT NULL DEFAULT '', |
@@ -748,17 +748,17 @@ discard block |
||
748 | 748 | |
749 | 749 | $strings = array(); |
750 | 750 | $query = doquery($query); |
751 | - while($row = db_fetch($query)) { |
|
752 | - $strings[] = '("' . db_escape($row['url']) . '")'; |
|
753 | - if(count($strings) > 100) { |
|
754 | - doquery($query_string . implode(',', $strings)); |
|
751 | + while ($row = db_fetch($query)) { |
|
752 | + $strings[] = '("'.db_escape($row['url']).'")'; |
|
753 | + if (count($strings) > 100) { |
|
754 | + doquery($query_string.implode(',', $strings)); |
|
755 | 755 | $strings = array(); |
756 | 756 | } |
757 | 757 | } |
758 | - !empty($strings) ? doquery($query_string . implode(',', $strings)) : false; |
|
758 | + !empty($strings) ? doquery($query_string.implode(',', $strings)) : false; |
|
759 | 759 | } |
760 | 760 | |
761 | - if(isset($update_tables['counter']['page'])) // TODO REMOVE |
|
761 | + if (isset($update_tables['counter']['page'])) // TODO REMOVE |
|
762 | 762 | { |
763 | 763 | update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}"); |
764 | 764 | update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}"); |
@@ -783,7 +783,7 @@ discard block |
||
783 | 783 | "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
784 | 784 | "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE", |
785 | 785 | ), !isset($update_tables['counter']['device_id'])); |
786 | - if(isset($update_tables['counter']['ip'])) { |
|
786 | + if (isset($update_tables['counter']['ip'])) { |
|
787 | 787 | // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)'); |
788 | 788 | upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)'); |
789 | 789 | upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id'); |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | |
835 | 835 | upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days); |
836 | 836 | |
837 | - if(classSupernova::$config->payment_currency_default != 'USD') { |
|
837 | + if (classSupernova::$config->payment_currency_default != 'USD') { |
|
838 | 838 | upd_check_key('payment_currency_default', 'USD', true); |
839 | 839 | upd_check_key('payment_currency_exchange_dm_', 20000, true); |
840 | 840 | upd_check_key('payment_currency_exchange_mm_', 20000, true); |
@@ -891,7 +891,7 @@ discard block |
||
891 | 891 | |
892 | 892 | $virtual_exploded = explode('/', SN_ROOT_VIRTUAL_PARENT); |
893 | 893 | // TODO - переделать всё на db_loadItem... НАВЕРНОЕ |
894 | - upd_check_key('server_email', 'root@' . $virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email')); |
|
894 | + upd_check_key('server_email', 'root@'.$virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email')); |
|
895 | 895 | |
896 | 896 | upd_alter_table('survey_votes', array( |
897 | 897 | "DROP FOREIGN KEY `FK_survey_votes_user`", |
@@ -917,12 +917,12 @@ discard block |
||
917 | 917 | function propagade_player_options($old_option_name, $new_option_id) { |
918 | 918 | global $update_tables; |
919 | 919 | |
920 | - if(!empty($update_tables['users'][$old_option_name])) { |
|
920 | + if (!empty($update_tables['users'][$old_option_name])) { |
|
921 | 921 | upd_do_query( |
922 | 922 | "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`) |
923 | 923 | SELECT `id`, {$new_option_id}, `{$old_option_name}` |
924 | 924 | FROM {{users}} |
925 | - WHERE `user_as_ally` is null and `user_bot` = " . USER_BOT_PLAYER); |
|
925 | + WHERE `user_as_ally` is null and `user_bot` = ".USER_BOT_PLAYER); |
|
926 | 926 | // TODO - UNCOMMENT !!! |
927 | 927 | upd_alter_table('users', array("DROP COLUMN `{$old_option_name}`",)); |
928 | 928 | } |
@@ -951,7 +951,7 @@ discard block |
||
951 | 951 | |
952 | 952 | |
953 | 953 | // 2015-08-03 15:05:26 40a6.0 |
954 | - if(empty($update_tables['planets']['position_original'])) { |
|
954 | + if (empty($update_tables['planets']['position_original'])) { |
|
955 | 955 | upd_alter_table('planets', array( |
956 | 956 | "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0", |
957 | 957 | "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0", |
@@ -966,7 +966,7 @@ discard block |
||
966 | 966 | upd_do_query('UPDATE {{planets}} SET `position_original` = `planet`, `field_max_original` = `field_max`, `temp_min_original` = `temp_min`, `temp_max_original` = `temp_max`;'); |
967 | 967 | |
968 | 968 | // Миграция тяжмета в оливин |
969 | - upd_do_query('UPDATE {{planets}} SET `density_index` = ' . PLANET_DENSITY_METAL_PERIDOT . ' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7); |
|
969 | + upd_do_query('UPDATE {{planets}} SET `density_index` = '.PLANET_DENSITY_METAL_PERIDOT.' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7); |
|
970 | 970 | |
971 | 971 | // Добавляем планету-странника |
972 | 972 | upd_check_key('game_maxPlanet', 16, Vector::$knownPlanets == 15); |
@@ -979,12 +979,12 @@ discard block |
||
979 | 979 | |
980 | 980 | // 2015-08-27 19:14:05 40a10.0 |
981 | 981 | // Старая версия таблицы |
982 | - if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
982 | + if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) { |
|
983 | 983 | upd_drop_table('account'); |
984 | 984 | upd_drop_table('account_translate'); |
985 | 985 | } |
986 | 986 | |
987 | - if(empty($update_tables['account'])) { |
|
987 | + if (empty($update_tables['account'])) { |
|
988 | 988 | upd_create_table('account', " ( |
989 | 989 | `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
990 | 990 | `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '', |
@@ -1003,7 +1003,7 @@ discard block |
||
1003 | 1003 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;"); |
1004 | 1004 | |
1005 | 1005 | upd_create_table('account_translate', " ( |
1006 | - `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider', |
|
1006 | + `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider', |
|
1007 | 1007 | `provider_account_id` bigint(20) unsigned NOT NULL COMMENT 'Account ID on provider', |
1008 | 1008 | `user_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
1009 | 1009 | `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, |
@@ -1018,12 +1018,12 @@ discard block |
||
1018 | 1018 | (`account_id`, `account_name`, `account_password`, `account_salt`, `account_email`, `account_register_time`, `account_language`, `account_metamatter`, `account_metamatter_total`, `account_immortal`) |
1019 | 1019 | SELECT |
1020 | 1020 | `id`, `username`, `password`, `salt`, `email_2`, FROM_UNIXTIME(register_time), `lang`, `metamatter`, `metamatter_total`, `immortal` |
1021 | - FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER . ";" |
|
1021 | + FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER.";" |
|
1022 | 1022 | ); |
1023 | 1023 | |
1024 | 1024 | upd_do_query( |
1025 | 1025 | "REPLACE INTO {{account_translate}} (`provider_id`, `provider_account_id`, `user_id`, `timestamp`) |
1026 | - SELECT " . ACCOUNT_PROVIDER_LOCAL . ", a.account_id, u.id, a.`account_register_time` |
|
1026 | + SELECT " . ACCOUNT_PROVIDER_LOCAL.", a.account_id, u.id, a.`account_register_time` |
|
1027 | 1027 | FROM {{users}} AS u |
1028 | 1028 | JOIN {{account}} AS a ON |
1029 | 1029 | a.account_name = u.username |
@@ -1038,7 +1038,7 @@ discard block |
||
1038 | 1038 | |
1039 | 1039 | |
1040 | 1040 | // 2015-09-05 17:07:15 40a10.17 |
1041 | - upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT " . UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result'])); |
|
1041 | + upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT ".UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result'])); |
|
1042 | 1042 | |
1043 | 1043 | |
1044 | 1044 | // 2015-09-07 21:11:48 40a10.19 |
@@ -1046,18 +1046,18 @@ discard block |
||
1046 | 1046 | |
1047 | 1047 | |
1048 | 1048 | // 2015-09-24 11:39:37 40a10.25 |
1049 | - if(empty($update_tables['log_metamatter']['provider_id'])) { |
|
1049 | + if (empty($update_tables['log_metamatter']['provider_id'])) { |
|
1050 | 1050 | upd_alter_table('log_metamatter', array( |
1051 | - "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'", |
|
1051 | + "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider'", |
|
1052 | 1052 | "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0", |
1053 | 1053 | "ADD COLUMN `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''", |
1054 | - "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '" . SN_ROOT_VIRTUAL . "'", |
|
1054 | + "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '".SN_ROOT_VIRTUAL."'", |
|
1055 | 1055 | ), empty($update_tables['log_metamatter']['provider_id'])); |
1056 | 1056 | |
1057 | 1057 | upd_do_query("UPDATE {{log_metamatter}} SET `account_id` = `user_id`, `account_name` = `username`"); |
1058 | 1058 | |
1059 | 1059 | upd_alter_table('payment', array( |
1060 | - "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Payment account provider'", |
|
1060 | + "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Payment account provider'", |
|
1061 | 1061 | "ADD COLUMN `payment_account_id` bigint(20) unsigned NOT NULL", |
1062 | 1062 | "ADD COLUMN `payment_account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''", |
1063 | 1063 | ), !$update_tables['payment']['payment_account_id']); |
@@ -1098,7 +1098,7 @@ discard block |
||
1098 | 1098 | upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code)); |
1099 | 1099 | upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp)); |
1100 | 1100 | upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used)); |
1101 | - if(empty($update_tables['log_halloween_2015'])) { |
|
1101 | + if (empty($update_tables['log_halloween_2015'])) { |
|
1102 | 1102 | upd_create_table('log_halloween_2015', " ( |
1103 | 1103 | `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1104 | 1104 | `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID', |
@@ -1113,7 +1113,7 @@ discard block |
||
1113 | 1113 | |
1114 | 1114 | |
1115 | 1115 | // 2015-11-28 06:30:27 40a19.21 |
1116 | - if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1116 | + if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) { |
|
1117 | 1117 | upd_alter_table('ube_report', array( |
1118 | 1118 | "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'", |
1119 | 1119 | "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module |
@@ -1128,7 +1128,7 @@ discard block |
||
1128 | 1128 | |
1129 | 1129 | |
1130 | 1130 | // 2015-12-06 15:10:58 40b1.0 |
1131 | - if(!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1131 | + if (!empty($update_indexes['planets']['I_metal_mine'])) { |
|
1132 | 1132 | upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']); |
1133 | 1133 | upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']); |
1134 | 1134 | upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']); |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | case 40: |
1192 | 1192 | upd_log_version_update(); |
1193 | 1193 | |
1194 | - if(empty($update_tables['festival'])) { |
|
1194 | + if (empty($update_tables['festival'])) { |
|
1195 | 1195 | upd_create_table('festival', " ( |
1196 | 1196 | `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT, |
1197 | 1197 | `start` datetime NOT NULL COMMENT 'Festival start datetime', |
@@ -1232,7 +1232,7 @@ discard block |
||
1232 | 1232 | ); |
1233 | 1233 | } |
1234 | 1234 | |
1235 | - if(empty($update_tables['festival_unit'])) { |
|
1235 | + if (empty($update_tables['festival_unit'])) { |
|
1236 | 1236 | upd_create_table('festival_unit', " ( |
1237 | 1237 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1238 | 1238 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1249,7 +1249,7 @@ discard block |
||
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | // 2015-12-21 06:06:09 41a0.12 |
1252 | - if(empty($update_tables['festival_unit_log'])) { |
|
1252 | + if (empty($update_tables['festival_unit_log'])) { |
|
1253 | 1253 | upd_create_table('festival_unit_log', " ( |
1254 | 1254 | `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, |
1255 | 1255 | `highspot_id` int(10) unsigned DEFAULT NULL, |
@@ -1279,19 +1279,19 @@ discard block |
||
1279 | 1279 | $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin' |
1280 | 1280 | ); |
1281 | 1281 | |
1282 | - if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1282 | + if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') { |
|
1283 | 1283 | upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true); |
1284 | 1284 | upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true); |
1285 | 1285 | } |
1286 | 1286 | |
1287 | - if(!empty($update_tables['fleets']['fleet_array'])) { |
|
1287 | + if (!empty($update_tables['fleets']['fleet_array'])) { |
|
1288 | 1288 | $query = upd_do_query("SELECT * FROM {{fleets}}"); |
1289 | - while($row = db_fetch($query)) { |
|
1289 | + while ($row = db_fetch($query)) { |
|
1290 | 1290 | $unit_list = sys_unit_str2arr($row['fleet_array']); |
1291 | - foreach($unit_list as $unit_id => $unit_count) { |
|
1291 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
1292 | 1292 | upd_do_query( |
1293 | 1293 | "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES |
1294 | - ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});", |
|
1294 | + ({$row['fleet_owner']}, ".LOC_FLEET.", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});", |
|
1295 | 1295 | // ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, " . get_unit_param($unit_id, P_UNIT_TYPE) . ", {$unit_id}, {$unit_count});", |
1296 | 1296 | true |
1297 | 1297 | ); |
@@ -1325,11 +1325,11 @@ discard block |
||
1325 | 1325 | |
1326 | 1326 | classSupernova::$cache->unset_by_prefix('lng_'); |
1327 | 1327 | |
1328 | -if($new_version) { |
|
1328 | +if ($new_version) { |
|
1329 | 1329 | classSupernova::$config->db_saveItem('db_version', $new_version); |
1330 | 1330 | upd_log_message("<font color=green>DB version is now {$new_version}</font>"); |
1331 | 1331 | } else { |
1332 | - upd_log_message("DB version didn't changed from " . classSupernova::$config->db_version); |
|
1332 | + upd_log_message("DB version didn't changed from ".classSupernova::$config->db_version); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | classSupernova::$config->db_loadAll(); |