@@ -419,7 +419,8 @@ discard block |
||
419 | 419 | $location_info = &static::$location_info[$location_type]; |
420 | 420 | $id_field = $location_info[P_ID]; |
421 | 421 | $table_name = $location_info[P_TABLE_NAME]; |
422 | - if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
422 | + if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
423 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
423 | 424 | { |
424 | 425 | if (static::$db->db_affected_rows()) { |
425 | 426 | // Обновляем данные только если ряд был затронут |
@@ -427,6 +428,7 @@ discard block |
||
427 | 428 | |
428 | 429 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
429 | 430 | _SnCacheInternal::$data[$location_type][$record_id] = null; |
431 | + } |
|
430 | 432 | // Вытаскиваем обновленную запись |
431 | 433 | static::db_get_record_by_id($location_type, $record_id); |
432 | 434 | _SnCacheInternal::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -460,9 +462,11 @@ discard block |
||
460 | 462 | $set = trim($set); |
461 | 463 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
462 | 464 | if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
463 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
465 | + if (static::$db->db_affected_rows()) { |
|
466 | + // Обновляем данные только если ряд был затронут |
|
464 | 467 | { |
465 | 468 | $record_id = db_insert_id(); |
469 | + } |
|
466 | 470 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
467 | 471 | $result = static::db_get_record_by_id($location_type, $record_id); |
468 | 472 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -483,10 +487,12 @@ discard block |
||
483 | 487 | $id_field = $location_info[P_ID]; |
484 | 488 | $table_name = $location_info[P_TABLE_NAME]; |
485 | 489 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
486 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
490 | + if (static::$db->db_affected_rows()) { |
|
491 | + // Обновляем данные только если ряд был затронут |
|
487 | 492 | { |
488 | 493 | _SnCacheInternal::cache_unset($location_type, $safe_record_id); |
489 | 494 | } |
495 | + } |
|
490 | 496 | } |
491 | 497 | |
492 | 498 | return $result; |
@@ -500,11 +506,13 @@ discard block |
||
500 | 506 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
501 | 507 | |
502 | 508 | if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
503 | - if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
509 | + if (static::$db->db_affected_rows()) { |
|
510 | + // Обновляем данные только если ряд был затронут |
|
504 | 511 | { |
505 | 512 | // Обнуление кэша, потому что непонятно, что поменялось |
506 | 513 | _SnCacheInternal::cache_clear($location_type); |
507 | 514 | } |
515 | + } |
|
508 | 516 | } |
509 | 517 | |
510 | 518 | return $result; |
@@ -139,11 +139,13 @@ |
||
139 | 139 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
140 | 140 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
141 | 141 | foreach($error_backtrace['cSN_data'] as &$location) { |
142 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
142 | + foreach($location as $location_id => &$location_data) { |
|
143 | + // $location_data = $location_id; |
|
143 | 144 | { |
144 | 145 | $location_data = isset($location_data['username']) ? $location_data['username'] : |
145 | 146 | (isset($location_data['name']) ? $location_data['name'] : $location_id); |
146 | 147 | } |
148 | + } |
|
147 | 149 | } |
148 | 150 | } |
149 | 151 |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | sprintf($lang['buddy_msg_accept_text'], $user['username'])); |
57 | 57 | sn_db_transaction_commit(); |
58 | 58 | throw new exception('buddy_err_accept_none', ERR_NONE); |
59 | - } |
|
60 | - else |
|
59 | + } else |
|
61 | 60 | { |
62 | 61 | throw new exception('buddy_err_accept_internal', ERR_ERROR); |
63 | 62 | } |
@@ -69,9 +68,11 @@ discard block |
||
69 | 68 | throw new exception('buddy_err_delete_alien', ERR_ERROR); |
70 | 69 | } |
71 | 70 | |
72 | - if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) // Existing friendship |
|
71 | + if($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_ACTIVE) { |
|
72 | + // Existing friendship |
|
73 | 73 | { |
74 | 74 | $ex_friend_id = $buddy_row['BUDDY_SENDER_ID'] == $user['id'] ? $buddy_row['BUDDY_OWNER_ID'] : $buddy_row['BUDDY_SENDER_ID']; |
75 | + } |
|
75 | 76 | |
76 | 77 | msg_send_simple_message($ex_friend_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_unfriend_title'], |
77 | 78 | sprintf($lang['buddy_msg_unfriend_text'], $user['username'])); |
@@ -79,17 +80,19 @@ discard block |
||
79 | 80 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
80 | 81 | sn_db_transaction_commit(); |
81 | 82 | throw new exception('buddy_err_unfriend_none', ERR_NONE); |
82 | - } |
|
83 | - elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) // Player's outcoming request - either denied or waiting |
|
83 | + } elseif($buddy_row['BUDDY_SENDER_ID'] == $user['id']) { |
|
84 | + // Player's outcoming request - either denied or waiting |
|
84 | 85 | { |
85 | 86 | doquery("DELETE FROM {{buddy}} WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
87 | + } |
|
86 | 88 | sn_db_transaction_commit(); |
87 | 89 | throw new exception('buddy_err_delete_own', ERR_NONE); |
88 | - } |
|
89 | - elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) // Deny incoming request |
|
90 | + } elseif($buddy_row['BUDDY_STATUS'] == BUDDY_REQUEST_WAITING) { |
|
91 | + // Deny incoming request |
|
90 | 92 | { |
91 | 93 | msg_send_simple_message($buddy_row['BUDDY_SENDER_ID'], $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, $user['username'], $lang['buddy_msg_deny_title'], |
92 | 94 | sprintf($lang['buddy_msg_deny_text'], $user['username'])); |
95 | + } |
|
93 | 96 | |
94 | 97 | doquery("UPDATE {{buddy}} SET `BUDDY_STATUS` = " . BUDDY_REQUEST_DENIED . " WHERE `BUDDY_ID` = {$buddy_id} LIMIT 1;"); |
95 | 98 | sn_db_transaction_commit(); |
@@ -104,8 +107,7 @@ discard block |
||
104 | 107 | if($new_friend_id = sys_get_param_id('request_user_id')) |
105 | 108 | { |
106 | 109 | $new_friend_row = db_user_by_id($new_friend_id, true, '`id`, `username`'); |
107 | - } |
|
108 | - elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
110 | + } elseif($new_friend_name = sys_get_param_str_unsafe('request_user_name')) |
|
109 | 111 | { |
110 | 112 | $new_friend_row = db_user_by_username($new_friend_name); |
111 | 113 | $new_friend_name = db_escape($new_friend_name); |
@@ -138,8 +140,7 @@ discard block |
||
138 | 140 | sn_db_transaction_commit(); |
139 | 141 | throw new exception('buddy_err_adding_none', ERR_NONE); |
140 | 142 | } |
141 | -} |
|
142 | -catch(exception $e) |
|
143 | +} catch(exception $e) |
|
143 | 144 | { |
144 | 145 | $result[] = array( |
145 | 146 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -6,8 +6,7 @@ discard block |
||
6 | 6 | require_once('db_queries_fleet.php'); |
7 | 7 | |
8 | 8 | |
9 | -function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) |
|
10 | -{ |
|
9 | +function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
|
11 | 10 | return doquery( |
12 | 11 | "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
13 | 12 | " FROM {{planets}} AS p |
@@ -16,8 +15,7 @@ discard block |
||
16 | 15 | " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
17 | 16 | } |
18 | 17 | |
19 | -function db_planet_list_search($searchtext) |
|
20 | -{ |
|
18 | +function db_planet_list_search($searchtext) { |
|
21 | 19 | return doquery( |
22 | 20 | "SELECT |
23 | 21 | p.galaxy, p.system, p.planet, p.planet_type, p.name as planet_name, |
@@ -37,8 +35,7 @@ discard block |
||
37 | 35 | |
38 | 36 | |
39 | 37 | |
40 | -function db_user_list_search($searchtext) |
|
41 | -{ |
|
38 | +function db_user_list_search($searchtext) { |
|
42 | 39 | return doquery( |
43 | 40 | "SELECT |
44 | 41 | pn.player_name, u.id as uid, u.username, u.ally_id, u.id_planet, u.total_points, u.total_rank, |
@@ -56,8 +53,7 @@ discard block |
||
56 | 53 | ); |
57 | 54 | } |
58 | 55 | |
59 | -function db_buddy_list_by_user($user_id) |
|
60 | -{ |
|
56 | +function db_buddy_list_by_user($user_id) { |
|
61 | 57 | // return ($user_id = intval($user_id)) ? doquery( |
62 | 58 | return ($user_id = idval($user_id)) ? doquery( |
63 | 59 | "SELECT |
@@ -87,8 +83,7 @@ discard block |
||
87 | 83 | |
88 | 84 | |
89 | 85 | |
90 | -function db_unit_records_sum($unit_id, $user_skip_list_unit) |
|
91 | -{ |
|
86 | +function db_unit_records_sum($unit_id, $user_skip_list_unit) { |
|
92 | 87 | return doquery ( |
93 | 88 | "SELECT unit_player_id, username, sum(unit_level) as unit_level |
94 | 89 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
@@ -99,8 +94,7 @@ discard block |
||
99 | 94 | , true); |
100 | 95 | } |
101 | 96 | |
102 | -function db_unit_records_plain($unit_id, $user_skip_list_unit) |
|
103 | -{ |
|
97 | +function db_unit_records_plain($unit_id, $user_skip_list_unit) { |
|
104 | 98 | return doquery ( |
105 | 99 | "SELECT unit_player_id, username, unit_level |
106 | 100 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
@@ -184,15 +178,13 @@ discard block |
||
184 | 178 | } |
185 | 179 | |
186 | 180 | |
187 | -function db_stat_list_delete_ally_player() |
|
188 | -{ |
|
181 | +function db_stat_list_delete_ally_player() { |
|
189 | 182 | return doquery('DELETE s FROM `{{statpoints}}` AS s JOIN `{{users}}` AS u ON u.id = s.id_owner WHERE s.id_ally IS NULL AND u.user_as_ally IS NOT NULL'); |
190 | 183 | } |
191 | 184 | |
192 | 185 | |
193 | 186 | |
194 | -function db_chat_player_list_online($chat_refresh_rate, $ally_add) |
|
195 | -{ |
|
187 | +function db_chat_player_list_online($chat_refresh_rate, $ally_add) { |
|
196 | 188 | $sql_date = SN_TIME_NOW - $chat_refresh_rate * 2; |
197 | 189 | |
198 | 190 | return doquery( |
@@ -206,13 +198,11 @@ discard block |
||
206 | 198 | ORDER BY authlevel DESC, `username`"); |
207 | 199 | } |
208 | 200 | |
209 | -function db_referrals_list_by_id($user_id) |
|
210 | -{ |
|
201 | +function db_referrals_list_by_id($user_id) { |
|
211 | 202 | return doquery("SELECT r.*, u.username, u.register_time FROM {{referrals}} AS r LEFT JOIN {{users}} AS u ON u.id = r.id WHERE id_partner = {$user_id}"); |
212 | 203 | } |
213 | 204 | |
214 | -function db_message_list_admin_by_type($int_type_selected, $StartRec) |
|
215 | -{ |
|
205 | +function db_message_list_admin_by_type($int_type_selected, $StartRec) { |
|
216 | 206 | return doquery("SELECT |
217 | 207 | message_id as `ID`, |
218 | 208 | message_from as `FROM`, |
@@ -231,8 +221,7 @@ discard block |
||
231 | 221 | } |
232 | 222 | |
233 | 223 | |
234 | -function db_message_insert_all($message_type, $from, $subject, $text) |
|
235 | -{ |
|
224 | +function db_message_insert_all($message_type, $from, $subject, $text) { |
|
236 | 225 | return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
237 | 226 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
238 | 227 | } |
@@ -1,8 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) |
|
5 | -{ |
|
4 | +function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) { |
|
6 | 5 | global $config, $user, $fleet_number, $lang; |
7 | 6 | |
8 | 7 | $fleet_events = array(); |
@@ -23,12 +22,10 @@ discard block |
||
23 | 22 | if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
24 | 23 | { |
25 | 24 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
26 | - } |
|
27 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
25 | + } elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
28 | 26 | { |
29 | 27 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
30 | - } |
|
31 | - else |
|
28 | + } else |
|
32 | 29 | { |
33 | 30 | $planet_end = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet'], $planet_end_type, false, 'name'); |
34 | 31 | $fleet['fleet_end_name'] = $planet_end['name']; |
@@ -80,8 +77,7 @@ discard block |
||
80 | 77 | return $fleet_events; |
81 | 78 | } |
82 | 79 | |
83 | -function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) |
|
84 | -{ |
|
80 | +function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) { |
|
85 | 81 | global $user, $planetrow, $fleet_number; |
86 | 82 | |
87 | 83 | switch($fleet['ov_label'] = $ov_label) |
@@ -121,8 +117,7 @@ discard block |
||
121 | 117 | if($fleet['fleet_owner'] == $user['id']) |
122 | 118 | { |
123 | 119 | $user_data = $user; |
124 | - } |
|
125 | - else |
|
120 | + } else |
|
126 | 121 | { |
127 | 122 | $user_data = db_user_by_id($fleet['fleet_owner']); |
128 | 123 | } |
@@ -134,8 +129,7 @@ discard block |
||
134 | 129 | * @param array $planetrow |
135 | 130 | * @param template $template |
136 | 131 | */ |
137 | -function int_planet_pretemplate($planetrow, &$template) |
|
138 | -{ |
|
132 | +function int_planet_pretemplate($planetrow, &$template) { |
|
139 | 133 | global $lang, $user; |
140 | 134 | |
141 | 135 | $governor_id = $planetrow['PLANET_GOVERNOR_ID']; |
@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @package phpBB3 |
39 | 39 | */ |
40 | -class template_compile |
|
41 | -{ |
|
40 | +class template_compile { |
|
42 | 41 | var $template; |
43 | 42 | |
44 | 43 | // Various storage arrays |
@@ -58,8 +57,7 @@ discard block |
||
58 | 57 | * Load template source from file |
59 | 58 | * @access private |
60 | 59 | */ |
61 | - function _tpl_load_file($handle, $store_in_db = false) |
|
62 | - { |
|
60 | + function _tpl_load_file($handle, $store_in_db = false) { |
|
63 | 61 | // Try and open template for read |
64 | 62 | if (!file_exists($this->template->files[$handle])) |
65 | 63 | { |
@@ -67,8 +65,7 @@ discard block |
||
67 | 65 | { |
68 | 66 | return; |
69 | 67 | trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); |
70 | - } |
|
71 | - else |
|
68 | + } else |
|
72 | 69 | { |
73 | 70 | $this->template->files[$handle] = $this->template->files_inherit[$handle]; |
74 | 71 | } |
@@ -104,8 +101,7 @@ discard block |
||
104 | 101 | * the ones that exist in zend_language_scanner.l |
105 | 102 | * @access private |
106 | 103 | */ |
107 | - function remove_php_tags(&$code) |
|
108 | - { |
|
104 | + function remove_php_tags(&$code) { |
|
109 | 105 | // This matches the information gathered from the internal PHP lexer |
110 | 106 | $match = array( |
111 | 107 | '#<([\?%])=?.*?\1>#s', |
@@ -120,8 +116,7 @@ discard block |
||
120 | 116 | * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
121 | 117 | * @access private |
122 | 118 | */ |
123 | - function compile($code, $no_echo = false, $echo_var = '') |
|
124 | - { |
|
119 | + function compile($code, $no_echo = false, $echo_var = '') { |
|
125 | 120 | global $config; |
126 | 121 | |
127 | 122 | if ($echo_var) |
@@ -226,15 +221,13 @@ discard block |
||
226 | 221 | $var = substr($temp, 2, -1); |
227 | 222 | //$file = $this->template->_tpldata['DEFINE']['.'][$var]; |
228 | 223 | $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; |
229 | - } |
|
230 | - else |
|
224 | + } else |
|
231 | 225 | { |
232 | 226 | $var = substr($temp, 1, -1); |
233 | 227 | //$file = $this->template->_rootref[$var]; |
234 | 228 | $temp = "\$this->_rootref['$var']"; |
235 | 229 | } |
236 | - } |
|
237 | - else |
|
230 | + } else |
|
238 | 231 | { |
239 | 232 | $file = $temp; |
240 | 233 | } |
@@ -293,8 +286,7 @@ discard block |
||
293 | 286 | * Compile variables |
294 | 287 | * @access private |
295 | 288 | */ |
296 | - function compile_var_tags(&$text_blocks) |
|
297 | - { |
|
289 | + function compile_var_tags(&$text_blocks) { |
|
298 | 290 | // including $lang variable |
299 | 291 | global $lang, $config; |
300 | 292 | |
@@ -368,8 +360,7 @@ discard block |
||
368 | 360 | * Compile blocks |
369 | 361 | * @access private |
370 | 362 | */ |
371 | - function compile_tag_block($tag_args) |
|
372 | - { |
|
363 | + function compile_tag_block($tag_args) { |
|
373 | 364 | $no_nesting = false; |
374 | 365 | |
375 | 366 | // Is the designer wanting to call another loop in a loop? |
@@ -392,8 +383,7 @@ discard block |
||
392 | 383 | if ($match[2] < 0) |
393 | 384 | { |
394 | 385 | $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
395 | - } |
|
396 | - else |
|
386 | + } else |
|
397 | 387 | { |
398 | 388 | $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
399 | 389 | } |
@@ -401,17 +391,14 @@ discard block |
||
401 | 391 | if (strlen($match[3]) < 1 || $match[3] == -1) |
402 | 392 | { |
403 | 393 | $loop_end = '$_' . $tag_args . '_count'; |
404 | - } |
|
405 | - else if ($match[3] >= 0) |
|
394 | + } else if ($match[3] >= 0) |
|
406 | 395 | { |
407 | 396 | $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
408 | - } |
|
409 | - else //if ($match[3] < -1) |
|
397 | + } else //if ($match[3] < -1) |
|
410 | 398 | { |
411 | 399 | $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
412 | 400 | } |
413 | - } |
|
414 | - else |
|
401 | + } else |
|
415 | 402 | { |
416 | 403 | $loop_start = 0; |
417 | 404 | $loop_end = '$_' . $tag_args . '_count'; |
@@ -424,8 +411,7 @@ discard block |
||
424 | 411 | { |
425 | 412 | // We need to implode $no_nesting times from the end... |
426 | 413 | $block = array_slice($this->block_names, -$no_nesting); |
427 | - } |
|
428 | - else |
|
414 | + } else |
|
429 | 415 | { |
430 | 416 | $block = $this->block_names; |
431 | 417 | } |
@@ -435,8 +421,7 @@ discard block |
||
435 | 421 | // Block is not nested. |
436 | 422 | $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
437 | 423 | $varref = "\$this->_tpldata['$tag_args']"; |
438 | - } |
|
439 | - else |
|
424 | + } else |
|
440 | 425 | { |
441 | 426 | // This block is nested. |
442 | 427 | // Generate a namespace string for this block. |
@@ -475,8 +460,7 @@ discard block |
||
475 | 460 | * some adaptions for our block level methods |
476 | 461 | * @access private |
477 | 462 | */ |
478 | - function compile_tag_if($tag_args, $elseif) |
|
479 | - { |
|
463 | + function compile_tag_if($tag_args, $elseif) { |
|
480 | 464 | // Tokenize args for 'if' tag. |
481 | 465 | preg_match_all('/(?: |
482 | 466 | "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | |
@@ -584,8 +568,7 @@ discard block |
||
584 | 568 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
585 | 569 | { |
586 | 570 | $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
587 | - } |
|
588 | - else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
571 | + } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
589 | 572 | { |
590 | 573 | // Allow checking if loops are set with .loopname |
591 | 574 | // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example |
@@ -601,8 +584,7 @@ discard block |
||
601 | 584 | |
602 | 585 | // Add the block reference for the last child. |
603 | 586 | $varref .= "['" . $block . "']"; |
604 | - } |
|
605 | - else |
|
587 | + } else |
|
606 | 588 | { |
607 | 589 | $varref = '$this->_tpldata'; |
608 | 590 | |
@@ -610,8 +592,7 @@ discard block |
||
610 | 592 | $varref .= "['" . $blocks[0] . "']"; |
611 | 593 | } |
612 | 594 | $token = "sizeof($varref)"; |
613 | - } |
|
614 | - else if (!empty($token)) |
|
595 | + } else if (!empty($token)) |
|
615 | 596 | { |
616 | 597 | $token = '(' . $token . ')'; |
617 | 598 | } |
@@ -632,8 +613,7 @@ discard block |
||
632 | 613 | * Compile DEFINE tags |
633 | 614 | * @access private |
634 | 615 | */ |
635 | - function compile_tag_define($tag_args, $op) |
|
636 | - { |
|
616 | + function compile_tag_define($tag_args, $op) { |
|
637 | 617 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
638 | 618 | |
639 | 619 | if (empty($match[2]) || (!isset($match[4]) && $op)) |
@@ -656,8 +636,7 @@ discard block |
||
656 | 636 | |
657 | 637 | // Now replace the php code |
658 | 638 | $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
659 | - } |
|
660 | - else |
|
639 | + } else |
|
661 | 640 | { |
662 | 641 | preg_match('#true|false|\.#i', $match[4], $type); |
663 | 642 | |
@@ -685,8 +664,7 @@ discard block |
||
685 | 664 | * Compile INCLUDE tag |
686 | 665 | * @access private |
687 | 666 | */ |
688 | - function compile_tag_include($tag_args) |
|
689 | - { |
|
667 | + function compile_tag_include($tag_args) { |
|
690 | 668 | // Process dynamic includes |
691 | 669 | if ($tag_args[0] == '$') |
692 | 670 | { |
@@ -700,8 +678,7 @@ discard block |
||
700 | 678 | * Compile INCLUDE_PHP tag |
701 | 679 | * @access private |
702 | 680 | */ |
703 | - function compile_tag_include_php($tag_args) |
|
704 | - { |
|
681 | + function compile_tag_include_php($tag_args) { |
|
705 | 682 | return "\$this->_php_include('$tag_args');"; |
706 | 683 | } |
707 | 684 | |
@@ -710,8 +687,7 @@ discard block |
||
710 | 687 | * This is from Smarty |
711 | 688 | * @access private |
712 | 689 | */ |
713 | - function _parse_is_expr($is_arg, $tokens) |
|
714 | - { |
|
690 | + function _parse_is_expr($is_arg, $tokens) { |
|
715 | 691 | $expr_end = 0; |
716 | 692 | $negate_expr = false; |
717 | 693 | |
@@ -719,8 +695,7 @@ discard block |
||
719 | 695 | { |
720 | 696 | $negate_expr = true; |
721 | 697 | $expr_type = array_shift($tokens); |
722 | - } |
|
723 | - else |
|
698 | + } else |
|
724 | 699 | { |
725 | 700 | $expr_type = $first_token; |
726 | 701 | } |
@@ -733,8 +708,7 @@ discard block |
||
733 | 708 | $expr_end++; |
734 | 709 | $expr_arg = $tokens[$expr_end++]; |
735 | 710 | $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; |
736 | - } |
|
737 | - else |
|
711 | + } else |
|
738 | 712 | { |
739 | 713 | $expr = "!($is_arg & 1)"; |
740 | 714 | } |
@@ -746,8 +720,7 @@ discard block |
||
746 | 720 | $expr_end++; |
747 | 721 | $expr_arg = $tokens[$expr_end++]; |
748 | 722 | $expr = "(($is_arg / $expr_arg) % $expr_arg)"; |
749 | - } |
|
750 | - else |
|
723 | + } else |
|
751 | 724 | { |
752 | 725 | $expr = "($is_arg & 1)"; |
753 | 726 | } |
@@ -786,8 +759,7 @@ discard block |
||
786 | 759 | * |
787 | 760 | * @return string |
788 | 761 | */ |
789 | - private function generate_block_varref($namespace, $varname, $defop = false) |
|
790 | - { |
|
762 | + private function generate_block_varref($namespace, $varname, $defop = false) { |
|
791 | 763 | // Strip the trailing period. |
792 | 764 | $namespace = substr($namespace, 0, -1); |
793 | 765 | |
@@ -810,8 +782,7 @@ discard block |
||
810 | 782 | * NOTE: does not expect a trailing "." on the blockname. |
811 | 783 | * @access private |
812 | 784 | */ |
813 | - function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
|
814 | - { |
|
785 | + function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) { |
|
815 | 786 | // Get an array of the blocks involved. |
816 | 787 | $blocks = explode('.', $blockname); |
817 | 788 | $blockcount = sizeof($blocks) - 1; |
@@ -833,12 +804,10 @@ discard block |
||
833 | 804 | $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
834 | 805 | } |
835 | 806 | return $varref; |
836 | - } |
|
837 | - else if ($include_last_iterator) |
|
807 | + } else if ($include_last_iterator) |
|
838 | 808 | { |
839 | 809 | return '$_'. $blocks[$blockcount] . '_val'; |
840 | - } |
|
841 | - else |
|
810 | + } else |
|
842 | 811 | { |
843 | 812 | return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
844 | 813 | } |
@@ -848,8 +817,7 @@ discard block |
||
848 | 817 | * Write compiled file to cache directory |
849 | 818 | * @access private |
850 | 819 | */ |
851 | - function compile_write($handle, $data) |
|
852 | - { |
|
820 | + function compile_write($handle, $data) { |
|
853 | 821 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
854 | 822 | |
855 | 823 | $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
@@ -873,8 +841,7 @@ discard block |
||
873 | 841 | * Minifies template w/i PHP code by removing extra spaces |
874 | 842 | * @access private |
875 | 843 | */ |
876 | - function minify($html) |
|
877 | - { |
|
844 | + function minify($html) { |
|
878 | 845 | global $config; |
879 | 846 | |
880 | 847 | if(!$config->tpl_minifier) |
@@ -290,10 +290,12 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - if ($fleet_id) // Не планета |
|
293 | + if ($fleet_id) { |
|
294 | + // Не планета |
|
294 | 295 | { |
295 | 296 | if ($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED) { |
296 | 297 | $new_fleet_count = 0; |
298 | + } |
|
297 | 299 | } |
298 | 300 | |
299 | 301 | if ($new_fleet_count) { |
@@ -316,10 +318,12 @@ discard block |
||
316 | 318 | } |
317 | 319 | DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp)); |
318 | 320 | } |
319 | - if (!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть |
|
321 | + if (!empty($db_changeset)) { |
|
322 | + // Сохраняем изменения юнитов на планете - если они есть |
|
320 | 323 | { |
321 | 324 | OldDbChangeSet::db_changeset_apply($db_changeset); |
322 | 325 | } |
326 | + } |
|
323 | 327 | } |
324 | 328 | } |
325 | 329 |
@@ -236,9 +236,11 @@ |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
239 | - if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
239 | + if (!isset($planet_row['id'])) { |
|
240 | + // || $planet_row['id'] != $user['current_planet'] |
|
240 | 241 | { |
241 | 242 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
243 | + } |
|
242 | 244 | // Если текущей планеты не существует - выставляем Столицу |
243 | 245 | if (!isset($planet_row['id'])) { |
244 | 246 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
@@ -1,7 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function art_use(&$user, &$planetrow, $unit_id) |
|
4 | -{ |
|
3 | +function art_use(&$user, &$planetrow, $unit_id) { |
|
5 | 4 | global $lang; |
6 | 5 | |
7 | 6 | if(!in_array($unit_id, sn_get_groups('artifacts'))) |
@@ -46,14 +45,12 @@ discard block |
||
46 | 45 | { |
47 | 46 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moonSize); |
48 | 47 | $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moonSize)); |
49 | - } |
|
50 | - else |
|
48 | + } else |
|
51 | 49 | { |
52 | 50 | $message = $lang['art_lhc_moon_fail']; |
53 | 51 | } |
54 | 52 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_ADMIN, $lang['art_lhc_from'], $lang['art_lhc_subj'], $message); |
55 | - } |
|
56 | - else |
|
53 | + } else |
|
57 | 54 | { |
58 | 55 | $message = $lang['art_moon_exists']; |
59 | 56 | } |
@@ -81,8 +78,9 @@ discard block |
||
81 | 78 | $sectors_used = 0; |
82 | 79 | foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
83 | 80 | { |
84 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
85 | - continue; |
|
81 | + if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
82 | + continue; |
|
83 | + } |
|
86 | 84 | $sectors_used += $levels_deployed; |
87 | 85 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']); |
88 | 86 | } |
@@ -116,8 +114,7 @@ discard block |
||
116 | 114 | DBStaticQue::db_que_set_time_left_by_id($que_item['que_id'], $que_item['que_time_left']); |
117 | 115 | $message = sprintf($lang['art_heurestic_chip_ok'], $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], sys_time_human($old_time - $que_item['que_time_left'])); |
118 | 116 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_heurestic_chip_subj'], $lang['art_heurestic_chip_subj'], $message); |
119 | - } |
|
120 | - else |
|
117 | + } else |
|
121 | 118 | { |
122 | 119 | $message = $lang['art_heurestic_chip_no_research']; |
123 | 120 | } |
@@ -145,8 +142,7 @@ discard block |
||
145 | 142 | $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], $planetrow['name'], uni_render_coordinates($planetrow), sys_time_human($old_time - $que_item['que_time_left']) |
146 | 143 | ); |
147 | 144 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_nano_builder_subj'], $lang['art_nano_builder_subj'], $message); |
148 | - } |
|
149 | - else |
|
145 | + } else |
|
150 | 146 | { |
151 | 147 | $message = $lang['art_nano_builder_no_que']; |
152 | 148 | } |
@@ -158,8 +154,7 @@ discard block |
||
158 | 154 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user); |
159 | 155 | OldDbChangeSet::db_changeset_apply($db_changeset); |
160 | 156 | } |
161 | - } |
|
162 | - else |
|
157 | + } else |
|
163 | 158 | { |
164 | 159 | $message = $lang['art_err_no_artifact']; |
165 | 160 | } |