@@ -477,6 +477,9 @@ |
||
477 | 477 | {$StartRec}, 25;"); |
478 | 478 | } |
479 | 479 | |
480 | + /** |
|
481 | + * @param integer $message_type |
|
482 | + */ |
|
480 | 483 | public static function db_message_insert_all($message_type, $from, $subject, $text) { |
481 | 484 | return classSupernova::$db->doInsert('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
482 | 485 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | $owners = array(); |
115 | 115 | } else { |
116 | 116 | $insert_values = array(); |
117 | - $insert_template = "('%u'," . str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
|
117 | + $insert_template = "('%u',".str_replace('%', '%%', " '{$sender}', '{$timestamp}', '{$message_type}', '{$from}', '{$subject}', '{$text}')"); |
|
118 | 118 | |
119 | 119 | foreach ($owners as $owner) { |
120 | 120 | if ($user['id'] != $owner) { |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | $sendList = array(); |
156 | 156 | $list = ''; |
157 | 157 | $query = DBStaticUser::db_user_list( |
158 | - "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
158 | + "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''), |
|
159 | 159 | false, 'id, username'); |
160 | 160 | foreach ($query as $u) { |
161 | 161 | $sendList[] = $u['id']; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix'])); |
254 | 254 | $re++; |
255 | 255 | } |
256 | - $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false; |
|
256 | + $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false; |
|
257 | 257 | |
258 | 258 | $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default']; |
259 | 259 | |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | return classSupernova::$db->doSelect( |
422 | 422 | "SELECT * FROM {{messages}} |
423 | 423 | WHERE |
424 | - `message_type` = '" . MSG_TYPE_PLAYER . "' AND |
|
424 | + `message_type` = '" . MSG_TYPE_PLAYER."' AND |
|
425 | 425 | ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}') |
426 | 426 | OR |
427 | 427 | (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;"); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | FROM |
466 | 466 | {{messages}} AS m |
467 | 467 | LEFT JOIN {{users}} AS u ON u.id = m.message_owner " . |
468 | - ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') . |
|
468 | + ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : ''). |
|
469 | 469 | "ORDER BY |
470 | 470 | `message_id` DESC |
471 | 471 | LIMIT |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | } |
474 | 474 | |
475 | 475 | public static function db_message_insert_all($message_type, $from, $subject, $text) { |
476 | - return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
|
476 | + return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '. |
|
477 | 477 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
478 | 478 | } |
479 | 479 | |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * @return array|bool|mysqli_result|null |
484 | 484 | */ |
485 | 485 | public static function db_message_count_by_type($int_type_selected) { |
486 | - $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
486 | + $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : '')); |
|
487 | 487 | |
488 | 488 | return $page_max; |
489 | 489 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | */ |
508 | 508 | public static function db_message_list_delete_by_date($delete_date, $int_type_selected) { |
509 | 509 | $where[] = "message_time <= UNIX_TIMESTAMP('{$delete_date}')"; |
510 | - if($int_type_selected >= 0) { |
|
510 | + if ($int_type_selected >= 0) { |
|
511 | 511 | $where['message_type'] = $int_type_selected; |
512 | 512 | } |
513 | 513 | classSupernova::$db->doDeleteDeprecated(TABLE_MESSAGES, $where); |
@@ -187,6 +187,9 @@ |
||
187 | 187 | return $error_backtrace; |
188 | 188 | } |
189 | 189 | |
190 | + /** |
|
191 | + * @param string $die_message |
|
192 | + */ |
|
190 | 193 | public function error_fatal($die_message, $details = 'There is a fatal error on page') { |
191 | 194 | // TODO - Записывать детали ошибки в лог-файл |
192 | 195 | die($die_message); |
@@ -32,10 +32,10 @@ discard block |
||
32 | 32 | |
33 | 33 | defined('INSIDE') || die(); |
34 | 34 | |
35 | -if(php_sapi_name() == "cli") { |
|
35 | +if (php_sapi_name() == "cli") { |
|
36 | 36 | // In cli-mode |
37 | 37 | define('__DEBUG_CRLF', "\r\n"); |
38 | - define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF); |
|
38 | + define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF); |
|
39 | 39 | } else { |
40 | 40 | // Not in cli-mode |
41 | 41 | define('__DEBUG_CRLF', '<br />'); |
@@ -52,17 +52,17 @@ discard block |
||
52 | 52 | public function log_file($message, $ident_change = 0) { |
53 | 53 | static $ident = 0; |
54 | 54 | |
55 | - if(!defined('SN_DEBUG_LOG')) { |
|
55 | + if (!defined('SN_DEBUG_LOG')) { |
|
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | - if($this->log_file_handler === null) { |
|
60 | - $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
|
59 | + if ($this->log_file_handler === null) { |
|
60 | + $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+'); |
|
61 | 61 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
62 | 62 | } |
63 | 63 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
64 | - if($this->log_file_handler) { |
|
65 | - @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
|
64 | + if ($this->log_file_handler) { |
|
65 | + @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n"); |
|
66 | 66 | } |
67 | 67 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
68 | 68 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | } |
83 | 83 | |
84 | 84 | public function echo_log() { |
85 | - 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>"; |
|
85 | + 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>"; |
|
86 | 86 | die(); |
87 | 87 | } |
88 | 88 | |
@@ -92,25 +92,25 @@ discard block |
||
92 | 92 | $result = array(); |
93 | 93 | $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId(); |
94 | 94 | $result[] = "tID {$transaction_id}"; |
95 | - foreach($backtrace as $a_trace) { |
|
96 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
95 | + foreach ($backtrace as $a_trace) { |
|
96 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
97 | 97 | continue; |
98 | 98 | } |
99 | 99 | $function = |
100 | 100 | ($a_trace['type'] |
101 | 101 | ? ($a_trace['type'] == '->' |
102 | - ? "({$a_trace['class']})" . get_class($a_trace['object']) |
|
102 | + ? "({$a_trace['class']})".get_class($a_trace['object']) |
|
103 | 103 | : $a_trace['class'] |
104 | - ) . $a_trace['type'] |
|
104 | + ).$a_trace['type'] |
|
105 | 105 | : '' |
106 | - ) . $a_trace['function'] . '()'; |
|
106 | + ).$a_trace['function'].'()'; |
|
107 | 107 | |
108 | 108 | $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file'])); |
109 | 109 | |
110 | 110 | // $result[] = "{$function} ({$a_trace['line']})'{$file}'"; |
111 | 111 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
112 | 112 | |
113 | - if(!$long_comment) { |
|
113 | + if (!$long_comment) { |
|
114 | 114 | break; |
115 | 115 | } |
116 | 116 | } |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | public function dump($dump = false, $force_base = false, $deadlock = false) { |
125 | 125 | global $user, $planetrow; |
126 | 126 | |
127 | - if($dump === false) { |
|
127 | + if ($dump === false) { |
|
128 | 128 | return; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $error_backtrace = array(); |
132 | 132 | $base_dump = false; |
133 | 133 | |
134 | - if($force_base === true) { |
|
134 | + if ($force_base === true) { |
|
135 | 135 | $base_dump = true; |
136 | 136 | } |
137 | 137 | |
138 | - if($dump === true) { |
|
138 | + if ($dump === true) { |
|
139 | 139 | $base_dump = true; |
140 | 140 | } else { |
141 | - if(!is_array($dump)) { |
|
141 | + if (!is_array($dump)) { |
|
142 | 142 | $dump = array('var' => $dump); |
143 | 143 | } |
144 | 144 | |
145 | - foreach($dump as $dump_var_name => $dump_var) { |
|
146 | - if($dump_var_name == 'base_dump') { |
|
145 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
146 | + if ($dump_var_name == 'base_dump') { |
|
147 | 147 | $base_dump = $dump_var; |
148 | 148 | } else { |
149 | 149 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -151,22 +151,21 @@ discard block |
||
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
154 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
155 | 155 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
156 | 156 | $error_backtrace['locks'] = SnCache::getLocks(); |
157 | 157 | $error_backtrace['cSN_data'] = SnCache::getData(); |
158 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
159 | - foreach($location as $location_id => &$location_data) { |
|
160 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
161 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
158 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
159 | + foreach ($location as $location_id => &$location_data) { |
|
160 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
162 | 161 | } |
163 | 162 | } |
164 | 163 | $error_backtrace['cSN_queries'] = SnCache::getQueries(); |
165 | 164 | } |
166 | 165 | |
167 | - if($base_dump) { |
|
168 | - if(is_array($this->log_array) && count($this->log_array) > 0) { |
|
169 | - foreach($this->log_array as $log) { |
|
166 | + if ($base_dump) { |
|
167 | + if (is_array($this->log_array) && count($this->log_array) > 0) { |
|
168 | + foreach ($this->log_array as $log) { |
|
170 | 169 | $error_backtrace['queries'][] = $log; |
171 | 170 | } |
172 | 171 | } |
@@ -195,14 +194,14 @@ discard block |
||
195 | 194 | public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
196 | 195 | global $sys_stop_log_hit, $sys_log_disabled, $user; |
197 | 196 | |
198 | - if(empty(classSupernova::$db->connected)) { |
|
197 | + if (empty(classSupernova::$db->connected)) { |
|
199 | 198 | // TODO - писать ошибку в файл |
200 | 199 | die('SQL server currently unavailable. Please contact Administration...'); |
201 | 200 | } |
202 | 201 | |
203 | 202 | sn_db_transaction_rollback(); |
204 | 203 | |
205 | - if(classSupernova::$config->debug == 1) { |
|
204 | + if (classSupernova::$config->debug == 1) { |
|
206 | 205 | echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>"; |
207 | 206 | echo "<table>{$this->log}</table>"; |
208 | 207 | } |
@@ -214,16 +213,16 @@ discard block |
||
214 | 213 | |
215 | 214 | $userId = empty($user['id']) ? 0 : $user['id']; |
216 | 215 | |
217 | - if(!$sys_log_disabled) { |
|
216 | + if (!$sys_log_disabled) { |
|
218 | 217 | $query = "INSERT INTO `{{logs}}` SET |
219 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
220 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
221 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
218 | + `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."', |
|
219 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
220 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
222 | 221 | // ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";"; |
223 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
224 | - classSupernova::$db->doExecute($query, true) or die($fatal_error . classSupernova::$db->db_error()); |
|
222 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
223 | + classSupernova::$db->doExecute($query, true) or die($fatal_error.classSupernova::$db->db_error()); |
|
225 | 224 | |
226 | - $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>"; |
|
225 | + $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>"; |
|
227 | 226 | |
228 | 227 | $sys_stop_log_hit = true; |
229 | 228 | $sys_log_disabled = true; |
@@ -233,7 +232,7 @@ discard block |
||
233 | 232 | ob_start(); |
234 | 233 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
235 | 234 | |
236 | - foreach($error_backtrace as $name => $value) { |
|
235 | + foreach ($error_backtrace as $name => $value) { |
|
237 | 236 | print(__DEBUG_LINE); |
238 | 237 | pdump($value, $name); |
239 | 238 | } |
@@ -245,7 +244,7 @@ discard block |
||
245 | 244 | public function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
246 | 245 | global $user, $sys_log_disabled; |
247 | 246 | |
248 | - if(empty(classSupernova::$db->connected)) { |
|
247 | + if (empty(classSupernova::$db->connected)) { |
|
249 | 248 | // TODO - писать ошибку в файл |
250 | 249 | die('SQL server currently unavailable. Please contact Administration...'); |
251 | 250 | } |
@@ -254,12 +253,12 @@ discard block |
||
254 | 253 | |
255 | 254 | $userId = empty($user['id']) ? 0 : $user['id']; |
256 | 255 | |
257 | - if(!$sys_log_disabled) { |
|
256 | + if (!$sys_log_disabled) { |
|
258 | 257 | $query = "INSERT INTO `{{logs}}` SET |
259 | - `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "', |
|
260 | - `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
|
261 | - `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" . |
|
262 | - ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";"; |
|
258 | + `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."', |
|
259 | + `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."', `log_text` = '".db_escape($message)."', |
|
260 | + `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'". |
|
261 | + ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";"; |
|
263 | 262 | classSupernova::$db->doExecute($query, true); |
264 | 263 | } else { |
265 | 264 | // // TODO Здесь надо писать в файло |
@@ -272,11 +271,11 @@ discard block |
||
272 | 271 | // Dump variables nicer then var_dump() |
273 | 272 | |
274 | 273 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
275 | - if(isset($varname)) { |
|
274 | + if (isset($varname)) { |
|
276 | 275 | $varname .= " = "; |
277 | 276 | } |
278 | 277 | |
279 | - if($level == -1) { |
|
278 | + if ($level == -1) { |
|
280 | 279 | $trans[' '] = '∴'; |
281 | 280 | $trans["\t"] = '⇒'; |
282 | 281 | $trans["\n"] = '¶;'; |
@@ -285,31 +284,31 @@ discard block |
||
285 | 284 | |
286 | 285 | return strtr(htmlspecialchars($value), $trans); |
287 | 286 | } |
288 | - if($level == 0) { |
|
287 | + if ($level == 0) { |
|
289 | 288 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
290 | - $dumper = mt_rand(10, 99) . '|' . $varname; |
|
289 | + $dumper = mt_rand(10, 99).'|'.$varname; |
|
291 | 290 | } |
292 | 291 | |
293 | 292 | $type = gettype($value); |
294 | 293 | $dumper .= $type; |
295 | 294 | |
296 | - if($type == TYPE_STRING) { |
|
297 | - $dumper .= '(' . strlen($value) . ')'; |
|
295 | + if ($type == TYPE_STRING) { |
|
296 | + $dumper .= '('.strlen($value).')'; |
|
298 | 297 | $value = dump($value, '', -1); |
299 | - } elseif($type == TYPE_BOOLEAN) { |
|
298 | + } elseif ($type == TYPE_BOOLEAN) { |
|
300 | 299 | $value = ($value ? 'true' : 'false'); |
301 | - } elseif($type == 'object') { |
|
300 | + } elseif ($type == 'object') { |
|
302 | 301 | $props = get_class_vars(get_class($value)); |
303 | - $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
|
304 | - foreach($props as $key => $val) { |
|
305 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
|
302 | + $dumper .= '('.count($props).') <u>'.get_class($value).'</u>'; |
|
303 | + foreach ($props as $key => $val) { |
|
304 | + $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => '; |
|
306 | 305 | $dumper .= dump($value->$key, '', $level + 1); |
307 | 306 | } |
308 | 307 | $value = ''; |
309 | - } elseif($type == TYPE_ARRAY) { |
|
310 | - $dumper .= '(' . count($value) . ')'; |
|
311 | - foreach($value as $key => $val) { |
|
312 | - $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
|
308 | + } elseif ($type == TYPE_ARRAY) { |
|
309 | + $dumper .= '('.count($value).')'; |
|
310 | + foreach ($value as $key => $val) { |
|
311 | + $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => '; |
|
313 | 312 | $dumper .= dump($val, '', $level + 1); |
314 | 313 | } |
315 | 314 | $value = ''; |
@@ -328,24 +327,24 @@ discard block |
||
328 | 327 | // $backtrace = $backtrace[1]; |
329 | 328 | |
330 | 329 | $caller = ''; |
331 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
332 | - $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
|
333 | - (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
|
334 | - $backtrace[1]['function'] . |
|
330 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
331 | + $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : ''). |
|
332 | + (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : ''). |
|
333 | + $backtrace[1]['function']. |
|
335 | 334 | (!empty($backtrace[0]['file']) |
336 | 335 | ? ( |
337 | - ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) . |
|
338 | - (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') . |
|
336 | + ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN). |
|
337 | + (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : ''). |
|
339 | 338 | ')' |
340 | 339 | ) |
341 | 340 | : '' |
342 | 341 | ); |
343 | - $caller = "\r\n" . $caller; |
|
342 | + $caller = "\r\n".$caller; |
|
344 | 343 | } |
345 | 344 | |
346 | - 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;">' . |
|
347 | - dump($value, $varname) . |
|
348 | - $caller . |
|
345 | + 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;">'. |
|
346 | + dump($value, $varname). |
|
347 | + $caller. |
|
349 | 348 | '</pre>' |
350 | 349 | ); |
351 | 350 | } |
@@ -355,24 +354,24 @@ discard block |
||
355 | 354 | } |
356 | 355 | |
357 | 356 | function pr($prePrint = false) { |
358 | - if($prePrint) { |
|
357 | + if ($prePrint) { |
|
359 | 358 | print(__DEBUG_CRLF); |
360 | 359 | } |
361 | - print(mt_rand() . __DEBUG_CRLF); |
|
360 | + print(mt_rand().__DEBUG_CRLF); |
|
362 | 361 | } |
363 | 362 | |
364 | 363 | function pc($prePrint = false) { |
365 | 364 | global $_PRINT_COUNT_VALUE; |
366 | 365 | $_PRINT_COUNT_VALUE++; |
367 | 366 | |
368 | - if($prePrint) { |
|
367 | + if ($prePrint) { |
|
369 | 368 | print(__DEBUG_CRLF); |
370 | 369 | } |
371 | - print($_PRINT_COUNT_VALUE . __DEBUG_CRLF); |
|
370 | + print($_PRINT_COUNT_VALUE.__DEBUG_CRLF); |
|
372 | 371 | } |
373 | 372 | |
374 | 373 | function prep($message) { |
375 | - print('<pre>' . $message . '</pre>'); |
|
374 | + print('<pre>'.$message.'</pre>'); |
|
376 | 375 | } |
377 | 376 | |
378 | 377 | function backtrace_no_arg() { |
@@ -396,9 +395,9 @@ discard block |
||
396 | 395 | */ |
397 | 396 | function pdie($message = '', $level = 0) { |
398 | 397 | $backtrace = debug_backtrace(); |
399 | - for($i = 0; $i < $level; $i++) { |
|
398 | + for ($i = 0; $i < $level; $i++) { |
|
400 | 399 | array_pop($backtrace); |
401 | 400 | } |
402 | 401 | |
403 | - die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']); |
|
402 | + die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']); |
|
404 | 403 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | * @return array|bool|mysqli_result|null |
24 | 24 | */ |
25 | 25 | public static function db_missile_list_by_arrival() { |
26 | - $iraks = classSupernova::$db->doSelect("SELECT * FROM `{{iraks}}` WHERE `fleet_end_time` <= " . SN_TIME_NOW . " FOR UPDATE;"); |
|
26 | + $iraks = classSupernova::$db->doSelect("SELECT * FROM `{{iraks}}` WHERE `fleet_end_time` <= ".SN_TIME_NOW." FOR UPDATE;"); |
|
27 | 27 | |
28 | 28 | return $iraks; |
29 | 29 | } |
@@ -2,6 +2,10 @@ |
||
2 | 2 | |
3 | 3 | class DBStaticFleetMissile { |
4 | 4 | |
5 | + /** |
|
6 | + * @param double $arrival |
|
7 | + * @param integer $target_structure |
|
8 | + */ |
|
5 | 9 | public static function db_missile_insert($target_coord, $user, $planetrow, $arrival, $fleet_ship_count, $target_structure) { |
6 | 10 | classSupernova::$db->doInsert( |
7 | 11 | "INSERT INTO `{{iraks}}` SET |
@@ -104,6 +104,9 @@ discard block |
||
104 | 104 | return $result; |
105 | 105 | } |
106 | 106 | |
107 | + /** |
|
108 | + * @param integer $config_user_birthday_range |
|
109 | + */ |
|
107 | 110 | public static function db_user_list_to_celebrate($config_user_birthday_range) { |
108 | 111 | $query = static::buildDBQ() |
109 | 112 | ->field('id', 'username', 'user_birthday', 'user_birthday_celebrated') |
@@ -178,6 +181,9 @@ discard block |
||
178 | 181 | } |
179 | 182 | |
180 | 183 | |
184 | + /** |
|
185 | + * @param string $username_unsafe |
|
186 | + */ |
|
181 | 187 | public static function db_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) { |
182 | 188 | // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ? |
183 | 189 | if (!($username_unsafe = trim($username_unsafe))) { |
@@ -232,8 +238,8 @@ discard block |
||
232 | 238 | * <p>array - запись пользователя с установленным полем ['id']</p> |
233 | 239 | * @param bool $for_update @deprecated |
234 | 240 | * @param string $fields @deprecated список полей или '*'/'' для всех полей |
235 | - * @param null $player |
|
236 | - * @param bool|null $player Признак выбора записи пользователь типа "игрок" |
|
241 | + * @param boolean $player |
|
242 | + * @param boolean $player Признак выбора записи пользователь типа "игрок" |
|
237 | 243 | * <p>null - Можно выбрать запись любого типа</p> |
238 | 244 | * <p>true - Выбирается только запись типа "игрок"</p> |
239 | 245 | * <p>false - Выбирается только запись типа "альянс"</p> |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | ->where('`user_as_ally` IS NULL') |
24 | 24 | ->orderBy(array('`id` DESC')); |
25 | 25 | |
26 | - return (string)$query->selectValue(); |
|
26 | + return (string) $query->selectValue(); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -48,15 +48,15 @@ discard block |
||
48 | 48 | static::buildDBQ() |
49 | 49 | ->field('id') |
50 | 50 | ->where("`user_as_ally` IS NULL") |
51 | - ->where("`user_bot` = " . USER_BOT_PLAYER) |
|
51 | + ->where("`user_bot` = ".USER_BOT_PLAYER) |
|
52 | 52 | ->setForUpdate(); |
53 | 53 | |
54 | 54 | return $query->selectIterator(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | public static function db_user_lock_with_target_owner_and_acs($user, $planet = array()) { |
58 | - $query = "SELECT 1 FROM `{{users}}` WHERE `id` = " . idval($user['id']) . |
|
59 | - (!empty($planet['id_owner']) ? ' OR `id` = ' . idval($planet['id_owner']) : '') |
|
58 | + $query = "SELECT 1 FROM `{{users}}` WHERE `id` = ".idval($user['id']). |
|
59 | + (!empty($planet['id_owner']) ? ' OR `id` = '.idval($planet['id_owner']) : '') |
|
60 | 60 | . " FOR UPDATE"; |
61 | 61 | |
62 | 62 | static::getDb()->doSelect($query); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | FROM `{{users}}` |
74 | 74 | WHERE |
75 | 75 | `user_as_ally` IS NULL" . |
76 | - ($online ? ' AND `onlinetime` > ' . (SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
76 | + ($online ? ' AND `onlinetime` > '.(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : '') |
|
77 | 77 | )); |
78 | 78 | } |
79 | 79 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ->fieldCount('r.id', 'referral_count') |
96 | 96 | ->fieldSingleFunction('sum', 'r.dark_matter', 'referral_dm') |
97 | 97 | ->join('LEFT JOIN {{referrals}} as r on r.id_partner = u.id') |
98 | - ->where($online ? "`onlinetime` >= " . intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
98 | + ->where($online ? "`onlinetime` >= ".intval(SN_TIME_NOW - classSupernova::$config->game_users_online_timeout) : 'user_as_ally IS NULL') |
|
99 | 99 | ->groupBy('u.id') |
100 | 100 | ->orderBy("user_as_ally, {$sort} ASC"); |
101 | 101 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | ->where('(`user_birthday_celebrated` IS NULL OR DATE_ADD(`user_birthday_celebrated`, INTERVAL 1 YEAR) < CURRENT_DATE)') |
114 | 114 | ->where('`user_as_ally` IS NULL') |
115 | 115 | ->having('`days_after_birthday` >= 0') |
116 | - ->having('`days_after_birthday` < ' . intval($config_user_birthday_range)) |
|
116 | + ->having('`days_after_birthday` < '.intval($config_user_birthday_range)) |
|
117 | 117 | ->setForUpdate(); |
118 | 118 | |
119 | 119 | $result = $query->selectIterator(); |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
208 | 208 | |
209 | 209 | $user = classSupernova::$db->doSelectFetch( |
210 | - "SELECT * FROM {{users}} WHERE `username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'" |
|
210 | + "SELECT * FROM {{users}} WHERE `username` ".($like ? 'LIKE' : '=')." '{$username_safe}'" |
|
211 | 211 | . " FOR UPDATE" |
212 | 212 | ); |
213 | 213 | SnCache::cache_set(LOC_USER, $user); // В кэш-юзер так же заполнять индексы |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | |
259 | 259 | public static function db_user_list_set_mass_mail(&$owners_list, $set) { |
260 | - return classSupernova::$gc->cacheOperator->db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : ''); |
|
260 | + return classSupernova::$gc->cacheOperator->db_upd_record_list(LOC_USER, $set, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : ''); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @param array $playerArray |
273 | 273 | */ |
274 | 274 | public static function renderNameAndCoordinates($playerArray) { |
275 | - return "{$playerArray['username']} " . uni_render_coordinates($playerArray); |
|
275 | + return "{$playerArray['username']} ".uni_render_coordinates($playerArray); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $fieldName = pname_resource_name($resourceId); |
304 | 304 | $value = "{$fieldName} = {$fieldName} + ('{$value}')"; |
305 | 305 | } |
306 | - if($query = implode(',', $playerRowFieldChanges)) { |
|
306 | + if ($query = implode(',', $playerRowFieldChanges)) { |
|
307 | 307 | classSupernova::$gc->db->doUpdate("UPDATE `{{users}}` SET {$query} WHERE id = {$userId}"); |
308 | 308 | } |
309 | 309 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $template->assign_vars($quest_templatized); |
180 | 180 | if (!empty($quest_templatized['quest_rewards_list'])) { |
181 | 181 | foreach ($quest_templatized['quest_rewards_list'] as $quest_reward) { |
182 | - $template->assign_block_vars(($block_name ? $block_name . '.' : '') . 'quest_rewards_list', $quest_reward); |
|
182 | + $template->assign_block_vars(($block_name ? $block_name.'.' : '').'quest_rewards_list', $quest_reward); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |
@@ -248,10 +248,10 @@ discard block |
||
248 | 248 | |
249 | 249 | $comment_reward = array(); |
250 | 250 | foreach ($reward_list as $unit_id => $unit_amount) { |
251 | - $comment_reward[] = $unit_amount . ' ' . classLocale::$lang['tech'][$unit_id]; |
|
251 | + $comment_reward[] = $unit_amount.' '.classLocale::$lang['tech'][$unit_id]; |
|
252 | 252 | $total_rewards[$user_id][$planet_id][$unit_id] += $unit_amount; |
253 | 253 | } |
254 | - $comment .= " {$classLocale['qst_msg_your_reward']} " . implode(',', $comment_reward); |
|
254 | + $comment .= " {$classLocale['qst_msg_your_reward']} ".implode(',', $comment_reward); |
|
255 | 255 | |
256 | 256 | DBStaticMessages::msg_send_simple_message($user['id'], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, classLocale::$lang['msg_from_admin'], classLocale::$lang['qst_msg_complete_subject'], $comment); |
257 | 257 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | |
290 | 290 | if (!empty($resourcesChange)) { |
291 | 291 | $planet_id = $planet_id == 0 && isset($user_row['id_planet']) ? $user_row['id_planet'] : $planet_id; |
292 | - if($planet_id) { |
|
292 | + if ($planet_id) { |
|
293 | 293 | // update planet |
294 | 294 | DBStaticPlanet::db_planet_update_resources($resourcesChange, $planet_id); |
295 | 295 | } else { |
@@ -38,7 +38,7 @@ |
||
38 | 38 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
39 | 39 | $query[] = "`que_planet_id` IS NULL"; |
40 | 40 | } elseif ($planet_id) { |
41 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
41 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
42 | 42 | } |
43 | 43 | if ($que_type) { |
44 | 44 | $query[] = "`que_type` = {$que_type}"; |
@@ -314,6 +314,9 @@ discard block |
||
314 | 314 | return $result; |
315 | 315 | } |
316 | 316 | |
317 | + /** |
|
318 | + * @param integer $location_type |
|
319 | + */ |
|
317 | 320 | public static function db_ins_field_set($location_type, $field_set, $serialize = false) { |
318 | 321 | // TODO multiinsert |
319 | 322 | !sn_db_field_set_is_safe($field_set) ? $field_set = sn_db_field_set_make_safe($field_set, $serialize) : false; |
@@ -350,7 +353,7 @@ discard block |
||
350 | 353 | /** |
351 | 354 | * Блокирует указанные таблицу/список таблиц |
352 | 355 | * |
353 | - * @param string|array $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
356 | + * @param string $tables Таблица/список таблиц для блокировки. Названия таблиц - без префиксов |
|
354 | 357 | * <p>string - название таблицы для блокировки</p> |
355 | 358 | * <p>array - массив, где ключ - имя таблицы, а значение - условия блокировки элементов</p> |
356 | 359 | */ |
@@ -298,9 +298,11 @@ |
||
298 | 298 | $set = trim($set); |
299 | 299 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
300 | 300 | if ($result = $this->db->doInsert("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
301 | - if ($this->db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
301 | + if ($this->db->db_affected_rows()) { |
|
302 | + // Обновляем данные только если ряд был затронут |
|
302 | 303 | { |
303 | 304 | $record_id = $this->db->db_insert_id(); |
305 | + } |
|
304 | 306 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
305 | 307 | $result = $this->db_get_record_by_id($location_type, $record_id); |
306 | 308 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -198,10 +198,10 @@ discard block |
||
198 | 198 | $query = $this->db->doSelect( |
199 | 199 | "SELECT |
200 | 200 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
201 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
202 | - ($filter ? ' WHERE ' . $filter : '') . |
|
201 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
202 | + ($filter ? ' WHERE '.$filter : ''). |
|
203 | 203 | ($fetch ? ' LIMIT 1' : '')); |
204 | - while($row = db_fetch($query)) { |
|
204 | + while ($row = db_fetch($query)) { |
|
205 | 205 | // Исключаем из списка родительских ИД уже заблокированные записи |
206 | 206 | if (!$this->snCache->cache_lock_get($owner_location_type, $row['parent_id'])) { |
207 | 207 | $parent_id_list[$row['parent_id']] = $row['parent_id']; |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | if ($indexes_str = implode(',', $parent_id_list)) { |
213 | 213 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
214 | 214 | classSupernova::$gc->cacheOperator->db_get_record_list($owner_location_type, |
215 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
215 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
219 | 219 | |
220 | 220 | $query = $this->db->doSelect( |
221 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
221 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
222 | 222 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
223 | 223 | . " FOR UPDATE" |
224 | 224 | ); |
225 | - while($row = db_fetch($query)) { |
|
225 | + while ($row = db_fetch($query)) { |
|
226 | 226 | // Caching record in row cache |
227 | 227 | $this->snCache->cache_set($location_type, $row); |
228 | 228 | // Making ref to cached record in query cache |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | $condition = trim($condition); |
293 | 293 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
294 | 294 | |
295 | - if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
295 | + if ($result = $this->db->doUpdate("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
296 | 296 | |
297 | 297 | if ($this->db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
298 | 298 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | public function db_lock_tables($tables) { |
364 | 364 | $tables = is_array($tables) ? $tables : array($tables => ''); |
365 | 365 | foreach ($tables as $table_name => $condition) { |
366 | - $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
366 | + $this->db->doSelect("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | } |
@@ -2,28 +2,28 @@ discard block |
||
2 | 2 | |
3 | 3 | $classLocale = classLocale::$lang; |
4 | 4 | |
5 | -if(SN_IN_FLEET !== true) { |
|
5 | +if (SN_IN_FLEET !== true) { |
|
6 | 6 | classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403); |
7 | 7 | } |
8 | 8 | |
9 | 9 | $fleetid = sys_get_param_id('fleetid'); |
10 | 10 | |
11 | -if(!is_numeric($fleetid) || empty($fleetid)) { |
|
11 | +if (!is_numeric($fleetid) || empty($fleetid)) { |
|
12 | 12 | header("Location: fleet.php"); |
13 | 13 | exit(); |
14 | 14 | } |
15 | 15 | |
16 | 16 | $objFleet = new Fleet(); |
17 | 17 | $objFleet->dbLoad($fleetid); |
18 | -if(!$objFleet->dbId) { |
|
18 | +if (!$objFleet->dbId) { |
|
19 | 19 | message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']); |
20 | 20 | } |
21 | 21 | |
22 | -if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
22 | +if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) { |
|
23 | 23 | message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']); |
24 | 24 | } |
25 | 25 | |
26 | -if($objFleet->playerOwnerId != $user['id']) { |
|
26 | +if ($objFleet->playerOwnerId != $user['id']) { |
|
27 | 27 | classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301); |
28 | 28 | message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']); |
29 | 29 | } |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | |
35 | 35 | !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false; |
36 | 36 | |
37 | -if($userToAdd_unsafe) { |
|
37 | +if ($userToAdd_unsafe) { |
|
38 | 38 | $userToAdd = db_escape($userToAdd_unsafe); |
39 | 39 | $userToAddID = DBStaticUser::db_user_by_username($userToAdd_unsafe, false, 'id', true, true); |
40 | 40 | $userToAddID = $userToAddID['id']; |
41 | 41 | |
42 | - if($objFleet->target_owner_id == $userToAddID) { |
|
42 | + if ($objFleet->target_owner_id == $userToAddID) { |
|
43 | 43 | message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']); |
44 | 44 | } |
45 | 45 | |
46 | - if($userToAddID) { |
|
47 | - if(!$aks) { |
|
46 | + if ($userToAddID) { |
|
47 | + if (!$aks) { |
|
48 | 48 | // No AСS exists - making one |
49 | - if(!$objFleet->group_id) { |
|
49 | + if (!$objFleet->group_id) { |
|
50 | 50 | DBStaticFleetACS::db_acs_insert($fleetid, $user, $objFleet); |
51 | 51 | |
52 | 52 | $aks = DBStaticFleetACS::db_acs_get_by_fleet($fleetid); |
@@ -61,22 +61,22 @@ discard block |
||
61 | 61 | |
62 | 62 | $isUserExists = false; |
63 | 63 | $invited_ar = explode(",", $aks['eingeladen']); |
64 | - foreach($invited_ar as $inv) { |
|
65 | - if($userToAddID == $inv) { |
|
64 | + foreach ($invited_ar as $inv) { |
|
65 | + if ($userToAddID == $inv) { |
|
66 | 66 | $isUserExists = true; |
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - if(count($invited_ar) >= 5) { |
|
70 | + if (count($invited_ar) >= 5) { |
|
71 | 71 | message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']); |
72 | 72 | } |
73 | 73 | |
74 | - if($isUserExists) { |
|
74 | + if ($isUserExists) { |
|
75 | 75 | $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false; |
76 | 76 | } else { |
77 | 77 | $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd); |
78 | 78 | !(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid)) ? die(sprintf(classLocale::$lang['fl_aks_adding_error'], classSupernova::$db->db_error())) : false; |
79 | - $aks['eingeladen'] .= ',' . $userToAddID; |
|
79 | + $aks['eingeladen'] .= ','.$userToAddID; |
|
80 | 80 | } |
81 | 81 | DBStaticMessages::msg_send_simple_message($userToAddID, $user['id'], SN_TIME_NOW, MSG_TYPE_COMBAT, $user['username'], |
82 | 82 | classLocale::$lang['fl_aks_invite_message_header'], sprintf(classLocale::$lang['fl_aks_invite_message'], $user['username'])); |
@@ -93,8 +93,8 @@ discard block |
||
93 | 93 | 'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS], |
94 | 94 | )); |
95 | 95 | |
96 | -if($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | - foreach($members as $row) { |
|
96 | +if ($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) { |
|
97 | + foreach ($members as $row) { |
|
98 | 98 | $template->assign_block_vars('invited', array( |
99 | 99 | 'NAME' => $row['username'], |
100 | 100 | )); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $fleet_data = tplParseFleetObject($objFleet, $i, $user); |
120 | 120 | |
121 | 121 | $template->assign_block_vars('fleets', $fleet_data['fleet']); |
122 | -foreach($fleet_data['ships'] as $ship_data) { |
|
122 | +foreach ($fleet_data['ships'] as $ship_data) { |
|
123 | 123 | $template->assign_block_vars('fleets.ships', $ship_data); |
124 | 124 | } |
125 | 125 |
@@ -26,8 +26,8 @@ |
||
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @param template $template |
29 | - * @param $query_where |
|
30 | - * @param $query_limit |
|
29 | + * @param string $query_where |
|
30 | + * @param integer $query_limit |
|
31 | 31 | * |
32 | 32 | * @return array|bool|mysqli_result|null |
33 | 33 | */ |
@@ -43,7 +43,7 @@ |
||
43 | 43 | LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce |
44 | 44 | LEFT JOIN {{users}} AS u ON u.id = a.user_id |
45 | 45 | {$query_where} |
46 | - ORDER BY `tsTimeStamp` DESC, idAnnounce" . |
|
46 | + ORDER BY `tsTimeStamp` DESC, idAnnounce". |
|
47 | 47 | ($query_limit ? " LIMIT {$query_limit}" : '')); |
48 | 48 | |
49 | 49 | $template->assign_var('NEWS_COUNT', classSupernova::$db->db_num_rows($announce_list)); |