@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * @param string $query |
126 | 126 | * |
127 | - * @return mixed|string |
|
127 | + * @return string |
|
128 | 128 | */ |
129 | 129 | public function replaceTablePlaceholders($query) { |
130 | 130 | $sql = $query; |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | - * @param $query |
|
142 | - * @param $fetch |
|
141 | + * @param string $query |
|
142 | + * @param boolean $fetch |
|
143 | 143 | */ |
144 | 144 | protected function logQuery($query, $fetch) { |
145 | 145 | if (!classSupernova::$config->debug) { |
@@ -257,6 +257,10 @@ discard block |
||
257 | 257 | |
258 | 258 | |
259 | 259 | // TODO Заменить это на новый логгер |
260 | + |
|
261 | + /** |
|
262 | + * @param string $query |
|
263 | + */ |
|
260 | 264 | protected function security_watch_user_queries($query) { |
261 | 265 | global $user; |
262 | 266 | |
@@ -280,6 +284,9 @@ discard block |
||
280 | 284 | } |
281 | 285 | |
282 | 286 | |
287 | + /** |
|
288 | + * @param string $query |
|
289 | + */ |
|
283 | 290 | public function security_query_check_bad_words($query, $skip_query_check = false) { |
284 | 291 | if ($skip_query_check) { |
285 | 292 | return; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | public function load_db_settings() { |
66 | 66 | $dbsettings = array(); |
67 | 67 | |
68 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
68 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
69 | 69 | |
70 | 70 | $this->dbsettings = $dbsettings; |
71 | 71 | } |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $sql = $query; |
131 | 131 | if (strpos($sql, '{{') !== false) { |
132 | 132 | foreach ($this->table_list as $tableName) { |
133 | - $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql); |
|
133 | + $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $arr = debug_backtrace(); |
151 | 151 | $file = end(explode('/', $arr[0]['file'])); |
152 | 152 | $line = $arr[0]['line']; |
153 | - classSupernova::$debug->add("<tr><th>Query {$this->queryCount}: </th><th>$query</th><th>{$file} @ {$line}</th><th> </th><th> " . ($fetch ? '+' : ' ') . " </th></tr>"); |
|
153 | + classSupernova::$debug->add("<tr><th>Query {$this->queryCount}: </th><th>$query</th><th>{$file} @ {$line}</th><th> </th><th> ".($fetch ? '+' : ' ')." </th></tr>"); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | ->execute() |
220 | 220 | ->getResult(); |
221 | 221 | } else { |
222 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
222 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
223 | 223 | } |
224 | 224 | if (!$queryResult) { |
225 | 225 | throw new Exception(); |
226 | 226 | } |
227 | 227 | } catch (Exception $e) { |
228 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
228 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | if ($fetch) { |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | ->execute() |
273 | 273 | ->getIterator(); |
274 | 274 | } else { |
275 | - $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace)); |
|
275 | + $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace)); |
|
276 | 276 | |
277 | 277 | if (!$queryResult) { |
278 | 278 | throw new Exception(); |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | } |
286 | 286 | } |
287 | 287 | } catch (Exception $e) { |
288 | - classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error'); |
|
288 | + classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error'); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | return $result; |
@@ -354,10 +354,10 @@ discard block |
||
354 | 354 | $this->isWatching = true; |
355 | 355 | $msg = "\$query = \"{$query}\"\n\r"; |
356 | 356 | if (!empty($_POST)) { |
357 | - $msg .= "\n\r" . dump($_POST, '$_POST'); |
|
357 | + $msg .= "\n\r".dump($_POST, '$_POST'); |
|
358 | 358 | } |
359 | 359 | if (!empty($_GET)) { |
360 | - $msg .= "\n\r" . dump($_GET, '$_GET'); |
|
360 | + $msg .= "\n\r".dump($_GET, '$_GET'); |
|
361 | 361 | } |
362 | 362 | classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true)); |
363 | 363 | $this->isWatching = false; |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | |
373 | 373 | global $user, $dm_change_legit, $mm_change_legit; |
374 | 374 | |
375 | - switch(true) { |
|
375 | + switch (true) { |
|
376 | 376 | case stripos($query, 'RUNCATE TABL') != false: |
377 | 377 | case stripos($query, 'ROP TABL') != false: |
378 | 378 | case stripos($query, 'ENAME TABL') != false: |
@@ -383,37 +383,37 @@ discard block |
||
383 | 383 | case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit: |
384 | 384 | case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit: |
385 | 385 | case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0: |
386 | - $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n"; |
|
386 | + $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n"; |
|
387 | 387 | $report .= ">Database Inforamation\n"; |
388 | - $report .= "\tID - " . $user['id'] . "\n"; |
|
389 | - $report .= "\tUser - " . $user['username'] . "\n"; |
|
390 | - $report .= "\tAuth level - " . $user['authlevel'] . "\n"; |
|
391 | - $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n"; |
|
392 | - $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n"; |
|
393 | - $report .= "\tUser IP - " . $user['user_lastip'] . "\n"; |
|
394 | - $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n"; |
|
395 | - $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
396 | - $report .= "\tCurrent Page - " . $user['current_page'] . "\n"; |
|
397 | - $report .= "\tRegister Time - " . $user['register_time'] . "\n"; |
|
388 | + $report .= "\tID - ".$user['id']."\n"; |
|
389 | + $report .= "\tUser - ".$user['username']."\n"; |
|
390 | + $report .= "\tAuth level - ".$user['authlevel']."\n"; |
|
391 | + $report .= "\tAdmin Notes - ".$user['adminNotes']."\n"; |
|
392 | + $report .= "\tCurrent Planet - ".$user['current_planet']."\n"; |
|
393 | + $report .= "\tUser IP - ".$user['user_lastip']."\n"; |
|
394 | + $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n"; |
|
395 | + $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
396 | + $report .= "\tCurrent Page - ".$user['current_page']."\n"; |
|
397 | + $report .= "\tRegister Time - ".$user['register_time']."\n"; |
|
398 | 398 | $report .= "\n"; |
399 | 399 | |
400 | 400 | $report .= ">Query Information\n"; |
401 | - $report .= "\tQuery - " . $query . "\n"; |
|
401 | + $report .= "\tQuery - ".$query."\n"; |
|
402 | 402 | $report .= "\n"; |
403 | 403 | |
404 | 404 | $report .= ">\$_SERVER Information\n"; |
405 | - $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n"; |
|
406 | - $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n"; |
|
407 | - $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n"; |
|
408 | - $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n"; |
|
409 | - $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n"; |
|
410 | - $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n"; |
|
411 | - $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n"; |
|
412 | - $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n"; |
|
405 | + $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n"; |
|
406 | + $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n"; |
|
407 | + $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n"; |
|
408 | + $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n"; |
|
409 | + $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n"; |
|
410 | + $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n"; |
|
411 | + $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n"; |
|
412 | + $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n"; |
|
413 | 413 | |
414 | 414 | $report .= "\n--------------------------------------------------------------------------------------------------\n"; |
415 | 415 | |
416 | - $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a'); |
|
416 | + $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a'); |
|
417 | 417 | fwrite($fp, $report); |
418 | 418 | fclose($fp); |
419 | 419 | |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | $prefix_length = strlen($this->db_prefix); |
435 | 435 | |
436 | 436 | $tl = array(); |
437 | - while($row = $this->db_fetch($query)) { |
|
437 | + while ($row = $this->db_fetch($query)) { |
|
438 | 438 | foreach ($row as $table_name) { |
439 | 439 | if (strpos($table_name, $this->db_prefix) === 0) { |
440 | 440 | $table_name = substr($table_name, $prefix_length); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | if (is_bool($query)) { |
566 | 566 | throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?'); |
567 | 567 | } |
568 | - while($row = db_fetch($query)) { |
|
568 | + while ($row = db_fetch($query)) { |
|
569 | 569 | $result[$row['Variable_name']] = $row['Value']; |
570 | 570 | } |
571 | 571 |
@@ -115,6 +115,9 @@ discard block |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | + /** |
|
119 | + * @param string $query |
|
120 | + */ |
|
118 | 121 | public function setQuery($query) { |
119 | 122 | $this->query = $query; |
120 | 123 | |
@@ -128,6 +131,9 @@ discard block |
||
128 | 131 | } |
129 | 132 | } |
130 | 133 | |
134 | + /** |
|
135 | + * @param string $comment |
|
136 | + */ |
|
131 | 137 | protected function commentAdd($comment) { |
132 | 138 | if (empty($this->values[static::COMMENT_PLACEHOLDER])) { |
133 | 139 | $this->query .= static::COMMENT_PLACEHOLDER; |
@@ -261,7 +267,7 @@ discard block |
||
261 | 267 | } |
262 | 268 | |
263 | 269 | /** |
264 | - * @return bool|mysqli_result |
|
270 | + * @return mysqli_result |
|
265 | 271 | */ |
266 | 272 | public function getResult() { |
267 | 273 | return $this->statement->get_result(); |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | // Removing comment placeholder from statement |
165 | 165 | $this->queryPrepared = str_replace(static::COMMENT_PLACEHOLDER, DbSqlHelper::quoteComment($this->comment), $this->queryPrepared); |
166 | 166 | // Removing comment value from values list |
167 | - $this->paramsPrepared = array_filter($this->paramsPrepared, function ($value) { return $value != DbSqlPrepare::COMMENT_PLACEHOLDER; }); |
|
167 | + $this->paramsPrepared = array_filter($this->paramsPrepared, function($value) { return $value != DbSqlPrepare::COMMENT_PLACEHOLDER; }); |
|
168 | 168 | // TODO - Add comment value directly to statement |
169 | 169 | } |
170 | 170 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | } |
269 | 269 | |
270 | 270 | public function getIterator() { |
271 | - if(DbSqlPrepare::$isUseGetResult) { |
|
271 | + if (DbSqlPrepare::$isUseGetResult) { |
|
272 | 272 | $mysqli_result = $this->statement->get_result(); |
273 | - if($mysqli_result instanceof mysqli_result) { |
|
273 | + if ($mysqli_result instanceof mysqli_result) { |
|
274 | 274 | $iterator = new DbMysqliResultIterator($this->statement->get_result()); |
275 | 275 | } else { |
276 | 276 | $iterator = new DbEmptyIterator(); |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
|
3 | +include('common.'.substr(strrchr(__FILE__, '.'), 1)); |
|
4 | 4 | |
5 | 5 | global $user; |
6 | 6 | |
7 | -if($user['authlevel'] < AUTH_LEVEL_DEVELOPER) { |
|
7 | +if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) { |
|
8 | 8 | $error_message = classSupernova::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : ( |
9 | 9 | !classSupernova::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : '' |
10 | 10 | ); |
11 | 11 | |
12 | - if($error_message) { |
|
12 | + if ($error_message) { |
|
13 | 13 | message(classLocale::$lang[$error_message], classLocale::$lang['sys_error'], 'overview.php', 10); |
14 | 14 | die(); |
15 | 15 | } |
@@ -18,16 +18,16 @@ discard block |
||
18 | 18 | $current_round = intval(classSupernova::$config->db_loadItem('game_blitz_register_round')); |
19 | 19 | $current_price = intval(classSupernova::$config->db_loadItem('game_blitz_register_price')); |
20 | 20 | |
21 | -if(classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
|
21 | +if (classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
|
22 | 22 | sn_db_transaction_start(); |
23 | 23 | $user = DBStaticUser::db_user_by_id($user['id'], true); |
24 | 24 | $is_registered = db_blitz_reg_get_id_by_player_and_round($user, $current_round); |
25 | - if(sys_get_param_str('register_me')) { |
|
26 | - if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
|
25 | + if (sys_get_param_str('register_me')) { |
|
26 | + if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
|
27 | 27 | db_blitz_reg_insert($user, $current_round); |
28 | 28 | classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица"); |
29 | 29 | } |
30 | - } elseif(sys_get_param_str('register_me_not') && !empty($is_registered)) { |
|
30 | + } elseif (sys_get_param_str('register_me_not') && !empty($is_registered)) { |
|
31 | 31 | db_blitz_reg_delete($user, $current_round); |
32 | 32 | classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION_CANCEL, $current_price, "Отмена регистрации в раунде {$current_round} Блица"); |
33 | 33 | } |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | $blitz_players = 0; |
43 | 43 | $blitz_prize_dark_matter = 0; |
44 | 44 | $blitz_prize_places = 0; |
45 | -if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
|
46 | - if(sys_get_param_str('generate')) { |
|
45 | +if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
|
46 | + if (sys_get_param_str('generate')) { |
|
47 | 47 | $next_id = 0; |
48 | 48 | $query = db_blitz_reg_get_random_id($current_round); |
49 | - while($row = db_fetch($query)) { |
|
49 | + while ($row = db_fetch($query)) { |
|
50 | 50 | $next_id++; |
51 | - $blitz_name = 'Игрок' . $next_id; |
|
51 | + $blitz_name = 'Игрок'.$next_id; |
|
52 | 52 | $blitz_password = sys_random_string(8); |
53 | 53 | db_blitz_reg_update_with_name_and_password($blitz_name, $blitz_password, $row, $current_round); |
54 | 54 | } |
55 | - } elseif(sys_get_param_str('import_generated')) { |
|
55 | + } elseif (sys_get_param_str('import_generated')) { |
|
56 | 56 | // ЭТО НА БЛИЦЕ!!! |
57 | 57 | DBStaticUser::db_player_list_blitz_delete_players(); |
58 | 58 | DBStaticPlanet::db_planets_purge(); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $system = $system_step; |
75 | 75 | $planet = round(Vector::$knownPlanets / 2); |
76 | 76 | |
77 | - foreach($imported_string as &$string_data) { |
|
77 | + foreach ($imported_string as &$string_data) { |
|
78 | 78 | $string_data = explode(',', $string_data); |
79 | 79 | $username_safe = $string_data[0]; |
80 | 80 | |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], 30, '', false); |
96 | 96 | |
97 | - if(($system += $system_step) >= Vector::$knownSystems) { |
|
97 | + if (($system += $system_step) >= Vector::$knownSystems) { |
|
98 | 98 | $galaxy++; |
99 | 99 | $system = $system_step; |
100 | 100 | } |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->users_amount + $new_players); |
105 | 105 | // pdump($imported_string); |
106 | 106 | // generated_string |
107 | - } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
|
107 | + } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
|
108 | 108 | $blitz_result = explode(';', $blitz_result_string); |
109 | 109 | $blitz_last_update = $blitz_result[0]; // Пока не используется |
110 | 110 | unset($blitz_result[0]); |
111 | - foreach($blitz_result as $blitz_result_data) { |
|
111 | + foreach ($blitz_result as $blitz_result_data) { |
|
112 | 112 | $blitz_result_data = explode(',', $blitz_result_data); |
113 | - if(count($blitz_result_data) == 5) { |
|
113 | + if (count($blitz_result_data) == 5) { |
|
114 | 114 | $blitz_result_data[1] = db_escape($blitz_result_data[1]); |
115 | 115 | db_blitz_reg_update_results($blitz_result_data, $current_round); |
116 | 116 | } |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | $blitz_result = array(); |
119 | 119 | } |
120 | 120 | |
121 | - if(classSupernova::$config->game_mode == GAME_BLITZ) { |
|
121 | + if (classSupernova::$config->game_mode == GAME_BLITZ) { |
|
122 | 122 | $blitz_result = array(classSupernova::$config->db_loadItem('var_stat_update')); |
123 | - foreach(DBStaticUser::db_player_list_export_blitz_info() as $row) { |
|
123 | + foreach (DBStaticUser::db_player_list_export_blitz_info() as $row) { |
|
124 | 124 | $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}"; |
125 | 125 | } |
126 | 126 | } else { |
127 | 127 | $query = db_blitz_reg_get_player_list($current_round); |
128 | - while($row = db_fetch($query)) { |
|
128 | + while ($row = db_fetch($query)) { |
|
129 | 129 | $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}"; |
130 | 130 | $row['blitz_online'] ? $blitz_prize_players_active++ : false; |
131 | 131 | $blitz_players++; |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | $blitz_prize_dark_matter = $blitz_prize_players_active * 20000; |
134 | 134 | $blitz_prize_places = ceil($blitz_prize_players_active / 5); |
135 | 135 | |
136 | - if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
|
136 | + if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
|
137 | 137 | // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'); |
138 | 138 | $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places'); |
139 | 139 | sn_db_transaction_start(); |
140 | 140 | $query = db_blitz_reg_get_player_list_order_by_place($current_round); |
141 | - while($row = db_fetch($query)) { |
|
142 | - if(!$row['blitz_place']) { |
|
141 | + while ($row = db_fetch($query)) { |
|
142 | + if (!$row['blitz_place']) { |
|
143 | 143 | continue; |
144 | 144 | } |
145 | 145 | |
@@ -148,14 +148,14 @@ discard block |
||
148 | 148 | |
149 | 149 | $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter']; |
150 | 150 | pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']); |
151 | - if($reward) { |
|
151 | + if ($reward) { |
|
152 | 152 | rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf( |
153 | 153 | classLocale::$lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name'] |
154 | 154 | )); |
155 | 155 | db_blitz_reg_update_apply_results($reward, $row, $current_round); |
156 | 156 | } |
157 | 157 | |
158 | - if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
|
158 | + if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
|
159 | 159 | break; |
160 | 160 | } |
161 | 161 | } |
@@ -170,12 +170,12 @@ discard block |
||
170 | 170 | |
171 | 171 | $player_registered = false; |
172 | 172 | $query = db_blitz_reg_get_player_list_and_users($current_round); |
173 | -while($row = db_fetch($query)) { |
|
173 | +while ($row = db_fetch($query)) { |
|
174 | 174 | $tpl_player_data = array( |
175 | 175 | 'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)), |
176 | 176 | ); |
177 | 177 | |
178 | - if(classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
|
178 | + if (classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
|
179 | 179 | // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда |
180 | 180 | $tpl_player_data = array_merge($tpl_player_data, array( |
181 | 181 | 'ID' => $row['id'], |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | $template->assign_block_vars('registrations', $tpl_player_data); |
191 | - if($row['id'] == $user['id']) { |
|
191 | + if ($row['id'] == $user['id']) { |
|
192 | 192 | $player_registered = $row; |
193 | 193 | } |
194 | 194 | } |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | public static function cache_clear($location_type, $hard = true) { |
237 | 237 | if ($hard && !empty(static::$data[$location_type])) { |
238 | 238 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
239 | - array_walk(static::$data[$location_type], function (&$item) { $item = null; }); |
|
239 | + array_walk(static::$data[$location_type], function(&$item) { $item = null; }); |
|
240 | 240 | } |
241 | 241 | static::$locator[$location_type] = array(); |
242 | 242 | static::$queries[$location_type] = array(); |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | |
355 | 355 | if (!empty($error_msg)) { |
356 | 356 | // TODO - Убрать позже |
357 | - print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
|
357 | + print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - '.$error_msg.'</h1>'); |
|
358 | 358 | $backtrace = debug_backtrace(); |
359 | 359 | array_shift($backtrace); |
360 | 360 | pdump($backtrace); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | public static function db_transaction_start($level = '') { |
368 | 368 | static::db_transaction_check(null); |
369 | 369 | |
370 | - $level ? doquery('SET TRANSACTION ISOLATION LEVEL ' . $level) : false; |
|
370 | + $level ? doquery('SET TRANSACTION ISOLATION LEVEL '.$level) : false; |
|
371 | 371 | |
372 | 372 | static::$transaction_id++; |
373 | 373 | doquery('START TRANSACTION'); |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | public static function db_lock_tables($tables) { |
428 | 428 | $tables = is_array($tables) ? $tables : array($tables => ''); |
429 | 429 | foreach ($tables as $table_name => $condition) { |
430 | - self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
|
430 | + self::$db->doquery("SELECT 1 FROM {{{$table_name}}}".($condition ? ' WHERE '.$condition : '')); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | |
@@ -488,11 +488,11 @@ discard block |
||
488 | 488 | $query = static::db_query( |
489 | 489 | "SELECT |
490 | 490 | distinct({{{$location_info[P_TABLE_NAME]}}}.{$owner_data[P_OWNER_FIELD]}) AS parent_id |
491 | - FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
492 | - ($filter ? ' WHERE ' . $filter : '') . |
|
491 | + FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
492 | + ($filter ? ' WHERE '.$filter : ''). |
|
493 | 493 | ($fetch ? ' LIMIT 1' : ''), false, true); |
494 | 494 | |
495 | - while($row = db_fetch($query)) { |
|
495 | + while ($row = db_fetch($query)) { |
|
496 | 496 | // Исключаем из списка родительских ИД уже заблокированные записи |
497 | 497 | if (!static::cache_lock_get($owner_location_type, $row['parent_id'])) { |
498 | 498 | $parent_id_list[$row['parent_id']] = $row['parent_id']; |
@@ -502,16 +502,16 @@ discard block |
||
502 | 502 | if ($indexes_str = implode(',', $parent_id_list)) { |
503 | 503 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
504 | 504 | static::db_get_record_list($owner_location_type, |
505 | - $parent_id_field . (count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
505 | + $parent_id_field.(count($parent_id_list) > 1 ? " IN ({$indexes_str})" : " = {$indexes_str}"), $fetch, true); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | } |
509 | 509 | |
510 | 510 | $query = static::db_query( |
511 | - "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
|
511 | + "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}". |
|
512 | 512 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
513 | 513 | ); |
514 | - while($row = db_fetch($query)) { |
|
514 | + while ($row = db_fetch($query)) { |
|
515 | 515 | static::cache_set($location_type, $row); |
516 | 516 | $query_cache[$row[$id_field]] = &static::$data[$location_type][$row[$id_field]]; |
517 | 517 | } |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | $condition = trim($condition); |
575 | 575 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
576 | 576 | |
577 | - if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
577 | + if ($result = static::db_query("UPDATE {{{$table_name}}} SET ".$set.($condition ? ' WHERE '.$condition : ''))) { |
|
578 | 578 | |
579 | 579 | if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
580 | 580 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
@@ -737,11 +737,11 @@ discard block |
||
737 | 737 | $user = self::$db->selectRow( |
738 | 738 | DBStaticUser::buildSelect() |
739 | 739 | ->field('*') |
740 | - ->where(array("`username` " . ($like ? 'LIKE' : '=') . " '{$username_safe}'")) |
|
740 | + ->where(array("`username` ".($like ? 'LIKE' : '=')." '{$username_safe}'")) |
|
741 | 741 | ->setFetchOne() |
742 | 742 | ); |
743 | 743 | |
744 | - if(empty($user)) { |
|
744 | + if (empty($user)) { |
|
745 | 745 | $user = null; |
746 | 746 | } |
747 | 747 | |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | |
836 | 836 | $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id]; |
837 | 837 | if (!isset($query_cache)) { |
838 | - $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions()); |
|
838 | + $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".static::db_unit_time_restrictions()); |
|
839 | 839 | if (is_array($got_data)) { |
840 | 840 | foreach ($got_data as $unit_id => $unit_data) { |
841 | 841 | $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | if ($que_type == QUE_RESEARCH || $planet_id === null) { |
897 | 897 | $query[] = "`que_planet_id` IS NULL"; |
898 | 898 | } elseif ($planet_id) { |
899 | - $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
|
899 | + $query[] = "(`que_planet_id` = {$planet_id}".($que_type ? '' : ' OR que_planet_id IS NULL').")"; |
|
900 | 900 | } |
901 | 901 | if ($que_type) { |
902 | 902 | $query[] = "`que_type` = {$que_type}"; |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | public function db_changeset_condition_compile(&$conditions, &$table_name = '') { |
990 | 990 | if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) { |
991 | 991 | $conditions[P_LOCATION] = LOC_NONE; |
992 | - switch($table_name) { |
|
992 | + switch ($table_name) { |
|
993 | 993 | case 'users': |
994 | 994 | case LOC_USER: |
995 | 995 | $conditions[P_TABLE_NAME] = $table_name = 'users'; |
@@ -1017,13 +1017,13 @@ discard block |
||
1017 | 1017 | $condition = "`{$field_name}` = "; |
1018 | 1018 | $value = ''; |
1019 | 1019 | if ($field_data['delta']) { |
1020 | - $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
|
1020 | + $value = "`{$field_name}`".($field_data['delta'] >= 0 ? '+' : '').$field_data['delta']; |
|
1021 | 1021 | } elseif ($field_data['set']) { |
1022 | 1022 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
1023 | 1023 | } |
1024 | 1024 | |
1025 | 1025 | if ($value) { |
1026 | - $fields[] = $condition . $value; |
|
1026 | + $fields[] = $condition.$value; |
|
1027 | 1027 | } |
1028 | 1028 | } |
1029 | 1029 | $conditions[P_FIELDS_STR] = implode(',', $fields); |
@@ -1037,9 +1037,7 @@ discard block |
||
1037 | 1037 | // Простое условие - $field_id = $field_value |
1038 | 1038 | if (is_string($field_id)) { |
1039 | 1039 | $field_value = |
1040 | - $field_value === null ? 'NULL' : |
|
1041 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
1042 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
1040 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'".db_escape($field_value)."'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
1043 | 1041 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
1044 | 1042 | } else { |
1045 | 1043 | die('Неподдерживаемый тип условия'); |
@@ -1051,7 +1049,7 @@ discard block |
||
1051 | 1049 | $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions); |
1052 | 1050 | } |
1053 | 1051 | |
1054 | - switch($conditions['action']) { |
|
1052 | + switch ($conditions['action']) { |
|
1055 | 1053 | case SQL_OP_DELETE: |
1056 | 1054 | $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}"); |
1057 | 1055 | break; |
@@ -1066,7 +1064,7 @@ discard block |
||
1066 | 1064 | die('Неподдерживаемая операция в classSupernova::db_changeset_condition_compile'); |
1067 | 1065 | } |
1068 | 1066 | |
1069 | - $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR] . ' ' . $conditions[P_FIELDS_STR] . (' WHERE ' . $conditions[P_WHERE_STR]); |
|
1067 | + $conditions[P_QUERY_STR] = $conditions[P_ACTION_STR].' '.$conditions[P_FIELDS_STR].(' WHERE '.$conditions[P_WHERE_STR]); |
|
1070 | 1068 | } |
1071 | 1069 | |
1072 | 1070 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
@@ -1088,7 +1086,7 @@ discard block |
||
1088 | 1086 | } // Защита от случайного удаления всех данных в таблице |
1089 | 1087 | |
1090 | 1088 | if ($conditions[P_LOCATION] != LOC_NONE) { |
1091 | - switch($conditions['action']) { |
|
1089 | + switch ($conditions['action']) { |
|
1092 | 1090 | case SQL_OP_DELETE: |
1093 | 1091 | $result = self::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result; |
1094 | 1092 | break; |
@@ -1164,7 +1162,7 @@ discard block |
||
1164 | 1162 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
1165 | 1163 | if (@get_magic_quotes_gpc()) { |
1166 | 1164 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
1167 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
1165 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
1168 | 1166 | $value = stripslashes($value); |
1169 | 1167 | }); |
1170 | 1168 | } |
@@ -1178,7 +1176,7 @@ discard block |
||
1178 | 1176 | public static function init_3_load_config_file() { |
1179 | 1177 | $dbsettings = array(); |
1180 | 1178 | |
1181 | - require(SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX); |
|
1179 | + require(SN_ROOT_PHYSICAL."config".DOT_PHP_EX); |
|
1182 | 1180 | self::$cache_prefix = !empty($dbsettings['cache_prefix']) ? $dbsettings['cache_prefix'] : $dbsettings['prefix']; |
1183 | 1181 | self::$db_name = $dbsettings['name']; |
1184 | 1182 | self::$sn_secret_word = $dbsettings['secretword']; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | ->orderBy(array('`id` DESC')) |
33 | 33 | ->setFetchOne(); |
34 | 34 | |
35 | - return (string)static::$dbStatic->selectValue($query); |
|
35 | + return (string) static::$dbStatic->selectValue($query); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | protected static function whereNotAlly() { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | static::buildSelect() |
62 | 62 | ->field('id') |
63 | 63 | ->where("`user_as_ally` IS NULL") |
64 | - ->where("`user_bot` = " . USER_BOT_PLAYER) |
|
64 | + ->where("`user_bot` = ".USER_BOT_PLAYER) |
|
65 | 65 | ->setForUpdate(); |
66 | 66 | |
67 | 67 | return static::selectIterator($query); |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | } |
220 | 220 | |
221 | 221 | public static function db_user_list_set_mass_mail(&$owners_list, $set) { |
222 | - return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN (' . implode(',', $owners_list) . ');' : '', $set); |
|
222 | + return classSupernova::db_upd_record_list(LOC_USER, !empty($owners_list) ? '`id` IN ('.implode(',', $owners_list).');' : '', $set); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | public static function db_user_list_set_by_ally_and_rank($ally_id, $ally_rank_id, $set) { |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return array|null |
92 | 92 | */ |
93 | 93 | public static function getRecordById($recordId, $fieldList = '*', $forUpdate = false) { |
94 | - return static::getRecord(array(static::$_idField . '=' . $recordId), $fieldList, $forUpdate); |
|
94 | + return static::getRecord(array(static::$_idField.'='.$recordId), $fieldList, $forUpdate); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | $query = static::selectIterator( |
105 | 105 | static::buildSelect() |
106 | 106 | ->fields(static::$_idField) |
107 | - ->where(array("`" . static::$_idField . "` IN (" . implode(',', $idList) . ")")) |
|
107 | + ->where(array("`".static::$_idField."` IN (".implode(',', $idList).")")) |
|
108 | 108 | ); |
109 | 109 | } else { |
110 | 110 | $query = new DbEmptyIterator(); |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | $result = array(); |
127 | 127 | if (!empty($idList)) { |
128 | - foreach(static::queryExistsIdInList($idList) as $row) { |
|
128 | + foreach (static::queryExistsIdInList($idList) as $row) { |
|
129 | 129 | $result[] = $row[static::$_idField]; |
130 | 130 | } |
131 | 131 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected static function selectIterator($sql) { |
152 | 152 | $result = static::$dbStatic->selectIterator($sql, false); |
153 | - if(!($result instanceof DbResultIterator)) { |
|
153 | + if (!($result instanceof DbResultIterator)) { |
|
154 | 154 | $result = new DbEmptyIterator(); |
155 | 155 | } |
156 | 156 | return $result; |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | $fields[0] = &$this->_result; |
16 | 16 | |
17 | - while($field = mysqli_fetch_field($data)) { |
|
17 | + while ($field = mysqli_fetch_field($data)) { |
|
18 | 18 | $fields[] = &$out[$field->name]; |
19 | 19 | } |
20 | 20 |
@@ -101,7 +101,7 @@ |
||
101 | 101 | static::makeArrayRef($arrayNew); |
102 | 102 | static::makeArrayRef($arrayOld); |
103 | 103 | |
104 | - switch($mergeStrategy) { |
|
104 | + switch ($mergeStrategy) { |
|
105 | 105 | case HelperArray::MERGE_PHP: |
106 | 106 | $arrayOld = array_merge($arrayOld, $arrayNew); |
107 | 107 | break; |
@@ -346,9 +346,9 @@ discard block |
||
346 | 346 | } |
347 | 347 | |
348 | 348 | protected function compileFrom() { |
349 | - $this->_compiledQuery[] = 'FROM `{{' . $this->escapeString($this->table) . '}}`'; |
|
349 | + $this->_compiledQuery[] = 'FROM `{{'.$this->escapeString($this->table).'}}`'; |
|
350 | 350 | if (!empty($this->alias)) { |
351 | - $this->_compiledQuery[] = 'AS `' . $this->escapeString($this->alias) . '`'; |
|
351 | + $this->_compiledQuery[] = 'AS `'.$this->escapeString($this->alias).'`'; |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
@@ -358,29 +358,29 @@ discard block |
||
358 | 358 | |
359 | 359 | protected function compileWhere() { |
360 | 360 | // TODO - fields should be escaped !! |
361 | - !empty($this->where) ? $this->_compiledQuery[] = 'WHERE ' . implode(' AND ', $this->where) : false; |
|
361 | + !empty($this->where) ? $this->_compiledQuery[] = 'WHERE '.implode(' AND ', $this->where) : false; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | protected function compileGroupBy() { |
365 | 365 | // TODO - fields should be escaped !! |
366 | 366 | // !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . implode(',', $this->arrayEscape($this->groupBy)) : false; |
367 | - !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY ' . $this->selectFieldsToString($this->groupBy) : false; |
|
367 | + !empty($this->groupBy) ? $this->_compiledQuery[] = 'GROUP BY '.$this->selectFieldsToString($this->groupBy) : false; |
|
368 | 368 | } |
369 | 369 | |
370 | 370 | protected function compileOrderBy() { |
371 | 371 | // TODO - fields should be escaped !! |
372 | - !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY ' . implode(',', $this->arrayEscape($this->orderBy)) : false; |
|
372 | + !empty($this->orderBy) ? $this->_compiledQuery[] = 'ORDER BY '.implode(',', $this->arrayEscape($this->orderBy)) : false; |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | protected function compileHaving() { |
376 | 376 | // TODO - fields should be escaped !! |
377 | - !empty($this->having) ? $this->_compiledQuery[] = 'HAVING ' . implode(' AND ', $this->having) : false; |
|
377 | + !empty($this->having) ? $this->_compiledQuery[] = 'HAVING '.implode(' AND ', $this->having) : false; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | protected function compileLimit() { |
381 | 381 | // TODO - fields should be escaped !! |
382 | 382 | if ($limit = $this->fetchOne ? 1 : $this->limit) { |
383 | - $this->_compiledQuery[] = 'LIMIT ' . $limit . (!empty($this->offset) ? ' OFFSET ' . $this->offset : ''); |
|
383 | + $this->_compiledQuery[] = 'LIMIT '.$limit.(!empty($this->offset) ? ' OFFSET '.$this->offset : ''); |
|
384 | 384 | } |
385 | 385 | } |
386 | 386 | |
@@ -424,14 +424,14 @@ discard block |
||
424 | 424 | */ |
425 | 425 | protected function processField($fieldName) { |
426 | 426 | if (is_bool($fieldName)) { |
427 | - $result = (string)intval($fieldName); |
|
427 | + $result = (string) intval($fieldName); |
|
428 | 428 | } elseif (is_numeric($fieldName)) { |
429 | 429 | $result = $fieldName; |
430 | 430 | } elseif (is_null($fieldName)) { |
431 | 431 | $result = 'NULL'; |
432 | 432 | } else { |
433 | 433 | // Field has other type - string or should be convertible to string |
434 | - $result = (string)$fieldName; |
|
434 | + $result = (string) $fieldName; |
|
435 | 435 | if (!$fieldName instanceof DbSqlLiteral) { |
436 | 436 | $result = $this->quoteField($fieldName); |
437 | 437 | } |