@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | global $config; |
32 | 34 |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -23,7 +23,9 @@ |
||
23 | 23 | * DO NOT CHANGE |
24 | 24 | */ |
25 | 25 | |
26 | -if (!defined('INSIDE')) die(); |
|
26 | +if (!defined('INSIDE')) { |
|
27 | + die(); |
|
28 | +} |
|
27 | 29 | |
28 | 30 | $a_lang_array = (array( |
29 | 31 | // Metamatter |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -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 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function db_counter_insert($user_id_unsafe) { |
168 | 168 | global $config, $sys_stop_log_hit, $is_watching; |
169 | 169 | |
170 | - if($sys_stop_log_hit || !$config->game_counter) { |
|
170 | + if ($sys_stop_log_hit || !$config->game_counter) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | // $this->ip_v4_int . ", '{$proxy_safe}', " . $this->page_address_id . ", " . $this->page_url_id . ");"); |
184 | 184 | doquery( |
185 | 185 | "INSERT INTO {{counter}} SET |
186 | - `visit_time` = '" . SN_TIME_SQL. "', |
|
186 | + `visit_time` = '" . SN_TIME_SQL . "', |
|
187 | 187 | `user_id` = {$user_id_safe}, |
188 | 188 | `device_id` = {$this->device_id}, |
189 | 189 | `browser_id` = {$this->browser_id}, |
190 | 190 | `user_ip` = {$this->ip_v4_int}, |
191 | 191 | `user_proxy` = '{$proxy_safe}', |
192 | 192 | `page_url_id` = {$this->page_address_id}" . |
193 | - ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ). |
|
193 | + ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '') . |
|
194 | 194 | ";"); |
195 | 195 | |
196 | 196 | $is_watching = false; |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | function db_unit_records_sum($unit_id, $user_skip_list_unit) |
105 | 105 | { |
106 | - return doquery ( |
|
106 | + return doquery( |
|
107 | 107 | "SELECT unit_player_id, username, sum(unit_level) as unit_level |
108 | 108 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
109 | 109 | WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit} |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | function db_unit_records_plain($unit_id, $user_skip_list_unit) |
117 | 117 | { |
118 | - return doquery ( |
|
118 | + return doquery( |
|
119 | 119 | "SELECT unit_player_id, username, unit_level |
120 | 120 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
121 | 121 | WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit} |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) { |
128 | - if(!$source) { |
|
128 | + if (!$source) { |
|
129 | 129 | $source = array( |
130 | 130 | 'statpoints' => 'statpoints', |
131 | 131 | 'users' => 'users', |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | ); |
147 | 147 | } |
148 | 148 | |
149 | - if($who == 1) { |
|
150 | - if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
149 | + if ($who == 1) { |
|
150 | + if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
151 | 151 | $query_str = |
152 | 152 | "SELECT |
153 | 153 | @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.* |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | ORDER BY |
162 | 162 | sp.`{$Rank}_rank`, subject.{$source['id']} |
163 | 163 | LIMIT |
164 | - ". $start .",100;"; |
|
164 | + " . $start . ",100;"; |
|
165 | 165 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
166 | 166 | $query_str = |
167 | 167 | "SELECT |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | ORDER BY |
175 | 175 | subject.{$Rank} DESC, subject.{$source['id']} |
176 | 176 | LIMIT |
177 | - ". $start .",100;"; |
|
177 | + " . $start . ",100;"; |
|
178 | 178 | } |
179 | 179 | } else { |
180 | 180 | // TODO |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | ORDER BY |
192 | 192 | sp.`{$Rank}_rank`, subject.id |
193 | 193 | LIMIT |
194 | - ". $start .",100;"; |
|
194 | + " . $start . ",100;"; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return doquery($query_str); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
278 | 278 | $current_value_safe = db_escape($current_value_unsafe); |
279 | 279 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
280 | - if(!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
280 | + if (!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
281 | 281 | doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');"); |
282 | 282 | $variable_id = db_insert_id(); |
283 | 283 | } else { |
@@ -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 | } |