@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public function debris_add_resource($resource_id, $resource_amount) { |
32 | 32 | // В обломках может быть только металл или кристалл |
33 | - if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
33 | + if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) { |
|
34 | 34 | return; |
35 | 35 | } |
36 | 36 | $this->debris[$resource_id] += $resource_amount; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param bool $is_simulator |
42 | 42 | */ |
43 | 43 | public function add_wrecks(array $wreckage, $is_simulator) { |
44 | - foreach($wreckage as $resource_id => $resource_amount) { |
|
44 | + foreach ($wreckage as $resource_id => $resource_amount) { |
|
45 | 45 | $this->debris_add_resource($resource_id, floor($resource_amount * |
46 | 46 | ($is_simulator |
47 | 47 | ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @param bool $is_simulator |
58 | 58 | */ |
59 | 59 | public function add_cargo_drop(array $dropped_resources, $is_simulator) { |
60 | - foreach($dropped_resources as $resource_id => $resource_amount) { |
|
60 | + foreach ($dropped_resources as $resource_id => $resource_amount) { |
|
61 | 61 | $this->debris_add_resource($resource_id, floor($resource_amount * |
62 | 62 | ($is_simulator |
63 | 63 | ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param $moon_debris_left_part |
97 | 97 | */ |
98 | 98 | public function debris_adjust_proportional($moon_debris_left_part) { |
99 | - foreach($this->debris as $resource_id => &$resource_amount) { |
|
99 | + foreach ($this->debris as $resource_id => &$resource_amount) { |
|
100 | 100 | $resource_amount = floor($resource_amount * $moon_debris_left_part); |
101 | 101 | } |
102 | 102 | } |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | */ |
118 | 118 | public function report_generate_sql() { |
119 | 119 | return " |
120 | - `ube_report_debris_metal` = " . (float)$this->debris_get_resource(RES_METAL) . ", |
|
121 | - `ube_report_debris_crystal` = " . (float)$this->debris_get_resource(RES_CRYSTAL) . ", |
|
122 | - `ube_report_debris_total_in_metal` = " . (float)$this->debris_in_metal() . ", "; |
|
120 | + `ube_report_debris_metal` = " . (float) $this->debris_get_resource(RES_METAL).", |
|
121 | + `ube_report_debris_crystal` = " . (float) $this->debris_get_resource(RES_CRYSTAL).", |
|
122 | + `ube_report_debris_total_in_metal` = " . (float) $this->debris_in_metal().", "; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * @version 41a6.49 |
12 | 12 | */ |
13 | 13 | public static function unit_dump_header() { |
14 | - if(!defined('DEBUG_UBE')) { |
|
14 | + if (!defined('DEBUG_UBE')) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @version 41a6.49 |
49 | 49 | */ |
50 | 50 | public static function unit_dump(UBEUnit $unit, $desc = '', UBEUnit $before = null) { |
51 | - if(!defined('DEBUG_UBE')) { |
|
51 | + if (!defined('DEBUG_UBE')) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | // print("<td>" . $this->units_lost . "</td>"); |
76 | 76 | // print("<td>" . $this->units_restored . "</td>"); |
77 | 77 | // print("<td>" . $this->capacity . "</td>"); |
78 | - print("<td>" . round($unit->share_of_side_armor, 4) . "</td>"); |
|
78 | + print("<td>".round($unit->share_of_side_armor, 4)."</td>"); |
|
79 | 79 | print('</tr>'); |
80 | 80 | } |
81 | 81 | |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @version 41a6.49 |
87 | 87 | */ |
88 | 88 | public static function unit_dump_footer() { |
89 | - if(!defined('DEBUG_UBE')) { |
|
89 | + if (!defined('DEBUG_UBE')) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @return UBEUnit |
102 | 102 | */ |
103 | 103 | public static function unit_dump_defender(UBEUnit $attacking_unit_pool, UBEUnit $defending_unit_pool, $defending_fleet_id) { |
104 | - if(!defined('DEBUG_UBE')) { |
|
104 | + if (!defined('DEBUG_UBE')) { |
|
105 | 105 | return null; |
106 | 106 | } |
107 | 107 | |
108 | 108 | $classLocale = classLocale::$lang; |
109 | 109 | |
110 | - print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}" . |
|
111 | - ' attacks ' . |
|
112 | - $defending_fleet_id . '@' . "[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}" . |
|
113 | - ' with ' . pretty_number($defending_unit_pool->attack_income) . |
|
110 | + print("[{$attacking_unit_pool->unitId}]{$classLocale['tech'][$attacking_unit_pool->unitId]}". |
|
111 | + ' attacks '. |
|
112 | + $defending_fleet_id.'@'."[{$defending_unit_pool->unitId}]{$classLocale['tech'][$defending_unit_pool->unitId]}". |
|
113 | + ' with '.pretty_number($defending_unit_pool->attack_income). |
|
114 | 114 | '<br>' |
115 | 115 | ); |
116 | 116 | $before = clone $defending_unit_pool; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @version 41a6.49 |
128 | 128 | */ |
129 | 129 | public static function unit_dump_delta(UBEUnit $unit, $field, UBEUnit $before = null) { |
130 | - if(!defined('DEBUG_UBE')) { |
|
130 | + if (!defined('DEBUG_UBE')) { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | print(pretty_number($unit->$field)); |
137 | 137 | print("</td>"); |
138 | 138 | print("<td>"); |
139 | - if(!empty($before)) { |
|
140 | - print('' . pretty_number($unit->$field - $before->$field) . ''); |
|
139 | + if (!empty($before)) { |
|
140 | + print(''.pretty_number($unit->$field - $before->$field).''); |
|
141 | 141 | } |
142 | 142 | print("</td>"); |
143 | 143 | } |
@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | // Инфа об устройстве и браузере - общая для всех |
90 | 90 | sn_db_transaction_start(); |
91 | 91 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
92 | - if($this->device_cypher) { |
|
92 | + if ($this->device_cypher) { |
|
93 | 93 | $cypher_safe = db_escape($this->device_cypher); |
94 | 94 | $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
95 | - if(!empty($device_id['device_id'])) { |
|
95 | + if (!empty($device_id['device_id'])) { |
|
96 | 96 | $this->device_id = $device_id['device_id']; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if($this->device_id <= 0) { |
|
100 | + if ($this->device_id <= 0) { |
|
101 | 101 | do { |
102 | 102 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
103 | 103 | $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string'); |
119 | 119 | sn_db_transaction_commit(); |
120 | 120 | |
121 | - if($this->write_full_url) { |
|
121 | + if ($this->write_full_url) { |
|
122 | 122 | sn_db_transaction_start(); |
123 | 123 | $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE)); |
124 | - if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
124 | + if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
125 | 125 | $this->page_url = '/simulator.php'; |
126 | 126 | } |
127 | 127 | $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function db_security_entry_insert($user_id_unsafe) { |
146 | 146 | // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL'; |
147 | - if(empty($user_id_unsafe)) { |
|
147 | + if (empty($user_id_unsafe)) { |
|
148 | 148 | // self::flog('Нет ИД пользователя'); |
149 | 149 | return true; |
150 | 150 | } |
@@ -154,8 +154,8 @@ discard block |
||
154 | 154 | // self::flog('Вставляем запись системы безопасности'); |
155 | 155 | return doquery( |
156 | 156 | "INSERT IGNORE INTO {{security_player_entry}} (`player_id`, `device_id`, `browser_id`, `user_ip`, `user_proxy`) |
157 | - VALUES ({$user_id_safe}," . $this->device_id . "," . $this->browser_id . "," . |
|
158 | - $this->ip_v4_int . ", '" . db_escape($this->ip_v4_proxy_chain) . "');" |
|
157 | + VALUES ({$user_id_safe},".$this->device_id.",".$this->browser_id.",". |
|
158 | + $this->ip_v4_int.", '".db_escape($this->ip_v4_proxy_chain)."');" |
|
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function db_counter_insert($user_id_unsafe) { |
168 | 168 | global $sys_stop_log_hit; |
169 | 169 | |
170 | - if($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
170 | + if ($sys_stop_log_hit || !classSupernova::$config->game_counter) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | classSupernova::$db->isWatching = true; |
178 | 178 | doquery( |
179 | 179 | "INSERT INTO {{counter}} SET |
180 | - `visit_time` = '" . SN_TIME_SQL. "', |
|
180 | + `visit_time` = '" . SN_TIME_SQL."', |
|
181 | 181 | `user_id` = {$user_id_safe}, |
182 | 182 | `device_id` = {$this->device_id}, |
183 | 183 | `browser_id` = {$this->browser_id}, |
184 | 184 | `user_ip` = {$this->ip_v4_int}, |
185 | 185 | `user_proxy` = '{$proxy_safe}', |
186 | - `page_url_id` = {$this->page_address_id}" . |
|
187 | - ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ). |
|
186 | + `page_url_id` = {$this->page_address_id}". |
|
187 | + ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : ''). |
|
188 | 188 | ";"); |
189 | 189 | |
190 | 190 | classSupernova::$db->isWatching = false; |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | public static function _init($group_name = '') { |
27 | 27 | parent::_init($group_name); |
28 | 28 | |
29 | - foreach(static::$_group_unit_id_list as $resource_id) { |
|
29 | + foreach (static::$_group_unit_id_list as $resource_id) { |
|
30 | 30 | static::$_group_pnames[$resource_id] = pname_resource_name($resource_id); |
31 | 31 | } |
32 | 32 | |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | |
49 | 49 | !is_array($resource_array) ? $resource_array = array() : false; |
50 | 50 | |
51 | - foreach($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | - if(!$resource_actual_delta) { |
|
51 | + foreach ($resource_array as $resource_id => $resource_actual_delta) { |
|
52 | + if (!$resource_actual_delta) { |
|
53 | 53 | // No delta - no changes |
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | - $result[$prefix . static::$_group_pnames[$resource_id]] = $resource_actual_delta; |
|
57 | + $result[$prefix.static::$_group_pnames[$resource_id]] = $resource_actual_delta; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $result; |
@@ -39,19 +39,19 @@ |
||
39 | 39 | |
40 | 40 | @$this->link = mysqli_connect($settings['server'], $settings['user'], $settings['pass'], $settings['name']); |
41 | 41 | if (!is_object($this->link) || $this->link->connect_error) { |
42 | - classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #' . $this->link->connect_errno, $this->link->connect_error); |
|
42 | + classSupernova::$debug->error_fatal('DB Error - cannot connect to server error #'.$this->link->connect_errno, $this->link->connect_error); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | !$this->mysql_query("/*!40101 SET NAMES 'utf8' */") |
47 | - ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #' . $this->link->errno, $this->link->error) |
|
47 | + ? classSupernova::$debug->error_fatal('DB error - cannot set names 1 error #'.$this->link->errno, $this->link->error) |
|
48 | 48 | : false; |
49 | 49 | !$this->mysql_query("SET NAMES 'utf8';") |
50 | - ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #' . $this->link->errno, $this->link->error) |
|
50 | + ? classSupernova::$debug->error_fatal('DB error - cannot set names 2 error #'.$this->link->errno, $this->link->error) |
|
51 | 51 | : false; |
52 | 52 | |
53 | - !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL ' . self::DB_MYSQL_TRANSACTION_REPEATABLE_READ . ';') |
|
54 | - ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #' . $this->link->errno, $this->link->error) |
|
53 | + !$this->mysql_query('SET SESSION TRANSACTION ISOLATION LEVEL '.self::DB_MYSQL_TRANSACTION_REPEATABLE_READ.';') |
|
54 | + ? classSupernova::$debug->error_fatal('DB error - cannot set desired isolation level error #'.$this->link->errno, $this->link->error) |
|
55 | 55 | : false; |
56 | 56 | |
57 | 57 | $this->connected = true; |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | protected static $is_init = false; |
20 | 20 | |
21 | 21 | protected static function init() { |
22 | - if(!empty(static::$db)) { |
|
22 | + if (!empty(static::$db)) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | static::$db = classSupernova::$db; |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | $provider_id_safe = intval($provider_id_unsafe); |
67 | 67 | !is_array($account_list) ? $account_list = array($account_list) : false; |
68 | 68 | |
69 | - foreach($account_list as $provider_account_id_unsafe) { |
|
69 | + foreach ($account_list as $provider_account_id_unsafe) { |
|
70 | 70 | $provider_account_id_safe = intval($provider_account_id_unsafe); |
71 | 71 | |
72 | 72 | // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером |
73 | 73 | $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE"); |
74 | - while($row = static::$db->db_fetch($query)) { |
|
74 | + while ($row = static::$db->db_fetch($query)) { |
|
75 | 75 | $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true; |
76 | 76 | } |
77 | 77 | } |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | $account_translation = array(); |
89 | 89 | |
90 | 90 | $query = static::$db->doquery( |
91 | - "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " . |
|
92 | - ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') . |
|
91 | + "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} ". |
|
92 | + ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : ''). |
|
93 | 93 | "ORDER BY `timestamp` FOR UPDATE"); |
94 | - while($row = static::$db->db_fetch($query)) { |
|
94 | + while ($row = static::$db->db_fetch($query)) { |
|
95 | 95 | $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row; |
96 | 96 | } |
97 | 97 |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * Инициализация харнилища скинов |
153 | 153 | */ |
154 | 154 | protected static function init() { |
155 | - if(static::$is_init) { |
|
155 | + if (static::$is_init) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | // Загружены ли уже данные по текущему скину? |
167 | 167 | //pdump(static::$skin_list[$ini_path], 'static'); |
168 | - if(empty(static::$skin_list[$skin_path])) { |
|
168 | + if (empty(static::$skin_list[$skin_path])) { |
|
169 | 169 | // Прогружаем текущий скин |
170 | 170 | static::$skin_list[$skin_path] = new skin($skin_path); |
171 | 171 | static::$active = static::$skin_list[$skin_path]; |
@@ -191,9 +191,9 @@ discard block |
||
191 | 191 | strpos($skin_path, 'skins/') !== false ? $skin_path = substr($skin_path, 6) : false; |
192 | 192 | strpos($skin_path, '/') !== false ? $skin_path = str_replace('/', '', $skin_path) : false; |
193 | 193 | |
194 | - $this->root_http_relative = 'skins/' . $skin_path . '/'; // Пока стоит base="" в body SN_ROOT_VIRTUAL - не нужен |
|
194 | + $this->root_http_relative = 'skins/'.$skin_path.'/'; // Пока стоит base="" в body SN_ROOT_VIRTUAL - не нужен |
|
195 | 195 | // $this->root_http = SN_ROOT_VIRTUAL . 'skins/' . $skin_path . '/'; // Всегда абсолютный путь от корня сайта |
196 | - $this->root_physical_absolute = SN_ROOT_PHYSICAL . 'skins/' . $skin_path . '/'; |
|
196 | + $this->root_physical_absolute = SN_ROOT_PHYSICAL.'skins/'.$skin_path.'/'; |
|
197 | 197 | $this->name = $skin_path; |
198 | 198 | // pdump($this->root_folder); |
199 | 199 | // Искать скин среди пользовательских - когда будет конструктор скинов |
@@ -201,22 +201,22 @@ discard block |
||
201 | 201 | |
202 | 202 | $this->is_ini_present = false; |
203 | 203 | // Проверка на корректность и существование пути |
204 | - if(is_file($this->root_physical_absolute . 'skin.ini')) { |
|
204 | + if (is_file($this->root_physical_absolute.'skin.ini')) { |
|
205 | 205 | // Пытаемся распарсить файл |
206 | 206 | |
207 | 207 | // По секциям? images и config? Что бы не копировать конфигурацию? Или просто unset(__inherit) а затем заново записать |
208 | - $this->config = parse_ini_file($this->root_physical_absolute . 'skin.ini'); |
|
209 | - if(!empty($this->config)) { |
|
208 | + $this->config = parse_ini_file($this->root_physical_absolute.'skin.ini'); |
|
209 | + if (!empty($this->config)) { |
|
210 | 210 | |
211 | 211 | $this->is_ini_present = true; |
212 | 212 | |
213 | - if(!empty($this->config['_inherit'])) { |
|
213 | + if (!empty($this->config['_inherit'])) { |
|
214 | 214 | // Если скин наследует себя... |
215 | - if($this->config['_inherit'] == $skin_path) { |
|
215 | + if ($this->config['_inherit'] == $skin_path) { |
|
216 | 216 | // TODO - определять более сложные случаи циклических ссылок в _inherit |
217 | 217 | die('">circular skin inheritance!'); |
218 | 218 | } |
219 | - if(empty(static::$skin_list[$this->config['_inherit']])) { |
|
219 | + if (empty(static::$skin_list[$this->config['_inherit']])) { |
|
220 | 220 | static::$skin_list[$this->config['_inherit']] = new skin($this->config['_inherit']); |
221 | 221 | } |
222 | 222 | $this->parent = static::$skin_list[$this->config['_inherit']]; |
@@ -232,15 +232,15 @@ discard block |
||
232 | 232 | } |
233 | 233 | |
234 | 234 | // Пытаемся скомпилировать _no_image заранее |
235 | - if(!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
235 | + if (!empty($this->config[SKIN_IMAGE_MISSED_FIELD])) { |
|
236 | 236 | $this->container[SKIN_IMAGE_MISSED_FIELD] = $this->compile_try_path(SKIN_IMAGE_MISSED_FIELD, $this->config[SKIN_IMAGE_MISSED_FIELD]); |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Если нет заглушки |
240 | - if(empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
240 | + if (empty($this->container[SKIN_IMAGE_MISSED_FIELD])) { |
|
241 | 241 | $this->container[SKIN_IMAGE_MISSED_FIELD] = empty($this->parent) |
242 | 242 | // Если нет парента - берем хардкод |
243 | - ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL . SKIN_IMAGE_MISSED_FILE_PATH |
|
243 | + ? $this->container[SKIN_IMAGE_MISSED_FIELD] = SN_ROOT_VIRTUAL.SKIN_IMAGE_MISSED_FILE_PATH |
|
244 | 244 | // Если есть парент - берем у парента. У предков всегда всё есть |
245 | 245 | : $this->parent->compile_image(SKIN_IMAGE_MISSED_FIELD, null); |
246 | 246 | } |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $image_tag = $this->image_tag_parse($image_tag, $template); |
268 | 268 | |
269 | 269 | // Проверяем наличие ключа RIT в хранилища. В нём не может быть несуществующих файлов по построению |
270 | - if(!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
270 | + if (!empty($this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]])) { |
|
271 | 271 | return $this->container[$image_tag[SKIN_IMAGE_TAG_RESOLVED]]; |
272 | 272 | } |
273 | 273 | |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | // Нет - image ID не является путём к файлу. Пора обратиться к предкам за помощью... |
286 | 286 | // Пытаемся вытащить путь из родителя и применить к нему свои параметры |
287 | 287 | // Тащим по ID изображения, а не по ТЭГУ - мало ли что там делает с путём родитель и как преобразовывает его в строку? |
288 | - if(empty($this->container[$image_id]) && !empty($this->parent)) { |
|
288 | + if (empty($this->container[$image_id]) && !empty($this->parent)) { |
|
289 | 289 | $this->container[$image_id] = $this->parent->compile_image($image_id, $template); |
290 | 290 | |
291 | 291 | // Если у родителя нет картинки - он вернет пустую строку. Тогда нам надо использовать заглушку - свою или родительскую |
@@ -306,18 +306,18 @@ discard block |
||
306 | 306 | protected function image_tag_parse($image_tag, $template) { |
307 | 307 | $image_tag_ptl_resolved = $image_tag; |
308 | 308 | // Есть переменные из темплейта ? |
309 | - if(strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
309 | + if (strpos($image_tag_ptl_resolved, '[') !== false && is_object($template)) { |
|
310 | 310 | // Что бы лишний раз не запускать регексп |
311 | 311 | // TODO - многоуровневые вложения ?! Надо ли и где их можно применить |
312 | 312 | preg_match_all('#(\[.+?\])#', $image_tag_ptl_resolved, $matches); |
313 | - foreach($matches[0] as &$match) { |
|
313 | + foreach ($matches[0] as &$match) { |
|
314 | 314 | $var_name = str_replace(array('[', ']'), '', $match); |
315 | - if(strpos($var_name, '.') !== false) { |
|
315 | + if (strpos($var_name, '.') !== false) { |
|
316 | 316 | // Вложенная переменная темплейта - на текущем уровне |
317 | 317 | // TODO Вложенная переменная из корня через "!" |
318 | 318 | list($block_name, $block_var) = explode('.', $var_name); |
319 | 319 | isset($template->_block_value[$block_name][$block_var]) ? $image_tag_ptl_resolved = str_replace($match, $template->_block_value[$block_name][$block_var], $image_tag_ptl_resolved) : false; |
320 | - } elseif(strpos($var_name, '$') !== false) { |
|
320 | + } elseif (strpos($var_name, '$') !== false) { |
|
321 | 321 | // Корневой DEFINE |
322 | 322 | $define_name = substr($var_name, 1); |
323 | 323 | isset($template->_tpldata['DEFINE']['.'][$define_name]) ? $image_tag_ptl_resolved = str_replace($match, $template->_tpldata['DEFINE']['.'][$define_name], $image_tag_ptl_resolved) : false; |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
331 | - if(strpos($image_tag_ptl_resolved, '|') !== false) { |
|
331 | + if (strpos($image_tag_ptl_resolved, '|') !== false) { |
|
332 | 332 | $params = explode('|', $image_tag_ptl_resolved); |
333 | 333 | $image_id = $params[0]; |
334 | 334 | unset($params[0]); |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | protected function compile_try_path($image_id, $file_path) { |
359 | 359 | // Если первый символ пути '/' - значит это путь от HTTP-корня |
360 | 360 | // Откусываем его и пользуем остальное |
361 | - $relative_path = strpos($file_path, '/') !== 0 ? $this->root_http_relative . $file_path : substr($file_path, 1); |
|
361 | + $relative_path = strpos($file_path, '/') !== 0 ? $this->root_http_relative.$file_path : substr($file_path, 1); |
|
362 | 362 | |
363 | - return is_file(SN_ROOT_PHYSICAL . $relative_path) ? $this->container[$image_id] = SN_ROOT_VIRTUAL . $relative_path : ''; |
|
363 | + return is_file(SN_ROOT_PHYSICAL.$relative_path) ? $this->container[$image_id] = SN_ROOT_VIRTUAL.$relative_path : ''; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | |
@@ -392,13 +392,13 @@ discard block |
||
392 | 392 | $image_string = $this->container[$image_tag]; |
393 | 393 | |
394 | 394 | // Нет параметров - просто возвращаем значение по $image_name из контейнера |
395 | - if(!empty($params) && is_array($params)) { |
|
395 | + if (!empty($params) && is_array($params)) { |
|
396 | 396 | // Здесь автоматически произойдёт упорядочивание параметров |
397 | 397 | |
398 | 398 | // Параметр 'html' - выводить изображение в виде HTML-тэга |
399 | - if(in_array('html', $params)) { |
|
400 | - $image_tag = $image_tag . '|html'; |
|
401 | - $image_string = '<img src="' . $image_string . '" />'; |
|
399 | + if (in_array('html', $params)) { |
|
400 | + $image_tag = $image_tag.'|html'; |
|
401 | + $image_string = '<img src="'.$image_string.'" />'; |
|
402 | 402 | $this->container[$image_tag] = $image_string; |
403 | 403 | } |
404 | 404 | } |
@@ -30,6 +30,6 @@ |
||
30 | 30 | |
31 | 31 | |
32 | 32 | public function addPlayerLock($table, $playerIdFieldName) { |
33 | - $this->lock_player[$table . '-' . $playerIdFieldName] = array($table, $playerIdFieldName); |
|
33 | + $this->lock_player[$table.'-'.$playerIdFieldName] = array($table, $playerIdFieldName); |
|
34 | 34 | } |
35 | 35 | } |
@@ -33,18 +33,18 @@ discard block |
||
33 | 33 | $fleets_added = array(); |
34 | 34 | |
35 | 35 | $query = doquery( |
36 | - "SELECT * FROM `{{fleets}}`" . |
|
37 | - (!empty($where_safe) ? " WHERE {$where_safe}" : '') . |
|
36 | + "SELECT * FROM `{{fleets}}`". |
|
37 | + (!empty($where_safe) ? " WHERE {$where_safe}" : ''). |
|
38 | 38 | " FOR UPDATE;" |
39 | 39 | ); |
40 | - while($row = db_fetch($query)) { |
|
40 | + while ($row = db_fetch($query)) { |
|
41 | 41 | /** |
42 | 42 | * @var Fleet $fleet |
43 | 43 | */ |
44 | 44 | $fleet = $this->_createElement(); |
45 | 45 | $fleet->dbRowParse($row); |
46 | 46 | |
47 | - if(isset($this[$fleet->dbId])) { |
|
47 | + if (isset($this[$fleet->dbId])) { |
|
48 | 48 | // Нужно ли ???? |
49 | 49 | classSupernova::$debug->error('Fleet list already set'); |
50 | 50 | } |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | public static function dbGetFleetListCurrentTick() { |
122 | 122 | return static::dbGetFleetList( |
123 | 123 | " |
124 | - (`fleet_start_time` <= " . SN_TIME_NOW . " AND `fleet_mess` = 0) |
|
124 | + (`fleet_start_time` <= " . SN_TIME_NOW." AND `fleet_mess` = 0) |
|
125 | 125 | OR |
126 | - (`fleet_end_stay` <= " . SN_TIME_NOW . " AND `fleet_end_stay` > 0 AND `fleet_mess` = 0) |
|
126 | + (`fleet_end_stay` <= " . SN_TIME_NOW." AND `fleet_end_stay` > 0 AND `fleet_mess` = 0) |
|
127 | 127 | OR |
128 | - (`fleet_end_time` <= " . SN_TIME_NOW . ")"); |
|
128 | + (`fleet_end_time` <= " . SN_TIME_NOW.")"); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | AND `fleet_end_planet` = {$planet_row['planet']} |
146 | 146 | AND `fleet_end_type` = {$planet_row['planet_type']} |
147 | 147 | AND `fleet_owner` = {$fleet_owner_id} |
148 | - AND `fleet_mission` IN (" . MT_ATTACK . "," . MT_ACS . "," . MT_DESTROY . ") |
|
148 | + AND `fleet_mission` IN (".MT_ATTACK.",".MT_ACS.",".MT_DESTROY.") |
|
149 | 149 | AND `fleet_mess` = 0" |
150 | 150 | ); |
151 | 151 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @return static |
171 | 171 | */ |
172 | 172 | public static function dbGetFleetListAndMissileByCoordinates($coordinates, $for_phalanx = false) { |
173 | - if(empty($coordinates) || !is_array($coordinates)) { |
|
173 | + if (empty($coordinates) || !is_array($coordinates)) { |
|
174 | 174 | return array(); |
175 | 175 | } |
176 | 176 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @var Fleet[] $array_of_Fleet |
200 | 200 | */ |
201 | 201 | $array_of_Fleet = array(); |
202 | - if(!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
203 | - foreach($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
202 | + if (!empty($fleet_db_list) && $fleet_db_list->count()) { |
|
203 | + foreach ($fleet_db_list->_container as $fleet_id => $objFleet) { |
|
204 | 204 | $array_of_Fleet[$fleet_id] = $objFleet; |
205 | 205 | } |
206 | 206 | $planet_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet); |
@@ -225,16 +225,16 @@ discard block |
||
225 | 225 | return static::dbGetFleetList( |
226 | 226 | "( |
227 | 227 | fleet_start_galaxy = {$galaxy} |
228 | - AND fleet_start_system = {$system}" . |
|
229 | - ($planet ? " AND fleet_start_planet = {$planet}" : '') . |
|
230 | - ($planet_type != PT_ALL ? " AND fleet_start_type = {$planet_type}" : '') . |
|
231 | - ($for_phalanx ? '' : " AND fleet_mess = 1") . |
|
228 | + AND fleet_start_system = {$system}". |
|
229 | + ($planet ? " AND fleet_start_planet = {$planet}" : ''). |
|
230 | + ($planet_type != PT_ALL ? " AND fleet_start_type = {$planet_type}" : ''). |
|
231 | + ($for_phalanx ? '' : " AND fleet_mess = 1"). |
|
232 | 232 | ") OR ( |
233 | 233 | fleet_end_galaxy = {$galaxy} |
234 | - AND fleet_end_system = {$system}" . |
|
235 | - ($planet ? " AND fleet_end_planet = {$planet}" : '') . |
|
236 | - ($planet_type != PT_ALL ? " AND fleet_end_type = {$planet_type} " : '') . |
|
237 | - ($for_phalanx ? '' : " AND fleet_mess = 0") . |
|
234 | + AND fleet_end_system = {$system}". |
|
235 | + ($planet ? " AND fleet_end_planet = {$planet}" : ''). |
|
236 | + ($planet_type != PT_ALL ? " AND fleet_end_type = {$planet_type} " : ''). |
|
237 | + ($for_phalanx ? '' : " AND fleet_mess = 0"). |
|
238 | 238 | ")" |
239 | 239 | ); |
240 | 240 | } |
@@ -246,10 +246,10 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function dbMergeMissileList($where) { |
248 | 248 | $query = doquery( |
249 | - "SELECT * FROM `{{iraks}}`" . |
|
250 | - (!empty($where) ? " WHERE {$where}" : '') . |
|
249 | + "SELECT * FROM `{{iraks}}`". |
|
250 | + (!empty($where) ? " WHERE {$where}" : ''). |
|
251 | 251 | " FOR UPDATE;"); |
252 | - while($missile_db_row = db_fetch($query)) { |
|
252 | + while ($missile_db_row = db_fetch($query)) { |
|
253 | 253 | /** |
254 | 254 | * @var Fleet $objFleet |
255 | 255 | */ |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | */ |
272 | 272 | public static function dbGetFleetListAndMissileINCOMING($owner_id) { |
273 | 273 | $owner_id_safe = idval($owner_id); |
274 | - if(empty($owner_id_safe)) { |
|
274 | + if (empty($owner_id_safe)) { |
|
275 | 275 | return array(); |
276 | 276 | } |
277 | 277 | |
@@ -305,10 +305,10 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public static function fleet_count_flying($player_id, $mission_id = 0) { |
307 | 307 | $player_id_safe = idval($player_id); |
308 | - if(!empty($player_id_safe)) { |
|
308 | + if (!empty($player_id_safe)) { |
|
309 | 309 | $mission_id_safe = intval($mission_id); |
310 | 310 | $result = static::db_fleet_count( |
311 | - "`fleet_owner` = {$player_id_safe}" . |
|
311 | + "`fleet_owner` = {$player_id_safe}". |
|
312 | 312 | ($mission_id_safe ? " AND `fleet_mission` = {$mission_id_safe}" : '') |
313 | 313 | ); |
314 | 314 | } else { |